コード例 #1
0
 /**
  * Display the form.
  * @param $request Request
  */
 function display($request)
 {
     $canOnlyRead = true;
     $canOnlyReview = false;
     if (Validation::isReviewer()) {
         $canOnlyRead = false;
         $canOnlyReview = true;
     }
     if (Validation::isSiteAdmin() || Validation::isJournalManager() || Validation::isEditor() || Validation::isSectionEditor()) {
         $canOnlyRead = false;
         $canOnlyReview = false;
     }
     $templateMgr =& TemplateManager::getManager();
     // Remove the notification setting categories that the user will not be receiving (to simplify the form)
     $notificationSettingCategories = $this->_getNotificationSettingCategories();
     if ($canOnlyRead || $canOnlyReview) {
         unset($notificationSettingCategories['submissions']);
     }
     if ($canOnlyRead) {
         unset($notificationSettingCategories['reviewing']);
     }
     $templateMgr->assign('notificationSettingCategories', $notificationSettingCategories);
     $templateMgr->assign('notificationSettings', $this->_getNotificationSettingsMap());
     $templateMgr->assign('titleVar', __('common.title'));
     return parent::display($request);
 }
コード例 #2
0
 /**
  * Display the form.
  * @param $request Request
  */
 function display($request)
 {
     $conferenceDao = DAORegistry::getDAO('ConferenceDAO');
     $conferences =& $conferenceDao->getNames();
     $canOnlyRead = true;
     $canOnlyReview = false;
     if (Validation::isReviewer()) {
         $canOnlyRead = false;
         $canOnlyReview = true;
     }
     if (Validation::isSiteAdmin() || Validation::isConferenceManager() || Validation::isDirector()) {
         $canOnlyRead = false;
         $canOnlyReview = false;
     }
     // Remove the notification setting categories that the user will not be receiving (to simplify the form)
     $notificationSettingCategories = $this->_getNotificationSettingCategories();
     if ($canOnlyRead || $canOnlyReview) {
         unset($notificationSettingCategories['submissions']);
     }
     if ($canOnlyRead) {
         unset($notificationSettingCategories['reviewing']);
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('notificationSettingCategories', $notificationSettingCategories);
     $templateMgr->assign('notificationSettings', $this->_getNotificationSettingsMap());
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('canOnlyRead', $canOnlyRead);
     $templateMgr->assign('canOnlyReview', $canOnlyReview);
     return parent::display($request);
 }
コード例 #3
0
 /**
  * @see ReportPlugin::display()
  */
 function display(&$args, &$request)
 {
     parent::display($args, $request);
     $journal =& $request->getJournal();
     if (!Validation::isSiteAdmin()) {
         Validation::redirectLogin();
     }
     $this->setBreadcrumbs();
     if ($request->getUserVar('type')) {
         $oldStats = (bool) $request->getUserVar('useOldCounterStats');
         $year = (string) $request->getUserVar('year');
         $type = (string) $request->getUserVar('type');
         switch ($type) {
             case 'report':
                 $this->_report($request, $year, $oldStats);
                 break;
             case 'reportxml':
                 $this->_reportXml($request, $year, $oldStats);
                 break;
             case 'sushixml':
                 $this->_sushiXML($oldStats);
                 break;
         }
     } else {
         $years = $this->_getYears();
         $legacyYears = $this->_getYears(true);
         $templateManager =& TemplateManager::getManager();
         $templateManager->assign('years', $years);
         if (!empty($legacyYears)) {
             $templateManager->assign('legacyYears', $legacyYears);
         }
         $templateManager->display($this->getTemplatePath() . 'index.tpl');
     }
 }
コード例 #4
0
ファイル: AdminHandler.inc.php プロジェクト: alenoosh/ojs
 /**
  * Validate that user has admin privileges and is not trying to access the admin module with a journal selected.
  * Redirects to the user index page if not properly authenticated.
  */
 function validate()
 {
     parent::validate();
     if (!Validation::isSiteAdmin() || Request::getRequestedJournalPath() != 'index') {
         Validation::redirectLogin();
     }
 }
コード例 #5
0
ファイル: PluginHandler.inc.php プロジェクト: Jouper/jouper
 /**
  * Display a list of plugins along with management options.
  */
 function plugins($args)
 {
     $category = isset($args[0]) ? $args[0] : null;
     parent::validate();
     $categories = PluginRegistry::getCategories();
     if (isset($category)) {
         // The user specified a category of plugins to view;
         // get the plugins in that category only.
         $plugins =& PluginRegistry::loadCategory($category);
     } else {
         // No plugin specified; display all.
         $plugins = array();
         foreach ($categories as $category) {
             $newPlugins =& PluginRegistry::loadCategory($category);
             if (isset($newPlugins)) {
                 $plugins = array_merge($plugins, PluginRegistry::loadCategory($category));
             }
         }
     }
     parent::setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('plugins', $plugins);
     $templateMgr->assign_by_ref('categories', $categories);
     $templateMgr->assign('isSiteAdmin', Validation::isSiteAdmin());
     $templateMgr->assign('helpTopicId', 'journal.managementPages.plugins');
     $templateMgr->display('manager/plugins/plugins.tpl');
 }
コード例 #6
0
 /**
  * Display the site or press index page.
  * (If a site admin is logged in and no presses exist, redirect to the
  * press administration page -- this may be useful upon install.)
  *
  * @param $args array
  * @param $request Request
  */
 function index($args, $request)
 {
     $targetPress = $this->getTargetContext($request);
     $press = $request->getPress();
     $user = $request->getUser();
     if ($user && !$targetPress && Validation::isSiteAdmin()) {
         // If the user is a site admin and no press exists,
         // send them to press administration to create one.
         return $request->redirect(null, 'admin', 'contexts');
     }
     // Public access.
     $this->setupTemplate($request);
     $templateMgr = TemplateManager::getManager($request);
     if ($press) {
         // Display the current press home.
         $this->_displayPressIndexPage($press, $templateMgr);
     } elseif ($targetPress) {
         // We're not on a press homepage, but there's one
         // available; redirect there.
         $request->redirect($targetPress->getPath());
     } else {
         // A target press couldn't be determined for some reason.
         if ($user) {
             // Redirect to user profile.
             $request->redirect(null, 'user', 'profile');
         } else {
             // Not logged in. Redirect to login page.
             $request->redirect(null, 'login');
         }
     }
 }
コード例 #7
0
ファイル: PluginHandler.inc.php プロジェクト: reconciler/ojs
 /**
  * Display a list of plugins along with management options.
  * @param $args array
  * @param $request PKPRequest
  */
 function plugins($args, &$request)
 {
     $category = isset($args[0]) ? $args[0] : null;
     $categories = PluginRegistry::getCategories();
     $templateMgr =& TemplateManager::getManager();
     $this->validate();
     if (isset($category) && in_array($category, $categories)) {
         // The user specified a category of plugins to view;
         // get the plugins in that category only.
         $mainPage = false;
         $plugins =& PluginRegistry::loadCategory($category);
         $this->setupTemplate(false);
         $templateMgr->assign('pageTitle', 'plugins.categories.' . $category);
         $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs($request, true));
     } else {
         // No plugin specified; display all.
         $mainPage = true;
         $plugins = array();
         foreach ($categories as $category) {
             $newPlugins =& PluginRegistry::loadCategory($category);
             if (isset($newPlugins)) {
                 $plugins = array_merge($plugins, PluginRegistry::loadCategory($category));
             }
         }
         $this->setupTemplate(true);
         $templateMgr->assign('pageTitle', 'manager.plugins.pluginManagement');
         $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs($request, false));
     }
     $templateMgr->assign_by_ref('plugins', $plugins);
     $templateMgr->assign_by_ref('categories', $categories);
     $templateMgr->assign('mainPage', $mainPage);
     $templateMgr->assign('isSiteAdmin', Validation::isSiteAdmin());
     $templateMgr->assign('helpTopicId', 'journal.managementPages.plugins');
     $templateMgr->display('manager/plugins/plugins.tpl');
 }
