/**
  * Save modified settings.
  */
 function execute()
 {
     $press =& Request::getPress();
     $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     // Verify additional locales
     foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) {
         ${$name} = array();
         foreach ($this->getData($name) as $locale) {
             if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
                 array_push(${$name}, $locale);
             }
         }
     }
     $primaryLocale = $this->getData('primaryLocale');
     // Make sure at least the primary locale is chosen as available
     if ($primaryLocale != null && !empty($primaryLocale)) {
         foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) {
             if (!in_array($primaryLocale, ${$name})) {
                 array_push(${$name}, $primaryLocale);
             }
         }
     }
     $this->setData('supportedLocales', $supportedLocales);
     $this->setData('supportedSubmissionLocales', $supportedSubmissionLocales);
     $this->setData('supportedFormLocales', $supportedFormLocales);
     foreach ($this->_data as $name => $value) {
         if (!in_array($name, array_keys($this->settings))) {
             continue;
         }
         $settingsDao->updateSetting($press->getId(), $name, $value, $this->settings[$name]);
     }
     $pressDao =& DAORegistry::getDAO('PressDAO');
     $press->setPrimaryLocale($this->getData('primaryLocale'));
     $pressDao->updatePress($press);
 }
 /**
  * Initialize form data from current settings.
  * @param $args array
  * @param $request PKPRequest
  */
 function initData($args, &$request)
 {
     $press =& Request::getPress();
     $submissionChecklistAll = $press->getSetting('submissionChecklist');
     $checklistItem = array();
     // preparea  localizable array for this checklist Item
     foreach (Locale::getSupportedLocales() as $locale => $name) {
         $checklistItem[$locale] = null;
     }
     // if editing, set the content
     // use of 'content' as key is for backwards compatibility
     if (isset($this->submissionChecklistId)) {
         foreach (Locale::getSupportedLocales() as $locale => $name) {
             if (!isset($submissionChecklistAll[$locale][$this->submissionChecklistId]['content'])) {
                 $checklistItem[$locale] = '';
             } else {
                 $checklistItem[$locale] = $submissionChecklistAll[$locale][$this->submissionChecklistId]['content'];
             }
         }
     }
     // assign the data to the form
     $this->_data = array('checklistItem' => $checklistItem);
     // grid related data
     $this->_data['gridId'] = $args['gridId'];
     $this->_data['rowId'] = $args['rowId'];
 }
 /**
  * Display the form.
  */
 function display()
 {
     $press =& Request::getPress();
     $user =& Request::getUser();
     $submission = $this->reviewerSubmission;
     $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment = $reviewAssignmentDao->getById($submission->getReviewId());
     if ($submission->getDateConfirmed() == null) {
         $confirmedStatus = 0;
     } else {
         $confirmedStatus = 1;
     }
     $templateMgr =& TemplateManager::getManager();
     $reviewerRequestParams = array('reviewer' => $reviewAssignment->getReviewerFullName(), 'personalNote' => 'EDITOR NOTE', 'editor' => $press->getSetting('contactName'));
     $templateMgr->assign('reviewerRequest', Locale::translate('reviewer.step1.requestBoilerplate', $reviewerRequestParams));
     $templateMgr->assign_by_ref('submission', $submission);
     $templateMgr->assign_by_ref('reviewAssignment', $reviewAssignment);
     $templateMgr->assign_by_ref('press', $press);
     $templateMgr->assign_by_ref('reviewGuidelines', $press->getLocalizedSetting('reviewGuidelines'));
     $templateMgr->assign('step', 1);
     $templateMgr->assign('completedSteps', $submission->getStatus());
     $templateMgr->assign('blindReview', true);
     // FIXME: Need to be able to get/set if a review is blind or not
     // FIXME: Need press setting that denotes competing interests are required
     $templateMgr->assign('competingInterestsText', $submission->getCompetingInterests());
     import('classes.submission.reviewAssignment.ReviewAssignment');
     $templateMgr->assign_by_ref('reviewerRecommendationOptions', ReviewAssignment::getReviewerRecommendationOptions());
     $templateMgr->assign('helpTopicId', 'editorial.reviewersRole.review');
     parent::display();
 }
 /**
  * Constructor.
  */
 function SubmissionSubmitStep3Form($monograph)
 {
     parent::SubmissionSubmitForm($monograph, 3);
     $press =& Request::getPress();
     // Validation checks for this form
     $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'submission.submit.form.titleRequired'));
 }
