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)  

GroupDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import ('group.Group');
20 
21 class GroupDAO extends DAO {
29  function &getGroup($groupId, $assocType = null, $assocId = null) {
30  $params = array((int) $groupId);
31  if ($assocType !== null) {
32  $params[] = (int) $assocType;
33  $params[] = (int) $assocId;
34  }
35  $result =& $this->retrieve(
36  'SELECT * FROM groups WHERE group_id = ?' . ($assocType !== null?' AND assoc_type = ? AND assoc_id = ?':''), $params
37  );
38 
39  $returner = null;
40  if ($result->RecordCount() != 0) {
41  $returner =& $this->_returnGroupFromRow($result->GetRowAssoc(false));
42  }
43  $result->Close();
44  unset($result);
45  return $returner;
46  }
47 
56  function &getGroups($assocType, $assocId, $context = null, $rangeInfo = null) {
57  $params = array((int) $assocType, (int) $assocId);
58  if ($context !== null) $params[] = (int) $context;
59 
60  $result =& $this->retrieveRange(
61  'SELECT * FROM groups WHERE assoc_type = ? AND assoc_id = ?' . ($context!==null?' AND context = ?':'') . ' ORDER BY context, seq',
62  $params, $rangeInfo
63  );
64 
65  $returner = new DAOResultFactory($result, $this, '_returnGroupFromRow', array('id'));
66  return $returner;
67  }
68 
73  function getLocaleFieldNames() {
74  return array('title');
75  }
76 
82  function &_returnGroupFromRow(&$row) {
83  $group = new Group();
84  $group->setId($row['group_id']);
85  $group->setAboutDisplayed($row['about_displayed']);
86  $group->setSequence($row['seq']);
87  $group->setContext($row['context']);
88  $group->setAssocType($row['assoc_type']);
89  $group->setAssocId($row['assoc_id']);
90  $this->getDataObjectSettings('group_settings', 'group_id', $row['group_id'], $group);
91 
92  HookRegistry::call('GroupDAO::_returnGroupFromRow', array(&$group, &$row));
93 
94  return $group;
95  }
96 
101  function updateLocaleFields(&$group) {
102  $this->updateDataObjectSettings('group_settings', $group, array(
103  'group_id' => $group->getId()
104  ));
105  }
106 
111  function insertGroup(&$group) {
112  $this->update(
113  'INSERT INTO groups
114  (seq, assoc_type, assoc_id, about_displayed, context)
115  VALUES
116  (?, ?, ?, ?, ?)',
117  array(
118  (int) $group->getSequence(),
119  (int) $group->getAssocType(),
120  (int) $group->getAssocId(),
121  (int) $group->getAboutDisplayed(),
122  (int) $group->getContext()
123  )
124  );
125 
126  $group->setId($this->getInsertGroupId());
127  $this->updateLocaleFields($group);
128  return $group->getId();
129  }
130 
135  function updateObject(&$group) {
136  $returner = $this->update(
137  'UPDATE groups
138  SET seq = ?,
139  assoc_type = ?,
140  assoc_id = ?,
141  about_displayed = ?,
142  context = ?
143  WHERE group_id = ?',
144  array(
145  (int) $group->getSequence(),
146  (int) $group->getAssocType(),
147  (int) $group->getAssocId(),
148  (int) $group->getAboutDisplayed(),
149  (int) $group->getContext(),
150  (int) $group->getId()
151  )
152  );
153  $this->updateLocaleFields($group);
154  return $returner;
155  }
156 
157  function updateGroup(&$group) {
158  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
159  return $this->updateObject($group);
160  }
161 
166  function deleteObject(&$group) {
167  return $this->deleteGroupById($group->getId());
168  }
169 
170  function deleteGroup(&$group) {
171  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
172  return $this->deleteObject($group);
173  }
174 
179  function deleteGroupById($groupId) {
180  $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
181  $groupMembershipDao->deleteMembershipByGroupId($groupId);
182  $this->update('DELETE FROM group_settings WHERE group_id = ?', $groupId);
183  return $this->update('DELETE FROM groups WHERE group_id = ?', $groupId);
184  }
185 
191  function deleteGroupsByAssocId($assocType, $assocId) {
192  $groups =& $this->getGroups($assocType, $assocId);
193  while ($group =& $groups->next()) {
194  $this->deleteObject($group);
195  unset($group);
196  }
197  }
198 
204  function resequenceGroups($assocType = null, $assocId = null) {
205  if ($assocType !== null) $params = array((int) $assocType, (int) $assocId);
206  else $params = array();
207  $result =& $this->retrieve(
208  'SELECT group_id FROM groups' .
209  ($assocType !== null?' WHERE assoc_type = ? AND assoc_id = ?':'') .
210  ' ORDER BY seq',
211  $params
212  );
213 
214  for ($i=1; !$result->EOF; $i++) {
215  list($groupId) = $result->fields;
216  $this->update(
217  'UPDATE groups SET seq = ? WHERE group_id = ?',
218  array(
219  $i,
220  $groupId
221  )
222  );
223 
224  $result->moveNext();
225  }
226 
227  $result->close();
228  unset($result);
229  }
230 
235  function getInsertGroupId() {
236  return $this->getInsertId('groups', 'group_id');
237  }
238 }
239 
240 ?>
updateLocaleFields(&$group)
config TEMPLATE inc php
Definition: config.inc.php:4
deleteObject(&$group)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
Operations for retrieving and modifying Group objects.
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateGroup(&$group)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
getLocaleFieldNames()
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
getInsertGroupId()
& _returnGroupFromRow(&$row)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
& getDAO($name, $dbconn=null)
resequenceGroups($assocType=null, $assocId=null)
& getGroups($assocType, $assocId, $context=null, $rangeInfo=null)
insertGroup(&$group)
deleteGroupsByAssocId($assocType, $assocId)
call($hookName, $args=null)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
deleteGroup(&$group)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
updateObject(&$group)
Describes user groups.
Definition: Group.inc.php:26
deleteGroupById($groupId)
& getGroup($groupId, $assocType=null, $assocId=null)