コード例 #8
0
 /**
  * Validate that user has permissions to manage the selected journal.
  * Redirects to user index page if not properly authenticated.
  */
 function validate()
 {
     parent::validate();
     $journal =& Request::getJournal();
     if (!$journal || !Validation::isJournalManager() && !Validation::isSiteAdmin()) {
         Validation::redirectLogin();
     }
 }
コード例 #9
0
 function addArchiveFormChecks(&$form)
 {
     $this->import('OAIHarvester');
     $oaiHarvester = new OAIHarvester($this->archive);
     $form->addCheck(new FormValidator($form, 'harvesterUrl', 'required', 'plugins.harvesters.oai.archive.form.harvesterUrlRequired'));
     $form->addCheck(new FormValidatorInSet($form, 'oaiIndexMethod', 'optional', 'plugins.harvesters.oai.archive.form.oaiIndexMethodRequired', array(OAI_INDEX_METHOD_LIST_RECORDS, OAI_INDEX_METHOD_LIST_IDENTIFIERS)));
     $form->addCheck(new FormValidatorCustom($form, 'harvesterUrl', 'required', 'plugins.harvester.oai.archive.form.harvesterUrlInvalid', array(&$oaiHarvester, 'validateHarvesterURL'), array(Request::getUserVar('isStatic'))));
     $form->addCheck(new FormValidatorEmail($form, 'adminEmail', Validation::isSiteAdmin() ? 'optional' : 'required', 'plugins.harvesters.oai.archive.form.adminEmailInvalid'));
     $form->addCheck(new FormValidatorCustom($form, 'harvesterUrl', 'required', 'plugins.harvester.oai.archive.form.harvesterUrlDuplicate', array(&$this, 'duplicateHarvesterUrlDoesNotExist'), array(Request::getUserVar('archiveId'))));
 }