Exemple #5
0
 /**
  * Become a given role.
  */
 function become($args)
 {
     parent::validate(true);
     $press =& Request::getPress();
     $user =& Request::getUser();
     switch (array_shift($args)) {
         case 'author':
             $roleId = ROLE_ID_AUTHOR;
             $setting = 'allowRegAuthor';
             $deniedKey = 'user.noRoles.submitMonographRegClosed';
             break;
         case 'reviewer':
             $roleId = ROLE_ID_REVIEWER;
             $setting = 'allowRegReviewer';
             $deniedKey = 'user.noRoles.regReviewerClosed';
             break;
         default:
             Request::redirect(null, null, 'index');
     }
     if ($press->getSetting($setting)) {
         $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
         $userGroup =& $userGroupDao->getDefaultByRoleId($press->getId(), $roleId);
         $userGroupDao->assignUserToGroup($user->getId(), $userGroup->getId());
         Request::redirectUrl(Request::getUserVar('source'));
     } else {
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('message', $deniedKey);
         return $templateMgr->display('common/message.tpl');
     }
 }
 /**
  * Display the form.
  */
 function display()
 {
     $templateMgr =& TemplateManager::getManager();
     $press = Request::getPress();
     $templateMgr->assign_by_ref('submission', $this->reviewerSubmission);
     $templateMgr->assign_by_ref('press', $press);
     $templateMgr->assign('step', 3);
     $reviewAssignment =& $this->getReviewAssignment();
     $templateMgr->assign_by_ref('reviewAssignment', $reviewAssignment);
     /*  FIXME #5123: Include when review form infrastructure is in place
     		if($reviewAssignment->getReviewFormId()) {
     
     			// Get the review form components
     			$reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
     			$reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewAssignment->getReviewFormId());
     			$reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
     			$reviewFormResponses =& $reviewFormResponseDao->getReviewReviewFormResponseValues($reviewAssignment->getReviewId());
     			$reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
     			$reviewformid = $reviewAssignment->getReviewFormId();
     			$reviewForm =& $reviewFormDao->getReviewForm($reviewAssignment->getReviewFormId(), ASSOC_TYPE_PRESS, $press->getId());
     
     			$templateMgr->assign_by_ref('reviewForm', $reviewForm);
     			$templateMgr->assign('reviewFormElements', $reviewFormElements);
     			$templateMgr->assign('reviewFormResponses', $reviewFormResponses);
     			$templateMgr->assign('isLocked', isset($reviewAssignment) && $reviewAssignment->getDateCompleted() != null);
     		}*/
     parent::display();
 }
 /**
  * Used by subclasses to validate access keys when they are allowed.
  * @param $userId int The user this key refers to
  * @param $reviewId int The ID of the review this key refers to
  * @param $newKey string The new key name, if one was supplied; otherwise, the existing one (if it exists) is used
  * @return object Valid user object if the key was valid; otherwise NULL.
  */
 function &validateAccessKey($userId, $reviewId, $newKey = null)
 {
     $press =& Request::getPress();
     if (!$press || !$press->getSetting('reviewerAccessKeysEnabled')) {
         $accessKey = false;
         return $accessKey;
     }
     define('REVIEWER_ACCESS_KEY_SESSION_VAR', 'ReviewerAccessKey');
     import('lib.pkp.classes.security.AccessKeyManager');
     $accessKeyManager = new AccessKeyManager();
     $session =& Request::getSession();
     // Check to see if a new access key is being used.
     if (!empty($newKey)) {
         if (Validation::isLoggedIn()) {
             Validation::logout();
         }
         $keyHash = $accessKeyManager->generateKeyHash($newKey);
         $session->setSessionVar(REVIEWER_ACCESS_KEY_SESSION_VAR, $keyHash);
     } else {
         $keyHash = $session->getSessionVar(REVIEWER_ACCESS_KEY_SESSION_VAR);
     }
     // Now that we've gotten the key hash (if one exists), validate it.
     $accessKey =& $accessKeyManager->validateKey('ReviewerContext', $userId, $keyHash, $reviewId);
     if ($accessKey) {
         $userDao =& DAORegistry::getDAO('UserDAO');
         $user =& $userDao->getUser($accessKey->getUserId(), false);
         return $user;
     }
     // No valid access key -- return NULL.
     return $accessKey;
 }
