/**
  * Update language settings.
  */
 function saveLanguageSettings()
 {
     parent::validate();
     parent::setupTemplate(true);
     $site =& Request::getSite();
     $primaryLocale = Request::getUserVar('primaryLocale');
     $supportedLocales = Request::getUserVar('supportedLocales');
     if (Locale::isLocaleValid($primaryLocale)) {
         $site->setPrimaryLocale($primaryLocale);
     }
     $newSupportedLocales = array();
     if (isset($supportedLocales) && is_array($supportedLocales)) {
         foreach ($supportedLocales as $locale) {
             if (Locale::isLocaleValid($locale)) {
                 array_push($newSupportedLocales, $locale);
             }
         }
     }
     if (!in_array($primaryLocale, $newSupportedLocales)) {
         array_push($newSupportedLocales, $primaryLocale);
     }
     $site->setSupportedLocales($newSupportedLocales);
     $siteDao =& DAORegistry::getDAO('SiteDAO');
     $siteDao->updateSite($site);
     AdminLanguagesHandler::removeLocalesFromJournals();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, 'admin'), 'backLinkLabel' => 'admin.siteAdmin'));
     $templateMgr->display('common/message.tpl');
 }
Ejemplo n.º 2
0
 /**
  * Display site admin index page.
  */
 function index()
 {
     AdminHandler::validate();
     AdminHandler::setupTemplate();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('helpTopicId', 'site.index');
     $templateMgr->display('admin/index.tpl');
 }
Ejemplo n.º 3
0
 /**
  * Display form to edit an authentication source.
  */
 function editAuthSource($args)
 {
     parent::validate();
     parent::setupTemplate(true);
     import('security.form.AuthSourceSettingsForm');
     $form =& new AuthSourceSettingsForm((int) @$args[0]);
     $form->initData();
     $form->display();
 }
Ejemplo n.º 4
0
 /**
  * Save modified system configuration settings.
  */
 function saveSystemConfig()
 {
     parent::validate();
     parent::setupTemplate(true);
     $configData =& Config::getData();
     // Update configuration based on user-supplied data
     foreach ($configData as $sectionName => $sectionData) {
         $newData = Request::getUserVar($sectionName);
         foreach ($sectionData as $settingName => $settingValue) {
             if (isset($newData[$settingName])) {
                 $newValue = $newData[$settingName];
                 if (strtolower($newValue) == "true" || strtolower($newValue) == "on") {
                     $newValue = "On";
                 } else {
                     if (strtolower($newValue) == "false" || strtolower($newValue) == "off") {
                         $newValue = "Off";
                     }
                 }
                 $configData[$sectionName][$settingName] = $newValue;
             }
         }
     }
     $templateMgr =& TemplateManager::getManager();
     // Update contents of configuration file
     $configParser =& new ConfigParser();
     if (!$configParser->updateConfig(Config::getConfigFileName(), $configData)) {
         // Error reading config file (this should never happen)
         $templateMgr->assign('errorMsg', 'admin.systemConfigFileReadError');
         $templateMgr->assign('backLink', Request::url(null, null, 'systemInfo'));
         $templateMgr->assign('backLinkLabel', 'admin.systemInformation');
         $templateMgr->display('common/error.tpl');
     } else {
         $writeConfigFailed = false;
         $displayConfigContents = Request::getUserVar('display') == null ? false : true;
         $configFileContents = $configParser->getFileContents();
         if (!$displayConfigContents) {
             if (!$configParser->writeConfig(Config::getConfigFileName())) {
                 $writeConfigFailed = true;
             }
         }
         // Display confirmation
         $templateMgr->assign('writeConfigFailed', $writeConfigFailed);
         $templateMgr->assign('displayConfigContents', $displayConfigContents);
         $templateMgr->assign('configFileContents', $configFileContents);
         $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
         $templateMgr->display('admin/systemConfigUpdated.tpl');
     }
 }
