/**
  * Create a new temporary file from an article file.
  * @param $articleFile object
  * @param $userId int
  * @return object The new TemporaryFile or false on failure
  */
 function articleToTemporaryFile($articleFile, $userId)
 {
     // Get the file extension, then rename the file.
     $fileExtension = $this->parseFileExtension($articleFile->getFileName());
     if (!$this->fileExists($this->filesDir, 'dir')) {
         // Try to create destination directory
         $this->mkdirtree($this->filesDir);
     }
     $newFileName = basename(tempnam($this->filesDir, $fileExtension));
     if (!$newFileName) {
         return false;
     }
     if (copy($articleFile->getFilePath(), $this->filesDir . $newFileName)) {
         $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = new TemporaryFile();
         $temporaryFile->setUserId($userId);
         $temporaryFile->setFileName($newFileName);
         $temporaryFile->setFileType($articleFile->getFileType());
         $temporaryFile->setFileSize($articleFile->getFileSize());
         $temporaryFile->setOriginalFileName($articleFile->getOriginalFileName());
         $temporaryFile->setDateUploaded(Core::getCurrentDate());
         $temporaryFileDao->insertTemporaryFile($temporaryFile);
         return $temporaryFile;
     } else {
         return false;
     }
 }
 /**
  * Public view book for review details.
  */
 function viewBookForReview($args = array(), &$request)
 {
     $this->setupTemplate(true);
     $journal =& $request->getJournal();
     $journalId = $journal->getId();
     $bfrPlugin =& PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME);
     $bookId = !isset($args) || empty($args) ? null : (int) $args[0];
     $bfrDao =& DAORegistry::getDAO('BookForReviewDAO');
     // Ensure book for review is valid and for this journal
     if ($bfrDao->getBookForReviewJournalId($bookId) == $journalId) {
         $book =& $bfrDao->getBookForReview($bookId);
         $bfrPlugin->import('classes.BookForReview');
         // Ensure book is still available
         if ($book->getStatus() == BFR_STATUS_AVAILABLE) {
             $isAuthor = Validation::isAuthor();
             import('classes.file.PublicFileManager');
             $publicFileManager = new PublicFileManager();
             $coverPagePath = $request->getBaseUrl() . '/';
             $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('coverPagePath', $coverPagePath);
             $templateMgr->assign('locale', AppLocale::getLocale());
             $templateMgr->assign_by_ref('bookForReview', $book);
             $templateMgr->assign('isAuthor', $isAuthor);
             $templateMgr->display($bfrPlugin->getTemplatePath() . 'bookForReview.tpl');
         }
     }
     $request->redirect(null, 'booksForReview');
 }
示例#3
0
 /**
  * Save group group. 
  */
 function execute()
 {
     $groupDao =& DAORegistry::getDAO('GroupDAO');
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     if (!isset($this->group)) {
         $this->group = new Group();
     }
     $this->group->setAssocType(ASSOC_TYPE_SCHED_CONF);
     $this->group->setAssocId($schedConf->getId());
     $this->group->setTitle($this->getData('title'), null);
     // Localized
     $this->group->setPublishEmail($this->getData('publishEmail'));
     // Eventually this will be a general Groups feature; for now,
     // we're just using it to display conference 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());
     }
 }