Exemple #8
0
 /**
  * Save group group.
  * @see Form::execute()
  */
 function execute()
 {
     $groupDao =& DAORegistry::getDAO('GroupDAO');
     $press =& Request::getPress();
     if (!isset($this->group)) {
         $this->group = $groupDao->newDataObject();
     }
     $this->group->setAssocType(ASSOC_TYPE_PRESS);
     $this->group->setAssocId($press->getId());
     $this->group->setTitle($this->getData('title'), Locale::getLocale());
     // Localized
     $this->group->setContext($this->getData('context'));
     // Eventually this will be a general Groups feature; for now,
     // we're just using it to display press team entries in About.
     $this->group->setAboutDisplayed(true);
     // Update or insert group group
     if ($this->group->getId() != null) {
         $groupDao->updateObject($this->group);
     } else {
         $this->group->setSequence(REALLY_BIG_NUMBER);
         $groupDao->insertGroup($this->group);
         // Re-order the groups so the new one is at the end of the list.
         $groupDao->resequenceGroups($this->group->getAssocType(), $this->group->getAssocId());
     }
     return true;
 }
 /**
  * Display the form.
  */
 function display()
 {
     $press =& Request::getPress();
     $templateMgr =& TemplateManager::getManager();
     if (Config::getVar('email', 'allow_envelope_sender')) {
         $templateMgr->assign('envelopeSenderEnabled', true);
     }
     $templateMgr->assign('pressEnabled', $press->getEnabled());
     parent::display();
 }
 /**
  * Save modified settings.
  */
 function execute()
 {
     $press =& Request::getPress();
     $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     foreach ($this->_data as $name => $value) {
         if (isset($this->settings[$name])) {
             $isLocalized = in_array($name, $this->getLocaleFieldNames());
             $settingsDao->updateSetting($press->getId(), $name, $value, $this->settings[$name], $isLocalized);
         }
     }
 }
 function getContents(&$templateMgr)
 {
     $user =& Request::getUser();
     $press =& Request::getPress();
     if ($user && $press) {
         $userId = $user->getId();
         $notificationDao =& DAORegistry::getDAO('NotificationDAO');
         $templateMgr->assign('unreadNotifications', $notificationDao->getUnreadNotificationCount($userId));
     }
     return parent::getContents($templateMgr);
 }
 /**
  * Get the HTML contents for this block.
  * @param $templateMgr object
  * @return $string
  */
 function getContents(&$templateMgr)
 {
     $press =& Request::getPress();
     if (!$press) {
         return '';
     }
     $templateMgr->assign('forReaders', $press->getLocalizedSetting('readerInformation'));
     $templateMgr->assign('forAuthors', $press->getLocalizedSetting('authorInformation'));
     $templateMgr->assign('forLibrarians', $press->getLocalizedSetting('librarianInformation'));
     return parent::getContents($templateMgr);
 }
Exemple #13
0
 /**
  * Helper Function - set mail from address
  * @param MailTemplate $mail 
  */
 function _setMailFrom(&$mail)
 {
     $site =& Request::getSite();
     $press =& Request::getPress();
     // Set the sender based on the current context
     if ($press && $press->getSetting('supportEmail')) {
         $mail->setFrom($press->getSetting('supportEmail'), $press->getSetting('supportName'));
     } else {
         $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName());
     }
 }
 function assignParams($paramArray = array())
 {
     $monograph =& $this->monograph;
     $press = isset($this->press) ? $this->press : Request::getPress();
     $paramArray['monographTitle'] = strip_tags($monograph->getLocalizedTitle());
     $paramArray['monographId'] = $monograph->getId();
     $paramArray['pressName'] = strip_tags($press->getLocalizedName());
     $paramArray['seriesName'] = strip_tags($monograph->getSeriesTitle());
     $paramArray['monographAbstract'] = String::html2text($monograph->getLocalizedAbstract());
     $paramArray['authorString'] = strip_tags($monograph->getAuthorString());
     parent::assignParams($paramArray);
 }
 /**
  * Display the form.
  */
 function display()
 {
     $templateMgr =& TemplateManager::getManager();
     $press = Request::getPress();
     $reviewerGuidelines = $press->getLocalizedSetting('reviewGuidelines');
     if (empty($reviewerGuidelines)) {
         $reviewerGuidelines = Locale::translate('reviewer.monograph.noGuidelines');
     }
     $templateMgr->assign_by_ref('reviewerGuidelines', $press->getLocalizedSetting('reviewGuidelines'));
     $templateMgr->assign_by_ref('submission', $this->reviewerSubmission);
     $templateMgr->assign('step', 2);
     parent::display();
 }