Ejemplo n.º 5
0
 /**
  * Validate and save changes to site settings.
  */
 function saveSettings()
 {
     parent::validate();
     parent::setupTemplate(true);
     $site =& Request::getSite();
     import('admin.form.SiteSettingsForm');
     $settingsForm =& new SiteSettingsForm();
     $settingsForm->readInputData();
     if (Request::getUserVar('uploadSiteStyleSheet')) {
         if (!$settingsForm->uploadSiteStyleSheet()) {
             $settingsForm->addError('siteStyleSheet', Locale::translate('admin.settings.siteStyleSheetInvalid'));
         }
     } elseif (Request::getUserVar('deleteSiteStyleSheet')) {
         $publicFileManager =& new PublicFileManager();
         $publicFileManager->removeSiteFile($site->getSiteStyleFilename());
     } elseif (Request::getUserVar('uploadPageHeaderTitleImage')) {
         if (!$settingsForm->uploadPageHeaderTitleImage($settingsForm->getFormLocale())) {
             $settingsForm->addError('pageHeaderTitleImage', Locale::translate('admin.settings.homeHeaderImageInvalid'));
         }
     } elseif (Request::getUserVar('deletePageHeaderTitleImage')) {
         $publicFileManager =& new PublicFileManager();
         $setting = $site->getData('pageHeaderTitleImage');
         $formLocale = $settingsForm->getFormLocale();
         if (isset($setting[$formLocale])) {
             $publicFileManager->removeSiteFile($setting[$formLocale]['uploadName']);
             unset($setting[$formLocale]);
             $site->setData('pageHeaderTitleImage', $setting);
             $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
             $siteSettingsDao->deleteSetting('pageHeaderTitleImage', $formLocale);
             // Refresh site header
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('displayPageHeaderTitle', $site->getSitePageHeaderTitle());
         }
     } elseif ($settingsForm->validate()) {
         $settingsForm->execute();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'settings'), 'pageTitle' => 'admin.siteSettings', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, Request::getRequestedPage()), 'backLinkLabel' => 'admin.siteAdmin'));
         $templateMgr->display('common/message.tpl');
         exit;
     }
     $settingsForm->display();
 }
 /**
  * Set up the template.
  */
 function setupTemplate()
 {
     parent::setupTemplate(true);
     AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_MANAGER));
 }
Ejemplo n.º 7
0
 /**
  * Setup common template variables.
  * @param $subclass boolean set to true if caller is below this handler in the hierarchy
  */
 function setupTemplate($subclass = false)
 {
     parent::setupTemplate();
     $templateMgr =& TemplateManager::getManager();
     $pageHierarchy = array(array(Request::url('admin'), 'admin.siteAdmin'));
     if ($subclass) {
         $pageHierarchy[] = array(Request::url('admin', 'archives'), 'admin.archives');
     }
     $templateMgr->assign('pageHierarchy', $pageHierarchy);
 }
 /**
  * Import data from an OJS 1.x journal.
  */
 function doImportOJS1()
 {
     parent::validate();
     import('admin.form.ImportOJS1Form');
     $importForm =& new ImportOJS1Form();
     $importForm->readInputData();
     if ($importForm->validate() && ($journalId = $importForm->execute()) !== false) {
         $redirects = $importForm->getRedirects();
         $conflicts = $importForm->getConflicts();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('journalId', $journalId);
         $templateMgr->assign('redirects', $redirects);
         $templateMgr->assign('conflicts', $conflicts);
         $templateMgr->display('admin/importComplete.tpl');
     } else {
         parent::setupTemplate(true);
         $importForm->display();
     }
 }
