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)  

GroupMembershipDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import ('group.GroupMembership');
20 
21 class GroupMembershipDAO extends DAO {
22  var $userDao;
23 
27  function GroupMembershipDAO() {
28  parent::DAO();
29  $this->userDao =& DAORegistry::getDAO('UserDAO');
30  }
31 
38  function &getMembership($groupId, $userId) {
39  $result =& $this->retrieve(
40  'SELECT * FROM group_memberships WHERE group_id = ? AND user_id = ?',
41  array($groupId, $userId)
42  );
43 
44  $returner = null;
45  if ($result->RecordCount() != 0) {
46  $returner =& $this->_returnMembershipFromRow($result->GetRowAssoc(false));
47  }
48  $result->Close();
49  unset($result);
50  return $returner;
51  }
52 
58  function &getMemberships($groupId, $rangeInfo = null) {
59  $result =& $this->retrieveRange(
60  'SELECT * FROM group_memberships m, users u WHERE group_id = ? AND u.user_id = m.user_id ORDER BY m.seq',
61  $groupId,
62  $rangeInfo
63  );
64 
65  $returner = new DAOResultFactory($result, $this, '_returnMembershipFromRow');
66  return $returner;
67  }
68 
74  function &_returnMembershipFromRow(&$row) {
75  // Keep a cache of users.
76  static $users;
77  if (!isset($users)) {
78  $users = array();
79  }
80  $userId = $row['user_id'];
81  if (!isset($users[$userId])) {
82  $users[$userId] =& $this->userDao->getUser($userId);
83  }
84 
85  $membership = new GroupMembership();
86  $membership->setGroupId($row['group_id']);
87  $membership->setUserId($row['user_id']);
88  $membership->setUser($users[$userId]);
89  $membership->setSequence($row['seq']);
90  $membership->setAboutDisplayed($row['about_displayed']);
91 
92  HookRegistry::call('GroupMembershipDAO::_returnMemberFromRow', array(&$membership, &$row));
93 
94  return $membership;
95  }
96 
101  function insertMembership(&$membership) {
102  $this->update(
103  'INSERT INTO group_memberships
104  (group_id, user_id, seq, about_displayed)
105  VALUES
106  (?, ?, ?, ?)',
107  array(
108  $membership->getGroupId(),
109  $membership->getUserId(),
110  $membership->getSequence() == null ? 0 : $membership->getSequence(),
111  $membership->getAboutDisplayed()
112  )
113  );
114  }
115 
120  function updateObject(&$membership) {
121  return $this->update(
122  'UPDATE group_memberships
123  SET
124  seq = ?,
125  about_displayed = ?
126  WHERE
127  group_id = ? AND
128  user_id = ?',
129  array(
130  $membership->getSequence(),
131  $membership->getAboutDisplayed(),
132  $membership->getGroupId(),
133  $membership->getUserId()
134  )
135  );
136  }
137 
138  function updateMembership(&$membership) {
139  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
140  return $this->updateObject($membership);
141  }
142 
147  function deleteObject(&$membership) {
148  return $this->deleteMembershipById($membership->getGroupId(), $membership->getUserId());
149  }
150 
151  function deleteMembership(&$membership) {
152  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
153  return $this->deleteObject($membership);
154  }
155 
161  function deleteMembershipById($groupId, $userId) {
162  return $this->update(
163  'DELETE FROM group_memberships WHERE group_id = ? AND user_id = ?',
164  array($groupId, $userId)
165  );
166  }
167 
172  function deleteMembershipByGroupId($groupId) {
173  return $this->update(
174  'DELETE FROM group_memberships WHERE group_id = ?',
175  $groupId
176  );
177  }
178 
183  function deleteMembershipByUserId($userId) {
184  return $this->update(
185  'DELETE FROM group_memberships WHERE user_id = ?',
186  $userId
187  );
188  }
189 
194  function resequenceMemberships($groupId) {
195  $result =& $this->retrieve(
196  'SELECT user_id, group_id FROM group_memberships WHERE group_id = ? ORDER BY seq',
197  $groupId
198  );
199 
200  for ($i=1; !$result->EOF; $i++) {
201  list($userId, $groupId) = $result->fields;
202  $this->update(
203  'UPDATE group_memberships SET seq = ? WHERE user_id = ? AND group_id = ?',
204  array(
205  $i,
206  $userId,
207  $groupId
208  )
209  );
210 
211  $result->moveNext();
212  }
213 
214  $result->close();
215  unset($result);
216  }
217 }
218 
219 ?>
& getMembership($groupId, $userId)
config TEMPLATE inc php
Definition: config.inc.php:4
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
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
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)
call($hookName, $args=null)
deleteMembershipById($groupId, $userId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
Describes memberships for editorial board positions.
Operations for retrieving and modifying group membership info.
& getMemberships($groupId, $rangeInfo=null)