コード例 #10
0
ファイル: CounterPlugin.inc.php プロジェクト: yuricampos/ojs
 function displayMenuOption($hookName, $args)
 {
     if (!Validation::isSiteAdmin()) {
         return false;
     }
     $params =& $args[0];
     $smarty =& $args[1];
     $output =& $args[2];
     $output .= '<li>&#187; <a href="' . Request::url(null, 'counter') . '">' . __('plugins.generic.counter') . '</a></li>';
     return false;
 }
コード例 #11
0
 /**
  * The site setting option 'preventManagerPluginManagement' must not be set for
  * journal managers to be able to manage plugins.
  * @param $request PKPRequest
  */
 function validate($request)
 {
     parent::validate();
     if (!Validation::isSiteAdmin()) {
         $site =& $request->getSite();
         $preventManagerPluginManagement = $site->getSetting('preventManagerPluginManagement');
         if ($preventManagerPluginManagement) {
             $request->redirect(null, 'manager', 'plugins');
         }
     }
 }
コード例 #12
0
ファイル: BackupPlugin.inc.php プロジェクト: utlib/ojs
 /**
  * Register the plugin, if enabled; note that this plugin
  * runs under both Conference and Site contexts.
  * @param $category string
  * @param $path string
  * @return boolean
  */
 function register($category, $path)
 {
     if (parent::register($category, $path)) {
         $this->addLocaleData();
         if ($this->getEnabled() && Validation::isSiteAdmin()) {
             HookRegistry::register('Templates::Admin::Index::AdminFunctions', array($this, 'addLink'));
             HookRegistry::register('LoadHandler', array($this, 'handleRequest'));
         }
         return true;
     }
     return false;
 }
コード例 #13
0
 /**
  * Display user index page.
  */
 function index()
 {
     $this->validate();
     $templateMgr =& TemplateManager::getManager();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $user =& Request::getUser();
     $site =& Request::getSite();
     $this->setupTemplate();
     $templateMgr->assign('isSiteAdmin', Validation::isSiteAdmin());
     $templateMgr->assign('userRoles', $roleDao->getRolesByUserId($user->getId()));
     $templateMgr->assign('enableSubmit', $site->getSetting('enableSubmit'));
     $templateMgr->display('user/index.tpl');
 }