示例#4
0
    /**
     * Retrieve all published submissions associated with authors with
     * the given first name, middle name, last name, affiliation, and country.
     * @param $journalId int (null if no restriction desired)
     * @param $firstName string
     * @param $middleName string
     * @param $lastName string
     * @param $affiliation string
     * @param $country string
     */
    function &getPublishedArticlesForAuthor($journalId, $firstName, $middleName, $lastName, $affiliation, $country)
    {
        $publishedArticles = array();
        $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
        $params = array('affiliation', $firstName, $middleName, $lastName, $affiliation, $country);
        if ($journalId !== null) {
            $params[] = (int) $journalId;
        }
        $result = $this->retrieve('SELECT DISTINCT
				aa.submission_id
			FROM	authors aa
				LEFT JOIN submissions a ON (aa.submission_id = a.submission_id)
				LEFT JOIN author_settings asl ON (asl.author_id = aa.author_id AND asl.setting_name = ?)
			WHERE	aa.first_name = ?
				AND a.status = ' . STATUS_PUBLISHED . '
				AND (aa.middle_name = ?' . (empty($middleName) ? ' OR aa.middle_name IS NULL' : '') . ')
				AND aa.last_name = ?
				AND (asl.setting_value = ?' . (empty($affiliation) ? ' OR asl.setting_value IS NULL' : '') . ')
				AND (aa.country = ?' . (empty($country) ? ' OR aa.country IS NULL' : '') . ') ' . ($journalId !== null ? ' AND a.context_id = ?' : ''), $params);
        while (!$result->EOF) {
            $row = $result->getRowAssoc(false);
            $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($row['submission_id']);
            if ($publishedArticle) {
                $publishedArticles[] = $publishedArticle;
            }
            $result->MoveNext();
        }
        $result->Close();
        return $publishedArticles;
    }
 /**
  * @see DataObjectRequiredPolicy::dataObjectEffect()
  */
 function dataObjectEffect()
 {
     $reviewId = (int) $this->getDataObjectId();
     if (!$reviewId) {
         return AUTHORIZATION_DENY;
     }
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     /* @var $reviewAssignmentDao ReviewAssignmentDAO */
     $reviewAssignment = $reviewAssignmentDao->getById($reviewId);
     if (!is_a($reviewAssignment, 'ReviewAssignment')) {
         return AUTHORIZATION_DENY;
     }
     // Ensure that the review assignment actually belongs to the
     // authorized submission.
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     assert(is_a($submission, 'Submission'));
     if ($reviewAssignment->getSubmissionId() != $submission->getId()) {
         AUTHORIZATION_DENY;
     }
     // Ensure that the review assignment is for this workflow stage
     $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
     if ($reviewAssignment->getStageId() != $stageId) {
         return AUTHORIZATION_DENY;
     }
     // Save the review Assignment to the authorization context.
     $this->addAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment);
     return AUTHORIZATION_PERMIT;
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     $request = $this->getRequest();
     // Get the user
     $user = $request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the submission file
     $submissionFile = $this->getSubmissionFile($request);
     if (!is_a($submissionFile, 'SubmissionFile')) {
         return AUTHORIZATION_DENY;
     }
     // Check if it's associated with a note.
     if ($submissionFile->getAssocType() != ASSOC_TYPE_NOTE) {
         return AUTHORIZATION_DENY;
     }
     $noteDao = DAORegistry::getDAO('NoteDAO');
     $note = $noteDao->getById($submissionFile->getAssocId());
     if (!is_a($note, 'Note')) {
         return AUTHORIZATION_DENY;
     }
     if ($note->getAssocType() != ASSOC_TYPE_QUERY) {
         return AUTHORIZATION_DENY;
     }
     $queryDao = DAORegistry::getDAO('QueryDAO');
     $query = $queryDao->getById($note->getAssocId());
     if (!$query) {
         return AUTHORIZATION_DENY;
     }
     if ($queryDao->getParticipantIds($note->getAssocId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     }
     return AUTHORIZATION_DENY;
 }
示例#7
0
 /**
  * Fetch the form
  * @param $request Request
  */
 function fetch($request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $baseUrl = $templateMgr->_request->getBaseUrl();
     // Add extra java script required for ajax components
     // FIXME: Must be removed after OMP->OJS backporting
     // NOTE: I believe this needs attention. jquery.validate.min.js is
     // loaded with our minifiedScripts.tpl list and includes some i18n
     // features.
     $templateMgr->addJavaScript('citation', $baseUrl . '/lib/pkp/js/functions/citation.js', array('contexts' => 'backend'));
     $templateMgr->addJavaScript('jqueryValidate', $baseUrl . '/lib/pkp/js/lib/jquery/plugins/validate/jquery.validate.min.js', array('contexts' => 'backend'));
     $templateMgr->addJavaScript('jqueryValidatorI18n', $baseUrl . '/lib/pkp/js/functions/jqueryValidatorI18n.js', array('contexts' => 'backend'));
     //
     // Citation editor filter configuration
     //
     // 1) Add the filter grid URLs
     $dispatcher = $request->getDispatcher();
     $parserFilterGridUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.filter.ParserFilterGridHandler', 'fetchGrid');
     $templateMgr->assign('parserFilterGridUrl', $parserFilterGridUrl);
     $lookupFilterGridUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.filter.LookupFilterGridHandler', 'fetchGrid');
     $templateMgr->assign('lookupFilterGridUrl', $lookupFilterGridUrl);
     // 2) Create a list of all available citation output filters.
     $router = $request->getRouter();
     $journal = $router->getContext($request);
     $filterDao = DAORegistry::getDAO('FilterDAO');
     /* @var $filterDao FilterDAO */
     $metaCitationOutputFilterObjects = $filterDao->getObjectsByGroup('nlm30-element-citation=>plaintext', $journal->getId());
     foreach ($metaCitationOutputFilterObjects as $metaCitationOutputFilterObject) {
         $metaCitationOutputFilters[$metaCitationOutputFilterObject->getId()] = $metaCitationOutputFilterObject->getDisplayName();
     }
     $templateMgr->assign_by_ref('metaCitationOutputFilters', $metaCitationOutputFilters);
     return parent::fetch($request);
 }
 /**
  * Extracts variables for a given column from a data element
  * so that they may be assigned to template before rendering.
  * @param $row GridRow
  * @param $column GridColumn
  * @return array
  */
 function getTemplateVarsFromRowColumn(&$row, &$column)
 {
     $element =& $row->getData();
     $columnId = $column->getId();
     assert(is_a($element, 'MonographFile') && !empty($columnId));
     // Numeric columns indicate a role-based column.
     if (is_numeric($columnId)) {
         if ($columnId == $element->getUserGroupId()) {
             // Show that this column's user group is the submitter
             return array('status' => 'uploaded');
         }
         // If column is not the submitter, cell is always empty.
         return array('status' => '');
     }
     // all other columns
     switch ($columnId) {
         case 'select':
             return array('rowId' => $element->getFileId() . "-" . $element->getRevision());
         case 'name':
             return array('label' => $element->getLocalizedName());
         case 'type':
             $genreDao =& DAORegistry::getDAO('GenreDAO');
             $genre = $genreDao->getById($element->getGenreId());
             return array('label' => $genre->getLocalizedName());
     }
 }
示例#9
0
 /**
  * Returns a "best-guess" journal, based in the request data, if
  * a request needs to have one in its context but may be in a site-level
  * context as specified in the URL.
  * @param $request Request
  * @param $journalsCount int Optional reference to receive journals count
  * @return mixed Either a Journal or null if none could be determined.
  */
 function getTargetContext($request, &$journalsCount = null)
 {
     // Get the requested path.
     $router = $request->getRouter();
     $requestedPath = $router->getRequestedContextPath($request);
     if ($requestedPath === 'index' || $requestedPath === '') {
         // No journal requested. Check how many journals the site has.
         $journalDao = DAORegistry::getDAO('JournalDAO');
         /* @var $journalDao JournalDAO */
         $journals = $journalDao->getAll();
         $journalsCount = $journals->getCount();
         $journal = null;
         if ($journalsCount === 1) {
             // Return the unique journal.
             $journal = $journals->next();
         }
         if (!$journal && $journalsCount > 1) {
             // Get the site redirect.
             $journal = $this->getSiteRedirectContext($request);
         }
     } else {
         // Return the requested journal.
         $journal = $router->getContext($request);
     }
     if (is_a($journal, 'Journal')) {
         return $journal;
     }
     return null;
 }
示例#10
0
 /**
  * @see DataObjectRequiredPolicy::dataObjectEffect()
  */
 function dataObjectEffect()
 {
     $queryId = (int) $this->getDataObjectId();
     if (!$queryId) {
         return AUTHORIZATION_DENY;
     }
     // Make sure the query belongs to the submission.
     $queryDao = DAORegistry::getDAO('QueryDAO');
     $query = $queryDao->getById($queryId);
     if (!is_a($query, 'Query')) {
         return AUTHORIZATION_DENY;
     }
     switch ($query->getAssocType()) {
         case ASSOC_TYPE_SUBMISSION:
             $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
             if (!is_a($submission, 'Submission')) {
                 return AUTHORIZATION_DENY;
             }
             if ($query->getAssocId() != $submission->getId()) {
                 return AUTHORIZATION_DENY;
             }
             break;
         default:
             return AUTHORIZATION_DENY;
     }
     // Save the query to the authorization context.
     $this->addAuthorizedContextObject(ASSOC_TYPE_QUERY, $query);
     return AUTHORIZATION_PERMIT;
 }
 function initialize(&$request)
 {
     parent::initialize($request);
     import('classes.file.LibraryFileManager');
     $libraryFileManager = new LibraryFileManager();
     // Fetch and validate fileType (validated in getNameFromType)
     $fileType = (int) $request->getUserVar('fileType');
     $this->setFileType($fileType);
     $name = $libraryFileManager->getNameFromType($this->getFileType());
     // Basic grid configuration
     $this->setId('libraryFile' . ucwords(strtolower($name)));
     $this->setTitle("grid.libraryFiles.{$name}.title");
     Locale::requireComponents(array(LOCALE_COMPONENT_PKP_COMMON, LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_SUBMISSION));
     // Elements to be displayed in the grid
     $router =& $request->getRouter();
     $context =& $router->getContext($request);
     $libraryFileDao =& DAORegistry::getDAO('LibraryFileDAO');
     $libraryFiles =& $libraryFileDao->getByPressId($context->getId(), $this->getFileType());
     $this->setGridDataElements($libraryFiles);
     // Add grid-level actions
     $this->addAction(new LinkAction('addFile', new AjaxModal($router->url($request, null, null, 'addFile', null, array('fileType' => $this->getFileType())), __('grid.action.addItem'), 'fileManagement'), __('grid.action.addItem'), 'add_item'));
     // Columns
     // Basic grid row configuration
     import('controllers.grid.settings.library.LibraryFileGridCellProvider');
     $this->addColumn(new GridColumn('files', 'grid.libraryFiles.column.files', null, 'controllers/grid/gridCell.tpl', new LibraryFileGridCellProvider()));
 }
 /**
  * Gathers the state of a given cell given a $row/$column combination
  * @param $row GridRow
  * @param $column GridColumn
  * @return string
  */
 function getCellState(&$row, &$column)
 {
     $element =& $row->getData();
     $columnId = $column->getId();
     assert(is_a($element, 'DataObject') && !empty($columnId));
     switch ($columnId) {
         case 'name':
             return $element->getDateCompleted() ? 'linkReview' : '';
         case is_numeric($columnId):
             // numeric implies a role column.
             if ($element->getDateCompleted()) {
                 $viewsDao =& DAORegistry::getDAO('ViewsDAO');
                 $sessionManager =& SessionManager::getManager();
                 $session =& $sessionManager->getUserSession();
                 $user =& $session->getUser();
                 $lastViewed = $viewsDao->getLastViewDate(ASSOC_TYPE_REVIEW_RESPONSE, $element->getId(), $user->getId());
                 if ($lastViewed) {
                     return 'completed';
                 } else {
                     return 'new';
                 }
             } else {
                 return '';
             }
         case 'reviewer':
             if ($element->getDateCompleted()) {
                 return 'completed';
             } elseif ($element->getDateDue() < Core::getCurrentDate()) {
                 return 'overdue';
             } elseif ($element->getDateConfirmed()) {
                 return $element->getDeclined() ? 'declined' : 'accepted';
             }
             return 'new';
     }
 }
示例#13
0
 /**
  * Constructor.
  * @param $args array script arguments
  */
 function FileLoader($args)
 {
     parent::ScheduledTask($args);
     // Set an initial process id and load translations (required
     // for email notifications).
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN);
     $this->_newProcessId();
     // Canonicalize the base path.
     $basePath = rtrim($args[0], DIRECTORY_SEPARATOR);
     $basePathFolder = basename($basePath);
     // We assume that the parent folder of the base path
     // does already exist and can be canonicalized.
     $basePathParent = realpath(dirname($basePath));
     if ($basePathParent === false) {
         $basePath = null;
     } else {
         $basePath = $basePathParent . DIRECTORY_SEPARATOR . $basePathFolder;
     }
     $this->_basePath = $basePath;
     // Configure paths.
     if (!is_null($basePath)) {
         $this->_stagePath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_STAGING;
         $this->_archivePath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_ARCHIVE;
         $this->_rejectPath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_REJECT;
         $this->_processingPath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_PROCESSING;
     }
     // Set admin email and name.
     $siteDao = DAORegistry::getDAO('SiteDAO');
     /* @var $siteDao SiteDAO */
     $site = $siteDao->getSite();
     /* @var $site Site */
     $this->_adminEmail = $site->getLocalizedContactEmail();
     $this->_adminName = $site->getLocalizedContactName();
 }