Exemple #16
0
 /**
  * Save email template.
  * @see Form::execute()
  */
 function execute()
 {
     $press =& Request::getPress();
     $sponsors = $press->getSetting('sponsors');
     if (empty($sponsors)) {
         $sponsors = array();
         $this->sponsorId = 1;
     } else {
         //FIXME: a bit of kludge to get unique sponsor id's
         $this->sponsorId = $this->sponsorId ? $this->sponsorId : max(array_keys($sponsors)) + 1;
     }
     $sponsors[$this->sponsorId] = array('institution' => $this->getData('institution'), 'url' => $this->getData('url'));
     $press->updateSetting('sponsors', $sponsors, 'object', false);
     return true;
 }
 /**
  * Initialize form data from current review form.
  * @param $args array
  * @param $request PKPRequest
  */
 function initData($args, &$request)
 {
     if ($this->reviewFormElementId != null) {
         $press =& Request::getPress();
         $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
         $reviewFormElement =& $reviewFormElementDao->getReviewFormElement($this->reviewFormElementId);
         if ($reviewFormElement == null) {
             $this->reviewFormElementId = null;
         } else {
             $this->_data = array('question' => $reviewFormElement->getQuestion(null), 'required' => $reviewFormElement->getRequired(), 'elementType' => $reviewFormElement->getElementType(), 'possibleResponses' => $reviewFormElement->getPossibleResponses(null));
         }
     }
     // grid related data
     $this->_data['gridId'] = $args['gridId'];
     $this->_data['reviewFormId'] = $args['reviewFormId'];
     $this->_data['rowId'] = isset($args['rowId']) ? $args['rowId'] : null;
 }
Exemple #18
0
 /**
  * Static function to send an email to a mailing list user regarding signup or a lost password
  * @param $email string
  * @param $password string the user's password
  * @param $template string The mail template to use
  */
 function sendMailingListEmail($email, $password, $template)
 {
     import('classes.mail.MailTemplate');
     $press = Request::getPress();
     $site = Request::getSite();
     $params = array('password' => $password, 'siteTitle' => $press->getLocalizedTitle(), 'unsubscribeLink' => Request::url(null, 'notification', 'unsubscribeMailList'));
     if ($template == 'NOTIFICATION_MAILLIST_WELCOME') {
         $keyHash = md5($password);
         $confirmLink = Request::url(null, 'notification', 'confirmMailListSubscription', array($keyHash, $email));
         $params["confirmLink"] = $confirmLink;
     }
     $mail = new MailTemplate($template);
     $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName());
     $mail->assignParams($params);
     $mail->addRecipient($email);
     $mail->send();
 }