コード例 #14
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  * @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory
  */
 function TemplateManager($request = null)
 {
     // FIXME: for backwards compatibility only - remove
     if (!isset($request)) {
         // FIXME: Trigger a deprecation warning when enough instances of this
         // call have been fixed to not clutter the error log.
         $request =& Registry::get('request');
     }
     assert(is_a($request, 'PKPRequest'));
     parent::PKPTemplateManager($request);
     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).
          */
         $site =& $request->getSite();
         $siteFilesDir = $request->getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath();
         $this->assign('sitePublicFilesDir', $siteFilesDir);
         $this->assign('publicFilesDir', $siteFilesDir);
         $this->assign('isAdmin', Validation::isSiteAdmin());
         // assign an empty home context
         $this->assign('homeContext', array());
         $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
         if (file_exists($siteStyleFilename)) {
             $this->addStyleSheet($request->getBaseUrl() . '/' . $siteStyleFilename);
         }
         // Load and apply theme plugin, if chosen
         $themePluginPath = $site->getSetting('theme');
         if (!empty($themePluginPath)) {
             // Load and activate the theme
             $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
             if ($themePlugin) {
                 $themePlugin->activate($this);
             }
         }
         // Add the site-wide logo, if set for this locale or the primary locale
         $this->assign('displayPageHeaderTitle', $site->getLocalizedPageHeaderTitle());
         $customLogo = $site->getSetting('customLogo');
         if ($customLogo) {
             $this->assign('displayPageHeaderLogo', $customLogo);
         }
         $this->assign('siteTitle', $site->getLocalizedTitle());
         $this->assign('enableSubmit', $site->getSetting('enableSubmit'));
         // Add java script for notifications
         $user =& $request->getUser();
         if ($user) {
             $this->addJavaScript('lib/pkp/js/lib/jquery/plugins/jquery.pnotify.js');
         }
     }
 }
コード例 #15
0
 /**
  * Generic plug-ins implement the enabled/disabled logic
  * by default. This is necessary so that we can make sure
  * that disabled plug-ins will not have to be instantiated.
  *
  * Call this method with a list of management verbs (if any)
  * generated by the custom plug-in.
  *
  * @see Plugin::getManagementVerbs()
  */
 function getManagementVerbs()
 {
     // Site plug-ins can only be administered by site admins
     if ($this->isSitePlugin() && !Validation::isSiteAdmin()) {
         return array();
     }
     $verbs = parent::getManagementVerbs();
     if ($this->getEnabled()) {
         $verbs[] = array('disable', __('common.disable'));
     } else {
         $verbs[] = array('enable', __('common.enable'));
     }
     return $verbs;
 }
コード例 #16
0
 /**
  * Generic plug-ins implement the enabled/disabled logic
  * by default. This is necessary so that we can make sure
  * that disabled plug-ins will not have to be instantiated.
  *
  * Call this method with a list of management verbs (if any)
  * generated by the custom plug-in.
  *
  * @see PKPPlugin::getManagementVerbs()
  */
 function getManagementVerbs($verbs = array())
 {
     assert(is_array($verbs));
     // Site plug-ins can only be administered by site admins
     if ($this->isSitePlugin() && !Validation::isSiteAdmin()) {
         return array();
     }
     if ($this->getEnabled()) {
         $verbs[] = array('disable', Locale::translate('common.disable'));
     } else {
         $verbs[] = array('enable', Locale::translate('common.enable'));
     }
     return $verbs;
 }