示例#14
0
 /**
  * Return a list of countries eligible as publication countries.
  * @return array
  */
 function &_getCountries()
 {
     $countryDao =& DAORegistry::getDAO('CountryDAO');
     /* @var $countryDao CountryDAO */
     $countries =& $countryDao->getCountries();
     return $countries;
 }
 /**
  * Create and return an author node.
  * @param $doc DOMDocument
  * @param $author PKPAuthor
  * @return DOMElement
  */
 function createPKPAuthorNode($doc, $author)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     // Create the author node
     $authorNode = $doc->createElementNS($deployment->getNamespace(), 'author');
     if ($author->getPrimaryContact()) {
         $authorNode->setAttribute('primary_contact', 'true');
     }
     if ($author->getIncludeInBrowse()) {
         $authorNode->setAttribute('include_in_browse', 'true');
     }
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $userGroup = $userGroupDao->getById($author->getUserGroupId());
     assert($userGroup);
     $authorNode->setAttribute('user_group_ref', $userGroup->getName($context->getPrimaryLocale()));
     // Add metadata
     $authorNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'firstname', $author->getFirstName()));
     $this->createOptionalNode($doc, $authorNode, 'middlename', $author->getMiddleName());
     $authorNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'lastname', $author->getLastName()));
     $this->createLocalizedNodes($doc, $authorNode, 'affiliation', $author->getAffiliation(null));
     $this->createOptionalNode($doc, $authorNode, 'country', $author->getCountry());
     $authorNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'email', $author->getEmail()));
     $this->createOptionalNode($doc, $authorNode, 'url', $author->getUrl());
     $this->createLocalizedNodes($doc, $authorNode, 'biography', $author->getBiography(null));
     return $authorNode;
 }
 /**
  * Save changes to article.
  * @param $request Request
  * @return int the article ID
  */
 function execute(&$request)
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $this->article;
     $articleContact = new ArticleContact();
     $articleContact->setArticleId($article->getId());
     $articleContact->setPQName($this->getData('pqName'));
     $articleContact->setPQAffiliation($this->getData('pqAffiliation'));
     $articleContact->setPQAddress($this->getData('pqAddress'));
     $articleContact->setPQCountry($this->getData('pqCountry'));
     $articleContact->setPQPhone($this->getData('pqPhone'));
     $articleContact->setPQFax($this->getData('pqFax'));
     $articleContact->setPQEmail($this->getData('pqEmail'));
     $articleContact->setSQName($this->getData('sqName'));
     $articleContact->setSQAffiliation($this->getData('sqAffiliation'));
     $articleContact->setSQAddress($this->getData('sqAddress'));
     $articleContact->setSQCountry($this->getData('sqCountry'));
     $articleContact->setSQPhone($this->getData('sqPhone'));
     $articleContact->setSQFax($this->getData('sqFax'));
     $articleContact->setSQEmail($this->getData('sqEmail'));
     $article->setArticleContact($articleContact);
     //update step
     if ($article->getSubmissionProgress() <= $this->step) {
         $article->stampStatusModified();
         $article->setSubmissionProgress($this->step + 1);
     } elseif ($article->getSubmissionProgress() == 9) {
         $article->setSubmissionProgress(8);
     }
     parent::execute();
     // Save the article
     $articleDao->updateArticle($article);
     return $this->articleId;
 }
