|
|
| 154 |
} |
154 |
} |
| 155 |
|
155 |
|
| 156 |
/** |
156 |
/** |
| 157 |
* Get all submissions for a journal. |
|
|
| 158 |
* @param $journalId int |
| 159 |
* @param $status boolean true if queued, false if archived. |
| 160 |
* @return array EditorSubmission |
| 161 |
*/ |
| 162 |
function &getEditorSubmissions($journalId, $status = true, $sectionId = 0, $rangeInfo = null) { |
| 163 |
$primaryLocale = Locale::getPrimaryLocale(); |
| 164 |
$locale = Locale::getLocale(); |
| 165 |
$params = array( |
| 166 |
'title', |
| 167 |
$primaryLocale, |
| 168 |
'title', |
| 169 |
$locale, |
| 170 |
'abbrev', |
| 171 |
$primaryLocale, |
| 172 |
'abbrev', |
| 173 |
$locale, |
| 174 |
$journalId, |
| 175 |
$status |
| 176 |
); |
| 177 |
if ($sectionId) $params[] = $sectionId; |
| 178 |
|
| 179 |
$sql = 'SELECT a.*, |
| 180 |
COALESCE(stl.setting_value, stpl.setting_value) AS section_title, |
| 181 |
COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev |
| 182 |
|
| 183 |
FROM articles a |
| 184 |
LEFT JOIN sections s ON (s.section_id = a.section_id) |
| 185 |
LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?) |
| 186 |
LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?) |
| 187 |
LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?) |
| 188 |
LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) |
| 189 |
WHERE a.journal_id = ? |
| 190 |
AND a.status = ?' . |
| 191 |
($sectionId?' AND a.section_id = ?':'') . |
| 192 |
' ORDER BY article_id ASC'; |
| 193 |
|
| 194 |
$result =& $this->retrieveRange($sql, $params, $rangeInfo); |
| 195 |
$returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow'); |
| 196 |
return $returner; |
| 197 |
} |
| 198 |
|
| 199 |
/** |
| 200 |
* Get all unfiltered submissions for a journal. |
157 |
* Get all unfiltered submissions for a journal. |
| 201 |
* @param $journalId int |
158 |
* @param $journalId int |
| 202 |
* @param $sectionId int |
159 |
* @param $sectionId int |
|
|
| 207 |
* @param $dateField int Symbolic SUBMISSION_FIELD_DATE_... identifier |
164 |
* @param $dateField int Symbolic SUBMISSION_FIELD_DATE_... identifier |
| 208 |
* @param $dateFrom String date to search from |
165 |
* @param $dateFrom String date to search from |
| 209 |
* @param $dateTo String date to search to |
166 |
* @param $dateTo String date to search to |
| 210 |
* @param $status boolean whether to return active or not |
167 |
* @param $additionalWhereSql String additional SQL "where" clause info |
| 211 |
* @param $rangeInfo object |
168 |
* @param $rangeInfo object |
| 212 |
* @return array result |
169 |
* @return array result |
| 213 |
*/ |
170 |
*/ |
| 214 |
function &getUnfilteredEditorSubmissions($journalId, $sectionId = 0, $editorId = 0, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $status = true, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
171 |
function &_getUnfilteredEditorSubmissions($journalId, $sectionId = 0, $editorId = 0, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $additionalWhereSql, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
| 215 |
$primaryLocale = Locale::getPrimaryLocale(); |
172 |
$primaryLocale = Locale::getPrimaryLocale(); |
| 216 |
$locale = Locale::getLocale(); |
173 |
$locale = Locale::getLocale(); |
| 217 |
$params = array( |
174 |
$params = array( |
|
|
| 334 |
LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) |
291 |
LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) |
| 335 |
LEFT JOIN article_settings atpl ON (a.article_id = atpl.article_id AND atpl.setting_name = ? AND atpl.locale = ?) |
292 |
LEFT JOIN article_settings atpl ON (a.article_id = atpl.article_id AND atpl.setting_name = ? AND atpl.locale = ?) |
| 336 |
LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? AND atl.locale = ?) |
293 |
LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? AND atl.locale = ?) |
| 337 |
WHERE |
294 |
LEFT JOIN edit_assignments ea ON (a.article_id = ea.article_id) |
| 338 |
a.journal_id = ? AND a.submission_progress = 0'; |
295 |
LEFT JOIN edit_assignments ea2 ON (a.article_id = ea2.article_id AND ea.edit_id < ea2.edit_id) |
| 339 |
|
296 |
LEFT JOIN edit_decisions edec ON (a.article_id = edec.article_id) |
| 340 |
// "Active" submissions have a status of STATUS_QUEUED and |
297 |
LEFT JOIN edit_decisions edec2 ON (a.article_id = edec2.article_id AND edec.date_decided < edec2.date_decided) |
| 341 |
// the layout editor has not yet been acknowledged. |
298 |
WHERE edec2.date_decided IS NULL |
| 342 |
// A status value of null doesn't discriminate. |
299 |
AND ea2.edit_id IS NULL |
| 343 |
if ($status === true) $sql .= ' AND a.status = ' . STATUS_QUEUED; |
300 |
AND a.journal_id = ? |
| 344 |
elseif ($status === false) $sql .= ' AND a.status <> ' . STATUS_QUEUED; |
301 |
AND a.submission_progress = 0' . |
|
|
302 |
(!empty($additionalWhereSql)?" AND ($additionalWhereSql)":''); |
| 345 |
|
303 |
|
| 346 |
if ($sectionId) { |
304 |
if ($sectionId) { |
| 347 |
$searchSql .= ' AND a.section_id = ?'; |
305 |
$searchSql .= ' AND a.section_id = ?'; |
|
|
| 397 |
* @return array EditorSubmission |
355 |
* @return array EditorSubmission |
| 398 |
*/ |
356 |
*/ |
| 399 |
function &getEditorSubmissionsUnassigned($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
357 |
function &getEditorSubmissionsUnassigned($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
| 400 |
$editorSubmissions = array(); |
358 |
$result =& $this->_getUnfilteredEditorSubmissions( |
| 401 |
|
359 |
$journalId, $sectionId, $editorId, |
| 402 |
// FIXME Does not pass $rangeInfo else we only get partial results |
360 |
$searchField, $searchMatch, $search, |
| 403 |
$result = $this->getUnfilteredEditorSubmissions($journalId, $sectionId, $editorId, $searchField, $searchMatch, $search, $dateField, $dateFrom, $dateTo, true, null, $sortBy, $sortDirection); |
361 |
$dateField, $dateFrom, $dateTo, |
| 404 |
|
362 |
'a.status = ' . STATUS_QUEUED . ' AND ea.edit_id IS NULL', |
| 405 |
while (!$result->EOF) { |
363 |
$rangeInfo, $sortBy, $sortDirection |
| 406 |
$editorSubmission =& $this->_returnEditorSubmissionFromRow($result->GetRowAssoc(false)); |
364 |
); |
| 407 |
|
365 |
$returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow'); |
| 408 |
// used to check if editor exists for this submission |
|
|
| 409 |
$editAssignments =& $editorSubmission->getEditAssignments(); |
| 410 |
|
| 411 |
if (empty($editAssignments)) { |
| 412 |
$editorSubmissions[] =& $editorSubmission; |
| 413 |
} |
| 414 |
unset($editorSubmission); |
| 415 |
$result->MoveNext(); |
| 416 |
} |
| 417 |
$result->Close(); |
| 418 |
unset($result); |
| 419 |
|
| 420 |
import('core.ArrayItemIterator'); |
| 421 |
$returner =& ArrayItemIterator::fromRangeInfo($editorSubmissions, $rangeInfo); |
| 422 |
return $returner; |
366 |
return $returner; |
| 423 |
} |
367 |
} |
| 424 |
|
368 |
|
|
|
| 437 |
* @return array EditorSubmission |
381 |
* @return array EditorSubmission |
| 438 |
*/ |
382 |
*/ |
| 439 |
function &getEditorSubmissionsInReview($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
383 |
function &getEditorSubmissionsInReview($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
| 440 |
$editorSubmissions = array(); |
384 |
$result =& $this->_getUnfilteredEditorSubmissions( |
| 441 |
|
385 |
$journalId, $sectionId, $editorId, |
| 442 |
// FIXME Does not pass $rangeInfo else we only get partial results |
386 |
$searchField, $searchMatch, $search, |
| 443 |
$result = $this->getUnfilteredEditorSubmissions($journalId, $sectionId, $editorId, $searchField, $searchMatch, $search, $dateField, $dateFrom, $dateTo, true, null, $sortBy, $sortDirection); |
387 |
$dateField, $dateFrom, $dateTo, |
| 444 |
|
388 |
'a.status = ' . STATUS_QUEUED . ' AND ea.edit_id IS NOT NULL AND edec.decision <> ' . SUBMISSION_EDITOR_DECISION_ACCEPT, |
| 445 |
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); |
389 |
$rangeInfo, $sortBy, $sortDirection |
| 446 |
while (!$result->EOF) { |
390 |
); |
| 447 |
$editorSubmission =& $this->_returnEditorSubmissionFromRow($result->GetRowAssoc(false)); |
391 |
$returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow'); |
| 448 |
$articleId = $editorSubmission->getArticleId(); |
|
|
| 449 |
for ($i = 1; $i <= $editorSubmission->getCurrentRound(); $i++) { |
| 450 |
$reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentsByArticleId($articleId, $i); |
| 451 |
if (!empty($reviewAssignment)) { |
| 452 |
$editorSubmission->setReviewAssignments($reviewAssignment, $i); |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
// check if submission is still in review |
| 457 |
$inReview = true; |
| 458 |
$decisions = $editorSubmission->getDecisions(); |
| 459 |
$decision = array_pop($decisions); |
| 460 |
if (!empty($decision)) { |
| 461 |
$latestDecision = array_pop($decision); |
| 462 |
if ($latestDecision['decision'] == SUBMISSION_EDITOR_DECISION_ACCEPT) { |
| 463 |
$inReview = false; |
| 464 |
} |
| 465 |
} |
| 466 |
|
| 467 |
// used to check if editor exists for this submission |
| 468 |
$editAssignments =& $editorSubmission->getEditAssignments(); |
| 469 |
|
| 470 |
if (!empty($editAssignments) && $inReview) { |
| 471 |
$editorSubmissions[] =& $editorSubmission; |
| 472 |
} |
| 473 |
unset($editorSubmission); |
| 474 |
$result->MoveNext(); |
| 475 |
} |
| 476 |
$result->Close(); |
| 477 |
unset($result); |
| 478 |
|
| 479 |
import('core.ArrayItemIterator'); |
| 480 |
$returner =& ArrayItemIterator::fromRangeInfo($editorSubmissions, $rangeInfo); |
| 481 |
return $returner; |
392 |
return $returner; |
| 482 |
} |
393 |
} |
| 483 |
|
394 |
|
|
|
| 496 |
* @return array EditorSubmission |
407 |
* @return array EditorSubmission |
| 497 |
*/ |
408 |
*/ |
| 498 |
function &getEditorSubmissionsInEditing($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
409 |
function &getEditorSubmissionsInEditing($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
| 499 |
$editorSubmissions = array(); |
410 |
$result =& $this->_getUnfilteredEditorSubmissions( |
| 500 |
$signoffDao =& DAORegistry::getDAO('SignoffDAO'); |
411 |
$journalId, $sectionId, $editorId, |
| 501 |
|
412 |
$searchField, $searchMatch, $search, |
| 502 |
// FIXME Does not pass $rangeInfo else we only get partial results |
413 |
$dateField, $dateFrom, $dateTo, |
| 503 |
$result = $this->getUnfilteredEditorSubmissions($journalId, $sectionId, $editorId, $searchField, $searchMatch, $search, $dateField, $dateFrom, $dateTo, true, null, $sortBy, $sortDirection); |
414 |
'a.status = ' . STATUS_QUEUED . ' AND ea.edit_id IS NOT NULL AND edec.decision = ' . SUBMISSION_EDITOR_DECISION_ACCEPT, |
| 504 |
|
415 |
$rangeInfo, $sortBy, $sortDirection |
| 505 |
while (!$result->EOF) { |
416 |
); |
| 506 |
$editorSubmission =& $this->_returnEditorSubmissionFromRow($result->GetRowAssoc(false)); |
417 |
$returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow'); |
| 507 |
$articleId = $editorSubmission->getArticleId(); |
|
|
| 508 |
|
| 509 |
// check if submission is still in review |
| 510 |
$inEditing = false; |
| 511 |
$decisions = $editorSubmission->getDecisions(); |
| 512 |
$decision = array_pop($decisions); |
| 513 |
if (!empty($decision)) { |
| 514 |
$latestDecision = array_pop($decision); |
| 515 |
if ($latestDecision['decision'] == SUBMISSION_EDITOR_DECISION_ACCEPT) { |
| 516 |
$inEditing = true; |
| 517 |
} |
| 518 |
} |
| 519 |
|
| 520 |
// used to check if editor exists for this submission |
| 521 |
$editAssignments = $editorSubmission->getEditAssignments(); |
| 522 |
|
| 523 |
if ($inEditing && !empty($editAssignments)) { |
| 524 |
$editorSubmissions[] =& $editorSubmission; |
| 525 |
} |
| 526 |
unset($editorSubmission); |
| 527 |
$result->MoveNext(); |
| 528 |
} |
| 529 |
$result->Close(); |
| 530 |
unset($result); |
| 531 |
|
| 532 |
import('core.ArrayItemIterator'); |
| 533 |
$returner =& ArrayItemIterator::fromRangeInfo($editorSubmissions, $rangeInfo); |
| 534 |
return $returner; |
418 |
return $returner; |
| 535 |
} |
419 |
} |
| 536 |
|
420 |
|
|
|
| 549 |
* @return array EditorSubmission |
433 |
* @return array EditorSubmission |
| 550 |
*/ |
434 |
*/ |
| 551 |
function &getEditorSubmissionsArchives($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
435 |
function &getEditorSubmissionsArchives($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { |
| 552 |
$editorSubmissions = array(); |
436 |
$result =& $this->_getUnfilteredEditorSubmissions( |
| 553 |
|
437 |
$journalId, $sectionId, $editorId, |
| 554 |
$result = $this->getUnfilteredEditorSubmissions($journalId, $sectionId, $editorId, $searchField, $searchMatch, $search, $dateField, $dateFrom, $dateTo, false, $rangeInfo, $sortBy, $sortDirection); |
438 |
$searchField, $searchMatch, $search, |
| 555 |
while (!$result->EOF) { |
439 |
$dateField, $dateFrom, $dateTo, |
| 556 |
$editorSubmission =& $this->_returnEditorSubmissionFromRow($result->GetRowAssoc(false)); |
440 |
'a.status = ' . STATUS_QUEUED, |
| 557 |
$editorSubmissions[] =& $editorSubmission; |
441 |
$rangeInfo, $sortBy, $sortDirection |
| 558 |
unset($editorSubmission); |
442 |
); |
| 559 |
$result->MoveNext(); |
443 |
$returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow'); |
| 560 |
} |
|
|
| 561 |
|
| 562 |
if (isset($rangeInfo) && $rangeInfo->isValid()) { |
| 563 |
import('core.VirtualArrayIterator'); |
| 564 |
$returner = new VirtualArrayIterator($editorSubmissions, $result->MaxRecordCount(), $rangeInfo->getPage(), $rangeInfo->getCount()); |
| 565 |
} else { |
| 566 |
import('core.ArrayItemIterator'); |
| 567 |
$returner = new ArrayItemIterator($editorSubmissions); |
| 568 |
} |
| 569 |
|
| 570 |
$result->Close(); |
| 571 |
unset($result); |
| 572 |
|
| 573 |
return $returner; |
444 |
return $returner; |
| 574 |
} |
445 |
} |
| 575 |
|
446 |
|