Exemple #19
0
 /**
  * Send an email to a user or group of users.
  */
 function email($args)
 {
     $this->setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('helpTopicId', 'press.users.emailUsers');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $site =& Request::getSite();
     $press =& Request::getPress();
     $user =& Request::getUser();
     import('classes.mail.MailTemplate');
     $email = new MailTemplate(Request::getUserVar('template'), Request::getUserVar('locale'));
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $email->send();
         Request::redirect(null, Request::getRequestedPage());
     } else {
         $email->assignParams();
         // FIXME Forces default parameters to be assigned (should do this automatically in MailTemplate?)
         if (!Request::getUserVar('continued')) {
             if (($groupId = Request::getUserVar('toGroup')) != '') {
                 // Special case for emailing entire groups:
                 // Check for a group ID and add recipients.
                 $groupDao =& DAORegistry::getDAO('GroupDAO');
                 $group =& $groupDao->getById($groupId);
                 if ($group && $group->getPressId() == $press->getId()) {
                     $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
                     $memberships =& $groupMembershipDao->getMemberships($group->getId());
                     $memberships =& $memberships->toArray();
                     foreach ($memberships as $membership) {
                         $user =& $membership->getUser();
                         $email->addRecipient($user->getEmail(), $user->getFullName());
                     }
                 }
             }
             if (count($email->getRecipients()) == 0) {
                 $email->addRecipient($user->getEmail(), $user->getFullName());
             }
         }
         $email->displayEditForm(Request::url(null, null, 'email'), array(), 'manager/people/email.tpl');
     }
 }
 /**
  * Save announcement.
  */
 function execute()
 {
     $announcement = parent::execute();
     $press =& Request::getPress();
     $pressId = $press->getId();
     // Send a notification to associated users
     import('lib.pkp.classes.notification.NotificationManager');
     $userGroupDao =& DAORegistry::getDAO('RoleAssignmentDAO');
     $notificationUsers = array();
     $allUsers = $userGroupDao->getUsersByContextId($pressId);
     while (!$allUsers->eof()) {
         $user =& $allUsers->next();
         $notificationUsers[] = array('id' => $user->getId());
         unset($user);
     }
     $url = Request::url(null, 'announcement', 'view', array($announcement->getId()));
     $notificationManager = new NotificationManager();
     foreach ($notificationUsers as $userRole) {
         $notificationManager->createNotification($userRole['id'], 'notification.type.newAnnouncement', null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT);
     }
     $notificationManager->sendToMailingList($notificationManager->createNotification(0, 'notification.type.newAnnouncement', null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT));
 }
 /**
  * Display the form.
  */
 function display()
 {
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('validateId', 'submit');
     $templateMgr->assign('monographId', $this->monographId);
     $templateMgr->assign('submitStep', $this->step);
     if (isset($this->monograph)) {
         $templateMgr->assign('submissionProgress', $this->monograph->getSubmissionProgress());
     }
     switch ($this->step) {
         case 3:
             $helpTopicId = 'submission.indexingAndMetadata';
             break;
         default:
             $helpTopicId = 'submission.index';
     }
     $templateMgr->assign('helpTopicId', $helpTopicId);
     $press =& Request::getPress();
     $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     $templateMgr->assign_by_ref('pressSettings', $settingsDao->getPressSettings($press->getId()));
     parent::display();
 }
 /**
  * Check if field value is valid.
  * Value is valid if it is empty and optional or validated by user-supplied function.
  * @return boolean
  */
 function isValid()
 {
     $press =& Request::getPress();
     $pressId = $press ? $press->getId() : 0;
     $user = Request::getUser();
     if (!$user) {
         return false;
     }
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $returner = true;
     foreach ($this->roles as $roleId) {
         if ($roleId == ROLE_ID_SITE_ADMIN) {
             $exists = $roleDao->userHasRole(0, $user->getId(), $roleId);
         } else {
             $exists = $roleDao->userHasRole($pressId, $user->getId(), $roleId);
         }
         if (!$this->all && $exists) {
             return true;
         }
         $returner = $returner && $exists;
     }
     return $returner;
 }
 function register($category, $path)
 {
     if (parent::register($category, $path)) {
         if ($this->getEnabled()) {
             import('lib.pkp.classes.file.FileManager');
             $press = Request::getPress();
             $pressId = $press->getId();
             $locale = Locale::getLocale();
             $localeFiles = Locale::getLocaleFiles($locale);
             $publicFilesDir = Config::getVar('files', 'public_files_dir');
             $customLocaleDir = $publicFilesDir . DIRECTORY_SEPARATOR . 'presses' . DIRECTORY_SEPARATOR . $pressId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR;
             foreach ($localeFiles as $localeFile) {
                 $localeFilename = $localeFile->getFilename();
                 $customLocalePath = $customLocaleDir . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFilename;
                 if (FileManager::fileExists($customLocalePath)) {
                     Locale::registerLocaleFile($locale, $customLocalePath, true);
                 }
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Assigns a reviewer to a submission.
  * @param $seriesEditorSubmission object
  * @param $reviewerId int
  */
 function addReviewer($seriesEditorSubmission, $reviewerId, $reviewType, $round = null, $reviewDueDate = null, $responseDueDate = null)
 {
     $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO');
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& Request::getUser();
     $reviewer =& $userDao->getUser($reviewerId);
     // Check to see if the requested reviewer is not already
     // assigned to review this monograph.
     if ($round == null) {
         $round = $seriesEditorSubmission->getCurrentRound();
     }
     $assigned = $seriesEditorSubmissionDao->reviewerExists($seriesEditorSubmission->getId(), $reviewerId, $reviewType, $round);
     // Only add the reviewer if he has not already
     // been assigned to review this monograph.
     if (!$assigned && isset($reviewer) && !HookRegistry::call('SeriesEditorAction::addReviewer', array(&$seriesEditorSubmission, $reviewerId))) {
         $reviewAssignment = new ReviewAssignment();
         $reviewAssignment->setSubmissionId($seriesEditorSubmission->getId());
         $reviewAssignment->setReviewerId($reviewerId);
         $reviewAssignment->setDateAssigned(Core::getCurrentDate());
         $reviewAssignment->setReviewType($reviewType);
         $reviewAssignment->setRound($round);
         // Assign review form automatically if needed
         $pressId = $seriesEditorSubmission->getPressId();
         $seriesDao =& DAORegistry::getDAO('SeriesDAO');
         $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
         $submissionId = $seriesEditorSubmission->getId();
         $series =& $seriesDao->getById($submissionId, $pressId);
         $seriesEditorSubmission->addReviewAssignment($reviewAssignment, $reviewType, $round);
         $seriesEditorSubmissionDao->updateSeriesEditorSubmission($seriesEditorSubmission);
         $reviewAssignment = $reviewAssignmentDao->getReviewAssignment($seriesEditorSubmission->getId(), $reviewerId, $round, $reviewType);
         $press =& Request::getPress();
         $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
         $settings =& $settingsDao->getPressSettings($press->getId());
         if (isset($reviewDueDate)) {
             SeriesEditorAction::setDueDate($seriesEditorSubmission->getId(), $reviewAssignment->getId(), $reviewDueDate);
         }
         if (isset($responseDueDate)) {
             SeriesEditorAction::setResponseDueDate($seriesEditorSubmission->getId(), $reviewAssignment->getId(), $responseDueDate);
         }
         // Add log
         import('classes.monograph.log.MonographLog');
         import('classes.monograph.log.MonographEventLogEntry');
         MonographLog::logEvent($seriesEditorSubmission->getId(), MONOGRAPH_LOG_REVIEW_ASSIGN, MONOGRAPH_LOG_TYPE_REVIEW, $reviewAssignment->getId(), 'log.review.reviewerAssigned', array('reviewerName' => $reviewer->getFullName(), 'monographId' => $seriesEditorSubmission->getId(), 'reviewType' => $reviewType, 'round' => $round));
     }
 }
 /**
  * Save email template.
  */
 function execute()
 {
     $press =& Request::getPress();
     $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplate =& $emailTemplateDao->getLocaleEmailTemplate($this->emailKey, $press->getId());
     if (!$emailTemplate) {
         $emailTemplate = new LocaleEmailTemplate();
         $emailTemplate->setCustomTemplate(true);
         $emailTemplate->setCanDisable(false);
         $emailTemplate->setEnabled(true);
         $emailTemplate->setEmailKey($this->getData('emailKey'));
     } else {
         $emailTemplate->setEmailId($this->getData('emailId'));
         if ($emailTemplate->getCanDisable()) {
             $emailTemplate->setEnabled($this->getData('enabled'));
         }
     }
     $emailTemplate->setAssocType(ASSOC_TYPE_PRESS);
     $emailTemplate->setAssocId($press->getPressId());
     $supportedLocales = $press->getSupportedLocaleNames();
     if (!empty($supportedLocales)) {
         foreach ($press->getSupportedLocaleNames() as $localeKey => $localeName) {
             $emailTemplate->setSubject($localeKey, $this->_data['subject'][$localeKey]);
             $emailTemplate->setBody($localeKey, $this->_data['body'][$localeKey]);
         }
     } else {
         $localeKey = Locale::getLocale();
         $emailTemplate->setSubject($localeKey, $this->_data['subject'][$localeKey]);
         $emailTemplate->setBody($localeKey, $this->_data['body'][$localeKey]);
     }
     if ($emailTemplate->getEmailId() != null) {
         $emailTemplateDao->updateLocaleEmailTemplate($emailTemplate);
     } else {
         $emailTemplateDao->insertLocaleEmailTemplate($emailTemplate);
     }
 }
Exemple #26
0
 /**
  * Check if a user is authorized to access the specified role in the specified press.
  * @param $roleId int
  * @param $pressId optional (e.g., for global site admin role), the ID of the press
  * @return boolean
  */
 function isAuthorized($roleId, $pressId = 0)
 {
     if (!Validation::isLoggedIn()) {
         return false;
     }
     if ($pressId === -1) {
         // Get press ID from request
         $press =& Request::getPress();
         $pressId = $press == null ? 0 : $press->getId();
     }
     $sessionManager =& SessionManager::getManager();
     $session =& $sessionManager->getUserSession();
     $user =& $session->getUser();
     $roleDAO =& DAORegistry::getDAO('RoleDAO');
     return $roleDAO->userHasRole($pressId, $user->getId(), $roleId);
 }
 /**
  * Register a new user.
  */
 function execute()
 {
     $requireValidation = Config::getVar('email', 'require_validation');
     if ($this->existingUser) {
         // If using implicit auth - we hardwire that we are working on an existing user
         // Existing user in the system
         $userDao =& DAORegistry::getDAO('UserDAO');
         if ($this->implicitAuth) {
             // If we are using implicit auth - then use the session username variable - rather than data from the form
             $sessionManager =& SessionManager::getManager();
             $session =& $sessionManager->getUserSession();
             $user =& $userDao->getUserByUsername($session->getSessionVar('username'));
         } else {
             $user =& $userDao->getUserByUsername($this->getData('username'));
         }
         if ($user == null) {
             return false;
         }
         $userId = $user->getId();
     } else {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $user->setSalutation($this->getData('salutation'));
         $user->setFirstName($this->getData('firstName'));
         $user->setMiddleName($this->getData('middleName'));
         $user->setInitials($this->getData('initials'));
         $user->setLastName($this->getData('lastName'));
         $user->setGender($this->getData('gender'));
         $user->setAffiliation($this->getData('affiliation'), null);
         // Localized
         $user->setSignature($this->getData('signature'), null);
         // Localized
         $user->setEmail($this->getData('email'));
         $user->setUrl($this->getData('userUrl'));
         $user->setPhone($this->getData('phone'));
         $user->setFax($this->getData('fax'));
         $user->setMailingAddress($this->getData('mailingAddress'));
         $user->setBiography($this->getData('biography'), null);
         // Localized
         $user->setDateRegistered(Core::getCurrentDate());
         $user->setCountry($this->getData('country'));
         $site =& Request::getSite();
         $availableLocales = $site->getSupportedLocales();
         $locales = array();
         foreach ($this->getData('userLocales') as $locale) {
             if (Locale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
                 array_push($locales, $locale);
             }
         }
         $user->setLocales($locales);
         if (isset($this->defaultAuth)) {
             $user->setPassword($this->getData('password'));
             // FIXME Check result and handle failures
             $this->defaultAuth->doCreateUser($user);
             $user->setAuthId($this->defaultAuth->authId);
         }
         $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password')));
         if ($requireValidation) {
             // The account should be created in a disabled
             // state.
             $user->setDisabled(true);
             $user->setDisabledReason(Locale::translate('user.login.accountNotValidated'));
         }
         $userDao =& DAORegistry::getDAO('UserDAO');
         $userDao->insertUser($user);
         $userId = $user->getId();
         if (!$userId) {
             return false;
         }
         // Add reviewing interests to interests table
         import('lib.pkp.classes.user.InterestManager');
         $interestManager = new InterestManager();
         $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests'));
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $session->setSessionVar('username', $user->getUsername());
     }
     $press =& Request::getPress();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     // Roles users are allowed to register themselves in
     $allowedRoles = array('reader' => 'registerAsReader', 'author' => 'registerAsAuthor', 'reviewer' => 'registerAsReviewer');
     $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegReader')) {
         unset($allowedRoles['reader']);
     }
     if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegAuthor')) {
         unset($allowedRoles['author']);
     }
     if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegReviewer')) {
         unset($allowedRoles['reviewer']);
     }
     foreach ($allowedRoles as $k => $v) {
         $roleId = $roleDao->getRoleIdFromPath($k);
         if ($this->getData($v) && !$roleDao->userHasRole($press->getId(), $userId, $roleId)) {
             $role = new Role();
             $role->setPressId($press->getId());
             $role->setUserId($userId);
             $role->setRoleId($roleId);
             $roleDao->insertRole($role);
         }
     }
     if (!$this->existingUser) {
         import('classes.mail.MailTemplate');
         if ($requireValidation) {
             // Create an access key
             import('lib.pkp.classes.security.AccessKeyManager');
             $accessKeyManager = new AccessKeyManager();
             $accessKey = $accessKeyManager->createKey('RegisterContext', $user->getId(), null, Config::getVar('email', 'validation_timeout'));
             // Send email validation request to user
             $mail = new MailTemplate('USER_VALIDATE');
             $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName'));
             $mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => Request::url($press->getPath(), 'user', 'activateUser', array($this->getData('username'), $accessKey))));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
             unset($mail);
         }
         if ($this->getData('sendPassword')) {
             // Send welcome email to user
             $mail = new MailTemplate('USER_REGISTER');
             $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName'));
             $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'userFullName' => $user->getFullName()));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
             unset($mail);
         }
     }
     // By default, self-registering readers will receive
     // press updates. (The double set is here to prevent a
     // duplicate insert error msg if there was a notification entry
     // left over from a previous role.)
     if (isset($allowedRoles['reader']) && $this->getData($allowedRoles['reader'])) {
         $notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
         $notificationStatusDao->setPressNotifications($press->getId(), $userId, false);
         $notificationStatusDao->setPressNotifications($press->getId(), $userId, true);
     }
 }
