17 import (
'classes.journal.Section');
18 import (
'lib.pkp.classes.context.PKPSectionDAO');
42 $section = $this->
getById($id,
null,
false);
43 $cache->setCache($id, $section);
48 if (!isset($this->cache)) {
50 $this->cache = $cacheManager->getObjectCache(
'sections', 0, array($this,
'_cacheMiss'));
62 function getById($sectionId, $journalId =
null, $useCache =
false) {
65 $returner =
$cache->get($sectionId);
66 if ($returner && $journalId !=
null && $journalId != $returner->getJournalId()) $returner =
null;
70 $sql =
'SELECT * FROM sections WHERE section_id = ?';
71 $params = array((
int) $sectionId);
72 if ($journalId !==
null) {
73 $sql .=
' AND journal_id = ?';
74 $params[] = (int) $journalId;
76 $result = $this->
retrieve($sql, $params);
79 if ($result->RecordCount() != 0) {
80 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
94 function getByAbbrev($sectionAbbrev, $journalId, $locale =
null) {
95 $params = array(
'abbrev', $sectionAbbrev, (
int) $journalId);
96 if ($locale !==
null) {
102 FROM sections s, section_settings l
103 WHERE l.section_id = s.section_id AND
104 l.setting_name = ? AND
105 l.setting_value = ? AND
107 ($locale!==
null?
' AND l.locale = ?':
''),
112 if ($result->RecordCount() != 0) {
113 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
127 function getByTitle($sectionTitle, $journalId, $locale =
null) {
128 $params = array(
'title', $sectionTitle, (
int) $journalId);
129 if ($locale !==
null) {
135 FROM sections s, section_settings l
136 WHERE l.section_id = s.section_id AND
137 l.setting_name = ? AND
138 l.setting_value = ? AND
140 ($locale !==
null?
' AND l.locale = ?':
''),
145 if ($result->RecordCount() != 0) {
146 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
159 $result = $this->
retrieve(
'SELECT sections.* FROM sections
161 ON (submissions.section_id = sections.section_id)
162 WHERE submissions.submission_id = ?',
163 array((
int) $submissionId));
166 if ($result->RecordCount() != 0) {
167 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
187 $section = parent::_fromRow($row);
189 $section->setId($row[
'section_id']);
190 $section->setJournalId($row[
'journal_id']);
191 $section->setMetaIndexed($row[
'meta_indexed']);
192 $section->setMetaReviewed($row[
'meta_reviewed']);
193 $section->setAbstractsNotRequired($row[
'abstracts_not_required']);
194 $section->setHideTitle($row[
'hide_title']);
195 $section->setHideAuthor($row[
'hide_author']);
196 $section->setIsInactive($row[
'is_inactive']);
197 $section->setAbstractWordCount($row[
'abstract_word_count']);
212 parent::getLocaleFieldNames(),
213 array(
'abbrev',
'identifyType',
'description')
223 parent::getAdditionalFieldNames(),
234 'section_id' => $section->getId()
245 'INSERT INTO sections
246 (journal_id, review_form_id, seq, meta_indexed, meta_reviewed, abstracts_not_required, editor_restricted, hide_title, hide_author, is_inactive, abstract_word_count)
248 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
250 (
int)$section->getJournalId(),
251 (
int)$section->getReviewFormId(),
252 (
float) $section->getSequence(),
253 $section->getMetaIndexed() ? 1 : 0,
254 $section->getMetaReviewed() ? 1 : 0,
255 $section->getAbstractsNotRequired() ? 1 : 0,
256 $section->getEditorRestricted() ? 1 : 0,
257 $section->getHideTitle() ? 1 : 0,
258 $section->getHideAuthor() ? 1 : 0,
259 $section->getIsInactive() ? 1 : 0,
260 (
int) $section->getAbstractWordCount()
266 return $section->getId();
281 abstracts_not_required = ?,
282 editor_restricted = ?,
286 abstract_word_count = ?
287 WHERE section_id = ?',
289 (
int)$section->getReviewFormId(),
290 (
float) $section->getSequence(),
291 (
int)$section->getMetaIndexed(),
292 (
int)$section->getMetaReviewed(),
293 (
int)$section->getAbstractsNotRequired(),
294 (
int)$section->getEditorRestricted(),
295 (
int)$section->getHideTitle(),
296 (
int)$section->getHideAuthor(),
297 (
int)$section->getIsInactive(),
298 $this->nullOrInt($section->getAbstractWordCount()),
299 (
int)$section->getId()
312 $subEditorsDao->deleteBySubmissionGroupId($sectionId, ASSOC_TYPE_SECTION, $contextId);
316 $submissionDao->removeSubmissionsFromSection($sectionId);
318 if (isset($contextId) && !$this->
sectionExists($sectionId, $contextId))
return false;
319 $this->
update(
'DELETE FROM section_settings WHERE section_id = ?', (
int) $sectionId);
320 $this->
update(
'DELETE FROM sections WHERE section_id = ?', (
int) $sectionId);
343 'SELECT s.*, se.user_id AS editor_id FROM subeditor_submission_group ssg, sections s WHERE ssg.assoc_id = s.section_id AND ssg.assoc_type = ? AND s.journal_id = ssg.context_id AND s.journal_id = ?',
344 (
int) ASSOC_TYPE_SECTION,
348 while (!$result->EOF) {
349 $row = $result->GetRowAssoc(
false);
351 if (!isset($returner[$row[
'editor_id']])) {
352 $returner[$row[
'editor_id']] = array($section);
354 $returner[$row[
'editor_id']][] = $section;
381 function getByContextId($journalId, $rangeInfo =
null, $submittableOnly =
false) {
383 'SELECT * FROM sections WHERE journal_id = ? ' . ($submittableOnly ?
' AND editor_restricted = 0' :
'') .
' ORDER BY seq',
384 (
int) $journalId, $rangeInfo
397 'SELECT * FROM sections ORDER BY journal_id, seq',
411 'SELECT s.section_id FROM sections s LEFT JOIN submissions a ON (a.section_id = s.section_id) WHERE a.section_id IS NULL AND s.journal_id = ?',
416 while (!$result->EOF) {
417 $returner[] = $result->fields[0];
432 'SELECT COUNT(*) FROM sections WHERE section_id = ? AND journal_id = ?',
433 array((
int) $sectionId, (
int) $journalId)
435 $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true :
false;
447 'SELECT section_id FROM sections WHERE journal_id = ? ORDER BY seq',
451 for ($i=1; !$result->EOF; $i++) {
452 list($sectionId) = $result->fields;
454 'UPDATE sections SET seq = ? WHERE section_id = ?',