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)  

PKPAnnouncementTypeDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('announcement.PKPAnnouncementType');
19 
20 class PKPAnnouncementTypeDAO extends DAO {
26  function &getAnnouncementType($typeId) {
27  $result =& $this->retrieve(
28  'SELECT * FROM announcement_types WHERE type_id = ?', $typeId
29  );
30 
31  $returner = null;
32  if ($result->RecordCount() != 0) {
33  $returner =& $this->_returnAnnouncementTypeFromRow($result->GetRowAssoc(false));
34  }
35  $result->Close();
36  return $returner;
37  }
38 
44  function getAnnouncementTypeAssocId($typeId) {
45  $result =& $this->retrieve(
46  'SELECT assoc_id FROM announcement_types WHERE type_id = ?', $typeId
47  );
48 
49  return isset($result->fields[0]) ? $result->fields[0] : 0;
50  }
51 
57  function getAnnouncementTypeName($typeId) {
58  $result =& $this->retrieve(
59  'SELECT COALESCE(l.setting_value, p.setting_value) FROM announcement_type_settings l LEFT JOIN announcement_type_settings p ON (p.type_id = ? AND p.setting_name = ? AND p.locale = ?) WHERE l.type_id = ? AND l.setting_name = ? AND l.locale = ?',
60  array(
61  $typeId, 'name', AppLocale::getLocale(),
62  $typeId, 'name', AppLocale::getPrimaryLocale()
63  )
64  );
65 
66  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
67 
68  $result->Close();
69  unset($result);
70 
71  return $returner;
72  }
73 
74 
81  function announcementTypeExistsByTypeId($typeId, $assocType, $assocId) {
82  $result =& $this->retrieve(
83  'SELECT COUNT(*)
84  FROM announcement_types
85  WHERE type_id = ? AND
86  assoc_type = ? AND
87  assoc_id = ?',
88  array(
89  $typeId,
90  $assocType,
91  $assocId
92  )
93  );
94  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
95 
96  $result->Close();
97  unset($result);
98 
99  return $returner;
100  }
101 
102  function getLocaleFieldNames() {
103  return array('name');
104  }
105 
112  function getAnnouncementTypeByTypeName($typeName, $assocType) {
113  $result =& $this->retrieve(
114  'SELECT type_id
115  FROM announcement_types
116  WHERE type_name = ?
117  AND assoc_type = ?
118  AND assoc_id = ?',
119  array(
120  $typeName,
121  $assocType
122  )
123  );
124  $returner = isset($result->fields[0]) ? $result->fields[0] : 0;
125 
126  $result->Close();
127  unset($result);
128 
129  return $returner;
130  }
131 
138  $announcementType = new AnnouncementType();
139  $announcementType->setId($row['type_id']);
140  $announcementType->setAssocType($row['assoc_type']);
141  $announcementType->setAssocId($row['assoc_id']);
142  $this->getDataObjectSettings('announcement_type_settings', 'type_id', $row['type_id'], $announcementType);
143 
144  return $announcementType;
145  }
146 
151  function updateLocaleFields(&$announcementType) {
152  $this->updateDataObjectSettings('announcement_type_settings', $announcementType, array(
153  'type_id' => $announcementType->getId()
154  ));
155  }
156 
162  function insertAnnouncementType(&$announcementType) {
163  $this->update(
164  sprintf('INSERT INTO announcement_types
165  (assoc_type, assoc_id)
166  VALUES
167  (?, ?)'),
168  array(
169  $announcementType->getAssocType(),
170  $announcementType->getAssocId()
171  )
172  );
173  $announcementType->setId($this->getInsertTypeId());
174  $this->updateLocaleFields($announcementType);
175  return $announcementType->getId();
176  }
177 
183  function updateObject(&$announcementType) {
184  $returner = $this->update(
185  'UPDATE announcement_types
186  SET assoc_type = ?,
187  assoc_id = ?
188  WHERE type_id = ?',
189  array(
190  $announcementType->getAssocType(),
191  $announcementType->getAssocId(),
192  $announcementType->getId()
193  )
194  );
195 
196  $this->updateLocaleFields($announcementType);
197  return $returner;
198  }
199 
200  function updateAnnouncementType(&$announcementType) {
201  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
202  return $this->updateObject($announcementType);
203  }
204 
211  function deleteObject($announcementType) {
212  return $this->deleteAnnouncementTypeById($announcementType->getId());
213  }
214 
215  function deleteAnnouncementType($announcementType) {
216  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
217  return $this->deleteObject($announcementType);
218  }
219 
226  function deleteAnnouncementTypeById($typeId) {
227  $this->update('DELETE FROM announcement_type_settings WHERE type_id = ?', $typeId);
228  $ret = $this->update('DELETE FROM announcement_types WHERE type_id = ?', $typeId);
229 
230  // Delete all announcements with this announcement type
231  if ($ret) {
232  $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
233  return $announcementDao->deleteAnnouncementByTypeId($typeId);
234  } else {
235  return $ret;
236  }
237  }
238 
243  function deleteAnnouncementTypesByAssocId($assocType, $assocId) {
244  $types =& $this->getAnnouncementTypesByAssocId($assocType, $assocId);
245  while (($type =& $types->next())) {
246  $this->deleteObject($type);
247  unset($type);
248  }
249  }
250 
256  function &getAnnouncementTypesByAssocId($assocType, $assocId, $rangeInfo = null) {
257  $result =& $this->retrieveRange(
258  'SELECT * FROM announcement_types WHERE assoc_type = ? AND assoc_id = ? ORDER BY type_id', array($assocType, $assocId), $rangeInfo
259  );
260 
261  $returner = new DAOResultFactory($result, $this, '_returnAnnouncementTypeFromRow');
262  return $returner;
263  }
264 
269  function getInsertTypeId() {
270  return $this->getInsertId('announcement_types', 'type_id');
271  }
272 }
273 
274 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
announcementTypeExistsByTypeId($typeId, $assocType, $assocId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
updateAnnouncementType(&$announcementType)
deleteAnnouncementType($announcementType)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
& getAnnouncementTypesByAssocId($assocType, $assocId, $rangeInfo=null)
updateLocaleFields(&$announcementType)
getAnnouncementTypeByTypeName($typeName, $assocType)
Operations for retrieving and modifying AnnouncementType objects.
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
deleteAnnouncementTypesByAssocId($assocType, $assocId)
& getDAO($name, $dbconn=null)
Basic class describing an announcement type.
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
insertAnnouncementType(&$announcementType)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186