Exemple #28
0
 /**
  * Retrieve the primary locale of the current context.
  * @return string
  */
 function getPrimaryLocale()
 {
     static $locale;
     if ($locale) {
         return $locale;
     }
     if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
         return $locale = LOCALE_DEFAULT;
     }
     $press =& Request::getPress();
     if (isset($press)) {
         $locale = $press->getPrimaryLocale();
     }
     if (!isset($locale)) {
         $site =& Request::getSite();
         $locale = $site->getPrimaryLocale();
     }
     if (!isset($locale) || !Locale::isLocaleValid($locale)) {
         $locale = LOCALE_DEFAULT;
     }
     return $locale;
 }
Exemple #29
0
 function getRealFilesDir($currentDir)
 {
     $press =& Request::getPress();
     return Config::getVar('files', 'files_dir') . '/presses/' . $press->getId() . '/' . $currentDir;
 }
 function execute()
 {
     // Save the block plugin layout settings.
     $blockVars = array('blockSelectLeft', 'blockUnselected', 'blockSelectRight');
     foreach ($blockVars as $varName) {
         ${$varName} = split(' ', Request::getUserVar($varName));
     }
     $plugins =& PluginRegistry::loadCategory('blocks');
     foreach ($plugins as $key => $junk) {
         $plugin =& $plugins[$key];
         // Ref hack
         $plugin->setEnabled(!in_array($plugin->getName(), $blockUnselected));
         if (in_array($plugin->getName(), $blockSelectLeft)) {
             $plugin->setBlockContext(BLOCK_CONTEXT_LEFT_SIDEBAR);
             $plugin->setSeq(array_search($key, $blockSelectLeft));
         } else {
             if (in_array($plugin->getName(), $blockSelectRight)) {
                 $plugin->setBlockContext(BLOCK_CONTEXT_RIGHT_SIDEBAR);
                 $plugin->setSeq(array_search($key, $blockSelectRight));
             }
         }
         unset($plugin);
     }
     // Save alt text for images
     $press =& Request::getPress();
     $pressId = $press->getId();
     $locale = $this->getFormLocale();
     $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     $images = $this->images;
     foreach ($images as $settingName) {
         $value = $press->getSetting($settingName);
         if (!empty($value)) {
             $imageAltText = $this->getData($this->image_settings[$settingName]);
             $value[$locale]['altText'] = $imageAltText[$locale];
             $settingsDao->updateSetting($pressId, $settingName, $value, 'object', true);
         }
     }
     // Save remaining settings
     return parent::execute();
 }