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')
223 'section_id' => $section->getId()
234 'INSERT INTO sections
235 (journal_id, review_form_id, seq, meta_indexed, meta_reviewed, abstracts_not_required, editor_restricted, hide_title, hide_author, is_inactive, abstract_word_count)
237 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
239 (
int)$section->getJournalId(),
240 (
int)$section->getReviewFormId(),
241 (
float) $section->getSequence(),
242 $section->getMetaIndexed() ? 1 : 0,
243 $section->getMetaReviewed() ? 1 : 0,
244 $section->getAbstractsNotRequired() ? 1 : 0,
245 $section->getEditorRestricted() ? 1 : 0,
246 $section->getHideTitle() ? 1 : 0,
247 $section->getHideAuthor() ? 1 : 0,
248 $section->getIsInactive() ? 1 : 0,
249 (
int) $section->getAbstractWordCount()
255 return $section->getId();
270 abstracts_not_required = ?,
271 editor_restricted = ?,
275 abstract_word_count = ?
276 WHERE section_id = ?',
278 (
int)$section->getReviewFormId(),
279 (
float) $section->getSequence(),
280 (
int)$section->getMetaIndexed(),
281 (
int)$section->getMetaReviewed(),
282 (
int)$section->getAbstractsNotRequired(),
283 (
int)$section->getEditorRestricted(),
284 (
int)$section->getHideTitle(),
285 (
int)$section->getHideAuthor(),
286 (
int)$section->getIsInactive(),
287 $this->nullOrInt($section->getAbstractWordCount()),
288 (
int)$section->getId()
301 $subEditorsDao->deleteBySubmissionGroupId($sectionId, ASSOC_TYPE_SECTION, $contextId);
305 $submissionDao->removeSubmissionsFromSection($sectionId);
307 if (isset($contextId) && !$this->
sectionExists($sectionId, $contextId))
return false;
308 $this->
update(
'DELETE FROM section_settings WHERE section_id = ?', (
int) $sectionId);
309 $this->
update(
'DELETE FROM sections WHERE section_id = ?', (
int) $sectionId);
332 '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 = ?',
333 (
int) ASSOC_TYPE_SECTION,
337 while (!$result->EOF) {
338 $row = $result->GetRowAssoc(
false);
340 if (!isset($returner[$row[
'editor_id']])) {
341 $returner[$row[
'editor_id']] = array($section);
343 $returner[$row[
'editor_id']][] = $section;
359 import (
'classes.submission.Submission');
361 $allowedStatuses = [STATUS_PUBLISHED];
362 if (!$issue->getPublished()) {
363 $allowedStatuses[] = STATUS_SCHEDULED;
365 $submissionsIterator =
Services::get(
'submission')->getMany([
366 'contextId' => $issue->getJournalId(),
367 'issueIds' => $issueId,
368 'status' => $allowedStatuses,
371 foreach ($submissionsIterator as $submission) {
372 $sectionIds[] = $submission->getCurrentPublication()->getData(
'sectionId');
374 if (empty($sectionIds)) {
377 $sectionIds = array_unique($sectionIds);
379 'SELECT s.*, COALESCE(o.seq, s.seq) AS section_seq
381 LEFT JOIN custom_section_orders o ON (s.section_id = o.section_id AND o.issue_id = ?)
382 WHERE s.section_id IN (' . substr(str_repeat(
'?,', count($sectionIds)), 0, -1) .
')
383 ORDER BY section_seq',
384 array_merge([(
int) $issueId], $sectionIds)
388 while (!$result->EOF) {
389 $row = $result->GetRowAssoc(
false);
390 $returner[] = $this->
_fromRow($row);
417 function getByContextId($journalId, $rangeInfo =
null, $submittableOnly =
false) {
419 'SELECT * FROM sections WHERE journal_id = ? ' . ($submittableOnly ?
' AND editor_restricted = 0' :
'') .
' ORDER BY seq',
420 (
int) $journalId, $rangeInfo
433 'SELECT * FROM sections ORDER BY journal_id, seq',
447 '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 = ?',
452 while (!$result->EOF) {
453 $returner[] = $result->fields[0];
468 'SELECT COUNT(*) FROM sections WHERE section_id = ? AND journal_id = ?',
469 array((
int) $sectionId, (
int) $journalId)
471 $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true :
false;
483 'SELECT section_id FROM sections WHERE journal_id = ? ORDER BY seq',
487 for ($i=1; !$result->EOF; $i++) {
488 list($sectionId) = $result->fields;
490 'UPDATE sections SET seq = ? WHERE section_id = ?',
517 'DELETE FROM custom_section_orders WHERE issue_id = ?', (
int) $issueId
530 'DELETE FROM custom_section_orders WHERE issue_id = ? AND section_id = ?',
531 array((
int) $issueId, (
int) $sectionId)
536 'UPDATE custom_section_orders SET seq = seq - 1 WHERE issue_id = ? AND seq > ?',
537 array((
int) $issueId, (
float) $seq)
547 'SELECT section_id FROM custom_section_orders WHERE issue_id = ? ORDER BY seq',
551 for ($i=1; !$result->EOF; $i++) {
552 list($sectionId) = $result->fields;
554 'UPDATE custom_section_orders SET seq = ? WHERE section_id = ? AND issue_id = ?',
555 array($i, $sectionId, (
int) $issueId)
570 'SELECT COUNT(*) FROM custom_section_orders WHERE issue_id = ?',
573 $returner = isset($result->fields[0]) && $result->fields[0] == 0 ? false :
true;
586 'SELECT seq FROM custom_section_orders WHERE issue_id = ? AND section_id = ?',
587 array((
int) $issueId, (
int) $sectionId)
592 list($returner) = $result->fields;
606 foreach ($issueSections as $section) {
620 'INSERT INTO custom_section_orders (section_id, issue_id, seq) VALUES (?, ?, ?)',
621 array((
int) $sectionId,(
int) $issueId, (
float) $seq)
633 'UPDATE custom_section_orders SET seq = ? WHERE issue_id = ? AND section_id = ?',
634 array((
float) $seq, (
int) $issueId, (
int) $sectionId)