/** * Check to make sure form conditions are met */ function validate() { // Ensure all submission types have names in the primary locale // as well as numeric word limits (optional) $primaryLocale = Locale::getPrimaryLocale(); if (isset($this->_data['paperTypes'])) { $paperTypes =& $this->_data['paperTypes']; if (!is_array($paperTypes)) { return false; } foreach ($paperTypes as $paperTypeId => $paperType) { if (!isset($paperType['name'][$primaryLocale]) || empty($paperType['name'][$primaryLocale])) { $fieldName = 'paperTypeName-' . $paperTypeId; $this->addError($fieldName, Locale::translate('manager.schedConfSetup.submissions.typeOfSubmission.nameMissing', array('primaryLocale' => $primaryLocale))); $this->addErrorField($fieldName); } if (isset($paperType['abstractLength']) && !empty($paperType['abstractLength']) && (!is_numeric($paperType['abstractLength']) || $paperType['abstractLength'] <= 0)) { $fieldName = 'paperTypeAbstractLength-' . $paperTypeId; $this->addError($fieldName, Locale::translate('manager.schedConfSetup.submissions.typeOfSubmission.abstractLengthInvalid')); $this->addErrorField($fieldName); } } } return parent::validate(); }
/** * Constructor. * @param $template string the path to the form template file */ function Form($template = null, $callHooks = true, $requiredLocale = null, $supportedLocales = null) { if ($callHooks === true && checkPhpVersion('4.3.0')) { $trace = debug_backtrace(); // Call hooks based on the calling entity, assuming // this method is only called by a subclass. Results // in hook calls named e.g. "papergalleyform::Constructor" // Note that class names are always lower case. HookRegistry::call(strtolower($trace[1]['class']) . '::Constructor', array(&$this, &$template)); } if ($requiredLocale === null) { $requiredLocale = Locale::getPrimaryLocale(); } $this->requiredLocale = $requiredLocale; if ($supportedLocales === null) { $supportedLocales = Locale::getSupportedFormLocales(); } $this->supportedLocales = $supportedLocales; $this->_template = $template; $this->_data = array(); $this->_checks = array(); $this->_errors = array(); $this->errorsArray = array(); $this->errorFields = array(); $this->formSectionErrors = array(); $this->fbvStyles = array('size' => array('SMALL' => 'SMALL', 'MEDIUM' => 'MEDIUM', 'LARGE' => 'LARGE'), 'float' => array('RIGHT' => 'RIGHT', 'LEFT' => 'LEFT'), 'align' => array('RIGHT' => 'RIGHT', 'LEFT' => 'LEFT'), 'measure' => array('1OF1' => '1OF1', '1OF2' => '1OF2', '1OF3' => '1OF3', '2OF3' => '2OF3', '1OF4' => '1OF4', '3OF4' => '3OF4', '1OF5' => '1OF5', '2OF5' => '2OF5', '3OF5' => '3OF5', '4OF5' => '4OF5', '1OF10' => '1OF10', '8OF10' => '8OF10'), 'layout' => array('THREE_COLUMNS' => 'THREE_COLUMNS', 'TWO_COLUMNS' => 'TWO_COLUMNS', 'ONE_COLUMN' => 'ONE_COLUMN')); }
/** * Get all authors for a given chapter. * @param $chapterId int * @param $monographId int * @return DAOResultFactory */ function &getAuthors($monographId = null, $chapterId = null) { $params = array('affiliation', Locale::getPrimaryLocale(), 'affiliation', Locale::getLocale()); if (isset($monographId)) { $params[] = (int) $monographId; } if (isset($chapterId)) { $params[] = (int) $chapterId; } // get all the monograph_author fields, // but replace the primary_contact and seq with monograph_chapter_authors.primary_contact $sql = 'SELECT ma.author_id, ma.submission_id, mca.chapter_id, mca.primary_contact, mca.seq, ma.first_name, ma.middle_name, ma.last_name, asl.setting_value AS affiliation_l, asl.locale, aspl.setting_value AS affiliation_pl, aspl.locale AS primary_locale, ma.country, ma.email, ma.url, ma.user_group_id FROM authors ma JOIN monograph_chapter_authors mca ON (ma.author_id = mca.author_id) LEFT JOIN author_settings aspl ON (mca.author_id = aspl.author_id AND aspl.setting_name = ? AND aspl.locale = ?) LEFT JOIN author_settings asl ON (mca.author_id = asl.author_id AND asl.setting_name = ? AND asl.locale = ?)' . (count($params) > 0 ? ' WHERE' : '') . (isset($monographId) ? ' ma.submission_id = ?' : '') . (isset($monographId) && isset($chapterId) ? ' AND' : '') . (isset($chapterId) ? ' mca.chapter_id = ?' : '') . ' ORDER BY mca.chapter_id, mca.seq'; $result =& $this->retrieve($sql, $params); $returner = new DAOResultFactory($result, $this, '_returnFromRow', array('id')); return $returner; }
/** * Get the error message associated with a failed validation check. * @see FormValidator::getMessage() * @return string */ function getMessage() { $primaryLocale = Locale::getPrimaryLocale(); $allLocales = Locale::getAllLocales(); //return parent::getMessage() . ' (' . $allLocales[$this->_requiredLocale] . ')'; return parent::getMessage(); //Edited by Anne Ivy Mirasol, April 27, 2011 }
/** * Retrieve registration option name by ID. * @param $optionId int * @return string */ function getRegistrationOptionName($optionId) { $result =& $this->retrieve('SELECT COALESCE(l.setting_value, p.setting_value) FROM registration_option_settings l LEFT JOIN registration_option_settings p ON (p.option_id = ? AND p.setting_name = ? AND p.locale = ?) WHERE l.option_id = ? AND l.setting_name = ? AND l.locale = ?', array($optionId, 'name', Locale::getLocale(), $optionId, 'name', Locale::getPrimaryLocale())); $returner = isset($result->fields[0]) ? $result->fields[0] : false; $result->Close(); unset($result); return $returner; }
/** * Retrieve subscription type name by ID. * @param $typeId int * @return string */ function getSubscriptionTypeName($typeId) { $result =& $this->retrieve('SELECT COALESCE(l.setting_value, p.setting_value) FROM subscription_type_settings l LEFT JOIN subscription_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 = ?', array($typeId, 'name', Locale::getLocale(), $typeId, 'name', Locale::getPrimaryLocale())); $returner = isset($result->fields[0]) ? $result->fields[0] : false; $result->Close(); unset($result); return $returner; }
/** * Get the article report data. * @param $journalId int * @return array */ function getArticleReport($journalId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve('SELECT a.article_id AS article_id, COALESCE(asl1.setting_value, aspl1.setting_value) AS title, COALESCE(asl2.setting_value, aspl2.setting_value) AS abstract, u.first_name AS fname, u.middle_name AS mname, u.last_name AS lname, u.email AS email, u.affiliation AS affiliation, u.country AS country, u.phone AS phone, u.fax AS fax, u.url AS url, u.mailing_address AS address, COALESCE(usl.setting_value, uspl.setting_value) AS biography, COALESCE(sl.setting_value, spl.setting_value) AS section_title, a.language AS language FROM articles a LEFT JOIN users u ON a.user_id=u.user_id LEFT JOIN user_settings uspl ON (u.user_id=uspl.user_id AND uspl.setting_name = ? AND uspl.locale = ?) LEFT JOIN user_settings usl ON (u.user_id=usl.user_id AND usl.setting_name = ? AND usl.locale = ?) LEFT JOIN article_settings aspl1 ON (aspl1.article_id=a.article_id AND aspl1.setting_name = ? AND aspl1.locale = ?) LEFT JOIN article_settings asl1 ON (asl1.article_id=a.article_id AND asl1.setting_name = ? AND asl1.locale = ?) LEFT JOIN article_settings aspl2 ON (aspl2.article_id=a.article_id AND aspl2.setting_name = ? AND aspl2.locale = ?) LEFT JOIN article_settings asl2 ON (asl2.article_id=a.article_id AND asl2.setting_name = ? AND asl2.locale = ?) LEFT JOIN section_settings spl ON (spl.section_id=a.section_id AND spl.setting_name = ? AND spl.locale = ?) LEFT JOIN section_settings sl ON (sl.section_id=a.section_id AND sl.setting_name = ? AND sl.locale = ?) WHERE a.journal_id = ? ORDER BY title', array('biography', $primaryLocale, 'biography', $locale, 'title', $primaryLocale, 'title', $locale, 'abstract', $primaryLocale, 'abstract', $locale, 'title', $primaryLocale, 'title', $locale, $journalId)); $articlesReturner =& new DBRowIterator($result); $result =& $this->retrieve('SELECT MAX(ed.date_decided) AS date, ed.article_id AS article_id FROM edit_decisions ed, articles a WHERE a.journal_id = ? AND a.article_id = ed.article_id GROUP BY ed.article_id', array($journalId)); $decisionDatesIterator =& new DBRowIterator($result); $decisions = array(); $decisionsReturner = array(); while ($row =& $decisionDatesIterator->next()) { $result =& $this->retrieve('SELECT decision AS decision, article_id AS article_id FROM edit_decisions WHERE date_decided = ? AND article_id = ?', array($row['date'], $row['article_id'])); $decisionsReturner[] =& new DBRowIterator($result); unset($result); } return array($articlesReturner, $decisionsReturner); }
function lockss($args, $request) { $this->validate(); $this->setupTemplate(); $journal =& $request->getJournal(); $templateMgr =& TemplateManager::getManager(); if ($journal != null) { if (!$journal->getSetting('enableLockss')) { $request->redirect(null, 'index'); } $year = $request->getUserVar('year'); $issueDao =& DAORegistry::getDAO('IssueDAO'); // FIXME Should probably go in IssueDAO or a subclass if (isset($year)) { $year = (int) $year; $result =& $issueDao->retrieve('SELECT * FROM issues WHERE journal_id = ? AND year = ? AND published = 1 ORDER BY current DESC, year ASC, volume ASC, number ASC', array($journal->getId(), $year)); if ($result->RecordCount() == 0) { unset($year); } } if (!isset($year)) { $showInfo = true; $result =& $issueDao->retrieve('SELECT MAX(year) FROM issues WHERE journal_id = ? AND published = 1', $journal->getId()); list($year) = $result->fields; $result =& $issueDao->retrieve('SELECT * FROM issues WHERE journal_id = ? AND year = ? AND published = 1 ORDER BY current DESC, year ASC, volume ASC, number ASC', array($journal->getId(), $year)); } else { $showInfo = false; } $issues = new DAOResultFactory($result, $issueDao, '_returnIssueFromRow'); $prevYear = null; $nextYear = null; if (isset($year)) { $result =& $issueDao->retrieve('SELECT MAX(year) FROM issues WHERE journal_id = ? AND published = 1 AND year < ?', array($journal->getId(), $year)); list($prevYear) = $result->fields; $result =& $issueDao->retrieve('SELECT MIN(year) FROM issues WHERE journal_id = ? AND published = 1 AND year > ?', array($journal->getId(), $year)); list($nextYear) = $result->fields; } $templateMgr->assign_by_ref('journal', $journal); $templateMgr->assign_by_ref('issues', $issues); $templateMgr->assign('year', $year); $templateMgr->assign('prevYear', $prevYear); $templateMgr->assign('nextYear', $nextYear); $templateMgr->assign('showInfo', $showInfo); $locales =& $journal->getSupportedLocaleNames(); if (!isset($locales) || empty($locales)) { $localeNames =& Locale::getAllLocales(); $primaryLocale = Locale::getPrimaryLocale(); $locales = array($primaryLocale => $localeNames[$primaryLocale]); } $templateMgr->assign_by_ref('locales', $locales); } else { $journalDao =& DAORegistry::getDAO('JournalDAO'); $journals =& $journalDao->getJournals(true); $templateMgr->assign_by_ref('journals', $journals); } $templateMgr->display('gateway/lockss.tpl'); }
/** * Get the registrant report data. * @param $conferenceId int * @param $schedConfId int * @return array */ function getRegistrantReport($conferenceId, $schedConfId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve('SELECT r.registration_id AS registration_id, r.user_id AS userid, u.username AS uname, u.first_name AS fname, u.middle_name AS mname, u.last_name AS lname, u.affiliation AS affiliation, u.url AS url, u.email AS email, u.phone AS phone, u.fax AS fax, u.mailing_address AS address, u.country AS country, COALESCE(rtsl.setting_value, rtspl.setting_value) AS type, r.date_registered AS regdate, r.date_paid AS paiddate, r.special_requests AS specialreq FROM registrations r LEFT JOIN users u ON r.user_id=u.user_id LEFT JOIN registration_type_settings rtsl ON (r.type_id=rtsl.type_id AND rtsl.locale=? AND rtsl.setting_name=?) LEFT JOIN registration_type_settings rtspl ON (r.type_id=rtspl.type_id AND rtsl.locale=? AND rtspl.setting_name=?) WHERE r.sched_conf_id= ? ORDER BY lname', array($locale, 'name', $primaryLocale, 'name', $schedConfId)); // prepare an iterator of all the registration information $registrationReturner = new DBRowIterator($result); $result =& $this->retrieve('SELECT r.registration_id as registration_id, roa.option_id as option_id FROM registrations r LEFT JOIN registration_option_assoc roa ON (r.registration_id = roa.registration_id) WHERE r.sched_conf_id= ?', $schedConfId); // Prepare an array of registration Options by registration Id $registrationOptionDAO =& DAORegistry::getDAO('RegistrationOptionDAO'); $iterator = new DBRowIterator($result); $registrationOptionReturner = array(); while ($row =& $iterator->next()) { $registrationId = $row['registration_id']; $registrationOptionReturner[$registrationId] =& $registrationOptionDAO->getRegistrationOptions($registrationId); } return array($registrationReturner, $registrationOptionReturner); }
/** * @see FormValidator::getFieldValue() * @return mixed */ function getFieldValue() { $form =& $this->getForm(); $data = $form->getData($this->getField()); $primaryLocale = Locale::getPrimaryLocale(); $fieldValue = ''; if (is_array($data) && isset($data[$primaryLocale])) { $fieldValue = $data[$primaryLocale]; if (is_scalar($fieldValue)) { $fieldValue = trim((string) $fieldValue); } } return $fieldValue; }
function &getPapersBySchedConfIdOrderByTrack($schedConfId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, $schedConfId); $papers = array(); $result =& $this->retrieve('SELECT p.*, COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title, COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev FROM papers p LEFT JOIN tracks t ON t.track_id = p.track_id LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?) LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?) LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?) LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?) WHERE p.sched_conf_id = ? ORDER BY track_id', $params); $returner = new DAOResultFactory($result, $this, '_returnPaperFromRow'); return $returner; }
/** * Get "localized" site page title (if applicable). * @return string */ function getSitePageHeaderTitle() { $typeArray = $this->getData('pageHeaderTitleType'); $imageArray = $this->getData('pageHeaderTitleImage'); $titleArray = $this->getData('title'); $title = null; foreach (array(Locale::getLocale(), Locale::getPrimaryLocale()) as $locale) { if (isset($typeArray[$locale]) && $typeArray[$locale]) { if (isset($imageArray[$locale])) { $title = $imageArray[$locale]; } } if (empty($title) && isset($titleArray[$locale])) { $title = $titleArray[$locale]; } if (!empty($title)) { return $title; } } return null; }
/** * Retrieve an series editor submission by monograph ID. * @param $monographId int * @return EditorSubmission */ function &getSeriesEditorSubmission($monographId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve('SELECT m.*, COALESCE(stl.setting_value, stpl.setting_value) AS series_title, COALESCE(sal.setting_value, sapl.setting_value) AS series_abbrev FROM monographs m LEFT JOIN series s ON (s.series_id = m.series_id) LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?) WHERE m.monograph_id = ?', array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, $monographId)); $returner = null; if ($result->RecordCount() != 0) { $returner =& $this->_fromRow($result->GetRowAssoc(false)); } $result->Close(); unset($result); return $returner; }
/** * Retrieve all published authors for a press in an associative array by * the first letter of the last name, for example: * $returnedArray['S'] gives array($misterSmithObject, $misterSmytheObject, ...) * Keys will appear in sorted order. Note that if pressId is null, * alphabetized authors for all presses are returned. * @param $pressId int * @param $initial An initial the last names must begin with * @return array Authors ordered by sequence */ function &getAuthorsAlphabetizedByPress($pressId = null, $initial = null, $rangeInfo = null) { $authors = array(); $params = array('affiliation', Locale::getPrimaryLocale(), 'affiliation', Locale::getLocale()); if (isset($pressId)) { $params[] = $pressId; } if (isset($initial)) { $params[] = String::strtolower($initial) . '%'; $initialSql = ' AND LOWER(ma.last_name) LIKE LOWER(?)'; } else { $initialSql = ''; } $result =& $this->retrieveRange('SELECT DISTINCT CAST(\'\' AS CHAR) AS url, 0 AS author_id, 0 AS submission_id, CAST(\'\' AS CHAR) AS email, 0 AS primary_contact, 0 AS seq, ma.first_name AS first_name, ma.middle_name AS middle_name, ma.last_name AS last_name, asl.setting_value AS affiliation_l, asl.locale, aspl.setting_value AS affiliation_pl, aspl.locale AS primary_locale, ma.country FROM authors ma LEFT JOIN author_settings aspl ON (aa.author_id = aspl.author_id AND aspl.setting_name = ? AND aspl.locale = ?) LEFT JOIN author_settings asl ON (aa.author_id = asl.author_id AND asl.setting_name = ? AND asl.locale = ?) LEFT JOIN monographs a ON (ma.submission_id = a.monograph_id) WHERE a.status = ' . STATUS_PUBLISHED . ' ' . (isset($pressId) ? 'AND a.press_id = ? ' : '') . ' AND (ma.last_name IS NOT NULL AND ma.last_name <> \'\')' . $initialSql . ' ORDER BY ma.last_name, ma.first_name', $params, $rangeInfo); $returner = new DAOResultFactory($result, $this, '_returnAuthorFromRow'); return $returner; }
/** * Get the review report data. * @param $conferenceId int * @param $schedConfId int * @return array */ function getReviewReport($schedConfId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve('SELECT paper_id, comments, author_id FROM paper_comments WHERE comment_type = ?', array(COMMENT_TYPE_PEER_REVIEW)); import('db.DBRowIterator'); $commentsReturner = new DBRowIterator($result); $result =& $this->retrieve('SELECT r.stage AS reviewStage, COALESCE(psl.setting_value, pspl.setting_value) AS paper, p.paper_id AS paperId, u.user_id AS reviewerId, u.username AS reviewer, u.first_name AS firstName, u.middle_name AS middleName, u.last_name AS lastName, r.date_assigned AS dateAssigned, r.date_notified AS dateNotified, r.date_confirmed AS dateConfirmed, r.date_completed AS dateCompleted, r.date_reminded AS dateReminded, (r.declined=1) AS declined, (r.cancelled=1) AS cancelled, r.recommendation AS recommendation FROM review_assignments r LEFT JOIN papers p ON r.paper_id=p.paper_id LEFT JOIN paper_settings psl ON (p.paper_id=psl.paper_id AND psl.locale=? AND psl.setting_name=?) LEFT JOIN paper_settings pspl ON (p.paper_id=pspl.paper_id AND pspl.locale=? AND pspl.setting_name=?), users u WHERE u.user_id=r.reviewer_id AND p.sched_conf_id= ? ORDER BY paper', array($locale, 'title', $primaryLocale, 'title', $schedConfId)); $reviewsReturner = new DBRowIterator($result); return array($commentsReturner, $reviewsReturner); }
/** * Get the review report data. * @param $journalId int * @return array */ function getReviewReport($journalId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve('SELECT article_id, comments, author_id FROM article_comments WHERE comment_type = ?', array(COMMENT_TYPE_PEER_REVIEW)); import('db.DBRowIterator'); $commentsReturner = new DBRowIterator($result); $result =& $this->retrieve('SELECT r.round AS round, COALESCE(asl.setting_value, aspl.setting_value) AS article, a.article_id AS articleId, u.user_id AS reviewerId, u.username AS reviewer, u.first_name AS firstName, u.middle_name AS middleName, u.last_name AS lastName, r.date_assigned AS dateAssigned, r.date_notified AS dateNotified, r.date_confirmed AS dateConfirmed, r.date_completed AS dateCompleted, r.date_reminded AS dateReminded, (r.declined=1) AS declined, (r.cancelled=1) AS cancelled, r.recommendation AS recommendation FROM review_assignments r LEFT JOIN articles a ON r.article_id = a.article_id LEFT JOIN article_settings asl ON (a.article_id=asl.article_id AND asl.locale=? AND asl.setting_name=?) LEFT JOIN article_settings aspl ON (a.article_id=aspl.article_id AND aspl.locale=? AND aspl.setting_name=?), users u WHERE u.user_id=r.reviewer_id AND a.journal_id= ? ORDER BY article', array($locale, 'title', $primaryLocale, 'title', $journalId)); $reviewsReturner = new DBRowIterator($result); return array($commentsReturner, $reviewsReturner); }
/** * Set localized log message (in the journal's primary locale) * @param $key localization message key * @param $params array optional array of parameters */ function setLogMessage($key, $params = array()) { $this->setMessage(Locale::translate($key, $params, Locale::getPrimaryLocale())); }
/** * Get all author submissions for an author. * @param $authorId int * @return DAOResultFactory continaing AuthorSubmissions */ function &getAuthorSubmissions($authorId, $pressId = null, $active = true, $rangeInfo = null) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, $authorId); if ($pressId) { $params[] = $pressId; } $result =& $this->retrieveRange('SELECT a.*, COALESCE(stl.setting_value, stpl.setting_value) AS series_title, COALESCE(sal.setting_value, sapl.setting_value) AS series_abbrev FROM monographs a LEFT JOIN series s ON (s.series_id = a.series_id) LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?) WHERE a.user_id = ?' . ($pressId ? ' AND a.press_id = ?' : '') . ($active ? ' AND a.status = 1' : 'AND (a.status <> 1 AND a.submission_progress = 0)'), $params, $rangeInfo); $returner = new DAOResultFactory($result, $this, '_returnAuthorSubmissionFromRow'); return $returner; }
/** * Retrieve an email template by key. * @param $emailKey string * @param $locale string * @param $assocType int * @param $assocId int * @return EmailTemplate */ function &getEmailTemplate($emailKey, $locale, $assocType, $assocId) { $primaryLocale = Locale::getPrimaryLocale(); $result =& $this->retrieve('SELECT COALESCE(edl.subject, ddl.subject, edpl.subject, ddpl.subject) AS subject, COALESCE(edl.body, ddl.body, edpl.body, ddpl.body) AS body, COALESCE(e.enabled, 1) AS enabled, d.email_key, d.can_edit, d.can_disable, e.assoc_type, e.assoc_id, e.email_id, COALESCE(ddl.locale, ddpl.locale) AS locale, d.from_role_id, d.to_role_id FROM email_templates_default d LEFT JOIN email_templates_default_data ddpl ON (ddpl.email_key = d.email_key AND ddpl.locale = ?) LEFT JOIN email_templates_default_data ddl ON (ddl.email_key = d.email_key AND ddl.locale = ?) LEFT JOIN email_templates e ON (d.email_key = e.email_key AND e.assoc_type = ? AND e.assoc_id = ?) LEFT JOIN email_templates_data edpl ON (edpl.email_key = e.email_key AND edpl.assoc_type = e.assoc_type AND edpl.assoc_id = e.assoc_id AND edpl.locale = ?) LEFT JOIN email_templates_data edl ON (edl.email_key = e.email_key AND edl.assoc_type = e.assoc_type AND edl.assoc_id = e.assoc_id AND edl.locale = ?) WHERE d.email_key = ?', array($primaryLocale, $locale, $assocType, $assocId, $primaryLocale, $locale, $emailKey)); $returner = null; if ($result->RecordCount() != 0) { $returner =& $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false)); $returner->setCustomTemplate(false); } else { $result->Close(); unset($result); // Check to see if there's a custom email template. This is done in PHP to avoid // having to do a full outer join or union in SQL. $result =& $this->retrieve('SELECT ed.subject, ed.body, 1 AS enabled, e.email_key, 1 AS can_edit, 0 AS can_disable, e.assoc_type, e.assoc_id, e.email_id, ed.locale, NULL AS from_role_id, NULL AS to_role_id FROM email_templates e LEFT JOIN email_templates_data ed ON (ed.email_key = e.email_key AND ed.assoc_type = e.assoc_type AND ed.assoc_id = e.assoc_id) LEFT JOIN email_templates_default d ON (e.email_key = d.email_key) WHERE d.email_key IS NULL AND e.assoc_type = ? AND e.assoc_id = ? AND e.email_key = ? AND ed.locale = ?', array($assocType, $assocId, $emailKey, $locale)); if ($result->RecordCount() != 0) { $returner =& $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false)); $returner->setCustomTemplate(true); } } $result->Close(); unset($result); return $returner; }
/** * Generate the unique filename for this monograph file. * @return string */ function _generateFileName() { // Remember the ID information we generated the file name // on so that we only have to re-generate the name if the // relevant information changed. static $lastIds = array(); static $fileName = null; // Retrieve the current id information. $currentIds = array('genreId' => $this->getGenreId(), 'dateUploaded' => $this->getDateUploaded(), 'monographId' => $this->getMonographId(), 'fileId' => $this->getFileId(), 'revision' => $this->getRevision(), 'fileStage' => $this->getFileStage(), 'extension' => strtolower($this->getExtension())); // Check whether we need a refresh. $refreshRequired = false; foreach ($currentIds as $key => $currentId) { if (!isset($lastIds[$key]) || $lastIds[$key] !== $currentId) { $refreshRequired = true; $lastIds = $currentIds; break; } } // Refresh the file name if required. if ($refreshRequired) { // If the file has a file genre set then include // human readable genre information. $genreName = ''; if ($currentIds['genreId']) { $primaryLocale = Locale::getPrimaryLocale(); $genreDao =& DAORegistry::getDAO('GenreDAO'); /* @var $genreDao GenreDAO */ $genre =& $genreDao->getById($currentIds['genreId']); assert(is_a($genre, 'Genre')); $genreName = $genre->getDesignation($primaryLocale) . '_' . $genre->getName($primaryLocale) . '-'; } // Generate a human readable time stamp. $timestamp = date('Ymd', strtotime($currentIds['dateUploaded'])); // Make the file name unique across all files and file revisions. // Also make sure that files can be ordered sensibly by file name. $fileName = $currentIds['monographId'] . '-' . $genreName . $currentIds['fileId'] . '-' . $currentIds['revision'] . '-' . $currentIds['fileStage'] . '-' . $timestamp . '.' . $currentIds['extension']; } return $fileName; }
/** * Parse an XML users file into a set of users to import. * @param $file string path to the XML file to parse * @return array ImportedUsers the collection of users read from the file */ function &parseData($file) { $roleDao =& DAORegistry::getDAO('RoleDAO'); $success = true; $this->usersToImport = array(); $tree = $this->parser->parse($file); $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); $schedConf =& $schedConfDao->getSchedConf($this->schedConfId); $schedConfPrimaryLocale = Locale::getPrimaryLocale(); $site =& Request::getSite(); $siteSupportedLocales = $site->getSupportedLocales(); if ($tree !== false) { foreach ($tree->getChildren() as $user) { if ($user->getName() == 'user') { // Match user element $newUser = new ImportedUser(); foreach ($user->getChildren() as $attrib) { switch ($attrib->getName()) { case 'username': // Usernames must be lowercase $newUser->setUsername(strtolower($attrib->getValue())); break; case 'password': $newUser->setMustChangePassword($attrib->getAttribute('change') == 'true' ? 1 : 0); $encrypted = $attrib->getAttribute('encrypted'); if (isset($encrypted) && $encrypted !== 'plaintext') { $ocsEncryptionScheme = Config::getVar('security', 'encryption'); if ($encrypted != $ocsEncryptionScheme) { $this->errors[] = Locale::translate('plugins.importexport.users.import.encryptionMismatch', array('importHash' => $encrypted, 'ocsHash' => $ocsEncryptionScheme)); } $newUser->setPassword($attrib->getValue()); } else { $newUser->setUnencryptedPassword($attrib->getValue()); } break; case 'salutation': $newUser->setSalutation($attrib->getValue()); break; case 'first_name': $newUser->setFirstName($attrib->getValue()); break; case 'middle_name': $newUser->setMiddleName($attrib->getValue()); break; case 'last_name': $newUser->setLastName($attrib->getValue()); break; case 'initials': $newUser->setInitials($attrib->getValue()); break; case 'gender': $newUser->setGender($attrib->getValue()); break; case 'affiliation': $locale = $attrib->getAttribute('locale'); if (empty($locale)) { $locale = $schedConfPrimaryLocale; } $newUser->setAffiliation($attrib->getValue(), $locale); break; case 'email': $newUser->setEmail($attrib->getValue()); break; case 'url': $newUser->setUrl($attrib->getValue()); break; case 'phone': $newUser->setPhone($attrib->getValue()); break; case 'fax': $newUser->setFax($attrib->getValue()); break; case 'mailing_address': $newUser->setMailingAddress($attrib->getValue()); break; case 'country': $newUser->setCountry($attrib->getValue()); break; case 'signature': $locale = $attrib->getAttribute('locale'); if (empty($locale)) { $locale = $schedConfPrimaryLocale; } $newUser->setSignature($attrib->getValue(), $locale); break; case 'interests': $locale = $attrib->getAttribute('locale'); if (empty($locale)) { $locale = $schedConfPrimaryLocale; } $newUser->setInterests($attrib->getValue(), $locale); break; case 'gossip': $locale = $attrib->getAttribute('locale'); if (empty($locale)) { $locale = $schedConfPrimaryLocale; } $newUser->setGossip($attrib->getValue(), $locale); break; case 'biography': $locale = $attrib->getAttribute('locale'); if (empty($locale)) { $locale = $schedConfPrimaryLocale; } $newUser->setBiography($attrib->getValue(), $locale); break; case 'locales': $locales = array(); foreach (explode(':', $attrib->getValue()) as $locale) { if (Locale::isLocaleValid($locale) && in_array($locale, $siteSupportedLocales)) { array_push($locales, $locale); } } $newUser->setLocales($locales); break; case 'role': $roleType = $attrib->getAttribute('type'); if ($this->validRole($roleType)) { $role = new Role(); $role->setRoleId($roleDao->getRoleIdFromPath($roleType)); $newUser->addRole($role); } break; } } array_push($this->usersToImport, $newUser); } } } return $this->usersToImport; }
/** * Get set of proofreader assignments assigned to the specified proofreader. * @param $proofreaderId int * @param $journalId int optional * @param $searchField int SUBMISSION_FIELD_... constant * @param $searchMatch String 'is' or 'contains' or 'startsWith' * @param $search String Search string * @param $dateField int SUBMISSION_FIELD_DATE_... constant * @param $dateFrom int Search from timestamp * @param $dateTo int Search to timestamp * @param $active boolean true to select active assignments, false to select completed assignments * @return array ProofreaderSubmission */ function &getSubmissions($proofreaderId, $journalId = null, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $countryField = null, $active = true, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, 'cleanTitle', 'cleanTitle', $locale, 'proposalCountry', 'proposalCountry', $locale, ASSOC_TYPE_ARTICLE, 'SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, 'SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, 'SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, 'SIGNOFF_COPYEDITING_INITIAL', $proofreaderId); if (isset($journalId)) { $params[] = $journalId; } $searchSql = ''; $countrySql = ''; if (!empty($search)) { switch ($searchField) { case SUBMISSION_FIELD_TITLE: if ($searchMatch === 'is') { $searchSql = ' AND LOWER(atl.setting_value) = LOWER(?)'; } elseif ($searchMatch === 'contains') { $searchSql = ' AND LOWER(atl.setting_value) LIKE LOWER(?)'; $search = '%' . $search . '%'; } else { // $searchMatch === 'startsWith' $searchSql = ' AND LOWER(atl.setting_value) LIKE LOWER(?)'; $search = $search . '%'; } $params[] = $search; break; case SUBMISSION_FIELD_AUTHOR: $first_last = $this->_dataSource->Concat('aa.first_name', '\' \'', 'aa.last_name'); $first_middle_last = $this->_dataSource->Concat('aa.first_name', '\' \'', 'aa.middle_name', '\' \'', 'aa.last_name'); $last_comma_first = $this->_dataSource->Concat('aa.last_name', '\', \'', 'aa.first_name'); $last_comma_first_middle = $this->_dataSource->Concat('aa.last_name', '\', \'', 'aa.first_name', '\' \'', 'aa.middle_name'); if ($searchMatch === 'is') { $searchSql = " AND (LOWER(aa.last_name) = LOWER(?) OR LOWER({$first_last}) = LOWER(?) OR LOWER({$first_middle_last}) = LOWER(?) OR LOWER({$last_comma_first}) = LOWER(?) OR LOWER({$last_comma_first_middle}) = LOWER(?))"; } elseif ($searchMatch === 'contains') { $searchSql = " AND (LOWER(aa.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = '%' . $search . '%'; } else { // $searchMatch === 'startsWith' $searchSql = " AND (LOWER(aa.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = $search . '%'; } $params[] = $params[] = $params[] = $params[] = $params[] = $search; break; case SUBMISSION_FIELD_EDITOR: $first_last = $this->_dataSource->Concat('ed.first_name', '\' \'', 'ed.last_name'); $first_middle_last = $this->_dataSource->Concat('ed.first_name', '\' \'', 'ed.middle_name', '\' \'', 'ed.last_name'); $last_comma_first = $this->_dataSource->Concat('ed.last_name', '\', \'', 'ed.first_name'); $last_comma_first_middle = $this->_dataSource->Concat('ed.last_name', '\', \'', 'ed.first_name', '\' \'', 'ed.middle_name'); if ($searchMatch === 'is') { $searchSql = " AND (LOWER(ed.last_name) = LOWER(?) OR LOWER({$first_last}) = LOWER(?) OR LOWER({$first_middle_last}) = LOWER(?) OR LOWER({$last_comma_first}) = LOWER(?) OR LOWER({$last_comma_first_middle}) = LOWER(?))"; } elseif ($searchMatch === 'contains') { $searchSql = " AND (LOWER(ed.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = '%' . $search . '%'; } else { // $searchMatch === 'startsWith' $searchSql = " AND (LOWER(ed.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = $search . '%'; } $params[] = $params[] = $params[] = $params[] = $params[] = $search; break; } } if (!empty($dateFrom) || !empty($dateTo)) { switch ($dateField) { case SUBMISSION_FIELD_DATE_SUBMITTED: if (!empty($dateFrom)) { $searchSql .= ' AND a.date_submitted >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND a.date_submitted <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND scp.date_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND scp.date_completed <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND sle.date_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND sle.date_completed <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND spr.date_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= 'AND spr.date_completed <= ' . $this->datetimeToDB($dateTo); } break; } } if (!empty($countryField)) { $countrySql = " AND LOWER(COALESCE(apc.setting_value, appc.setting_value)) = '" . $countryField . "'"; } // EL on April 2013: no edit assignments anymore /* $sql = 'SELECT DISTINCT a.*, spr.date_notified AS date_assigned, spr.date_completed AS date_completed, COALESCE(atl.setting_value, atpl.setting_value) AS submission_title, aap.last_name AS author_name, COALESCE(stl.setting_value, stpl.setting_value) AS section_title, COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev FROM articles a LEFT JOIN article_site ars ON (ars.article_id = a.article_id) LEFT JOIN authors aa ON (aa.site_id = ars.site_id) LEFT JOIN authors aap ON (aap.site_id = ars.site_id AND aap.primary_contact = 1) LEFT JOIN section_decisions sdec ON (a.article_id = sdec.article_id) LEFT JOIN section_decisions sdec2 ON (a.article_id = sdec2.article_id AND sdec.section_decision_id < sdec2.section_decision_id) LEFT JOIN edit_assignments e ON (e.article_id = a.article_id) LEFT JOIN users ed ON (e.editor_id = ed.user_id) LEFT JOIN section_settings stpl ON (sdec.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN section_settings stl ON (sdec.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN section_settings sapl ON (sdec.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN section_settings sal ON (sdec.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) LEFT JOIN article_settings atpl ON (atpl.article_id = a.article_id AND atpl.setting_name = ? AND atpl.locale = a.locale) LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? and atl.locale = ?) LEFT JOIN article_settings appc ON (a.article_id = appc.article_id AND appc.setting_name = ? AND appc.locale = a.locale) LEFT JOIN article_settings apc ON (a.article_id = apc.article_id AND apc.setting_name = ? AND apc.locale = ?) LEFT JOIN signoffs scpf ON (a.article_id = scpf.assoc_id AND scpf.assoc_type = ? AND scpf.symbolic = ?) LEFT JOIN signoffs sle ON (a.article_id = sle.assoc_id AND sle.assoc_type = ? AND sle.symbolic = ?) LEFT JOIN signoffs spr ON (a.article_id = spr.assoc_id AND spr.assoc_type = ? AND spr.symbolic = ?) LEFT JOIN signoffs scpi ON (a.article_id = scpi.assoc_id AND scpi.assoc_type = ? AND scpi.symbolic = ?) WHERE spr.user_id = ? AND sdec2.section_decision_id IS NULL AND ' . (isset($journalId)?'a.journal_id = ? AND':'') . ' spr.date_notified IS NOT NULL'; */ $sql = 'SELECT DISTINCT a.*, spr.date_notified AS date_assigned, spr.date_completed AS date_completed, COALESCE(atl.setting_value, atpl.setting_value) AS submission_title, aap.last_name AS author_name, COALESCE(stl.setting_value, stpl.setting_value) AS section_title, COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev FROM articles a LEFT JOIN article_site ars ON (ars.article_id = a.article_id) LEFT JOIN authors aa ON (aa.site_id = ars.site_id) LEFT JOIN authors aap ON (aap.site_id = ars.site_id AND aap.primary_contact = 1) LEFT JOIN section_decisions sdec ON (a.article_id = sdec.article_id) LEFT JOIN section_decisions sdec2 ON (a.article_id = sdec2.article_id AND sdec.section_decision_id < sdec2.section_decision_id) LEFT JOIN section_editors se ON (se.section_id = sdec.section_id) LEFT JOIN users ed ON (se.editor_id = ed.user_id) LEFT JOIN section_settings stpl ON (sdec.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN section_settings stl ON (sdec.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN section_settings sapl ON (sdec.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN section_settings sal ON (sdec.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) LEFT JOIN article_settings atpl ON (atpl.article_id = a.article_id AND atpl.setting_name = ? AND atpl.locale = a.locale) LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? and atl.locale = ?) LEFT JOIN article_settings appc ON (a.article_id = appc.article_id AND appc.setting_name = ? AND appc.locale = a.locale) LEFT JOIN article_settings apc ON (a.article_id = apc.article_id AND apc.setting_name = ? AND apc.locale = ?) LEFT JOIN signoffs scpf ON (a.article_id = scpf.assoc_id AND scpf.assoc_type = ? AND scpf.symbolic = ?) LEFT JOIN signoffs sle ON (a.article_id = sle.assoc_id AND sle.assoc_type = ? AND sle.symbolic = ?) LEFT JOIN signoffs spr ON (a.article_id = spr.assoc_id AND spr.assoc_type = ? AND spr.symbolic = ?) LEFT JOIN signoffs scpi ON (a.article_id = scpi.assoc_id AND scpi.assoc_type = ? AND scpi.symbolic = ?) WHERE spr.user_id = ? AND sdec2.section_decision_id IS NULL AND ' . (isset($journalId) ? 'a.journal_id = ? AND' : '') . ' spr.date_notified IS NOT NULL'; if ($active) { $sql .= ' AND spr.date_completed IS NULL'; } else { $sql .= ' AND spr.date_completed IS NOT NULL'; } $result =& $this->retrieveRange($sql . ' ' . $searchSql . $countrySql . ($sortBy ? ' ORDER BY ' . $this->getSortMapping($sortBy) . ' ' . $this->getDirectionMapping($sortDirection) : ''), $params, $rangeInfo); $returner = new DAOResultFactory($result, $this, '_returnSubmissionFromRow'); return $returner; }
/** * Retrieve unfiltered track director submissions */ function &_getUnfilteredTrackDirectorSubmissions($trackDirectorId, $schedConfId, $trackId = 0, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $additionalWhereSql = '', $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, 'cleanTitle', $locale, 'cleanTitle', $schedConfId, $trackDirectorId); $searchSql = ''; if (!empty($search)) { switch ($searchField) { case SUBMISSION_FIELD_TITLE: if ($searchMatch === 'is') { $searchSql = ' AND LOWER(ptl.setting_value) = LOWER(?)'; } elseif ($searchMatch === 'contains') { $searchSql = ' AND LOWER(ptl.setting_value) LIKE LOWER(?)'; $search = '%' . $search . '%'; } else { // $searchMatch === 'startsWith' $searchSql = ' AND LOWER(ptl.setting_value) LIKE LOWER(?)'; $search = '%' . $search . '%'; } $params[] = $search; break; case SUBMISSION_FIELD_AUTHOR: $first_last = $this->_dataSource->Concat('pa.first_name', '\' \'', 'pa.last_name'); $first_middle_last = $this->_dataSource->Concat('pa.first_name', '\' \'', 'pa.middle_name', '\' \'', 'pa.last_name'); $last_comma_first = $this->_dataSource->Concat('pa.last_name', '\', \'', 'pa.first_name'); $last_comma_first_middle = $this->_dataSource->Concat('pa.last_name', '\', \'', 'pa.first_name', '\' \'', 'pa.middle_name'); if ($searchMatch === 'is') { $searchSql = " AND (LOWER(pa.last_name) = LOWER(?) OR LOWER({$first_last}) = LOWER(?) OR LOWER({$first_middle_last}) = LOWER(?) OR LOWER({$last_comma_first}) = LOWER(?) OR LOWER({$last_comma_first_middle}) = LOWER(?))"; } elseif ($searchMatch === 'contains') { $searchSql = " AND (LOWER(pa.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = '%' . $search . '%'; } else { // $searchMatch === 'startsWith' $searchSql = " AND (LOWER(pa.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = $search . '%'; } $params[] = $params[] = $params[] = $params[] = $params[] = $search; break; case SUBMISSION_FIELD_DIRECTOR: $first_last = $this->_dataSource->Concat('ed.first_name', '\' \'', 'ed.last_name'); $first_middle_last = $this->_dataSource->Concat('ed.first_name', '\' \'', 'ed.middle_name', '\' \'', 'ed.last_name'); $last_comma_first = $this->_dataSource->Concat('ed.last_name', '\', \'', 'ed.first_name'); $last_comma_first_middle = $this->_dataSource->Concat('ed.last_name', '\', \'', 'ed.first_name', '\' \'', 'ed.middle_name'); if ($searchMatch === 'is') { $searchSql = " AND (LOWER(ed.last_name) = LOWER(?) OR LOWER({$first_last}) = LOWER(?) OR LOWER({$first_middle_last}) = LOWER(?) OR LOWER({$last_comma_first}) = LOWER(?) OR LOWER({$last_comma_first_middle}) = LOWER(?))"; } elseif ($searchMatch === 'contains') { $searchSql = " AND (LOWER(ed.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = '%' . $search . '%'; } else { // $searchMatch === 'startsWith' $searchSql = " AND (LOWER(ed.last_name) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = $search . '%'; } $params[] = $params[] = $params[] = $params[] = $params[] = $search; break; } } if (!empty($dateFrom) || !empty($dateTo)) { switch ($dateField) { case SUBMISSION_FIELD_DATE_SUBMITTED: if (!empty($dateFrom)) { $searchSql .= ' AND p.date_submitted >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND p.date_submitted <= ' . $this->datetimeToDB($dateTo); } break; } } $sql = 'SELECT DISTINCT p.*, r2.review_revision, COALESCE(ptl.setting_value, ptpl.setting_value) AS submission_title, pap.last_name AS author_name, COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title, COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev FROM papers p LEFT JOIN authors pa ON (pa.submission_id = p.paper_id) LEFT JOIN authors pap ON (pap.submission_id = p.paper_id AND pap.primary_contact = 1) LEFT JOIN edit_assignments e ON (e.paper_id = p.paper_id) LEFT JOIN users ed ON (e.director_id = ed.user_id) LEFT JOIN tracks t ON (t.track_id = p.track_id) LEFT JOIN review_rounds r2 ON (p.paper_id = r2.submission_id and p.current_round = r2.round) LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?) LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?) LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?) LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?) LEFT JOIN paper_settings ptl ON (p.paper_id = ptl.paper_id AND ptl.setting_name = ? AND ptl.locale = ?) LEFT JOIN paper_settings ptpl ON (p.paper_id = ptpl.paper_id AND ptpl.setting_name = ? AND ptpl.locale = p.locale) WHERE p.sched_conf_id = ? ' . (!empty($additionalWhereSql) ? " AND ({$additionalWhereSql})" : '') . ' AND e.director_id = ?'; if ($trackId) { $params[] = $trackId; $searchSql .= ' AND p.track_id = ?'; } $result =& $this->retrieveRange($sql . ' ' . $searchSql . ($sortBy ? ' ORDER BY ' . $this->getSortMapping($sortBy) . ' ' . $this->getDirectionMapping($sortDirection) : ''), $params, $rangeInfo); return $result; }
/** * Get the error message associated with a failed validation check. * @return string */ function getMessage() { $primaryLocale = Locale::getPrimaryLocale(); $allLocales = Locale::getAllLocales(); return parent::getMessage() . ' (' . $allLocales[$primaryLocale] . ')'; }
/** * Get set of proofreader assignments assigned to the specified proofreader. * @param $proofreaderId int * @param $journalId int optional * @param $searchField int SUBMISSION_FIELD_... constant * @param $searchMatch String 'is' or 'contains' * @param $search String Search string * @param $dateField int SUBMISSION_FIELD_DATE_... constant * @param $dateFrom int Search from timestamp * @param $dateTo int Search to timestamp * @param $active boolean true to select active assignments, false to select completed assignments * @return array ProofreaderSubmission */ function &getSubmissions($proofreaderId, $journalId = null, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $active = true, $rangeInfo = null) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, 'title', 'firstName', $locale, 'lastName', $locale, 'middleName', $locale, 'firstName', $locale, 'lastName', $locale, 'middleName', $locale, $proofreaderId); if (isset($journalId)) { $params[] = $journalId; } $searchSql = ''; if (!empty($search)) { switch ($searchField) { case SUBMISSION_FIELD_TITLE: if ($searchMatch === 'is') { $searchSql = ' AND LOWER(atl.setting_value) = LOWER(?)'; } else { $searchSql = ' AND LOWER(atl.setting_value) LIKE LOWER(?)'; $search = '%' . $search . '%'; } $params[] = $search; break; case SUBMISSION_FIELD_AUTHOR: $first_last = $this->_dataSource->Concat('aaf.setting_value', '\' \'', 'aal.setting_value'); $first_middle_last = $this->_dataSource->Concat('aaf.setting_value', '\' \'', 'aam.setting_value', '\' \'', 'aal.setting_value'); $last_comma_first = $this->_dataSource->Concat('aal.setting_value', '\', \'', 'aaf.setting_value'); $last_comma_first_middle = $this->_dataSource->Concat('aal.setting_value', '\', \'', 'aaf.setting_value', '\' \'', 'aam.setting_value'); if ($searchMatch === 'is') { $searchSql = " AND (LOWER(aal.setting_value) = LOWER(?) OR LOWER({$first_last}) = LOWER(?) OR LOWER({$first_middle_last}) = LOWER(?) OR LOWER({$last_comma_first}) = LOWER(?) OR LOWER({$last_comma_first_middle}) = LOWER(?))"; } else { $searchSql = " AND (LOWER(aal.setting_value) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = '%' . $search . '%'; } $params[] = $params[] = $params[] = $params[] = $params[] = $search; break; case SUBMISSION_FIELD_EDITOR: $first_last = $this->_dataSource->Concat('edsf.setting_value', '\' \'', 'edsl.setting_value'); $first_middle_last = $this->_dataSource->Concat('edsf.setting_value', '\' \'', 'edsm.setting_value', '\' \'', 'edsl.setting_value'); $last_comma_first = $this->_dataSource->Concat('edsl.setting_value', '\', \'', 'edsf.setting_value'); $last_comma_first_middle = $this->_dataSource->Concat('edsl.setting_value', '\', \'', 'edsf.setting_value', '\' \'', 'edsm.setting_value'); if ($searchMatch === 'is') { $searchSql = " AND (LOWER(edsl.setting_value) = LOWER(?) OR LOWER({$first_last}) = LOWER(?) OR LOWER({$first_middle_last}) = LOWER(?) OR LOWER({$last_comma_first}) = LOWER(?) OR LOWER({$last_comma_first_middle}) = LOWER(?))"; } else { $searchSql = " AND (LOWER(edsl.setting_value) LIKE LOWER(?) OR LOWER({$first_last}) LIKE LOWER(?) OR LOWER({$first_middle_last}) LIKE LOWER(?) OR LOWER({$last_comma_first}) LIKE LOWER(?) OR LOWER({$last_comma_first_middle}) LIKE LOWER(?))"; $search = '%' . $search . '%'; } $params[] = $params[] = $params[] = $params[] = $params[] = $search; break; } } if (!empty($dateFrom) || !empty($dateTo)) { switch ($dateField) { case SUBMISSION_FIELD_DATE_SUBMITTED: if (!empty($dateFrom)) { $searchSql .= ' AND a.date_submitted >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND a.date_submitted <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND c.date_final_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND c.date_final_completed <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND l.date_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND l.date_completed <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND p.date_proofreader_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= 'AND p.date_proofreader_completed <= ' . $this->datetimeToDB($dateTo); } break; } } $sql = 'SELECT DISTINCT a.*, COALESCE(stl.setting_value, stpl.setting_value) AS section_title, COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev FROM articles a INNER JOIN article_authors aa ON (aa.article_id = a.article_id) INNER JOIN proof_assignments p ON (p.article_id = a.article_id) LEFT JOIN sections s ON s.section_id = a.section_id LEFT JOIN copyed_assignments c ON (c.article_id = a.article_id) LEFT JOIN edit_assignments e ON (e.article_id = a.article_id) LEFT JOIN users ed ON (e.editor_id = ed.user_id) LEFT JOIN layouted_assignments l ON (l.article_id = a.article_id) LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ?) LEFT JOIN user_settings edsf ON (ed.user_id = edsf.user_id AND edsf.setting_name = ? AND edsf.locale = ?) LEFT JOIN user_settings edsl ON (ed.user_id = edsl.user_id AND edsl.setting_name = ? AND edsl.locale = ?) LEFT JOIN user_settings edsm ON (ed.user_id = edsm.user_id AND edsm.setting_name = ? AND edsm.locale = ?) LEFT JOIN article_author_settings aaf ON (aa.author_id = aaf.author_id AND aaf.setting_name = ? AND aaf.locale = ?) LEFT JOIN article_author_settings aal ON (aa.author_id = aal.author_id AND aal.setting_name = ? AND aal.locale = ?) LEFT JOIN article_author_settings aam ON (aa.author_id = aam.author_id AND aam.setting_name = ? AND aam.locale = ?) WHERE p.proofreader_id = ? AND ' . (isset($journalId) ? 'a.journal_id = ? AND' : '') . ' p.date_proofreader_notified IS NOT NULL'; if ($active) { $sql .= ' AND p.date_proofreader_completed IS NULL'; } else { $sql .= ' AND p.date_proofreader_completed IS NOT NULL'; } $result =& $this->retrieveRange($sql . ' ' . $searchSql, $params, $rangeInfo); $returner =& new DAOResultFactory($result, $this, '_returnSubmissionFromRow'); return $returner; }
/** * Get all articles for a user. * @param $userId int * @param $journalId int optional * @return array Articles */ function &getArticlesByUserId($userId, $journalId = null) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, $userId); if ($journalId) { $params[] = $journalId; } $articles = array(); $result =& $this->retrieve('SELECT a.*, COALESCE(stl.setting_value, stpl.setting_value) AS section_title, COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev FROM articles a LEFT JOIN sections s ON s.section_id = a.section_id LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) WHERE a.user_id = ?' . (isset($journalId) ? ' AND a.journal_id = ?' : ''), $params); while (!$result->EOF) { $articles[] =& $this->_returnArticleFromRow($result->GetRowAssoc(false)); $result->MoveNext(); } $result->Close(); unset($result); return $articles; }
/** * Get all unfiltered submissions for a journal. * @param $journalId int * @param $sectionId int * @param $editorId int * @param $searchField int Symbolic SUBMISSION_FIELD_... identifier * @param $searchMatch string "is" or "contains" * @param $search String to look in $searchField for * @param $dateField int Symbolic SUBMISSION_FIELD_DATE_... identifier * @param $dateFrom String date to search from * @param $dateTo String date to search to * @param $status boolean whether to return active or not * @param $rangeInfo object * @return array result */ function &getUnfilteredEditorSubmissions($journalId, $sectionId = 0, $editorId = 0, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $status = true, $rangeInfo = null) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $params = array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, 'title', $primaryLocale, 'title', $locale, 'firstName', $locale, 'firstName', $locale, 'firstName', $locale, 'firstName', $locale, 'firstName', $locale, 'firstName', $locale, 'lastName', $locale, 'lastName', $locale, 'lastName', $locale, 'lastName', $locale, 'lastName', $locale, 'lastName', $locale, 'middleName', $locale, 'middleName', $locale, 'middleName', $locale, 'middleName', $locale, 'middleName', $locale, 'middleName', $locale, $journalId); $searchSql = ''; if (!empty($search)) { switch ($searchField) { case SUBMISSION_FIELD_TITLE: if ($searchMatch === 'is') { $searchSql = ' AND LOWER(COALESCE(atl.setting_value, atpl.setting_value)) = LOWER(?)'; } else { $searchSql = ' AND LOWER(COALESCE(atl.setting_value, atpl.setting_value)) LIKE LOWER(?)'; $search = '%' . $search . '%'; } $params[] = $search; break; case SUBMISSION_FIELD_AUTHOR: $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'aa', $params); break; case SUBMISSION_FIELD_EDITOR: $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'ed', $params); break; case SUBMISSION_FIELD_REVIEWER: $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 're', $params); break; case SUBMISSION_FIELD_COPYEDITOR: $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'ce', $params); break; case SUBMISSION_FIELD_LAYOUTEDITOR: $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'le', $params); break; case SUBMISSION_FIELD_PROOFREADER: $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'pe', $params); break; } } if (!empty($dateFrom) || !empty($dateTo)) { switch ($dateField) { case SUBMISSION_FIELD_DATE_SUBMITTED: if (!empty($dateFrom)) { $searchSql .= ' AND a.date_submitted >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND a.date_submitted <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND c.date_final_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND c.date_final_completed <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND l.date_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND l.date_completed <= ' . $this->datetimeToDB($dateTo); } break; case SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE: if (!empty($dateFrom)) { $searchSql .= ' AND p.date_proofreader_completed >= ' . $this->datetimeToDB($dateFrom); } if (!empty($dateTo)) { $searchSql .= ' AND p.date_proofreader_completed <= ' . $this->datetimeToDB($dateTo); } break; } } $sql = 'SELECT DISTINCT a.*, COALESCE(stl.setting_value, stpl.setting_value) AS section_title, COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev FROM articles a INNER JOIN article_authors aa ON (aa.article_id = a.article_id) LEFT JOIN sections s ON (s.section_id = a.section_id) LEFT JOIN edit_assignments e ON (e.article_id = a.article_id) LEFT JOIN users ed ON (e.editor_id = ed.user_id) LEFT JOIN copyed_assignments c ON (a.article_id = c.article_id) LEFT JOIN users ce ON (c.copyeditor_id = ce.user_id) LEFT JOIN proof_assignments p ON (p.article_id = a.article_id) LEFT JOIN users pe ON (pe.user_id = p.proofreader_id) LEFT JOIN layouted_assignments l ON (l.article_id = a.article_id) LEFT JOIN users le ON (le.user_id = l.editor_id) LEFT JOIN review_assignments r ON (r.article_id = a.article_id) LEFT JOIN users re ON (re.user_id = r.reviewer_id AND cancelled = 0) LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?) LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?) LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?) LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) LEFT JOIN article_settings atpl ON (a.article_id = atpl.article_id AND atpl.setting_name = ? AND atpl.locale = ?) LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? AND atl.locale = ?) LEFT JOIN article_author_settings aasf ON (aa.author_id = aasf.author_id AND aasf.setting_name = ? AND aasf.locale = ?) LEFT JOIN user_settings edsf ON (ed.user_id = edsf.user_id AND edsf.setting_name = ? AND edsf.locale = ?) LEFT JOIN user_settings cesf ON (ce.user_id = cesf.user_id AND cesf.setting_name = ? AND cesf.locale = ?) LEFT JOIN user_settings pesf ON (pe.user_id = pesf.user_id AND pesf.setting_name = ? AND pesf.locale = ?) LEFT JOIN user_settings lesf ON (le.user_id = lesf.user_id AND lesf.setting_name = ? AND lesf.locale = ?) LEFT JOIN user_settings resf ON (re.user_id = resf.user_id AND resf.setting_name = ? AND resf.locale = ?) LEFT JOIN article_author_settings aasl ON (aa.author_id = aasl.author_id AND aasl.setting_name = ? AND aasl.locale = ?) LEFT JOIN user_settings edsl ON (ed.user_id = edsl.user_id AND edsl.setting_name = ? AND edsl.locale = ?) LEFT JOIN user_settings cesl ON (ce.user_id = cesl.user_id AND cesl.setting_name = ? AND cesl.locale = ?) LEFT JOIN user_settings pesl ON (pe.user_id = pesl.user_id AND pesl.setting_name = ? AND pesl.locale = ?) LEFT JOIN user_settings lesl ON (le.user_id = lesl.user_id AND lesl.setting_name = ? AND lesl.locale = ?) LEFT JOIN user_settings resl ON (re.user_id = resl.user_id AND resl.setting_name = ? AND resl.locale = ?) LEFT JOIN article_author_settings aasm ON (aa.author_id = aasm.author_id AND aasm.setting_name = ? AND aasm.locale = ?) LEFT JOIN user_settings edsm ON (ed.user_id = edsm.user_id AND edsm.setting_name = ? AND edsm.locale = ?) LEFT JOIN user_settings cesm ON (ce.user_id = cesm.user_id AND cesm.setting_name = ? AND cesm.locale = ?) LEFT JOIN user_settings pesm ON (pe.user_id = pesm.user_id AND pesm.setting_name = ? AND pesm.locale = ?) LEFT JOIN user_settings lesm ON (le.user_id = lesm.user_id AND lesm.setting_name = ? AND lesm.locale = ?) LEFT JOIN user_settings resm ON (re.user_id = resm.user_id AND resm.setting_name = ? AND resm.locale = ?) WHERE a.journal_id = ? AND a.submission_progress = 0'; // "Active" submissions have a status of STATUS_QUEUED and // the layout editor has not yet been acknowledged. // A status value of null doesn't discriminate. if ($status === true) { $sql .= ' AND a.status = ' . STATUS_QUEUED; } elseif ($status === false) { $sql .= ' AND a.status <> ' . STATUS_QUEUED; } if ($sectionId) { $searchSql .= ' AND a.section_id = ?'; $params[] = $sectionId; } if ($editorId) { $searchSql .= ' AND ed.user_id = ?'; $params[] = $editorId; } $result =& $this->retrieveRange($sql . ' ' . $searchSql . ' ORDER BY article_id ASC', count($params) === 1 ? array_shift($params) : $params, $rangeInfo); return $result; }
/** * Get the paper report data. * @param $conferenceId int * @param $schedConfId int * @return array */ function getPaperReport($conferenceId, $schedConfId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieve('SELECT p.status AS status, p.start_time AS start_time, p.end_time AS end_time, pp.room_id AS room_id, p.paper_id AS paper_id, COALESCE(psl1.setting_value, pspl1.setting_value) AS title, COALESCE(psl2.setting_value, pspl2.setting_value) AS abstract, COALESCE(tl.setting_value, tpl.setting_value) AS track_title, p.language AS language FROM papers p LEFT JOIN published_papers pp ON (p.paper_id = pp.paper_id) LEFT JOIN paper_settings pspl1 ON (pspl1.paper_id=p.paper_id AND pspl1.setting_name = ? AND pspl1.locale = ?) LEFT JOIN paper_settings psl1 ON (psl1.paper_id=p.paper_id AND psl1.setting_name = ? AND psl1.locale = ?) LEFT JOIN paper_settings pspl2 ON (pspl2.paper_id=p.paper_id AND pspl2.setting_name = ? AND pspl2.locale = ?) LEFT JOIN paper_settings psl2 ON (psl2.paper_id=p.paper_id AND psl2.setting_name = ? AND psl2.locale = ?) LEFT JOIN track_settings tpl ON (tpl.track_id=p.track_id AND tpl.setting_name = ? AND tpl.locale = ?) LEFT JOIN track_settings tl ON (tl.track_id=p.track_id AND tl.setting_name = ? AND tl.locale = ?) WHERE p.sched_conf_id = ? ORDER BY p.paper_id', array('title', $primaryLocale, 'title', $locale, 'abstract', $primaryLocale, 'abstract', $locale, 'title', $primaryLocale, 'title', $locale, $schedConfId)); $papersReturner = new DBRowIterator($result); unset($result); $result =& $this->retrieve('SELECT MAX(ed.date_decided) AS date, ed.paper_id AS paper_id FROM edit_decisions ed, papers p WHERE p.sched_conf_id = ? AND p.paper_id = ed.paper_id GROUP BY p.paper_id, ed.paper_id', array($schedConfId)); $decisionDatesIterator = new DBRowIterator($result); unset($result); $decisionsReturner = array(); while ($row =& $decisionDatesIterator->next()) { $result =& $this->retrieve('SELECT decision AS decision, paper_id AS paper_id FROM edit_decisions WHERE date_decided = ? AND paper_id = ?', array($row['date'], $row['paper_id'])); $decisionsReturner[] = new DBRowIterator($result); unset($result); } $paperDao =& DAORegistry::getDAO('PaperDAO'); $papers =& $paperDao->getPapersBySchedConfId($schedConfId); $authorsReturner = array(); $index = 1; while ($paper =& $papers->next()) { $result =& $this->retrieve('SELECT pa.first_name AS fname, pa.middle_name AS mname, pa.last_name AS lname, pa.email AS email, pa.affiliation AS affiliation, pa.country AS country, pa.url AS url, COALESCE(pasl.setting_value, pas.setting_value) AS biography FROM paper_authors pa LEFT JOIN papers p ON pa.paper_id=p.paper_id LEFT JOIN paper_author_settings pas ON (pa.author_id=pas.author_id AND pas.setting_name = ? AND pas.locale = ?) LEFT JOIN paper_author_settings pasl ON (pa.author_id=pasl.author_id AND pasl.setting_name = ? AND pasl.locale = ?) WHERE p.sched_conf_id = ? AND p.paper_id = ?', array('biography', $primaryLocale, 'biography', $locale, $schedConfId, $paper->getId())); $authorIterator = new DBRowIterator($result); unset($result); $authorsReturner[$paper->getId()] = $authorIterator; unset($authorIterator); $index++; unset($paper); } return array($papersReturner, $authorsReturner, $decisionsReturner); }
/** * @see MetadataDataObjectAdapter::extractMetadataFromDataObject() * @param $submission Submission * @param $authorMarcrelatorRole string the marcrelator role to be used * for submission authors. * @return MetadataDescription */ function &extractMetadataFromDataObject(&$submission, $authorMarcrelatorRole = 'aut') { assert(is_a($submission, 'Submission')); $mods34Description =& $this->instantiateMetadataDescription(); // Retrieve the primary locale. $catalogingLocale = Locale::getPrimaryLocale(); $catalogingLanguage = Locale::get3LetterIsoFromLocale($catalogingLocale); // Establish the association between the meta-data description // and the submission. $mods34Description->setAssocId($submission->getId()); // Title $localizedTitles =& $submission->getTitle(null); // Localized $this->addLocalizedStatements($mods34Description, 'titleInfo/title', $localizedTitles); // Authors // FIXME: Move this to a dedicated adapter in the Author class. $authors =& $submission->getAuthors(); foreach ($authors as $author) { /* @var $author Author */ // Create a new name description. $authorDescription = new MetadataDescription('lib.pkp.plugins.metadata.mods34.schema.Mods34NameSchema', ASSOC_TYPE_AUTHOR); // Type $authorType = 'personal'; $authorDescription->addStatement('[@type]', $authorType); // Family Name $authorDescription->addStatement('namePart[@type="family"]', $author->getLastName()); // Given Names $firstName = (string) $author->getFirstName(); $middleName = (string) $author->getMiddleName(); $givenNames = trim($firstName . ' ' . $middleName); if (!empty($givenNames)) { $authorDescription->addStatement('namePart[@type="given"]', $givenNames); } // Affiliation // NB: Our MODS mapping currently doesn't support translation for names. // This can be added when required by data consumers. We therefore only use // translations in the cataloging language. $affiliation = $author->getAffiliation($catalogingLocale); if ($affiliation) { $authorDescription->addStatement('affiliation', $affiliation); } // Terms of address (unmapped field) $termsOfAddress = $author->getData('nlm34:namePart[@type="termsOfAddress"]'); if ($termsOfAddress) { $authorDescription->addStatement('namePart[@type="termsOfAddress"]', $termsOfAddress); } // Date (unmapped field) $date = $author->getData('nlm34:namePart[@type="date"]'); if ($date) { $authorDescription->addStatement('namePart[@type="date"]', $date); } // Role $authorDescription->addStatement('role/roleTerm[@type="code" @authority="marcrelator"]', $authorMarcrelatorRole); // Add the author to the MODS schema. $mods34Description->addStatement('name', $authorDescription); unset($authorDescription); } // Sponsor // NB: Our MODS mapping currently doesn't support translation for names. // This can be added when required by data consumers. We therefore only use // translations in the cataloging language. $supportingAgency = $submission->getSponsor($catalogingLocale); if ($supportingAgency) { $supportingAgencyDescription = new MetadataDescription('lib.pkp.plugins.metadata.mods34.schema.Mods34NameSchema', ASSOC_TYPE_AUTHOR); $sponsorNameType = 'corporate'; $supportingAgencyDescription->addStatement('[@type]', $sponsorNameType); $supportingAgencyDescription->addStatement('namePart', $supportingAgency); $sponsorRole = 'spn'; $supportingAgencyDescription->addStatement('role/roleTerm[@type="code" @authority="marcrelator"]', $sponsorRole); $mods34Description->addStatement('name', $supportingAgencyDescription); } // Type of resource $typeOfResource = 'text'; $mods34Description->addStatement('typeOfResource', $typeOfResource); // Creation & copyright date $submissionDate = $submission->getDateSubmitted(); if (strlen($submissionDate) >= 4) { $mods34Description->addStatement('originInfo/dateCreated[@encoding="w3cdtf"]', $submissionDate); $mods34Description->addStatement('originInfo/copyrightDate[@encoding="w3cdtf"]', substr($submissionDate, 0, 4)); } // Submission language $submissionLanguage = Locale::get3LetterFrom2LetterIsoLanguage($submission->getLanguage()); if (!$submissionLanguage) { // Assume the cataloging language by default. $submissionLanguage = $catalogingLanguage; } $mods34Description->addStatement('language/languageTerm[@type="code" @authority="iso639-2b"]', $submissionLanguage); // Pages (extent) $mods34Description->addStatement('physicalDescription/extent', $submission->getPages()); // Abstract $localizedAbstracts =& $submission->getAbstract(null); // Localized $this->addLocalizedStatements($mods34Description, 'abstract', $localizedAbstracts); // Discipline $localizedDisciplines = $submission->getDiscipline(null); // Localized $this->addLocalizedStatements($mods34Description, 'subject/topic', $localizedDisciplines); // Subject class $localizedSubjectClasses = $submission->getSubjectClass(null); // Localized $this->addLocalizedStatements($mods34Description, 'subject/topic', $localizedSubjectClasses); // Subject $localizedSubjects = $submission->getSubject(null); // Localized $this->addLocalizedStatements($mods34Description, 'subject/topic', $localizedSubjects); // Geographical coverage $localizedCoverageGeo = $submission->getCoverageGeo(null); // Localized $this->addLocalizedStatements($mods34Description, 'subject/geographic', $localizedCoverageGeo); // Chronological coverage $localizedCoverageChron = $submission->getCoverageChron(null); // Localized $this->addLocalizedStatements($mods34Description, 'subject/temporal', $localizedCoverageChron); // Record creation date $recordCreationDate = date('Y-m-d'); $mods34Description->addStatement('recordInfo/recordCreationDate[@encoding="w3cdtf"]', $recordCreationDate); // Record identifier $mods34Description->addStatement('recordInfo/recordIdentifier[@source="pkp"]', $submission->getId()); // Cataloging language $mods34Description->addStatement('recordInfo/languageOfCataloging/languageTerm[@authority="iso639-2b"]', $catalogingLanguage); // Handle unmapped fields. $this->extractUnmappedDataObjectMetadataFields($submission, $mods34Description); return $mods34Description; }
/** * Get all submissions for a reviewer of a conference. * @param $reviewerId int * @param $schedConfId int * @param $rangeInfo object * @return array ReviewerSubmissions */ function &getReviewerSubmissionsByReviewerId($reviewerId, $schedConfId, $active = true, $rangeInfo = null) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $result =& $this->retrieveRange('SELECT p.*, r.*, r2.review_revision, u.first_name, u.last_name, COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title, COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev FROM papers p LEFT JOIN review_assignments r ON (p.paper_id = r.submission_id) LEFT JOIN tracks t ON (t.track_id = p.track_id) LEFT JOIN users u ON (r.reviewer_id = u.user_id) LEFT JOIN review_rounds r2 ON (r.submission_id = r2.submission_id AND r.round = r2.round) LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?) LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?) LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?) LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?) WHERE p.sched_conf_id = ? AND r.reviewer_id = ? AND r.date_notified IS NOT NULL' . ($active ? ' AND r.date_completed IS NULL AND r.declined <> 1 AND (r.cancelled = 0 OR r.cancelled IS NULL)' : ' AND (r.date_completed IS NOT NULL OR r.cancelled = 1 OR r.declined = 1)'), array('title', $primaryLocale, 'title', $locale, 'abbrev', $primaryLocale, 'abbrev', $locale, $schedConfId, $reviewerId), $rangeInfo); $returner = new DAOResultFactory($result, $this, '_returnReviewerSubmissionFromRow'); return $returner; }