コード例 #17
0
 /**
  * Display the form.
  */
 function display()
 {
     $canOnlyRead = true;
     $canOnlyReview = false;
     if (Validation::isReviewer()) {
         $canOnlyRead = false;
         $canOnlyReview = true;
     }
     if (Validation::isSiteAdmin() || Validation::isJournalManager() || Validation::isEditor() || Validation::isSectionEditor()) {
         $canOnlyRead = false;
         $canOnlyReview = false;
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('canOnlyRead', $canOnlyRead);
     $templateMgr->assign('canOnlyReview', $canOnlyReview);
     return parent::display();
 }
コード例 #18
0
 /**
  * @copydoc GridRow::initialize()
  */
 function initialize($request, $template = null)
 {
     parent::initialize($request, $template);
     // Is this a new row or an existing row?
     $rowId = $this->getId();
     $rowData = $this->getData();
     if (!empty($rowId)) {
         // Only add row actions if this is an existing row
         $router = $request->getRouter();
         $actionArgs = array('gridId' => $this->getGridId(), 'rowId' => $rowId);
         if (Validation::isSiteAdmin()) {
             if (!$rowData['primary']) {
                 $this->addAction(new LinkAction('uninstall', new RemoteActionConfirmationModal($request->getSession(), __('admin.languages.confirmUninstall'), __('grid.action.remove'), $router->url($request, null, null, 'uninstallLocale', null, $actionArgs)), __('grid.action.remove'), 'delete'));
             }
             $this->addAction(new LinkAction('reload', new RemoteActionConfirmationModal($request->getSession(), __('manager.language.confirmDefaultSettingsOverwrite'), __('manager.language.reloadLocalizedDefaultSettings'), $router->url($request, null, null, 'reloadLocale', null, $actionArgs)), __('manager.language.reloadLocalizedDefaultSettings')));
         }
     }
 }
コード例 #19
0
 function manage($verb, $args)
 {
     if (!Validation::isSiteAdmin()) {
         return false;
     }
     switch ($verb) {
         case 'enable':
             $this->updateSetting(0, 'enabled', true);
             break;
         case 'disable':
             $this->updateSetting(0, 'enabled', false);
             break;
         case 'translate':
             Request::redirect('index', 'translate');
             break;
     }
     return false;
 }
コード例 #20
0
 /**
  * Display the form.
  */
 function display()
 {
     $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
     $conferences =& $conferenceDao->getConferenceTitles();
     $canOnlyRead = true;
     $canOnlyReview = false;
     if (Validation::isReviewer()) {
         $canOnlyRead = false;
         $canOnlyReview = true;
     }
     if (Validation::isSiteAdmin() || Validation::isConferenceManager() || Validation::isDirector()) {
         $canOnlyRead = false;
         $canOnlyReview = false;
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('canOnlyRead', $canOnlyRead);
     $templateMgr->assign('canOnlyReview', $canOnlyReview);
     return parent::display();
 }
コード例 #21
0
ファイル: TranslatorPlugin.inc.php プロジェクト: jalperin/ocs
 function manage($verb, $args, &$message)
 {
     if (!Validation::isSiteAdmin()) {
         return false;
     }
     switch ($verb) {
         case 'enable':
             $this->updateSetting(0, 0, 'enabled', true);
             $message = Locale::translate('plugins.generic.translator.enabled');
             break;
         case 'disable':
             $this->updateSetting(0, 0, 'enabled', false);
             $message = Locale::translate('plugins.generic.translator.disabled');
             break;
         case 'translate':
             Request::redirect('index', 'index', 'translate');
             break;
     }
     return false;
 }
コード例 #22
0
 /**
  * Display the form.
  */
 function display()
 {
     $canOnlyRead = true;
     $canOnlyReview = false;
     // FIXME: Bug #6538. These policies used to use several role checks
     // that are no longer appropriate / have been removed. The remaining
     // ones should be too.
     if (Validation::isReviewer()) {
         $canOnlyRead = false;
         $canOnlyReview = true;
     }
     if (Validation::isSiteAdmin()) {
         $canOnlyRead = false;
         $canOnlyReview = false;
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('canOnlyRead', $canOnlyRead);
     $templateMgr->assign('canOnlyReview', $canOnlyReview);
     return parent::display();
 }
コード例 #23
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  */
 function TemplateManager()
 {
     parent::PKPTemplateManager();
     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).
          */
         $site =& Request::getSite();
         $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath();
         $this->assign('sitePublicFilesDir', $siteFilesDir);
         $this->assign('publicFilesDir', $siteFilesDir);
         $this->assign('isAdmin', Validation::isSiteAdmin());
         // assign an empty home context
         $this->assign('homeContext', array());
         $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
         if (file_exists($siteStyleFilename)) {
             $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename);
         }
         // Load and apply theme plugin, if chosen
         $themePluginPath = $site->getSetting('theme');
         if (!empty($themePluginPath)) {
             // Load and activate the theme
             $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
             if ($themePlugin) {
                 $themePlugin->activate($this);
             }
         }
         // Add the site-wide logo, if set for this locale or the primary locale
         $this->assign('displayPageHeaderTitle', $site->getLocalizedPageHeaderTitle());
         $customLogo = $site->getSetting('customLogo');
         if ($customLogo) {
             $this->assign('useCustomLogo', $customLogo);
         }
         $this->assign('siteTitle', $site->getLocalizedTitle());
         $this->assign('enableSubmit', $site->getSetting('enableSubmit'));
     }
 }