示例#17
0
 /**
  * Return string containing the contents of the HTML file.
  * This function performs any necessary filtering, like image URL replacement.
  * @param $baseImageUrl string base URL for image references
  * @return string
  */
 function getHTMLContents()
 {
     import('file.ArticleFileManager');
     $fileManager =& new ArticleFileManager($this->getArticleId());
     $contents = $fileManager->readFile($this->getFileId());
     $journal =& Request::getJournal();
     // Replace media file references
     $images =& $this->getImageFiles();
     foreach ($images as $image) {
         $imageUrl = Request::url(null, 'article', 'viewFile', array($this->getArticleId(), $this->getBestGalleyId($journal), $image->getFileId()));
         $pattern = preg_quote(rawurlencode($image->getOriginalFileName()));
         $contents = preg_replace('/([Ss][Rr][Cc]|[Hh][Rr][Ee][Ff]|[Dd][Aa][Tt][Aa])\\s*=\\s*"([^"]*' . $pattern . ')"/', '\\1="' . $imageUrl . '"', $contents);
         // Replacement for Flowplayer
         $contents = preg_replace('/[Uu][Rr][Ll]\\s*\\:\\s*\'(' . $pattern . ')\'/', 'url:\'' . $imageUrl . '\'', $contents);
         // Replacement for other players (ested with odeo; yahoo and google player won't work w/ OJS URLs, might work for others)
         $contents = preg_replace('/[Uu][Rr][Ll]=([^"]*' . $pattern . ')/', 'url=' . $imageUrl, $contents);
     }
     // Perform replacement for ojs://... URLs
     $contents = String::regexp_replace_callback('/(<[^<>]*")[Oo][Jj][Ss]:\\/\\/([^"]+)("[^<>]*>)/', array(&$this, '_handleOjsUrl'), $contents);
     // Perform variable replacement for journal, issue, site info
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getIssueByArticleId($this->getArticleId());
     $journal =& Request::getJournal();
     $site =& Request::getSite();
     $paramArray = array('issueTitle' => $issue ? $issue->getIssueIdentification() : Locale::translate('editor.article.scheduleForPublication.toBeAssigned'), 'journalTitle' => $journal->getJournalTitle(), 'siteTitle' => $site->getSiteTitle(), 'currentUrl' => Request::getRequestUrl());
     foreach ($paramArray as $key => $value) {
         $contents = str_replace('{$' . $key . '}', $value, $contents);
     }
     return $contents;
 }
 /**
  * Save email template.
  */
 function execute()
 {
     $journal =& Request::getJournal();
     $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplate =& $emailTemplateDao->getLocaleEmailTemplate($this->emailKey, $journal->getJournalId());
     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->setJournalId($journal->getJournalId());
     $supportedLocales = $journal->getSupportedLocaleNames();
     if (!empty($supportedLocales)) {
         foreach ($journal->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);
     }
 }
 function saveSettings()
 {
     RTAdminHandler::validate();
     // Bring in the comments constants.
     $commentDao =& DAORegistry::getDao('CommentDAO');
     $journal = Request::getJournal();
     if ($journal) {
         $rtDao =& DAORegistry::getDAO('RTDAO');
         $rt = $rtDao->getJournalRTByJournal($journal);
         if (Request::getUserVar('version') == '') {
             $rt->setVersion(null);
         } else {
             $rt->setVersion(Request::getUserVar('version'));
         }
         $rt->setEnabled(Request::getUserVar('enabled') == true);
         $rt->setAbstract(Request::getUserVar('abstract') == true);
         $rt->setCaptureCite(Request::getUserVar('captureCite') == true);
         $rt->setViewMetadata(Request::getUserVar('viewMetadata') == true);
         $rt->setSupplementaryFiles(Request::getUserVar('supplementaryFiles') == true);
         $rt->setPrinterFriendly(Request::getUserVar('printerFriendly') == true);
         $rt->setAuthorBio(Request::getUserVar('authorBio') == true);
         $rt->setDefineTerms(Request::getUserVar('defineTerms') == true);
         $rt->setEmailAuthor(Request::getUserVar('emailAuthor') == true);
         $rt->setEmailOthers(Request::getUserVar('emailOthers') == true);
         $rt->setFindingReferences(Request::getUserVar('findingReferences') == true);
         $journal->updateSetting('enableComments', Request::getUserVar('enableComments') ? Request::getUserVar('enableCommentsMode') : COMMENTS_DISABLED);
         $rtDao->updateJournalRT($rt);
     }
     Request::redirect(null, Request::getRequestedPage());
 }
 /**
  * Fetch information for the author on the specified review round
  * @param $args array
  * @param $request Request
  * @return JSONMessage JSON object
  */
 function fetchReviewRoundInfo($args, $request)
 {
     $this->setupTemplate($request);
     $templateMgr = TemplateManager::getManager($request);
     $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
     if ($stageId !== WORKFLOW_STAGE_ID_INTERNAL_REVIEW && $stageId !== WORKFLOW_STAGE_ID_EXTERNAL_REVIEW) {
         fatalError('Invalid Stage Id');
     }
     $templateMgr->assign('stageId', $stageId);
     $reviewRound = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ROUND);
     $templateMgr->assign('reviewRoundId', $reviewRound->getId());
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     $templateMgr->assign('submission', $submission);
     // Review round request notification options.
     $notificationRequestOptions = array(NOTIFICATION_LEVEL_NORMAL => array(NOTIFICATION_TYPE_REVIEW_ROUND_STATUS => array(ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId())), NOTIFICATION_LEVEL_TRIVIAL => array());
     $templateMgr->assign('reviewRoundNotificationRequestOptions', $notificationRequestOptions);
     // Editor has taken an action and sent an email; Display the email
     import('classes.workflow.EditorDecisionActionsManager');
     if (EditorDecisionActionsManager::getEditorTakenActionInReviewRound($reviewRound)) {
         $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
         $user = $request->getUser();
         $submissionEmailFactory = $submissionEmailLogDao->getByEventType($submission->getId(), SUBMISSION_EMAIL_EDITOR_NOTIFY_AUTHOR, $user->getId());
         $templateMgr->assign('submissionEmails', $submissionEmailFactory);
         $templateMgr->assign('showReviewAttachments', true);
     }
     return $templateMgr->fetchJson('authorDashboard/reviewRoundInfo.tpl');
 }
