当前位置: 首页>>代码示例>>PHP>>正文


PHP GridHandler::validate方法代码示例

本文整理汇总了PHP中GridHandler::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP GridHandler::validate方法的具体用法?PHP GridHandler::validate怎么用?PHP GridHandler::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridHandler的用法示例。


在下文中一共展示了GridHandler::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * Validate that the user is the assigned section editor for
  * the citation's article, or is a managing editor. Raises a
  * fatal error if validation fails.
  * @param $requiredContexts array
  * @param $request PKPRequest
  * @return boolean
  */
 function validate($requiredContexts, $request)
 {
     // Retrieve the request context
     $router =& $request->getRouter();
     $journal =& $router->getContext($request);
     // Authorization and validation checks
     // NB: Error messages are in plain English as they directly go to fatal errors.
     // (Validation errors in components are either programming errors or somebody
     // trying to call components directly which is no legal use case anyway.)
     // 1) restricted site access
     if (isset($journal) && $journal->getSetting('restrictSiteAccess')) {
         import('handler.validation.HandlerValidatorCustom');
         $this->addCheck(new HandlerValidatorCustom($this, false, 'Restricted site access!', null, create_function('', 'if (!Validation::isLoggedIn()) return false; else return true;')));
     }
     // 2) we need a journal
     $this->addCheck(new HandlerValidatorJournal($this, false, 'No journal in context!'));
     // 3) only editors or section editors may access
     $this->addCheck(new HandlerValidatorRoles($this, false, 'Insufficient privileges!', null, array(ROLE_ID_EDITOR, ROLE_ID_SECTION_EDITOR)));
     // Execute standard checks
     if (!parent::validate($requiredContexts, $request)) {
         return false;
     }
     // Retrieve and validate the article id
     $articleId =& $request->getUserVar('articleId');
     if (!is_numeric($articleId)) {
         return false;
     }
     // Retrieve the article associated with this citation grid
     $articleDAO =& DAORegistry::getDAO('ArticleDAO');
     $article =& $articleDAO->getArticle($articleId);
     // Article and editor validation
     if (!is_a($article, 'Article')) {
         return false;
     }
     if ($article->getJournalId() != $journal->getId()) {
         return false;
     }
     // Editors have access to all articles, section editors will be
     // checked individually.
     if (!Validation::isEditor()) {
         // Retrieve the edit assignments
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($article->getId());
         assert(is_a($editAssignments, 'DAOResultFactory'));
         $editAssignmentsArray =& $editAssignments->toArray();
         // Check whether the user is the article's editor,
         // otherwise deny access.
         $user =& $request->getUser();
         $userId = $user->getId();
         $wasFound = false;
         foreach ($editAssignmentsArray as $editAssignment) {
             if ($editAssignment->getEditorId() == $userId) {
                 if ($editAssignment->getCanEdit()) {
                     $wasFound = true;
                 }
                 break;
             }
         }
         if (!$wasFound) {
             return false;
         }
     }
     // Validation successful
     $this->_article =& $article;
     return true;
 }
开发者ID:reedstrm,项目名称:pkp-lib,代码行数:74,代码来源:CitationGridHandler.inc.php


注:本文中的GridHandler::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。