Open Journal Systems  3.3.0
SubEditorsDAO.inc.php
1 <?php
2 
16 class SubEditorsDAO extends DAO {
17 
25  function insertEditor($contextId, $assocId, $userId, $assocType) {
26  return $this->update(
27  'INSERT INTO subeditor_submission_group
28  (context_id, assoc_id, user_id, assoc_type)
29  VALUES
30  (?, ?, ?, ?)',
31  array(
32  (int) $contextId,
33  (int) $assocId,
34  (int) $userId,
35  (int) $assocType,
36  )
37  );
38  }
39 
47  function deleteEditor($contextId, $assocId, $userId, $assocType) {
48  $this->update(
49  'DELETE FROM subeditor_submission_group WHERE context_id = ? AND section_id = ? AND user_id = ? AND assoc_type = ?',
50  array(
51  (int) $contextId,
52  (int) $assocId,
53  (int) $userId,
54  (int) $assocType,
55  )
56  );
57  }
58 
66  function getBySubmissionGroupId($assocId, $assocType, $contextId) {
67  $userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */
68  $params = array((int) $contextId, (int) $assocId, (int) $assocType);
69  $params = array_merge($userDao->getFetchParameters(), $params);
70  $result = $this->retrieve(
71  'SELECT u.user_id,
72  ' . $userDao->getFetchColumns() . '
73  FROM subeditor_submission_group e
74  JOIN users u ON (e.user_id = u.user_id)
75  ' . $userDao->getFetchJoins() . '
76  WHERE e.context_id = ? AND
77  e.assoc_id = ? AND e.assoc_type = ?
78  ' . $userDao->getOrderBy(),
79  $params
80  );
81 
82  $users = array();
83  while (!$result->EOF) {
84  $row = $result->GetRowAssoc(false);
85  $user = $userDao->getById($row['user_id']);
86  $users[$user->getId()] = $user;
87  $result->MoveNext();
88  }
89 
90  $result->Close();
91  return $users;
92  }
93 
100  function deleteBySubmissionGroupId($assocId, $assocType, $contextId = null) {
101  $params = array((int) $assocId, (int) $assocType);
102  if ($contextId) $params[] = (int) $contextId;
103  $this->update(
104  'DELETE FROM subeditor_submission_group WHERE assoc_id = ? AND assoc_type = ?' .
105  ($contextId?' AND context_id = ?':''),
106  $params
107  );
108  }
109 
117  function deleteByUserId($userId, $contextId = null, $assocId = null, $assocType = null) {
118  $params = array((int) $userId);
119  if ($contextId) $params[] = (int) $contextId;
120  if ($assocId) $params[] = (int) $assocId;
121  if ($assocType) $params[] = (int) $assocType;
122 
123  $this->update(
124  'DELETE FROM subeditor_submission_group WHERE user_id = ?' .
125  ($contextId?' AND context_id = ?':'') .
126  ($assocId?' AND assoc_id = ?':'') .
127  ($assocType?' AND assoc_type = ?':''),
128  $params
129  );
130  }
131 
140  function editorExists($contextId, $assocId, $userId, $assocType) {
141  $result = $this->retrieve(
142  'SELECT COUNT(*) FROM subeditor_submission_group WHERE context_id = ? AND section_id = ? AND user_id = ? AND assoc_id = ?',
143  array((int) $contextId, (int) $assocId, (int) $userId, (int) $assocType)
144  );
145  $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
146 
147  $result->Close();
148  return $returner;
149  }
150 }
151 
152 
SubEditorsDAO
Base class associating sections, series and categories to sub editors.
Definition: SubEditorsDAO.inc.php:16
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
DAO\retrieve
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:85
SubEditorsDAO\deleteEditor
deleteEditor($contextId, $assocId, $userId, $assocType)
Definition: SubEditorsDAO.inc.php:47
DAO\update
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:214
SubEditorsDAO\insertEditor
insertEditor($contextId, $assocId, $userId, $assocType)
Definition: SubEditorsDAO.inc.php:25
SubEditorsDAO\editorExists
editorExists($contextId, $assocId, $userId, $assocType)
Definition: SubEditorsDAO.inc.php:140
DAO
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:31
SubEditorsDAO\deleteBySubmissionGroupId
deleteBySubmissionGroupId($assocId, $assocType, $contextId=null)
Definition: SubEditorsDAO.inc.php:100
SubEditorsDAO\deleteByUserId
deleteByUserId($userId, $contextId=null, $assocId=null, $assocType=null)
Definition: SubEditorsDAO.inc.php:117
SubEditorsDAO\getBySubmissionGroupId
getBySubmissionGroupId($assocId, $assocType, $contextId)
Definition: SubEditorsDAO.inc.php:66