コード例 #24
0
 function email($args)
 {
     parent::validate();
     parent::setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     // See if this is the Editor or Manager and an email template has been chosen
     $template = Request::getUserVar('template');
     if (!$journal || empty($template) || !Validation::isJournalManager($journal->getJournalId()) && !Validation::isEditor($journal->getJournalId()) && !Validation::isSectionEditor($journal->getJournalId())) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_JOURNAL_MANAGER, ROLE_ID_EDITOR, ROLE_ID_SECTION_EDITOR);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     if ($journal) {
         $roles =& $roleDao->getRolesByUserId($user->getUserId(), $journal->getJournalId());
         foreach ($roles as $role) {
             if (in_array($role->getRoleId(), $unlimitedEmailRoles)) {
                 $canSendUnlimitedEmails = true;
             }
         }
     }
     // Check when this user last sent an email, and if it's too
     // recent, make them wait.
     if (!$canSendUnlimitedEmails) {
         $dateLastEmail = $user->getDateLastEmail();
         if ($dateLastEmail && strtotime($dateLastEmail) + (int) Config::getVar('email', 'time_between_emails') > strtotime(Core::getCurrentDate())) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooSoon');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
     }
     $email = null;
     if ($articleId = Request::getUserVar('articleId')) {
         // This message is in reference to an article.
         // Determine whether the current user has access
         // to the article in some form, and if so, use an
         // ArticleMailTemplate.
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $article =& $articleDao->getArticle($articleId);
         $hasAccess = false;
         // First, conditions where access is OK.
         // 1. User is submitter
         if ($article && $article->getUserId() == $user->getUserId()) {
             $hasAccess = true;
         }
         // 2. User is section editor of article or full editor
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($articleId);
         while ($editAssignment =& $editAssignments->next()) {
             if ($editAssignment->getEditorId() === $user->getUserId()) {
                 $hasAccess = true;
             }
         }
         if (Validation::isEditor($journal->getJournalId())) {
             $hasAccess = true;
         }
         // 3. User is reviewer
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         foreach ($reviewAssignmentDao->getReviewAssignmentsByArticleId($articleId) as $reviewAssignment) {
             if ($reviewAssignment->getReviewerId() === $user->getUserId()) {
                 $hasAccess = true;
             }
         }
         // 4. User is copyeditor
         $copyAssignmentDao =& DAORegistry::getDAO('CopyAssignmentDAO');
         $copyAssignment =& $copyAssignmentDao->getCopyAssignmentByArticleId($articleId);
         if ($copyAssignment && $copyAssignment->getCopyeditorId() === $user->getUserId()) {
             $hasAccess = true;
         }
         // 5. User is layout editor
         $layoutAssignmentDao =& DAORegistry::getDAO('LayoutAssignmentDAO');
         $layoutAssignment =& $layoutAssignmentDao->getLayoutAssignmentByArticleId($articleId);
         if ($layoutAssignment && $layoutAssignment->getEditorId() === $user->getUserId()) {
             $hasAccess = true;
         }
         // 6. User is proofreader
         $proofAssignmentDao =& DAORegistry::getDAO('ProofAssignmentDAO');
         $proofAssignment =& $proofAssignmentDao->getProofAssignmentByArticleId($articleId);
         if ($proofAssignment && $proofAssignment->getProofreaderId() === $user->getUserId()) {
             $hasAccess = true;
         }
         // Last, "deal-breakers" -- access is not allowed.
         if (!$article || $article && $article->getJournalId() !== $journal->getJournalId()) {
             $hasAccess = false;
         }
         if ($hasAccess) {
             import('mail.ArticleMailTemplate');
             $email =& new ArticleMailTemplate($articleDao->getArticle($articleId, $template));
         }
     }
     if ($email === null) {
         import('mail.MailTemplate');
         $email =& new MailTemplate($template);
     }
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $recipients = $email->getRecipients();
         $ccs = $email->getCcs();
         $bccs = $email->getBccs();
         // Make sure there aren't too many recipients (to
         // prevent use as a spam relay)
         $recipientCount = 0;
         if (is_array($recipients)) {
             $recipientCount += count($recipients);
         }
         if (is_array($ccs)) {
             $recipientCount += count($ccs);
         }
         if (is_array($bccs)) {
             $recipientCount += count($bccs);
         }
         if (!$canSendUnlimitedEmails && $recipientCount > (int) Config::getVar('email', 'max_recipients')) {
             $templateMgr->assign('pageTitle', 'email.compose');
             $templateMgr->assign('message', 'email.compose.tooManyRecipients');
             $templateMgr->assign('backLink', 'javascript:history.back()');
             $templateMgr->assign('backLinkLabel', 'email.compose');
             return $templateMgr->display('common/message.tpl');
         }
         $email->send();
         $redirectUrl = Request::getUserVar('redirectUrl');
         if (empty($redirectUrl)) {
             $redirectUrl = Request::url(null, 'user');
         }
         $user->setDateLastEmail(Core::getCurrentDate());
         $userDao->updateUser($user);
         Request::redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm(Request::url(null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl'), 'articleId' => $articleId), null, array('disableSkipButton' => true, 'articleId' => $articleId));
     }
 }
