18 import(
'lib.pkp.classes.announcement.AnnouncementType');
37 function getById($typeId, $assocType =
null, $assocId =
null) {
38 $params = array((
int) $typeId);
39 if ($assocType !==
null) $params[] = (int) $assocType;
40 if ($assocId !==
null) $params[] = (int) $assocId;
42 'SELECT * FROM announcement_types WHERE type_id = ?' .
43 ($assocType !==
null?
' AND assoc_type = ?':
'') .
44 ($assocId !==
null?
' AND assoc_id = ?':
''),
49 if ($result->RecordCount() != 0) {
50 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
63 'SELECT assoc_id FROM announcement_types WHERE type_id = ?',
67 return isset($result->fields[0]) ? $result->fields[0] : 0;
77 'SELECT COALESCE(l.setting_value, p.setting_value) FROM announcement_type_settings p LEFT JOIN announcement_type_settings l ON (l.type_id = ? AND l.setting_name = ? AND l.locale = ?) WHERE p.type_id = ? AND p.setting_name = ? AND p.locale = ?',
84 $returner = isset($result->fields[0]) ? $result->fields[0] :
false;
101 FROM announcement_types
102 WHERE type_id = ? AND
111 $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true :
false;
122 return array(
'name');
135 FROM announcement_type_settings AS ats
136 LEFT JOIN announcement_types at ON ats.type_id = at.type_id
137 WHERE ats.setting_name = \'name\'
138 AND ats.setting_value = ?
139 AND at.assoc_type = ?
140 AND at.assoc_id = ?',
147 $returner = isset($result->fields[0]) ? $result->fields[0] : 0;
160 $announcementType->setId($row[
'type_id']);
161 $announcementType->setAssocType($row[
'assoc_type']);
162 $announcementType->setAssocId($row[
'assoc_id']);
163 $this->
getDataObjectSettings(
'announcement_type_settings',
'type_id', $row[
'type_id'], $announcementType);
165 return $announcementType;
174 'type_id' => (
int) $announcementType->getId()
185 sprintf(
'INSERT INTO announcement_types
186 (assoc_type, assoc_id)
190 (
int) $announcementType->getAssocType(),
191 (
int) $announcementType->getAssocId()
196 return $announcementType->getId();
205 $returner = $this->
update(
206 'UPDATE announcement_types
211 (
int) $announcementType->getAssocType(),
212 (
int) $announcementType->getAssocId(),
213 (
int) $announcementType->getId()
228 return $this->
deleteById($announcementType->getId());
237 $this->
update(
'DELETE FROM announcement_type_settings WHERE type_id = ?', (
int) $typeId);
238 $this->
update(
'DELETE FROM announcement_types WHERE type_id = ?', (
int) $typeId);
241 $announcementDao->deleteByTypeId($typeId);
250 $types = $this->
getByAssoc($assocType, $assocId);
251 while ($type = $types->next()) {
263 function getByAssoc($assocType, $assocId, $rangeInfo =
null) {
265 'SELECT * FROM announcement_types WHERE assoc_type = ? AND assoc_id = ? ORDER BY type_id',
266 array((
int) $assocType, (
int) $assocId),
278 return $this->
_getInsertId(
'announcement_types',
'type_id');