ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

PKPUserSettingsDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 class PKPUserSettingsDAO extends DAO {
28  function &getSetting($userId, $name, $assocType = null, $assocId = null) {
29  $result =& $this->retrieve(
30  'SELECT setting_value,
31  setting_type
32  FROM user_settings
33  WHERE user_id = ? AND
34  setting_name = ? AND
35  assoc_type = ? AND
36  assoc_id = ?',
37  array(
38  (int) $userId,
39  $name,
40  (int) $assocType,
41  (int) $assocId
42  )
43  );
44 
45  if ($result->RecordCount() != 0) {
46  $row =& $result->getRowAssoc(false);
47  $returner = $this->convertFromDB($row['setting_value'], $row['setting_type']);
48  } else {
49  $returner = null;
50  }
51 
52  return $returner;
53  }
54 
64  function &getUsersBySetting($name, $value, $type = null, $assocType = null, $assocId = null) {
65  $userDao =& DAORegistry::getDAO('UserDAO');
66 
67  $value = $this->convertToDB($value, $type);
68  $result =& $this->retrieve(
69  'SELECT u.*
70  FROM users u,
71  user_settings s
72  WHERE u.user_id = s.user_id AND
73  s.setting_name = ? AND
74  s.setting_value = ? AND
75  s.assoc_type = ? AND
76  s.assoc_id = ?',
77  array($name, $value, (int) $assocType, (int) $assocId)
78  );
79 
80  $returner = new DAOResultFactory($result, $userDao, '_returnUserFromRow');
81  return $returner;
82  }
83 
91  function &getSettingsByAssoc($userId, $assocType = null, $assocId = null) {
92  $userSettings = array();
93 
94  $result =& $this->retrieve(
95  'SELECT setting_name,
96  setting_value,
97  setting_type
98  FROM user_settings
99  WHERE user_id = ? AND
100  assoc_type = ?
101  AND assoc_id = ?',
102  array((int) $userId, (int) $assocType, (int) $assocId)
103  );
104 
105  while (!$result->EOF) {
106  $row =& $result->getRowAssoc(false);
107  $value = $this->convertFromDB($row['setting_value'], $row['setting_type']);
108  $userSettings[$row['setting_name']] = $value;
109  $result->MoveNext();
110  }
111  $result->Close();
112  unset($result);
113 
114  return $userSettings;
115  }
116 
126  function updateSetting($userId, $name, $value, $type = null, $assocType = null, $assocId = null) {
127  $result = $this->retrieve(
128  'SELECT COUNT(*)
129  FROM user_settings
130  WHERE user_id = ? AND
131  setting_name = ?
132  AND assoc_type = ?
133  AND assoc_id = ?',
134  array((int) $userId, $name, (int) $assocType, (int) $assocId)
135  );
136 
137  $value = $this->convertToDB($value, $type);
138  if ($result->fields[0] == 0) {
139  $returner = $this->update(
140  'INSERT INTO user_settings
141  (user_id, setting_name, assoc_type, assoc_id, setting_value, setting_type)
142  VALUES
143  (?, ?, ?, ?, ?, ?)',
144  array(
145  (int) $userId,
146  $name,
147  (int) $assocType,
148  (int) $assocId,
149  $value,
150  $type
151  )
152  );
153  } else {
154  $returner = $this->update(
155  'UPDATE user_settings
156  SET setting_value = ?,
157  setting_type = ?
158  WHERE user_id = ? AND
159  setting_name = ? AND
160  assoc_type = ?
161  AND assoc_id = ?',
162  array(
163  $value,
164  $type,
165  (int) $userId,
166  $name,
167  (int) $assocType,
168  (int) $assocId
169  )
170  );
171  }
172 
173  $result->Close();
174  unset($result);
175 
176  return $returner;
177  }
178 
186  function deleteSetting($userId, $name, $assocType = null, $assocId = null) {
187  return $this->update(
188  'DELETE FROM user_settings WHERE user_id = ? AND setting_name = ? AND assoc_type = ? AND assoc_id = ?',
189  array((int) $userId, $name, (int) $assocType, (int) $assocId)
190  );
191  }
192 
197  function deleteSettings($userId) {
198  return $this->update(
199  'DELETE FROM user_settings WHERE user_id = ?', $userId
200  );
201  }
202 }
203 
204 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
deleteSetting($userId, $name, $assocType=null, $assocId=null)
& getSetting($userId, $name, $assocType=null, $assocId=null)
& getUsersBySetting($name, $value, $type=null, $assocType=null, $assocId=null)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
updateSetting($userId, $name, $value, $type=null, $assocType=null, $assocId=null)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
convertFromDB($value, $type)
Definition: DAO.inc.php:296
& getDAO($name, $dbconn=null)
convertToDB($value, &$type)
Definition: DAO.inc.php:352
& getSettingsByAssoc($userId, $assocType=null, $assocId=null)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
Operations for retrieving and modifying user settings.