示例#21
0
 /**
  * Add the comment.
  */
 function execute()
 {
     // Personalized execute() method since now there are possibly two comments contained within each form submission.
     $commentDao = DAORegistry::getDAO('PaperCommentDAO');
     $this->insertedComments = array();
     // Assign all common information
     $comment = new PaperComment();
     $comment->setCommentType($this->commentType);
     $comment->setRoleId($this->roleId);
     $comment->setPaperId($this->paper->getPaperId());
     $comment->setAssocId($this->assocId);
     $comment->setAuthorId($this->user->getId());
     $comment->setCommentTitle($this->getData('commentTitle'));
     $comment->setDatePosted(Core::getCurrentDate());
     // If comments "For authors and director" submitted
     if ($this->getData('authorComments') != null) {
         $comment->setComments($this->getData('authorComments'));
         $comment->setViewable(1);
         array_push($this->insertedComments, $commentDao->insertPaperComment($comment));
     }
     // If comments "For director" submitted
     if ($this->getData('comments') != null) {
         $comment->setComments($this->getData('comments'));
         $comment->setViewable(null);
         array_push($this->insertedComments, $commentDao->insertPaperComment($comment));
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the submission id.
     $submissionId = $this->getDataObjectId();
     if ($submissionId === false) {
         return AUTHORIZATION_DENY;
     }
     // Validate the section editor submission id.
     $sectionEditorSubmissionDao = DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($submissionId);
     if (!is_a($sectionEditorSubmission, 'SectionEditorSubmission')) {
         return AUTHORIZATION_DENY;
     }
     // Check whether the article is actually part of the journal
     // in the context.
     $request = $this->getRequest();
     $router = $request->getRouter();
     $journal = $router->getContext($request);
     if (!is_a($journal, 'Journal')) {
         return AUTHORIZATION_DENY;
     }
     if ($sectionEditorSubmission->getJournalId() != $journal->getId()) {
         return AUTHORIZATION_DENY;
     }
     // Save the section editor submission to the authorization context.
     $this->addAuthorizedContextObject(ASSOC_TYPE_ARTICLE, $sectionEditorSubmission);
     return AUTHORIZATION_PERMIT;
 }
示例#23
0
 function saveSettings()
 {
     $this->validate();
     $conference = Request::getConference();
     if ($conference) {
         $rtDao =& DAORegistry::getDAO('RTDAO');
         $rt = $rtDao->getConferenceRTByConference($conference);
         if (Request::getUserVar('version') == '') {
             $rt->setVersion(null);
         } else {
             $rt->setVersion(Request::getUserVar('version'));
         }
         $rt->setEnabled(Request::getUserVar('enabled') == true);
         $rt->setAbstract(Request::getUserVar('abstract') == true);
         $rt->setCaptureCite(Request::getUserVar('captureCite') == true);
         $rt->setViewMetadata(Request::getUserVar('viewMetadata') == true);
         $rt->setSupplementaryFiles(Request::getUserVar('supplementaryFiles') == true);
         $rt->setPrinterFriendly(Request::getUserVar('printerFriendly') == true);
         $rt->setAuthorBio(Request::getUserVar('authorBio') == true);
         $rt->setDefineTerms(Request::getUserVar('defineTerms') == true);
         $rt->setAddComment(Request::getUserVar('addComment') == true);
         $rt->setEmailAuthor(Request::getUserVar('emailAuthor') == true);
         $rt->setEmailOthers(Request::getUserVar('emailOthers') == true);
         $rt->setFindingReferences(Request::getUserVar('findingReferences') == true);
         $rtDao->updateConferenceRT($rt);
     }
     Request::redirect(null, null, Request::getRequestedPage());
 }
示例#24
0
 /**
  * Constructor.
  */
 function OAIDAO()
 {
     parent::DAO();
     $this->archiveDao =& DAORegistry::getDAO('ArchiveDAO');
     $this->recordDao =& DAORegistry::getDAO('RecordDAO');
     PluginRegistry::loadCategory('schemas');
 }
 /**
  * @covers FilterGroupDAO
  */
 public function testFilterGroupCrud()
 {
     $filterGroupDao = DAORegistry::getDAO('FilterGroupDAO');
     /* @var $filterGroupDao FilterGroupDAO */
     // Instantiate a test filter group object.
     $testFilterGroup = new FilterGroup();
     $testFilterGroup->setSymbolic('some-symbol');
     $testFilterGroup->setDisplayName('translation.key.displayName');
     $testFilterGroup->setDescription('translation.key.description');
     $testFilterGroup->setInputType('primitive::string');
     $testFilterGroup->setOutputType('primitive::integer');
     // Insert filter group instance.
     $filterGroupId = $filterGroupDao->insertObject($testFilterGroup, 9999);
     self::assertTrue(is_numeric($filterGroupId));
     self::assertTrue($filterGroupId > 0);
     // Retrieve filter group instance by id.
     $filterGroupById =& $filterGroupDao->getObjectById($filterGroupId);
     self::assertEquals($testFilterGroup, $filterGroupById);
     // Update filter group instance.
     $testFilterGroup->setSymbolic('some-other-symbol');
     $testFilterGroup->setDisplayName('translation.key.otherDisplayName');
     $testFilterGroup->setDescription('translation.key.otherDescription');
     $testFilterGroup->setInputType('primitive::integer');
     $testFilterGroup->setOutputType('primitive::string');
     $filterGroupDao->updateObject($testFilterGroup);
     $filterGroupAfterUpdate =& $filterGroupDao->getObject($testFilterGroup);
     self::assertEquals($testFilterGroup, $filterGroupAfterUpdate);
     // Retrieve filter group instance by symbolic name.
     $filterGroupBySymbolic =& $filterGroupDao->getObjectBySymbolic('some-other-symbol');
     self::assertEquals($testFilterGroup, $filterGroupAfterUpdate);
     // Delete filter group instance.
     $filterGroupDao->deleteObjectById($filterGroupId);
     self::assertNull($filterGroupDao->getObjectById($filterGroupId));
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     $request = $this->getRequest();
     // Get the user
     $user = $request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the submission file
     $submissionFile = $this->getSubmissionFile($request);
     if (!is_a($submissionFile, 'SubmissionFile')) {
         return AUTHORIZATION_DENY;
     }
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignments = $reviewAssignmentDao->getByUserId($user->getId());
     $reviewFilesDao = DAORegistry::getDAO('ReviewFilesDAO');
     foreach ($reviewAssignments as $reviewAssignment) {
         if (!$reviewAssignment->getDateConfirmed()) {
             continue;
         }
         if ($submissionFile->getSubmissionId() == $reviewAssignment->getSubmissionId() && $submissionFile->getFileStage() == SUBMISSION_FILE_REVIEW_FILE && $submissionFile->getViewable() && $reviewFilesDao->check($reviewAssignment->getId(), $submissionFile->getFileId())) {
             return AUTHORIZATION_PERMIT;
         }
     }
     // If a pass condition wasn't found above, deny access.
     return AUTHORIZATION_DENY;
 }
示例#27
0
 function validateUrls($args)
 {
     $this->validate();
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $conference = Request::getConference();
     if (!$conference) {
         Request::redirect(null, null, Request::getRequestedPage());
         return;
     }
     $versionId = isset($args[0]) ? $args[0] : 0;
     $conferenceId = $conference->getId();
     $version = $rtDao->getVersion($versionId, $conferenceId);
     if ($version) {
         // Validate the URLs for a single version
         $versions = array(&$version);
         import('core.ArrayItemIterator');
         $versions = new ArrayItemIterator($versions, 1, 1);
     } else {
         // Validate all URLs for this conference
         $versions = $rtDao->getVersions($conferenceId);
     }
     $this->setupTemplate(true, $version);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->register_modifier('validate_url', 'smarty_rtadmin_validate_url');
     $templateMgr->assign_by_ref('versions', $versions);
     $templateMgr->assign('helpTopicId', 'conference.generalManagement.readingTools');
     $templateMgr->display('rtadmin/validate.tpl');
 }
示例#28
0
 /**
  * Save changes to context.
  * @return int the context ID
  */
 function execute()
 {
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $context = $this->context;
     if (!isset($context)) {
         $context = new RTContext();
         $context->setVersionId($this->versionId);
     }
     $context->setTitle($this->getData('title'));
     $context->setAbbrev($this->getData('abbrev'));
     $context->setCitedBy($this->getData('citedBy') == true);
     $context->setAuthorTerms($this->getData('authorTerms') == true);
     $context->setGeoTerms($this->getData('geoTerms') == true);
     $context->setDefineTerms($this->getData('defineTerms') == true);
     $context->setDescription($this->getData('description'));
     if (!isset($this->context)) {
         $context->setOrder(-1);
     }
     if (isset($this->context)) {
         $rtDao->updateContext($context);
     } else {
         $rtDao->insertContext($context);
         $this->contextId = $context->getContextId();
     }
     return $this->contextId;
 }
示例#29
0
 /**
  * Redirect to user home page (or the role home page if the user has one role).
  * @param $request PKPRequest the request to be routed
  */
 function redirectHome(&$request)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $user = $request->getUser();
     $userId = $user->getId();
     if ($schedConf =& $this->getContext($request, 2)) {
         // The user is in the sched. conf. context, see if they have one role only
         $roles =& $roleDao->getRolesByUserId($userId, $schedConf->getConferenceId(), $schedConf->getId());
         if (count($roles) == 1) {
             $role = array_shift($roles);
             if ($role->getRoleId() == ROLE_ID_READER) {
                 $request->redirect(null, 'index');
             }
             $request->redirect(null, null, $role->getRolePath());
         } else {
             $request->redirect(null, null, 'user');
         }
     } elseif ($conference =& $this->getContext($request, 1)) {
         // The user is in the conference context, see if they have one role only
         $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
         $roles =& $roleDao->getRolesByUserId($userId, $conference->getId());
         if (count($roles) == 1) {
             $role = array_shift($roles);
             $confPath = $conference->getPath();
             $schedConfPath = 'index';
             if ($role->getSchedConfId()) {
                 $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
                 $schedConfPath = $schedConf->getPath();
             }
             if ($role->getRoleId() == ROLE_ID_READER) {
                 $request->redirect($confPath, $schedConfPath, 'index');
             }
             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
         } else {
             $request->redirect(null, null, 'user');
         }
     } else {
         // The user is at the site context, check to see if they are
         // only registered in one conf/SchedConf w/ one role
         $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
         $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
         $roles = $roleDao->getRolesByUserId($userId);
         if (count($roles) == 1) {
             $role = array_shift($roles);
             $confPath = 'index';
             $schedConfPath = 'index';
             if ($role->getConferenceId()) {
                 $conference = $conferenceDao->getConference($role->getConferenceId());
                 isset($conference) ? $confPath = $conference->getPath() : ($confPath = 'index');
             }
             if ($role->getSchedConfId()) {
                 $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
                 isset($schedConf) ? $schedConfPath = $schedConf->getPath() : ($schedConfPath = 'index');
             }
             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
         } else {
             $request->redirect('index', 'index', 'user');
         }
     }
 }
 /**
  * @see AuthorizationPolicy::effect()
  */
 function effect()
 {
     // Get the user
     $user =& $this->_request->getUser();
     if (!is_a($user, 'PKPUser')) {
         return AUTHORIZATION_DENY;
     }
     // Get the press
     $router =& $this->_request->getRouter();
     $press =& $router->getContext($this->_request);
     if (!is_a($press, 'Press')) {
         return AUTHORIZATION_DENY;
     }
     // Get the monograph
     $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
     if (!is_a($monograph, 'Monograph')) {
         return AUTHORIZATION_DENY;
     }
     // Series editors can access all submissions in their series.
     // Even those they've not been explicitly assigned to.
     $seriesEditorsDao =& DAORegistry::getDAO('SeriesEditorsDAO');
     if ($seriesEditorDao->editorExists($press->getId(), $monograph->getSeriesId(), $user->getId())) {
         return AUTHORIZATION_PERMIT;
     } else {
         return AUTHORIZATION_DENY;
     }
 }