Open Monograph Press  3.3.0
NewReleaseDAO.inc.php
1 <?php
2 
17 class NewReleaseDAO extends DAO {
21  function __construct() {
22  parent::__construct();
23  }
24 
31  function getMonographIdsByAssoc($assocType, $assocId) {
32  $returner = array();
33  $result = $this->retrieve(
34  'SELECT submission_id FROM new_releases WHERE assoc_type = ? AND assoc_id = ?',
35  array((int) $assocType, (int) $assocId)
36  );
37 
38  while (!$result->EOF) {
39  list($monographId) = $result->fields;
40  $returner[$monographId] = true;
41  $result->MoveNext();
42  }
43 
44  $result->Close();
45  return $returner;
46  }
47 
54  function getMonographsByAssoc($assocType, $assocId) {
55  // import STATUS_PUBLISHED constant
56  import('classes.submission.Submission');
57  $result = $this->retrieve(
58  'SELECT n.submission_id
59  FROM new_releases n,
60  submissions s,
61  publications p
62  WHERE n.submission_id = s.submission_id
63  AND p.publication_id = s.current_publication_id
64  AND n.assoc_type = ? AND n.assoc_id = ?
65  AND s.status = ?
66  ORDER BY p.date_published DESC',
67  array((int) $assocType, (int) $assocId, STATUS_PUBLISHED)
68  );
69 
70  $returner = array();
71  while (!$result->EOF) {
72  list($monographId) = $result->fields;
73  $returner[] = Services::get('submission')->get($monographId);
74  $result->MoveNext();
75  }
76  $result->Close();
77  return $returner;
78  }
79 
86  function insertNewRelease($monographId, $assocType, $assocId) {
87  $this->update(
88  'INSERT INTO new_releases
89  (submission_id, assoc_type, assoc_id)
90  VALUES
91  (?, ?, ?)',
92  array(
93  (int) $monographId,
94  (int) $assocType,
95  (int) $assocId
96  )
97  );
98  }
99 
105  function deleteByMonographId($monographId) {
106  $this->update(
107  'DELETE FROM new_releases WHERE submission_id = ?',
108  (int) $monographId
109  );
110  }
111 
117  function deleteByAssoc($assocType, $assocId) {
118  $this->update(
119  'DELETE FROM new_releases WHERE assoc_type = ? AND assoc_id = ?',
120  array((int) $assocType, (int) $assocId)
121  );
122  }
123 
130  function deleteNewRelease($monographId, $assocType, $assocId) {
131  $this->update(
132  'DELETE FROM new_releases
133  WHERE submission_id = ? AND
134  assoc_type = ? AND
135  assoc_id = ?',
136  array(
137  (int) $monographId,
138  (int) $assocType,
139  (int) $assocId
140  )
141  );
142  }
143 
154  function isNewRelease($monographId, $assocType, $assocId) {
155  $result = $this->retrieve(
156  'SELECT submission_id FROM new_releases WHERE submission_id = ? AND assoc_type = ? AND assoc_id = ?',
157  array((int) $monographId, (int) $assocType, (int) $assocId)
158  );
159  if ($result->RecordCount() > 0) {
160  return true;
161  }
162 
163  return false;
164  }
165 
172  function getNewReleaseAll($monographId) {
173  $result = $this->retrieve(
174  'SELECT assoc_type, assoc_id FROM new_releases WHERE submission_id = ?',
175  array((int) $monographId)
176  );
177 
178  $newRelease = array();
179  while (!$result->EOF) {
180  $newRelease[] = array(
181  'assoc_type' => (int) $result->fields['assoc_type'],
182  'assoc_id' => (int) $result->fields['assoc_id'],
183  );
184  $result->MoveNext();
185  }
186 
187  return $newRelease;
188  }
189 }
190 
191 
NewReleaseDAO\getNewReleaseAll
getNewReleaseAll($monographId)
Definition: NewReleaseDAO.inc.php:172
DAO\retrieve
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:85
NewReleaseDAO\insertNewRelease
insertNewRelease($monographId, $assocType, $assocId)
Definition: NewReleaseDAO.inc.php:86
NewReleaseDAO\deleteNewRelease
deleteNewRelease($monographId, $assocType, $assocId)
Definition: NewReleaseDAO.inc.php:130
NewReleaseDAO\__construct
__construct()
Definition: NewReleaseDAO.inc.php:21
NewReleaseDAO\getMonographsByAssoc
getMonographsByAssoc($assocType, $assocId)
Definition: NewReleaseDAO.inc.php:54
DAO\update
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:214
NewReleaseDAO\isNewRelease
isNewRelease($monographId, $assocType, $assocId)
Definition: NewReleaseDAO.inc.php:154
NewReleaseDAO\deleteByMonographId
deleteByMonographId($monographId)
Definition: NewReleaseDAO.inc.php:105
DAO
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:31
NewReleaseDAO
Operations for setting new release status on various items.
Definition: NewReleaseDAO.inc.php:17
NewReleaseDAO\deleteByAssoc
deleteByAssoc($assocType, $assocId)
Definition: NewReleaseDAO.inc.php:117
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49
NewReleaseDAO\getMonographIdsByAssoc
getMonographIdsByAssoc($assocType, $assocId)
Definition: NewReleaseDAO.inc.php:31