コード例 #25
0
ファイル: Validation.inc.php プロジェクト: jerico-dev/omp
 /**
  * Check whether a user is allowed to administer another user.
  * @param $pressId int
  * @param $userId int
  * @return boolean
  */
 function canAdminister($pressId, $userId)
 {
     if (Validation::isSiteAdmin()) {
         return true;
     }
     if (!Validation::isPressManager($pressId)) {
         return false;
     }
     // Check for roles in other presses that this user
     // doesn't have administrative rights over.
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     if ($roleDao->userHasRole(0, $userId, ROLE_ID_SITE_ADMIN)) {
         return false;
     }
     $pressDao =& DAORegistry::getDAO('PressDAO');
     $presses =& $pressDao->getPresses();
     while (!$presses->eof()) {
         $press =& $presses->next();
         if ($press->getId() != $pressId && !$roleDao->userHasRole($press->getId(), $userId, ROLE_ID_PRESS_MANAGER)) {
             return false;
         }
     }
     // There were no conflicting roles.
     return true;
 }
コード例 #26
0
ファイル: Validation.inc.php プロジェクト: jalperin/harvester
 /**
  * Determine whether or not the current user can administer another.
  */
 function canAdminister($userId)
 {
     return Validation::isSiteAdmin();
 }
コード例 #27
0
 /**
  * Validate that user has site admin privileges or journal manager priveleges.
  * Redirects to the user index page if not properly authenticated.
  * @param $canRedirect boolean Whether or not to redirect if the user cannot be validated; if not, the script simply terminates.
  */
 function validate($canRedirect = true)
 {
     parent::validate();
     $journal =& Request::getJournal();
     if (!Validation::isSiteAdmin()) {
         if ($canRedirect) {
             Validation::redirectLogin();
         } else {
             exit;
         }
     }
     $plugin =& Registry::get('plugin');
     $this->plugin =& $plugin;
     return true;
 }
