• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/monograph/SubmissionFileDAO.inc.php

00001 <?php
00002 
00021 import('lib.pkp.classes.submission.PKPSubmissionFileDAO');
00022 
00023 class SubmissionFileDAO extends PKPSubmissionFileDAO {
00027    function SubmissionFileDAO() {
00028       return parent::PKPSubmissionFileDAO();
00029    }
00030 
00031 
00032    //
00033    // Implement protected template methods from PKPSubmissionFileDAO
00034    //
00038    function getSubmissionEntityName() {
00039       return 'monograph';
00040    }
00041 
00045    function getDelegateClassNames() {
00046       static $delegateClasses = array(
00047          'artworkfile' => 'classes.monograph.ArtworkFileDAODelegate',
00048          'monographfile' => 'classes.monograph.MonographFileDAODelegate'
00049       );
00050       return $delegateClasses;
00051    }
00052 
00056    function getGenreCategoryMapping() {
00057       static $genreCategoryMapping = array(
00058          GENRE_CATEGORY_ARTWORK => 'artworkfile',
00059          GENRE_CATEGORY_DOCUMENT => 'monographfile'
00060       );
00061       return $genreCategoryMapping;
00062    }
00063 
00067    function baseQueryForFileSelection() {
00068       // Build the basic query that joins the class tables.
00069       // The DISTINCT is required to de-dupe the review_round_files join in
00070       // PKPSubmissionFileDAO.
00071       return 'SELECT DISTINCT
00072             sf.file_id AS monograph_file_id, sf.revision AS monograph_revision,
00073             af.file_id AS artwork_file_id, af.revision AS artwork_revision,
00074             sf.*, af.*
00075          FROM  monograph_files sf
00076             LEFT JOIN monograph_artwork_files af ON sf.file_id = af.file_id AND sf.revision = af.revision ';
00077    }
00078 
00079 
00080    //
00081    // Override methods from PKPSubmissionFileDAO
00082    // FIXME *6902* Move this code to PKPSubmissionFileDAO after the review round
00083    // refactoring is ported to other applications.
00084    //
00088    function deleteAllRevisionsByReviewRound($reviewRoundId) {
00089       // Remove currently assigned review files.
00090       return $this->update('DELETE FROM review_round_files
00091                   WHERE review_round_id = ?',
00092       array((int)$reviewRoundId));
00093    }
00094 
00098    function assignRevisionToReviewRound($fileId, $revision, &$reviewRound) {
00099       if (!is_numeric($fileId) || !is_numeric($revision)) fatalError('Invalid file!');
00100       return $this->update('INSERT INTO review_round_files
00101                   ('.$this->getSubmissionEntityName().'_id, review_round_id, stage_id, file_id, revision)
00102                   VALUES (?, ?, ?, ?, ?)',
00103       array((int)$reviewRound->getSubmissionId(), (int)$reviewRound->getId(), (int)$reviewRound->getStageId(), (int)$fileId, (int)$revision));
00104    }
00105 
00109    function &getRevisionsByReviewRound(&$reviewRound, $fileStage = null,
00110    $uploaderUserId = null, $uploaderUserGroupId = null) {
00111       if (!is_a($reviewRound, 'ReviewRound')) {
00112          $nullVar = null;
00113          return $nullVar;
00114       }
00115       return $this->_getInternally($reviewRound->getSubmissionId(),
00116          $fileStage, null, null, null, null, null,
00117          $uploaderUserId, $uploaderUserGroupId, null, $reviewRound->getId()
00118       );
00119    }
00120 
00124    function &getLatestNewRevisionsByReviewRound($reviewRound, $fileStage = null) {
00125       if (!is_a($reviewRound, 'ReviewRound')) {
00126          $emptyArray = array();
00127          return $emptyArray;
00128       }
00129       return $this->_getInternally($reviewRound->getSubmissionId(),
00130          $fileStage, null, null, null, null, $reviewRound->getStageId(),
00131          null, null, null, $reviewRound->getId(), true
00132       );
00133    }
00134 
00139    function getAllFileStages() {
00140       // Bring in the file stages definition.
00141       import('classes.monograph.MonographFile');
00142       return array(
00143          MONOGRAPH_FILE_PUBLIC,
00144          MONOGRAPH_FILE_SUBMISSION,
00145          MONOGRAPH_FILE_NOTE,
00146          MONOGRAPH_FILE_REVIEW_FILE,
00147          MONOGRAPH_FILE_REVIEW_ATTACHMENT,
00148          MONOGRAPH_FILE_FINAL,
00149          MONOGRAPH_FILE_FAIR_COPY,
00150          MONOGRAPH_FILE_EDITOR,
00151          MONOGRAPH_FILE_COPYEDIT,
00152          MONOGRAPH_FILE_PROOF,
00153          MONOGRAPH_FILE_PRODUCTION_READY,
00154          MONOGRAPH_FILE_LAYOUT,
00155          MONOGRAPH_FILE_ATTACHMENT,
00156          MONOGRAPH_FILE_SIGNOFF,
00157          MONOGRAPH_FILE_REVIEW_REVISION,
00158       );
00159    }
00160 
00161 
00162    //
00163    // Protected helper methods
00164    //
00168    function &fromRow(&$row) {
00169       // Identify the appropriate file implementation for the
00170       // given row.
00171       if (isset($row['artwork_file_id']) && is_numeric($row['artwork_file_id'])) {
00172          $fileImplementation = 'ArtworkFile';
00173       } else {
00174          $fileImplementation = 'MonographFile';
00175       }
00176 
00177       // Let the superclass instantiate the file.
00178       return parent::fromRow($row, $fileImplementation);
00179    }
00180 }
00181 
00182 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1