コード例 #1
0
 /**
  * Return the next item in the iterator.
  * @return object Record
  */
 function &next()
 {
     $recordId = parent::next();
     $returner =& $this->recordDao->getRecord($recordId);
     return $returner;
 }
コード例 #2
0
 /**
  * @copydoc SubmissionListGridHandler::getSubmissions()
  */
 function getSubmissions($request, $userId)
 {
     $submissionDao = Application::getSubmissionDAO();
     /* @var $submissionDao SubmissionDAO */
     // Determine whether this is a Sub Editor or Manager.
     // Managers can access all submissions, Sub Editors
     // only assigned submissions.
     $user = $request->getUser();
     // Get all submissions for all contexts that user is
     // enrolled in as manager or series editor.
     $roleDao = DAORegistry::getDAO('RoleDAO');
     $contextDao = Application::getContextDAO();
     $contexts = $contextDao->getAll();
     $accessibleContexts = array();
     while ($context = $contexts->next()) {
         $isManager = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_MANAGER);
         $isSubEditor = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_SUB_EDITOR);
         if (!$isManager && !$isSubEditor) {
             continue;
         }
         $accessibleContexts[] = $context->getId();
     }
     $accessibleSubmissions = array();
     // Don't use range info to retrieve the object, because we do
     // some more filtering below, and that would end up breaking
     // the range info. FIXME: to speed up the process, do all
     // the filtering needed in SQL and use range info here.
     $submissionFactory = $submissionDao->getBySubEditorId($accessibleContexts, null, false, false);
     if (!$submissionFactory->wasEmpty()) {
         $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
         while ($submission = $submissionFactory->next()) {
             if (!$stageAssignmentDao->editorAssignedToStage($submission->getId())) {
                 $accessibleSubmissions[$submission->getId()] = $submission;
             }
         }
     }
     $rangeInfo = $this->getGridRangeInfo($request, $this->getId());
     import('lib.pkp.classes.core.VirtualArrayIterator');
     return VirtualArrayIterator::factory($accessibleSubmissions, $rangeInfo);
 }
コード例 #3
0
 /**
  * Intercept the author index page to add referral content
  */
 function handleAuthorTemplateInclude($hookName, $args)
 {
     $templateMgr =& $args[0];
     $params =& $args[1];
     $request =& $this->getRequest();
     if (!isset($params['smarty_include_tpl_file'])) {
         return false;
     }
     switch ($params['smarty_include_tpl_file']) {
         case 'common/footer.tpl':
             $referralDao = DAORegistry::getDAO('ReferralDAO');
             $user = $request->getUser();
             $rangeInfo =& Handler::getRangeInfo($request, 'referrals');
             $referralFilter = (int) $request->getUserVar('referralFilter');
             if ($referralFilter == 0) {
                 $referralFilter = null;
             }
             // Fetch article titles
             $journal = $request->getJournal();
             $referrals = $referralDao->getByUserId($user->getId(), $journal->getId(), $referralFilter, $rangeInfo);
             $articleDao = DAORegistry::getDAO('ArticleDAO');
             $articleTitles = $referralsArray = array();
             while ($referral = $referrals->next()) {
                 $article = $articleDao->getById($referral->getArticleId());
                 if (!$article) {
                     continue;
                 }
                 $articleTitles[$article->getId()] = $article->getLocalizedTitle();
                 $referralsArray[] = $referral;
             }
             // Turn the array back into an interator for display
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $referrals = new VirtualArrayIterator($referralsArray, $referrals->getCount(), $referrals->getPage(), $rangeInfo->getCount());
             $templateMgr->assign('articleTitles', $articleTitles);
             $templateMgr->assign('referrals', $referrals);
             $templateMgr->assign('referralFilter', $referralFilter);
             $templateMgr->display($this->getTemplatePath() . 'authorReferrals.tpl', 'text/html', 'ReferralPlugin::addAuthorReferralContent');
             break;
     }
     return false;
 }
 function display(&$args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     parent::display($args, $request);
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $journal = $request->getJournal();
     switch (array_shift($args)) {
         case 'exportIssues':
             $issueIds = $request->getUserVar('issueId');
             if (!isset($issueIds)) {
                 $issueIds = array();
             }
             $issues = array();
             foreach ($issueIds as $issueId) {
                 $issue = $issueDao->getById($issueId);
                 if (!$issue) {
                     $request->redirect();
                 }
                 $issues[] = $issue;
             }
             $this->exportIssues($journal, $issues);
             break;
         case 'exportIssue':
             $issueId = array_shift($args);
             $issue = $issueDao->getById($issueId);
             if (!$issue) {
                 $request->redirect();
             }
             $issues = array($issue);
             $this->exportIssues($journal, $issues);
             break;
         case 'exportArticle':
             $articleIds = array(array_shift($args));
             $articleSearch = new ArticleSearch();
             $result = $articleSearch->formatResults($articleIds);
             $this->exportArticles($journal, $result);
             break;
         case 'exportArticles':
             $articleIds = $request->getUserVar('articleId');
             if (!isset($articleIds)) {
                 $articleIds = array();
             }
             $articleSearch = new ArticleSearch();
             $results = $articleSearch->formatResults($articleIds);
             $this->exportArticles($journal, $results);
             break;
         case 'issues':
             // Display a list of issues for export
             // that contain an article with DOI
             AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR);
             $issueDao = DAORegistry::getDAO('IssueDAO');
             $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
             $allIssues = $issueDao->getPublishedIssues($journal->getId());
             $issues = array();
             $numArticles = array();
             while ($issue = $allIssues->next()) {
                 $issueArticles =& $publishedArticleDao->getPublishedArticles($issue->getId());
                 $issueArticlesNo = 0;
                 foreach ($issueArticles as $issueArticle) {
                     if ($issueArticle->getPubId('doi')) {
                         if (!in_array($issue, $issues)) {
                             $issues[] = $issue;
                         }
                         $issueArticlesNo++;
                     }
                 }
                 $numArticles[$issue->getId()] = $issueArticlesNo;
             }
             // Paginate issues.
             $rangeInfo = Handler::getRangeInfo('issues');
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $iterator = VirtualArrayIterator::factory($issues, $rangeInfo);
             $templateMgr->assign('issues', $iterator);
             $templateMgr->assign('numArticles', $numArticles);
             $templateMgr->display($this->getTemplatePath() . 'issues.tpl');
             break;
         case 'articles':
             // Display a list of articles with DOI for export
             $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
             $articleIterator = $publishedArticleDao->getPublishedArticlesByJournalId($journal->getId());
             $articleIds = array();
             while ($article = $articleIterator->next()) {
                 // Check whether there is a DOI.
                 if ($article->getPubId('doi')) {
                     $articleIds[] = $article->getId();
                 }
             }
             // Paginate articles.
             $rangeInfo = Handler::getRangeInfo('articles');
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $iterator = VirtualArrayIterator::factory(ArticleSearch::formatResults($articleIds), $rangeInfo);
             $templateMgr->assign_by_ref('articles', $iterator);
             $templateMgr->display($this->getTemplatePath() . 'articles.tpl');
             break;
         default:
             $doiPrefix = null;
             $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
             if (isset($pubIdPlugins['DOIPubIdPlugin'])) {
                 $doiPrefix = $pubIdPlugins['DOIPubIdPlugin']->getSetting($journal->getId(), 'doiPrefix');
             }
             $templateMgr->assign('doiPrefix', $doiPrefix);
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
     }
 }