コード例 #28
0
 function manage($verb, $args)
 {
     switch ($verb) {
         case 'exportHoldings':
             if (Validation::isSiteAdmin() && $this->getEnabled()) {
                 $this->exportHoldings();
                 return true;
             }
             break;
     }
     return parent::manage($verb, $args);
 }
コード例 #29
0
ファイル: PeopleHandler.inc.php プロジェクト: ramonsodoma/ocs
 /**
  * Display a user's profile.
  * @param $args array first parameter is the ID or username of the user to display
  */
 function userProfile($args)
 {
     $this->validate();
     $this->setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all'));
     $templateMgr->assign('helpTopicId', 'conference.users.index');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userId = isset($args[0]) ? $args[0] : 0;
     if (is_numeric($userId)) {
         $userId = (int) $userId;
         $user = $userDao->getUser($userId);
     } else {
         $user = $userDao->getUserByUsername($userId);
     }
     if ($user == null) {
         // Non-existent user requested
         $templateMgr->assign('pageTitle', 'manager.people');
         $templateMgr->assign('errorMsg', 'manager.people.invalidUser');
         $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all'));
         $templateMgr->assign('backLinkLabel', 'manager.people.allUsers');
         $templateMgr->display('common/error.tpl');
     } else {
         $site =& Request::getSite();
         $conference =& Request::getConference();
         $isSiteAdmin = Validation::isSiteAdmin();
         $templateMgr->assign('isSiteAdmin', $isSiteAdmin);
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $roles =& $roleDao->getRolesByUserId($user->getId(), $conference->getId());
         if ($isSiteAdmin) {
             // We'll be displaying all roles, so get ready to display
             // conference names other than the current journal.
             $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
             $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
             $conferenceTitles =& $conferenceDao->getConferenceTitles();
             $schedConfTitles =& $schedConfDao->getSchedConfTitles();
             $templateMgr->assign_by_ref('conferenceTitles', $conferenceTitles);
             $templateMgr->assign_by_ref('schedConfTitles', $schedConfTitles);
         }
         $countryDao =& DAORegistry::getDAO('CountryDAO');
         $country = null;
         if ($user->getCountry() != '') {
             $country = $countryDao->getCountry($user->getCountry());
         }
         $templateMgr->assign('country', $country);
         $templateMgr->assign_by_ref('user', $user);
         $templateMgr->assign_by_ref('userRoles', $roles);
         $templateMgr->assign('localeNames', Locale::getAllLocales());
         $templateMgr->display('manager/people/userProfile.tpl');
     }
 }
コード例 #30
0
ファイル: Validation.inc.php プロジェクト: sedici/ocs
 /**
  * Check whether a user is allowed to administer another user.
  * @param $conferenceId int
  * @param $userId int
  * @return boolean
  */
 function canAdminister($conferenceId, $userId)
 {
     if (Validation::isSiteAdmin()) {
         return true;
     }
     if (!Validation::isConferenceManager($conferenceId)) {
         return false;
     }
     // Check for roles in other conferences that this user
     // doesn't have administrative rights over.
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $roles =& $roleDao->getRolesByUserId($userId);
     foreach ($roles as $role) {
         // Other user cannot be site admin
         if ($role->getRoleId() == ROLE_ID_SITE_ADMIN) {
             return false;
         }
         if ($role->getConferenceId() != $conferenceId) {
             // Other conferences: We must have admin privileges there too
             if (!Validation::isConferenceManager($role->getConferenceId())) {
                 return false;
             }
         }
     }
     return true;
 }