Ejemplo n.º 9
0
 /**
  * Allow the Site Administrator to merge user accounts, including attributed articles etc.
  */
 function mergeUsers($args)
 {
     parent::validate();
     parent::setupTemplate(true);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $templateMgr =& TemplateManager::getManager();
     $oldUserId = Request::getUserVar('oldUserId');
     $newUserId = Request::getUserVar('newUserId');
     if (!empty($oldUserId) && !empty($newUserId)) {
         // Both user IDs have been selected. Merge the accounts.
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         foreach ($articleDao->getArticlesByUserId($oldUserId) as $article) {
             $article->setUserId($newUserId);
             $articleDao->updateArticle($article);
             unset($article);
         }
         $commentDao =& DAORegistry::getDAO('CommentDAO');
         foreach ($commentDao->getCommentsByUserId($oldUserId) as $comment) {
             $comment->setUserId($newUserId);
             $commentDao->updateComment($comment);
             unset($comment);
         }
         $articleNoteDao =& DAORegistry::getDAO('ArticleNoteDAO');
         $articleNotes =& $articleNoteDao->getArticleNotesByUserId($oldUserId);
         while ($articleNote =& $articleNotes->next()) {
             $articleNote->setUserId($newUserId);
             $articleNoteDao->updateArticleNote($articleNote);
             unset($articleNote);
         }
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByUserId($oldUserId);
         while ($editAssignment =& $editAssignments->next()) {
             $editAssignment->setEditorId($newUserId);
             $editAssignmentDao->updateEditAssignment($editAssignment);
             unset($editAssignment);
         }
         $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO');
         $editorSubmissionDao->transferEditorDecisions($oldUserId, $newUserId);
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         foreach ($reviewAssignmentDao->getReviewAssignmentsByUserId($oldUserId) as $reviewAssignment) {
             $reviewAssignment->setReviewerId($newUserId);
             $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
             unset($reviewAssignment);
         }
         $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
         $copyeditorSubmissions =& $copyeditorSubmissionDao->getCopyeditorSubmissionsByCopyeditorId($oldUserId);
         while ($copyeditorSubmission =& $copyeditorSubmissions->next()) {
             $copyeditorSubmission->setCopyeditorId($newUserId);
             $copyeditorSubmissionDao->updateCopyeditorSubmission($copyeditorSubmission);
             unset($copyeditorSubmission);
         }
         $layoutEditorSubmissionDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO');
         $layoutEditorSubmissions =& $layoutEditorSubmissionDao->getSubmissions($oldUserId);
         while ($layoutEditorSubmission =& $layoutEditorSubmissions->next()) {
             $layoutAssignment =& $layoutEditorSubmission->getLayoutAssignment();
             $layoutAssignment->setEditorId($newUserId);
             $layoutEditorSubmissionDao->updateSubmission($layoutEditorSubmission);
             unset($layoutAssignment);
             unset($layoutEditorSubmission);
         }
         $proofreaderSubmissionDao =& DAORegistry::getDAO('ProofreaderSubmissionDAO');
         $proofreaderSubmissions =& $proofreaderSubmissionDao->getSubmissions($oldUserId);
         while ($proofreaderSubmission =& $proofreaderSubmissions->next()) {
             $proofAssignment =& $proofreaderSubmission->getProofAssignment();
             $proofAssignment->setProofreaderId($newUserId);
             $proofreaderSubmissionDao->updateSubmission($proofreaderSubmission);
             unset($proofAssignment);
             unset($proofreaderSubmission);
         }
         $articleEmailLogDao =& DAORegistry::getDAO('ArticleEmailLogDAO');
         $articleEmailLogDao->transferArticleLogEntries($oldUserId, $newUserId);
         $articleEventLogDao =& DAORegistry::getDAO('ArticleEventLogDAO');
         $articleEventLogDao->transferArticleLogEntries($oldUserId, $newUserId);
         $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
         foreach ($articleCommentDao->getArticleCommentsByUserId($oldUserId) as $articleComment) {
             $articleComment->setAuthorId($newUserId);
             $articleCommentDao->updateArticleComment($articleComment);
             unset($articleComment);
         }
         $accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
         $accessKeyDao->transferAccessKeys($oldUserId, $newUserId);
         // Delete the old user and associated info.
         $sessionDao =& DAORegistry::getDAO('SessionDAO');
         $sessionDao->deleteSessionsByUserId($oldUserId);
         $subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO');
         $subscriptionDao->deleteSubscriptionsByUserId($oldUserId);
         $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFileDao->deleteTemporaryFilesByUserId($oldUserId);
         $notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
         $notificationStatusDao->deleteNotificationStatusByUserId($oldUserId);
         $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
         $userSettingsDao->deleteSettings($oldUserId);
         $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
         $groupMembershipDao->deleteMembershipByUserId($oldUserId);
         $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
         $sectionEditorsDao->deleteEditorsByUserId($oldUserId);
         // Transfer old user's roles
         $roles =& $roleDao->getRolesByUserId($oldUserId);
         foreach ($roles as $role) {
             if (!$roleDao->roleExists($role->getJournalId(), $newUserId, $role->getRoleId())) {
                 $role->setUserId($newUserId);
                 $roleDao->insertRole($role);
             }
         }
         $roleDao->deleteRoleByUserId($oldUserId);
         $userDao->deleteUserById($oldUserId);
         Request::redirect(null, 'admin', 'mergeUsers');
     }
     if (!empty($oldUserId)) {
         // Get the old username for the confirm prompt.
         $oldUser =& $userDao->getUser($oldUserId);
         $templateMgr->assign('oldUsername', $oldUser->getUsername());
         unset($oldUser);
     }
     // The administrator must select one or both IDs.
     if (Request::getUserVar('roleSymbolic') != null) {
         $roleSymbolic = Request::getUserVar('roleSymbolic');
     } else {
         $roleSymbolic = isset($args[0]) ? $args[0] : 'all';
     }
     if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) {
         $roleId = $roleDao->getRoleIdFromPath($matches[1]);
         if ($roleId == null) {
             Request::redirect(null, null, null, 'all');
         }
         $roleName = $roleDao->getRoleName($roleId, true);
     } else {
         $roleId = 0;
         $roleName = 'admin.mergeUsers.allUsers';
     }
     $searchType = null;
     $searchMatch = null;
     $search = Request::getUserVar('search');
     $searchInitial = Request::getUserVar('searchInitial');
     if (isset($search)) {
         $searchType = Request::getUserVar('searchField');
         $searchMatch = Request::getUserVar('searchMatch');
     } else {
         if (isset($searchInitial)) {
             $searchInitial = String::strtoupper($searchInitial);
             $searchType = USER_FIELD_INITIAL;
             $search = $searchInitial;
         }
     }
     $rangeInfo = Handler::getRangeInfo('users');
     if ($roleId) {
         $users =& $roleDao->getUsersByRoleId($roleId, null, $searchType, $search, $searchMatch, $rangeInfo);
         $templateMgr->assign('roleId', $roleId);
     } else {
         $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo);
     }
     $templateMgr->assign('currentUrl', Request::url(null, null, 'mergeUsers'));
     $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
     $templateMgr->assign('roleName', $roleName);
     $templateMgr->assign_by_ref('users', $users);
     $templateMgr->assign_by_ref('thisUser', Request::getUser());
     $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER);
     $templateMgr->assign('searchField', $searchType);
     $templateMgr->assign('searchMatch', $searchMatch);
     $templateMgr->assign('search', $search);
     $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
     if ($roleId == ROLE_ID_REVIEWER) {
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         $templateMgr->assign('rateReviewerOnQuality', $journal->getSetting('rateReviewerOnQuality'));
         $templateMgr->assign('qualityRatings', $journal->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($journalId) : null);
     }
     $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests'));
     $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList')));
     $templateMgr->assign('oldUserId', $oldUserId);
     $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId));
     $templateMgr->assign('roleSymbolic', $roleSymbolic);
     $templateMgr->display('admin/selectMergeUser.tpl');
 }
Ejemplo n.º 10
0
 function setupTemplate($request = null, $category = null, $subclass = false)
 {
     parent::setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     if ($subclass) {
         $templateMgr->append('pageHierarchy', array($request->url(null, 'admin', 'categories'), 'admin.categories'));
     }
     if ($category) {
         $templateMgr->append('pageHierarchy', array($request->url(null, 'admin', 'editCategory', $category->getId()), $category->getLocalizedName(), true));
     }
 }
Ejemplo n.º 11
0
 /**
  * Setup common template variables.
  * @param $subclass boolean set to true if caller is below this handler in the hierarchy
  */
 function setupTemplate($request, $subclass = false)
 {
     parent::setupTemplate($request);
     $templateMgr =& TemplateManager::getManager($request);
     $pageHierarchy = array(array($request->url('admin'), 'admin.siteAdmin'));
     if ($subclass) {
         $pageHierarchy[] = array($request->url('admin', 'sortOrders'), 'admin.sortOrders');
     }
     $templateMgr->assign('pageHierarchy', $pageHierarchy);
 }