/**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the section editor submission.
     $sectionEditorSubmission =& $this->getAuthorizedContextObject(ASSOC_TYPE_ARTICLE);
     if (!is_a($sectionEditorSubmission, 'SectionEditorSubmission')) {
         return AUTHORIZATION_DENY;
     }
     // Section editors can only access submissions in their series
     // that they have been explicitly assigned to.
     $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
     $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($sectionEditorSubmission->getJournalId(), $sectionEditorSubmission->getSectionId());
     $foundAssignment = false;
     foreach ($sectionEditors as $sectionEditor) {
         if ($sectionEditor->getId() == $user->getId()) {
             $foundAssignment = true;
         }
     }
     if ($foundAssignment) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @copydoc AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user = $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the context
     $router = $this->_request->getRouter();
     $context = $router->getContext($this->_request);
     if (!is_a($context, 'Context')) {
         return AUTHORIZATION_DENY;
     }
     // Get the submission
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     if (!is_a($submission, 'Submission')) {
         return AUTHORIZATION_DENY;
     }
     import('lib.pkp.classes.security.authorization.internal.SectionAssignmentRule');
     if (SectionAssignmentRule::effect($context->getId(), $submission->getSectionId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user = $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the press
     $router = $this->_request->getRouter();
     $press = $router->getContext($this->_request);
     if (!is_a($press, 'Press')) {
         return AUTHORIZATION_DENY;
     }
     // Get the monograph
     $monograph = $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
     if (!is_a($monograph, 'Monograph')) {
         return AUTHORIZATION_DENY;
     }
     import('classes.security.authorization.internal.SeriesAssignmentRule');
     if (SeriesAssignmentRule::effect($press->getId(), $monograph->getSeriesId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @copydoc AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user = $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the journal
     $router = $this->_request->getRouter();
     $context = $router->getContext($this->_request);
     if (!is_a($context, 'Journal')) {
         return AUTHORIZATION_DENY;
     }
     // Get the article
     $article = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     if (!is_a($article, 'Article')) {
         return AUTHORIZATION_DENY;
     }
     import('classes.security.authorization.internal.SectionAssignmentRule');
     if (SectionAssignmentRule::effect($context->getId(), $article->getSectionId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the press
     $router =& $this->_request->getRouter();
     $press =& $router->getContext($this->_request);
     if (!is_a($press, 'Press')) {
         return AUTHORIZATION_DENY;
     }
     // Get the monograph
     $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
     if (!is_a($monograph, 'Monograph')) {
         return AUTHORIZATION_DENY;
     }
     // Series editors can access all submissions in their series.
     // Even those they've not been explicitly assigned to.
     $seriesEditorsDao =& DAORegistry::getDAO('SeriesEditorsDAO');
     if ($seriesEditorDao->editorExists($press->getId(), $monograph->getSeriesId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the copyeditor submission
     $copyeditorSubmission =& $this->getAuthorizedContextObject(ASSOC_TYPE_ARTICLE);
     if (!is_a($copyeditorSubmission, 'CopyeditorSubmission')) {
         return AUTHORIZATION_DENY;
     }
     // Copyeditors can only access submissions
     // they have been explicitly assigned to.
     if ($copyeditorSubmission->getUserIdBySignoffType('SIGNOFF_COPYEDITING_INITIAL') != $user->getId()) {
         return AUTHORIZATION_DENY;
     }
     return AUTHORIZATION_PERMIT;
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user = $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the submission
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     if (!is_a($submission, 'Submission')) {
         return AUTHORIZATION_DENY;
     }
     // Check authorship of the submission.
     if ($submission->getUserId() === $user->getId()) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the monograph
     $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
     if (!is_a($monograph, 'Monograph')) {
         return AUTHORIZATION_DENY;
     }
     // Check authorship of the monograph.
     if ($monograph->getUserId() === $user->getId()) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // A signoff should already be in the context.
     $signoff = $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
     if (!is_a($signoff, 'Signoff')) {
         return AUTHORIZATION_DENY;
     }
     // Check that there is a currently logged in user.
     $user = $this->_request->getUser();
     if (!is_a($user, 'User')) {
         return AUTHORIZATION_DENY;
     }
     // Check if the signoff is assigned to the user.
     if ($signoff->getUserId() == $user->getId()) {
         return AUTHORIZATION_PERMIT;
     }
     // Otherwise, deny.
     return AUTHORIZATION_DENY;
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // A query should already be in the context.
     $query = $this->getAuthorizedContextObject(ASSOC_TYPE_QUERY);
     if (!is_a($query, 'Query')) {
         return AUTHORIZATION_DENY;
     }
     // Check that there is a currently logged in user.
     $user = $this->_request->getUser();
     if (!is_a($user, 'User')) {
         return AUTHORIZATION_DENY;
     }
     // Determine if the query is assigned to the user.
     $queryDao = DAORegistry::getDAO('QueryDAO');
     if ($queryDao->getParticipantIds($query->getId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     }
     // Otherwise, deny.
     return AUTHORIZATION_DENY;
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the section editor submission.
     $sectionEditorSubmission =& $this->getAuthorizedContextObject(ASSOC_TYPE_ARTICLE);
     if (!is_a($sectionEditorSubmission, 'SectionEditorSubmission')) {
         return AUTHORIZATION_DENY;
     }
     // Section editors can only access submissions in their series
     // that they have been explicitly assigned to.
     // 1) Retrieve the edit assignments
     $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
     $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($sectionEditorSubmission->getId());
     if (!is_a($editAssignments, 'DAOResultFactory')) {
         return AUTHORIZATION_DENY;
     }
     $editAssignmentsArray =& $editAssignments->toArray();
     // 2) Check whether the user is the article's editor,
     //    otherwise deny access.
     $foundAssignment = false;
     foreach ($editAssignmentsArray as $editAssignment) {
         if ($editAssignment->getEditorId() == $user->getId()) {
             if ($editAssignment->getCanEdit()) {
                 $foundAssignment = true;
             }
             break;
         }
     }
     if ($foundAssignment) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the monograph
     $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
     if (!is_a($monograph, 'Monograph')) {
         return AUTHORIZATION_DENY;
     }
     // Check if a review assignment exists between the submission and the user
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     /* @var $reviewAssignmentDao ReviewAssignmentDAO */
     $reviewAssignment =& $reviewAssignmentDao->getReviewAssignment($monograph->getId(), $user->getId(), $monograph->getCurrentRound());
     if (is_a($reviewAssignment, 'ReviewAssignment')) {
         // Save the review assignment to the authorization context.
         $this->addAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment);
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user = $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the submission
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     if (!is_a($submission, 'Submission')) {
         return AUTHORIZATION_DENY;
     }
     // Check authorship of the submission. Any ROLE_ID_AUTHOR assignment will do.
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $submitterAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), null, null, $user->getId());
     while ($assignment = $submitterAssignments->next()) {
         $userGroup = $userGroupDao->getById($assignment->getUserGroupId());
         if ($userGroup->getRoleId() == ROLE_ID_AUTHOR) {
             return AUTHORIZATION_PERMIT;
         }
     }
     return AUTHORIZATION_DENY;
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user = $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the submission
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     if (!is_a($submission, 'Submission')) {
         return AUTHORIZATION_DENY;
     }
     // Check if a review assignment exists between the submission and the user
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     /* @var $reviewAssignmentDao ReviewAssignmentDAO */
     $reviewAssignment = $reviewAssignmentDao->getLastReviewRoundReviewAssignmentByReviewer($submission->getId(), $user->getId());
     if (is_a($reviewAssignment, 'ReviewAssignment')) {
         // Save the review assignment to the authorization context.
         $this->addAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment);
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }
Example #15
0
 /**
  * Determines whether the current user can create user accounts from authors present
  * in the grid.
  * @param PKPRequest $request
  * @return boolean
  */
 function allowedToCreateUser($request)
 {
     $submission = $this->getSubmission();
     $user = $request->getUser();
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $submission->getStageId(), null, $user->getId());
     while ($stageAssignment = $stageAssignments->next()) {
         $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
         if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_EDITOR))) {
             return true;
             break;
         }
     }
     return false;
 }
