Ejemplo n.º 1
0
 /**
  * @see Filter::process()
  * @param $document DOMDocument|string
  * @return array Array of imported documents
  */
 function &process(&$document)
 {
     $importedObjects =& parent::process($document);
     // Index imported content
     import('classes.search.MonographSearchIndex');
     foreach ($importedObjects as $submission) {
         assert(is_a($submission, 'Submission'));
         MonographSearchIndex::indexMonographMetadata($submission);
         MonographSearchIndex::indexMonographFiles($submission);
     }
     return $importedObjects;
 }
 /**
  * Approve a proof submission file.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function saveApproveProof($args, $request)
 {
     $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE);
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     // Make sure we only alter files associated with a publication format.
     if ($submissionFile->getAssocType() !== ASSOC_TYPE_PUBLICATION_FORMAT) {
         fatalError('The requested file is not associated with any publication format.');
     }
     if ($submissionFile->getViewable()) {
         // No longer expose the file to readers.
         $submissionFile->setViewable(false);
     } else {
         // Expose the file to readers (e.g. via e-commerce).
         $submissionFile->setViewable(true);
         // Log the approve proof event.
         import('lib.pkp.classes.log.SubmissionLog');
         import('classes.log.SubmissionEventLogEntry');
         // constants
         $user = $request->getUser();
         $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
         $publicationFormat = $publicationFormatDao->getById($submissionFile->getAssocId(), $submission->getId());
         SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PROOFS_APPROVED, 'submission.event.proofsApproved', array('formatName' => $publicationFormat->getLocalizedName(), 'name' => $user->getFullName(), 'username' => $user->getUsername()));
     }
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     $submissionFileDao->updateObject($submissionFile);
     // update the submission's file index
     import('classes.search.MonographSearchIndex');
     MonographSearchIndex::clearMonographFiles($submission);
     MonographSearchIndex::indexMonographFiles($submission);
     return DAO::getDataChangedEvent($submissionFile->getId());
 }
Ejemplo n.º 3
0
 /**
  * Rebuild the search index for all presses.
  */
 function rebuildIndex($log = false)
 {
     // Clear index
     if ($log) {
         echo 'Clearing index ... ';
     }
     $searchDao =& DAORegistry::getDAO('MonographSearchDAO');
     // FIXME Abstract into MonographSearchDAO?
     $searchDao->update('DELETE FROM monograph_search_object_keywords');
     $searchDao->update('DELETE FROM monograph_search_objects');
     $searchDao->update('DELETE FROM monograph_search_keyword_list');
     $searchDao->setCacheDir(Config::getVar('files', 'files_dir') . '/_db');
     $searchDao->_dataSource->CacheFlush();
     if ($log) {
         echo "done\n";
     }
     // Build index
     $pressDao =& DAORegistry::getDAO('PressDAO');
     $monographDao =& DAORegistry::getDAO('MonographDAO');
     $presses =& $pressDao->getPresses();
     while (!$presses->eof()) {
         $press =& $presses->next();
         $numIndexed = 0;
         if ($log) {
             echo "Indexing \"", $press->getLocalizedTitle(), "\" ... ";
         }
         $monographs =& $monographDao->getMonographs($press->getPressId());
         while (!$monographs->eof()) {
             $monograph =& $monographs->next();
             if ($monograph->getDateSubmitted()) {
                 MonographSearchIndex::indexMonographMetadata($monograph);
                 MonographSearchIndex::indexMonographFiles($monograph);
                 $numIndexed++;
             }
             unset($monograph);
         }
         if ($log) {
             echo $numIndexed, " monographs indexed\n";
         }
         unset($press);
     }
 }