Example #16
0
 /**
  * Determines whether the current user can create user accounts from authors present
  * in the grid.
  * @param PKPRequest $request
  * @return boolean
  */
 function canAdminister($request)
 {
     $submission = $this->getSubmission();
     $user = $request->getUser();
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     // If the submission hasn't been finalized, allow.
     if (!$submission->getDateSubmitted()) {
         return true;
     }
     $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $submission->getStageId(), null, $user->getId());
     while ($stageAssignment = $stageAssignments->next()) {
         $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
         if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER))) {
             return true;
         }
     }
     return false;
 }
 /**
  * Initialize the template manager.
  */
 function initialize()
 {
     $locale = AppLocale::getLocale();
     $application = PKPApplication::getApplication();
     $router = $this->_request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     $this->assign(array('defaultCharset' => Config::getVar('i18n', 'client_charset'), 'basePath' => $this->_request->getBasePath(), 'baseUrl' => $this->_request->getBaseUrl(), 'requiresFormRequest' => $this->_request->isPost(), 'currentUrl' => $this->_request->getCompleteUrl(), 'dateFormatTrunc' => Config::getVar('general', 'date_format_trunc'), 'dateFormatShort' => Config::getVar('general', 'date_format_short'), 'dateFormatLong' => Config::getVar('general', 'date_format_long'), 'datetimeFormatShort' => Config::getVar('general', 'datetime_format_short'), 'datetimeFormatLong' => Config::getVar('general', 'datetime_format_long'), 'timeFormat' => Config::getVar('general', 'time_format'), 'allowCDN' => Config::getVar('general', 'enable_cdn'), 'useMinifiedJavaScript' => Config::getVar('general', 'enable_minified'), 'currentContext' => $this->_request->getContext(), 'currentLocale' => $locale, 'pageTitle' => $application->getNameKey(), 'applicationName' => __($application->getNameKey()), 'exposedConstants' => $application->getExposedConstants(), 'jsLocaleKeys' => $application->getJSLocaleKeys()));
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign(array('requestedPage' => $router->getRequestedPage($this->_request), 'requestedOp' => $router->getRequestedOp($this->_request)));
     }
     if ($dispatcher = $this->_request->getDispatcher()) {
         $this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE, 'backend');
     }
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet, 'backend');
     }
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('PKPString', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('PKPString', 'substr'));
     $this->register_modifier('to_array', array($this, 'smartyToArray'));
     $this->register_modifier('compare', array($this, 'smartyCompare'));
     $this->register_modifier('concat', array($this, 'smartyConcat'));
     $this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
     $this->register_modifier('explode', array($this, 'smartyExplode'));
     $this->register_modifier('assign', array($this, 'smartyAssign'));
     $this->register_function('translate', array($this, 'smartyTranslate'));
     $this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
     $this->register_function('help', array($this, 'smartyHelp'));
     $this->register_function('flush', array($this, 'smartyFlush'));
     $this->register_function('call_hook', array($this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array($this, 'smartyIterate'));
     $this->register_function('page_links', array($this, 'smartyPageLinks'));
     $this->register_function('page_info', array($this, 'smartyPageInfo'));
     $this->register_function('pluck_files', array($this, 'smartyPluckFiles'));
     // Modified vocabulary for creating forms
     $fbv = $this->getFBV();
     $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
     $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
     $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
     $this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
     $this->assign('fbvStyles', $fbv->getStyles());
     $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
     // register the resource name "core"
     $coreResource = new PKPTemplateResource($this->core_template_dir);
     $this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted')));
     $appResource = new PKPTemplateResource($this->app_template_dir);
     $this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted')));
     $this->register_function('url', array($this, 'smartyUrl'));
     // ajax load into a div or any element
     $this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl'));
     $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
     // load stylesheets from a given context
     $this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet'));
     /**
      * Kludge to make sure no code that tries to connect to the
      * database is executed (e.g., when loading installer pages).
      */
     if (!defined('SESSION_DISABLE_INIT')) {
         $application = PKPApplication::getApplication();
         $currentVersion = $application->getCurrentVersion();
         $this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'currentVersionString' => $currentVersion->getVersionString(false), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links')));
         $user = $this->_request->getUser();
         $hasSystemNotifications = false;
         if ($user) {
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             if ($notifications->getCount() > 0) {
                 $this->assign('hasSystemNotifications', true);
             }
             // Assign the user name to be used in the sitenav
             $this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp()));
         }
     }
     // Load enabled block plugins and setup active sidebar variables
     PluginRegistry::loadCategory('blocks', true);
     $leftSidebarHooks = HookRegistry::getHooks('Templates::Common::LeftSidebar');
     $this->assign(array('hasLeftSidebar' => !empty($leftSidebarHooks)));
 }
 /**
  * Initialize the template manager.
  */
 function initialize()
 {
     $locale = AppLocale::getLocale();
     $application = PKPApplication::getApplication();
     $router = $this->_request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     $currentContext = $this->_request->getContext();
     $this->assign(array('defaultCharset' => Config::getVar('i18n', 'client_charset'), 'basePath' => $this->_request->getBasePath(), 'baseUrl' => $this->_request->getBaseUrl(), 'requiresFormRequest' => $this->_request->isPost(), 'currentUrl' => $this->_request->getCompleteUrl(), 'dateFormatTrunc' => Config::getVar('general', 'date_format_trunc'), 'dateFormatShort' => Config::getVar('general', 'date_format_short'), 'dateFormatLong' => Config::getVar('general', 'date_format_long'), 'datetimeFormatShort' => Config::getVar('general', 'datetime_format_short'), 'datetimeFormatLong' => Config::getVar('general', 'datetime_format_long'), 'timeFormat' => Config::getVar('general', 'time_format'), 'currentContext' => $currentContext, 'currentLocale' => $locale, 'pageTitle' => $application->getNameKey(), 'applicationName' => __($application->getNameKey())));
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign(array('requestedPage' => $router->getRequestedPage($this->_request), 'requestedOp' => $router->getRequestedOp($this->_request)));
         // Register the jQuery script
         $min = Config::getVar('general', 'enable_minified') ? '.min' : '';
         if (Config::getVar('general', 'enable_cdn')) {
             $jquery = '//ajax.googleapis.com/ajax/libs/jquery/' . CDN_JQUERY_VERSION . '/jquery' . $min . '.js';
             $jqueryUI = '//ajax.googleapis.com/ajax/libs/jqueryui/' . CDN_JQUERY_UI_VERSION . '/jquery-ui' . $min . '.js';
         } else {
             $jquery = $this->_request->getBaseUrl() . '/lib/pkp/lib/components/jquery/jquery' . $min . '.js';
             $jqueryUI = $this->_request->getBaseUrl() . '/lib/pkp/lib/components/jquery-ui/jquery-ui' . $min . '.js';
         }
         $this->addJavaScript('jquery', $jquery, array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         $this->addJavaScript('jqueryUI', $jqueryUI, array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         // Register the pkp-lib JS library
         $this->registerJSLibraryData();
         $this->registerJSLibrary();
         // Load Noto Sans font from Google Font CDN
         // To load extended latin or other character sets, see:
         // https://www.google.com/fonts#UsePlace:use/Collection:Noto+Sans
         if (Config::getVar('general', 'enable_cdn')) {
             $this->addStyleSheet('pkpLibNotoSans', '//fonts.googleapis.com/css?family=Noto+Sans:400,400italic,700,700italic', array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         }
         // Register the primary backend stylesheet
         if ($dispatcher = $this->_request->getDispatcher()) {
             $this->addStyleSheet('pkpLib', $dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), array('priority' => STYLE_SEQUENCE_CORE, 'contexts' => 'backend'));
         }
         // Add reading language flag based on locale
         $this->assign('currentLocaleLangDir', AppLocale::getLocaleDirection($locale));
         // If there's a locale-specific stylesheet, add it.
         if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
             $this->addStyleSheet('pkpLibLocale', $this->_request->getBaseUrl() . '/' . $localeStyleSheet, array('contexts' => array('frontend', 'backend')));
         }
         // Register colour picker assets on the appearance page
         $this->addJavaScript('spectrum', $this->_request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/spectrum/spectrum.js', array('contexts' => array('backend-management-settings', 'backend-admin-settings', 'backend-admin-contexts')));
         $this->addStyleSheet('spectrum', $this->_request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/spectrum/spectrum.css', array('contexts' => array('backend-management-settings', 'backend-admin-settings', 'backend-admin-contexts')));
         // Register recaptcha on relevant pages
         if (Config::getVar('captcha', 'recaptcha') && Config::getVar('captcha', 'captcha_on_register')) {
             $this->addJavaScript('recaptcha', 'https://www.google.com/recaptcha/api.js', array('contexts' => array('frontend-user-register', 'frontend-user-registerUser')));
         }
         // Register meta tags
         if (Config::getVar('general', 'installed')) {
             if (($this->_request->getRequestedPage() == '' || $this->_request->getRequestedPage() == 'index') && $currentContext && $currentContext->getLocalizedSetting('searchDescription')) {
                 $this->addHeader('searchDescription', '<meta name="description" content="' . $currentContext->getLocalizedSetting('searchDescription') . '">');
             }
             $this->addHeader('generator', '<meta name="generator" content="' . __($application->getNameKey()) . ' ' . $application->getCurrentVersion()->getVersionString(false) . '">', array('contexts' => array('frontend', 'backend')));
             if ($currentContext) {
                 $customHeaders = $currentContext->getLocalizedSetting('customHeaders');
                 if (!empty($customHeaders)) {
                     $this->addHeader('customHeaders', $customHeaders);
                 }
             }
         }
         if ($currentContext && !$currentContext->getEnabled()) {
             $this->addHeader('noindex', '<meta name="robots" content="noindex,nofollow">', array('contexts' => array('frontend', 'backend')));
         }
     }
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('PKPString', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('PKPString', 'substr'));
     $this->register_modifier('dateformatPHP2JQueryDatepicker', array('PKPString', 'dateformatPHP2JQueryDatepicker'));
     $this->register_modifier('to_array', array($this, 'smartyToArray'));
     $this->register_modifier('compare', array($this, 'smartyCompare'));
     $this->register_modifier('concat', array($this, 'smartyConcat'));
     $this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
     $this->register_modifier('explode', array($this, 'smartyExplode'));
     $this->register_modifier('assign', array($this, 'smartyAssign'));
     $this->register_function('csrf', array($this, 'smartyCSRF'));
     $this->register_function('translate', array($this, 'smartyTranslate'));
     $this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
     $this->register_function('help', array($this, 'smartyHelp'));
     $this->register_function('flush', array($this, 'smartyFlush'));
     $this->register_function('call_hook', array($this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array($this, 'smartyIterate'));
     $this->register_function('page_links', array($this, 'smartyPageLinks'));
     $this->register_function('page_info', array($this, 'smartyPageInfo'));
     $this->register_function('pluck_files', array($this, 'smartyPluckFiles'));
     // Modified vocabulary for creating forms
     $fbv = $this->getFBV();
     $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
     $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
     $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
     $this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
     $this->assign('fbvStyles', $fbv->getStyles());
     $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
     // register the resource name "core"
     $coreResource = new PKPTemplateResource($this->core_template_dir);
     $this->register_resource('core', array(array($coreResource, 'fetch'), array($coreResource, 'fetchTimestamp'), array($coreResource, 'getSecure'), array($coreResource, 'getTrusted')));
     $appResource = new PKPTemplateResource($this->app_template_dir);
     $this->register_resource('app', array(array($appResource, 'fetch'), array($appResource, 'fetchTimestamp'), array($appResource, 'getSecure'), array($appResource, 'getTrusted')));
     $this->register_function('url', array($this, 'smartyUrl'));
     // ajax load into a div or any element
     $this->register_function('load_url_in_el', array($this, 'smartyLoadUrlInEl'));
     $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
     // load stylesheets/scripts/headers from a given context
     $this->register_function('load_stylesheet', array($this, 'smartyLoadStylesheet'));
     $this->register_function('load_script', array($this, 'smartyLoadScript'));
     $this->register_function('load_header', array($this, 'smartyLoadHeader'));
     /**
      * Kludge to make sure no code that tries to connect to the
      * database is executed (e.g., when loading installer pages).
      */
     if (!defined('SESSION_DISABLE_INIT')) {
         $application = PKPApplication::getApplication();
         $this->assign(array('isUserLoggedIn' => Validation::isLoggedIn(), 'isUserLoggedInAs' => Validation::isLoggedInAs(), 'itemsPerPage' => Config::getVar('interface', 'items_per_page'), 'numPageLinks' => Config::getVar('interface', 'page_links')));
         $user = $this->_request->getUser();
         $hasSystemNotifications = false;
         if ($user) {
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             if ($notifications->getCount() > 0) {
                 $this->assign('hasSystemNotifications', true);
             }
             // Assign the user name to be used in the sitenav
             $this->assign(array('loggedInUsername' => $user->getUserName(), 'initialHelpState' => (int) $user->getInlineHelp()));
         }
     }
     // Load enabled block plugins and setup active sidebar variables
     PluginRegistry::loadCategory('blocks', true);
     $sidebarHooks = HookRegistry::getHooks('Templates::Common::Sidebar');
     $this->assign(array('hasSidebar' => !empty($sidebarHooks)));
 }
Example #19
0
 /**
  * Initialize the template manager.
  */
 function initialize()
 {
     // Retrieve the router
     $router = $this->_request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset'));
     $this->assign('basePath', $this->_request->getBasePath());
     $this->assign('baseUrl', $this->_request->getBaseUrl());
     $this->assign('requiresFormRequest', $this->_request->isPost());
     if (is_a($router, 'PKPPageRouter')) {
         $this->assign('requestedPage', $router->getRequestedPage($this->_request));
     }
     $this->assign('currentUrl', $this->_request->getCompleteUrl());
     $this->assign('dateFormatTrunc', Config::getVar('general', 'date_format_trunc'));
     $this->assign('dateFormatShort', Config::getVar('general', 'date_format_short'));
     $this->assign('dateFormatLong', Config::getVar('general', 'date_format_long'));
     $this->assign('datetimeFormatShort', Config::getVar('general', 'datetime_format_short'));
     $this->assign('datetimeFormatLong', Config::getVar('general', 'datetime_format_long'));
     $this->assign('timeFormat', Config::getVar('general', 'time_format'));
     $this->assign('allowCDN', Config::getVar('general', 'enable_cdn'));
     $this->assign('useMinifiedJavaScript', Config::getVar('general', 'enable_minified'));
     $this->assign('toggleHelpOnText', __('help.toggleInlineHelpOn'));
     $this->assign('toggleHelpOffText', __('help.toggleInlineHelpOff'));
     $this->assign('currentContext', $this->_request->getContext());
     $locale = AppLocale::getLocale();
     $this->assign('currentLocale', $locale);
     // Add uncompilable styles
     $this->addStyleSheet($this->_request->getBaseUrl() . '/styles/lib.css', STYLE_SEQUENCE_CORE);
     $dispatcher = $this->_request->getDispatcher();
     if ($dispatcher) {
         $this->addStyleSheet($dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'page.PageHandler', 'css'), STYLE_SEQUENCE_CORE);
     }
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = AppLocale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet($this->_request->getBaseUrl() . '/' . $localeStyleSheet);
     }
     $application = PKPApplication::getApplication();
     $this->assign('pageTitle', $application->getNameKey());
     $this->assign('applicationName', __($application->getNameKey()));
     $this->assign('exposedConstants', $application->getExposedConstants());
     $this->assign('jsLocaleKeys', $application->getJSLocaleKeys());
     // Register custom functions
     $this->register_modifier('translate', array('AppLocale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('String', 'substr'));
     $this->register_modifier('to_array', array($this, 'smartyToArray'));
     $this->register_modifier('compare', array($this, 'smartyCompare'));
     $this->register_modifier('concat', array($this, 'smartyConcat'));
     $this->register_modifier('escape', array($this, 'smartyEscape'));
     $this->register_modifier('strtotime', array($this, 'smartyStrtotime'));
     $this->register_modifier('explode', array($this, 'smartyExplode'));
     $this->register_modifier('assign', array($this, 'smartyAssign'));
     $this->register_function('translate', array($this, 'smartyTranslate'));
     $this->register_function('null_link_action', array($this, 'smartyNullLinkAction'));
     $this->register_function('flush', array($this, 'smartyFlush'));
     $this->register_function('call_hook', array($this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array($this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array($this, 'smartyIterate'));
     $this->register_function('page_links', array($this, 'smartyPageLinks'));
     $this->register_function('page_info', array($this, 'smartyPageInfo'));
     $this->register_function('icon', array($this, 'smartyIcon'));
     $this->register_modifier('truncate', array($this, 'smartyTruncate'));
     // Modified vocabulary for creating forms
     $fbv = $this->getFBV();
     $this->register_block('fbvFormSection', array($fbv, 'smartyFBVFormSection'));
     $this->register_block('fbvFormArea', array($fbv, 'smartyFBVFormArea'));
     $this->register_function('fbvFormButtons', array($fbv, 'smartyFBVFormButtons'));
     $this->register_function('fbvElement', array($fbv, 'smartyFBVElement'));
     $this->assign('fbvStyles', $fbv->getStyles());
     $this->register_function('fieldLabel', array($fbv, 'smartyFieldLabel'));
     // register the resource name "core"
     $this->register_resource('core', array(array($this, 'smartyResourceCoreGetTemplate'), array($this, 'smartyResourceCoreGetTimestamp'), array($this, 'smartyResourceCoreGetSecure'), array($this, 'smartyResourceCoreGetTrusted')));
     $this->register_function('url', array($this, 'smartyUrl'));
     // ajax load into a div
     $this->register_function('load_url_in_div', array($this, 'smartyLoadUrlInDiv'));
     if (!defined('SESSION_DISABLE_INIT')) {
         /**
          * Kludge to make sure no code that tries to connect to
          * the database is executed (e.g., when loading
          * installer pages).
          */
         $this->assign('isUserLoggedIn', Validation::isLoggedIn());
         $this->assign('isUserLoggedInAs', Validation::isLoggedInAs());
         $application = PKPApplication::getApplication();
         $currentVersion = $application->getCurrentVersion();
         $this->assign('currentVersionString', $currentVersion->getVersionString(false));
         $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page'));
         $this->assign('numPageLinks', Config::getVar('interface', 'page_links'));
     }
     // Load enabled block plugins.
     PluginRegistry::loadCategory('blocks', true);
     if (!defined('SESSION_DISABLE_INIT')) {
         $user = $this->_request->getUser();
         $hasSystemNotifications = false;
         if ($user) {
             // Assign the user name to be used in the sitenav
             $this->assign('loggedInUsername', $user->getUserName());
             $notificationDao = DAORegistry::getDAO('NotificationDAO');
             $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL);
             if ($notifications->getCount() > 0) {
                 $hasSystemNotifications = true;
             }
             $this->assign('initialHelpState', (int) $user->getInlineHelp());
         }
         $this->assign('hasSystemNotifications', $hasSystemNotifications);
     }
 }
 /**
  * Batch import from an ONIX XML export.
  * @param array $args
  * @param PKPRequest $request
  */
 function uploadONIXObjectForReview($args, &$request)
 {
     $user = $request->getUser();
     $journal =& $request->getJournal();
     $ofrOrgDao =& DAORegistry::getDAO('ObjectForReviewOrganizationDAO');
     $ofrPlugin =& $this->_getObjectsForReviewPlugin();
     $ofrPlugin->import('classes.form.ObjectForReviewForm');
     $reviewObjectTypeId = (int) $request->getUserVar('reviewObjectTypeId');
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFile = $temporaryFileManager->handleUpload('onixFile', $user->getId());
     $filePath = $temporaryFile->getFilePath();
     $parser = new XMLParser();
     $doc =& $parser->parse($filePath);
     $multiple = $request->getUserVar('multiple');
     if ($doc) {
         // Determine if we have short or long tags.
         $productNodes = $doc->getChildByName('product');
         $shortTags = $productNodes ? true : false;
         for ($index = 0; $productNode = $doc->getChildByName($this->_getOnixTag('Product', $shortTags), $index); $index++) {
             $importData = array();
             if ($productNode) {
                 $publisherNode = $productNode->getChildByName($this->_getOnixTag('Publisher', $shortTags));
                 if ($publisherNode) {
                     $publisherNameNode = $publisherNode->getChildByName($this->_getOnixTag('PublisherName', $shortTags));
                     if ($publisherNameNode) {
                         $publisher = $publisherNameNode->getValue();
                         $organization =& $ofrOrgDao->getOrganizationByName(trim($publisher));
                         if ($organization) {
                             $importData['publisherId'] = $organization->getId();
                         }
                     }
                 }
                 $websiteNode = $publisherNode->getChildByName($this->_getOnixTag('Website', $shortTags));
                 if ($websiteNode) {
                     $websiteLinkNode = $websiteNode->getChildByName($this->_getOnixTag('WebsiteLink', $shortTags));
                     $websiteLink = $websiteLinkNode->getValue();
                     $importData['book_publisher_url'] = $websiteLink;
                 }
                 $titleNode = $productNode->getChildByName($this->_getOnixTag('Title', $shortTags));
                 if ($titleNode) {
                     $titleTextNode = $titleNode->getChildByName($this->_getOnixTag('TitleText', $shortTags));
                     $title = $titleTextNode->getValue();
                     $importData['title'] = $title;
                 }
                 $subTitleNode = $titleNode->getChildByName($this->_getOnixTag('Subtitle', $shortTags));
                 if ($subTitleNode) {
                     $subTitle = $subTitleNode->getValue();
                     $importData['shortTitle'] = $subTitle;
                 }
                 $seriesNode = $productNode->getChildByName($this->_getOnixTag('Series', $shortTags));
                 if ($seriesNode) {
                     $seriesTextNode = $seriesNode->getChildByName($this->_getOnixTag('TitleOfSeries', $shortTags));
                     $series = $seriesTextNode->getValue();
                     $importData['book_series'] = $series;
                 }
                 $languageNode = $productNode->getChildByName($this->_getOnixTag('Language', $shortTags));
                 if ($languageNode) {
                     $languageCodeNode = $languageNode->getChildByName($this->_getOnixTag('LanguageCode', $shortTags));
                     $language = $languageCodeNode->getValue();
                     $importData['language'] = substr($language, 0, 2);
                 } else {
                     $importData['language'] = 'en';
                 }
                 $pageNode = $productNode->getChildByName($this->_getOnixTag('NumberOfPages', $shortTags));
                 if ($pageNode) {
                     $pages = $pageNode->getValue();
                     $importData['book_pages_no'] = $pages;
                 }
                 // Abstract. Look for OtherText with
                 // sub element of TextTypeCode of '01' (main description)
                 $abstract = '';
                 for ($authorIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('OtherText', $shortTags), $authorIndex); $authorIndex++) {
                     $typeNode = $node->getChildByName($this->_getOnixTag('TextTypeCode', $shortTags));
                     if ($typeNode && $typeNode->getValue() == '01') {
                         $textNode = $node->getChildByName($this->_getOnixTag('Text', $shortTags));
                         if ($textNode) {
                             $abstract = strip_tags($textNode->getValue());
                         }
                         break;
                     }
                 }
                 $importData['abstract'] = $abstract;
                 // ISBN-13
                 for ($productIdentifierIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('ProductIdentifier', $shortTags), $productIdentifierIndex); $productIdentifierIndex++) {
                     $idTypeNode = $node->getChildByName($this->_getOnixTag('ProductIDType', $shortTags));
                     if ($idTypeNode && $idTypeNode->getValue() == '15') {
                         // ISBN-13
                         $textNode = $node->getChildByName($this->_getOnixTag('IDValue', $shortTags));
                         if ($textNode) {
                             $importData['book_isbn'] = $textNode->getValue();
                         }
                         break;
                     }
                 }
                 // Subjects
                 $importData['subjectKeywords'] = '';
                 $subjects = array();
                 for ($subjectIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('Subject', $shortTags), $subjectIndex); $subjectIndex++) {
                     $textNode = $node->getChildByName($this->_getOnixTag('SubjectHeadingText', $shortTags));
                     if ($textNode) {
                         $subjects[] = $textNode->getValue();
                     }
                 }
                 $importData['subjectKeywords'] = join(', ', $subjects);
                 $publicationDateNode = $productNode->getChildByName($this->_getOnixTag('PublicationDate', $shortTags));
                 if ($publicationDateNode) {
                     $publicationDate = $publicationDateNode->getValue();
                     $importData['date'] = $publicationDate;
                 }
                 // Contributors.
                 $persons = array();
                 for ($authorIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('Contributor', $shortTags), $authorIndex); $authorIndex++) {
                     $firstNameNode = $node->getChildByName($this->_getOnixTag('NamesBeforeKey', $shortTags));
                     if ($firstNameNode) {
                         $firstName = $firstNameNode->getValue();
                     }
                     $lastNameNode = $node->getChildByName($this->_getOnixTag('KeyNames', $shortTags));
                     if ($lastNameNode) {
                         $lastName = $lastNameNode->getValue();
                     }
                     $seqNode = $node->getChildByName($this->_getOnixTag('SequenceNumber', $shortTags));
                     if ($seqNode) {
                         $seq = $seqNode->getValue();
                     }
                     $contributorRoleNode = $node->getChildByName($this->_getOnixTag('ContributorRole', $shortTags));
                     $contributorRole = '';
                     if ($contributorRoleNode) {
                         switch ($contributorRoleNode->getValue()) {
                             case 'A01':
                                 $contributorRole = '1';
                                 break;
                             case 'B01':
                                 $contributorRole = '3';
                                 break;
                             case 'B09':
                                 $contributorRole = '4';
                                 break;
                             case 'B06':
                                 $contributorRole = '5';
                                 break;
                             default:
                                 $contributorRole = '2';
                                 // Contributor
                                 break;
                         }
                     }
                     $persons[] = array('personId' => '', 'role' => $contributorRole, 'firstName' => $firstName, 'middleName' => '', 'lastName' => $lastName, 'seq' => (int) $seq);
                     unset($node);
                 }
                 $importData['persons'] = $persons;
                 if (!$multiple) {
                     $temporaryFileManager->deleteFile($temporaryFile->getId(), $user->getId());
                     $this->editObjectForReview($args, &$request, $importData);
                     break;
                 } else {
                     // we are processing more than one Product.  Instaniate the form and let it
                     // handle the object creation.
                     $ofrForm = new ObjectForReviewForm($ofrPlugin->getName(), null, $reviewObjectTypeId, $importData);
                     $ofrForm->initData();
                     $ofrForm->execute();
                 }
             } else {
                 $request->redirect(null, 'editor', 'objectsForReview', 'onixError');
             }
         }
         $request->redirect(null, 'editor', 'objectsForReview');
     } else {
         // this deleteFile is only called if the document does not parse.
         $temporaryFileManager->deleteFile($temporaryFile->getId(), $user->getId());
         $request->redirect(null, 'editor', 'objectsForReview');
     }
 }
 /**
  * Store decline by author to review an object.
  * @param array $args
  * @param PKPRequest $request
  */
 function declineToReviewObject($args, $request)
 {
     $journal =& $request->getJournal();
     $journalId = $journal->getId();
     $user =& $request->getUser();
     $objectId = !isset($args) || empty($args) ? null : (int) $args[0];
     if (!$this->_ensureObjectExists($objectId, $journalId)) {
         $request->redirect(null, 'objectsForReview');
     }
     $ofrDao =& DAORegistry::getDAO('ObjectForReviewDAO');
     $objectForReview =& $ofrDao->getById($objectId);
     $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO');
     $assignment =& $ofrAssignmentDao->getByObjectAndUserId($objectId, $user->getId());
     $redirect = true;
     if ($assignment) {
         import('classes.mail.MailTemplate');
         $email = new MailTemplate('OFR_OBJECT_DECLINED');
         $send = $request->getUserVar('send');
         // Author has filled out mail form or decided to skip email
         if ($send && !$email->hasErrors()) {
             // Update object for review as requested
             $assignment->setStatus(OFR_STATUS_DECLINED);
             $ofrAssignmentDao->updateObject($assignment);
             $email->send();
             $this->_createTrivialNotification(NOTIFICATION_TYPE_OFR_DECLINED, $request);
         } else {
             $returnUrl = $request->url(null, 'author', 'declineToReviewObject', $objectId);
             $this->_displayEmailForm($email, $objectForReview, $user, $returnUrl, 'OFR_OBJECT_DECLINED', $request);
             $redirect = false;
         }
     }
     if ($redirect) {
         $request->redirect(null, 'author', 'objectsForReview');
     }
 }
Example #22
0
 /**
  * Get an instance of the queries grid access helper
  * @return QueriesGridAccessHelper
  */
 function getAccessHelper()
 {
     import('lib.pkp.controllers.grid.queries.QueriesAccessHelper');
     return new QueriesAccessHelper($this->getAuthorizedContext(), $this->_request->getUser());
 }