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

controllers/grid/files/signoff/SignoffFilesGridHandler.inc.php

00001 <?php
00002 
00015 // import grid base classes
00016 import('lib.pkp.classes.controllers.grid.CategoryGridHandler');
00017 
00018 // import copyediting grid specific classes
00019 import('controllers.grid.files.signoff.SignoffFilesGridCategoryRow');
00020 import('controllers.grid.files.signoff.SignoffGridRow');
00021 import('controllers.grid.files.signoff.SignoffGridCellProvider');
00022 import('controllers.grid.files.signoff.SignoffFilesGridCellProvider');
00023 
00024 // Link actions
00025 import('lib.pkp.classes.linkAction.request.AjaxModal');
00026 
00027 class SignoffFilesGridHandler extends CategoryGridHandler {
00028    /* @var int */
00029    var $_stageId;
00030 
00031    /* @var string */
00032    var $_symbolic;
00033 
00034    /* @var int */
00035    var $_fileStage;
00036 
00037    /* @var string */
00038    var $_eventType;
00039 
00040    /* @var int */
00041    var $_assocType;
00042 
00043    /* @var int */
00044    var $_assocId;
00045 
00046 
00050    function SignoffFilesGridHandler($stageId, $fileStage, $symbolic, $eventType, $assocType = null, $assocId = null) {
00051       $this->_stageId = $stageId;
00052       $this->_fileStage = $fileStage;
00053       $this->_symbolic = $symbolic;
00054       $this->_eventType = $eventType;
00055       $this->_assocType = $assocType;
00056       $this->_assocId = $assocId;
00057 
00058       $this->addRoleAssignment(
00059          array(ROLE_ID_PRESS_MANAGER, ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_ASSISTANT),
00060          array(
00061             'fetchGrid', 'fetchCategory', 'fetchRow', 'returnFileRow', 'returnSignoffRow',
00062             'addAuditor', 'saveAddAuditor', 'getAuditorAutocomplete',
00063             'signOffsignOff', 'deleteSignOffSignOff', 'deleteSignoff', 'viewLibrary',
00064             'editReminder', 'sendReminder'
00065          )
00066       );
00067       parent::CategoryGridHandler();
00068    }
00069 
00070 
00071    //
00072    // Implement template methods from PKPHandler
00073    //
00080    function authorize(&$request, $args, $roleAssignments) {
00081       import('classes.security.authorization.OmpWorkflowStageAccessPolicy');
00082       $this->addPolicy(new OmpWorkflowStageAccessPolicy($request, $args, $roleAssignments, 'monographId', $this->getStageId()));
00083 
00084       // If a signoff ID was specified, authorize it.
00085       if ($request->getUserVar('signoffId')) {
00086          import('classes.security.authorization.OmpSignoffAccessPolicy');
00087          $this->addPolicy(new OmpSignoffAccessPolicy($request, $args, $roleAssignments, SIGNOFF_ACCESS_MODIFY, $this->getStageId()));
00088       }
00089 
00090       // If a publication ID was specified, authorize it.
00091       if ($request->getUserVar('publicationFormatId')) {
00092          import('classes.security.authorization.internal.PublicationFormatRequiredPolicy');
00093          $this->addPolicy(new PublicationFormatRequiredPolicy($request, $args));
00094       }
00095 
00096       return parent::authorize($request, $args, $roleAssignments);
00097    }
00098 
00099 
00100    //
00101    // Implement template methods from PKPHandler
00102    //
00107    function initialize(&$request) {
00108       parent::initialize($request);
00109 
00110       AppLocale::requireComponents(
00111          LOCALE_COMPONENT_PKP_COMMON,
00112          LOCALE_COMPONENT_APPLICATION_COMMON,
00113          LOCALE_COMPONENT_PKP_SUBMISSION,
00114          LOCALE_COMPONENT_OMP_EDITOR,
00115          LOCALE_COMPONENT_OMP_SUBMISSION
00116       );
00117 
00118       $monograph =& $this->getMonograph();
00119 
00120       // Bring in file constants
00121       import('classes.monograph.MonographFile');
00122 
00123       // Grid actions
00124       // Action to add a file -- Adds a category row for the file
00125       import('controllers.api.file.linkAction.AddFileLinkAction');
00126       $this->addAction(new AddFileLinkAction(
00127          $request, $monograph->getId(),
00128          $this->getStageId(),
00129          array(ROLE_ID_PRESS_MANAGER, ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_ASSISTANT),
00130          $this->getFileStage(),
00131          $this->getAssocType(), $this->getAssocId()
00132       ));
00133 
00134       // Action to signoff on a file -- Lets user interact with their own rows.
00135       $user =& $request->getUser();
00136       $signoffDao =& DAORegistry::getDAO('MonographFileSignoffDAO'); /* @var $signoffDao MonographFileSignoffDAO */
00137       $signoffFactory =& $signoffDao->getAllByMonograph($monograph->getId(), $this->getSymbolic(), $user->getId(), null, true);
00138       if (!$signoffFactory->wasEmpty()) {
00139          import('controllers.api.signoff.linkAction.AddSignoffFileLinkAction');
00140          $this->addAction(new AddSignoffFileLinkAction(
00141             $request, $monograph->getId(),
00142             $this->getStageId(), $this->getSymbolic(), null,
00143             __('submission.upload.signoff'), __('submission.upload.signoff')));
00144       }
00145 
00146       $router =& $request->getRouter();
00147 
00148       // Action to add a user -- Adds the user as a subcategory to the files selected in its modal
00149       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
00150       $monographFiles =& $submissionFileDao->getLatestRevisions($monograph->getId(), $this->getFileStage());
00151 
00152       // The "Add Auditor" link should only be available if at least
00153       // one file already exists.
00154       if (!empty($monographFiles)) {
00155          $this->addAction(new LinkAction(
00156             'addAuditor',
00157             new AjaxModal(
00158                $router->url($request, null, null, 'addAuditor', null, $this->getRequestArgs()),
00159                __('editor.monograph.addAuditor'),
00160                'modal_add_user'
00161             ),
00162             __('editor.monograph.addAuditor'),
00163             'add_user'
00164          ));
00165       }
00166 
00167       //
00168       // Grid Columns
00169       //
00170       $userIds = $this->_getSignoffCapableUsersId();
00171 
00172       // Add a column for the file's label
00173       $this->addColumn(
00174          new GridColumn(
00175             'name',
00176             'common.file',
00177             null,
00178             'controllers/grid/gridCell.tpl',
00179             new SignoffGridCellProvider($monograph->getId(), $this->getStageId()),
00180             array('alignment' => COLUMN_ALIGNMENT_LEFT, 'width' => 60)
00181          )
00182       );
00183 
00184       // Add the considered column (signoff).
00185       import('controllers.grid.files.SignoffOnSignoffGridColumn');
00186       $this->addColumn(new SignoffOnSignoffGridColumn('common.considered', $userIds, $this->getRequestArgs(), array('hoverTitle' => true)));
00187 
00188       // Add approved column (make the file visible). This column
00189       // will only have content in category rows, so we define
00190       // a cell provider there. See getCategoryRowInstance().
00191       import('lib.pkp.classes.controllers.grid.GridColumn');
00192       import('lib.pkp.classes.controllers.grid.NullGridCellProvider');
00193       $this->addColumn(new GridColumn(
00194          'approved',
00195          'editor.signoff.approved', null, 'controllers/grid/gridCell.tpl',
00196          new NullGridCellProvider())
00197       );
00198 
00199       // Set the no-row locale key
00200       $this->setEmptyRowText('grid.noFiles');
00201    }
00202 
00203 
00204    //
00205    // Getters and Setters
00206    //
00211    function &getMonograph() {
00212       return $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00213    }
00214 
00215 
00220    function getStageId() {
00221       return $this->_stageId;
00222    }
00223 
00224 
00229    function getSymbolic() {
00230       return $this->_symbolic;
00231    }
00232 
00233 
00237    function getFileStage() {
00238       return $this->_fileStage;
00239    }
00240 
00241 
00245    function getEventType() {
00246       return $this->_eventType;
00247    }
00248 
00249 
00253    function getAssocType() {
00254       return $this->_assocType;
00255    }
00256 
00257 
00261    function setAssocId($assocId) {
00262       $this->_assocId = $assocId;
00263    }
00264 
00265 
00269    function getAssocId() {
00270       return $this->_assocId;
00271    }
00272 
00277    function &getPublicationFormat() {
00278       return $this->getAuthorizedContextObject(ASSOC_TYPE_PUBLICATION_FORMAT);
00279    }
00280 
00281 
00285    function getRequestArgs() {
00286       $monograph =& $this->getMonograph();
00287       $signoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00288       $args = array_merge(
00289          parent::getRequestArgs(),
00290          array('monographId' => $monograph->getId(),
00291             'stageId' => $this->getStageId())
00292       );
00293 
00294       if (is_a($signoff, 'Signoff')) {
00295          $args['signoffId'] = $signoff->getId();
00296       }
00297 
00298       return $args;
00299    }
00300 
00301 
00305    function &loadData(&$request, $filter) {
00306       // Grab the files to display as categories
00307       $monograph =& $this->getMonograph();
00308       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
00309       if ($this->getAssocType() && $this->getAssocId()) {
00310          $monographFiles =& $submissionFileDao->getLatestRevisionsByAssocId(
00311             $this->getAssocType(), $this->getAssocId(),
00312             $monograph->getId(), $this->getFileStage()
00313          );
00314       } else {
00315          $monographFiles =& $submissionFileDao->getLatestRevisions($monograph->getId(), $this->getFileStage());
00316       }
00317 
00318       // $monographFiles is keyed on file and revision, for the grid we need to key on file only
00319       // since the grid shows only the most recent revision.
00320       $data = array();
00321       foreach ($monographFiles as $monographFile) {
00322          $data[$monographFile->getFileId()] = $monographFile;
00323       }
00324       return $data;
00325    }
00326 
00327 
00328    //
00329    // Overridden methods from GridHandler
00330    //
00335    function &getCategoryRowInstance() {
00336       $row = new SignoffFilesGridCategoryRow($this->getStageId());
00337       $monograph =& $this->getMonograph();
00338       $row->setCellProvider(new SignoffFilesGridCellProvider($monograph->getId(), $this->getStageId()));
00339       $row->addFlag('gridRowStyle', true);
00340       return $row;
00341    }
00342 
00343 
00350    function getCategoryData(&$monographFile) {
00351       $monographFileSignoffDao =& DAORegistry::getDAO('MonographFileSignoffDAO');
00352       $signoffFactory =& $monographFileSignoffDao->getAllBySymbolic($this->getSymbolic(), $monographFile->getFileId()); /* @var $signoffs DAOResultFactory */
00353       $signoffs = $signoffFactory->toAssociativeArray();
00354       return $signoffs;
00355    }
00356 
00360    function getCategoryRowIdParameterName() {
00361       return 'fileId';
00362    }
00363 
00364 
00369    function &getRowInstance() {
00370       $row = new SignoffGridRow($this->getStageId());
00371       return $row;
00372    }
00373 
00374 
00375    //
00376    // Public methods
00377    //
00384    function addAuditor($args, &$request) {
00385       // Identify the monograph being worked on
00386       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00387 
00388       // Form handling
00389       $router =& $request->getRouter();
00390       $autocompleteUrl = $router->url($request, null, null, 'getAuditorAutocomplete', null, $this->getRequestArgs());
00391       $templateMgr =& TemplateManager::getManager();
00392       $templateMgr->assign('autocompleteUrl', $autocompleteUrl);
00393 
00394       import('controllers.grid.files.signoff.form.FileAuditorForm');
00395       $publicationFormat =& $this->getPublicationFormat();
00396       $publicationFormatId = null;
00397       if (is_a($publicationFormat, 'PublicationFormat')) {
00398          $publicationFormatId = $publicationFormat->getId();
00399       }
00400       $auditorForm = new FileAuditorForm($monograph, $this->getFileStage(), $this->getStageId(), $this->getSymbolic(), $this->getEventType(), $this->getAssocId(), $publicationFormatId);
00401       if ($auditorForm->isLocaleResubmit()) {
00402          $auditorForm->readInputData();
00403       } else {
00404          $auditorForm->initData($args, $request);
00405       }
00406 
00407       $json = new JSONMessage(true, $auditorForm->fetch($request));
00408       return $json->getString();
00409    }
00410 
00411 
00418    function saveAddAuditor($args, &$request) {
00419       // Identify the monograph being worked on
00420       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00421 
00422       // Form handling
00423       import('controllers.grid.files.signoff.form.FileAuditorForm');
00424       $auditorForm = new FileAuditorForm($monograph, $this->getFileStage(), $this->getStageId(), $this->getSymbolic(), $this->getEventType(), $this->getAssocId());
00425       $auditorForm->readInputData();
00426       if ($auditorForm->validate()) {
00427          $auditorForm->execute($request);
00428 
00429          // Create trivial notification.
00430          $currentUser =& $request->getUser();
00431          NotificationManager::createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.addedAuditor')));
00432 
00433          // We need to refresh the whole grid because multiple files can be assigned at once.
00434          return DAO::getDataChangedEvent();
00435       }
00436 
00437       $json = new JSONMessage(false);
00438       return $json->getString();
00439    }
00440 
00441 
00448    function getAuditorAutocomplete($args, &$request) {
00449       // Identify the Monograph we are working with
00450       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00451 
00452       // Retrieve the users for the autocomplete control: Any user assigned to this stage
00453       $stageAssignmentDao = & DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
00454       $stageUsers = $stageAssignmentDao->getBySubmissionAndStageId($monograph->getId(), $this->getStageId());
00455 
00456       $itemList = array();
00457       $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
00458       $userDao =& DAORegistry::getDAO('UserDAO');
00459       $term =& $request->getUserVar('term');
00460       while($stageUser =& $stageUsers->next()) {
00461          $userGroup =& $userGroupDao->getById($stageUser->getUserGroupId());
00462          $user =& $userDao->getById($stageUser->getUserId());
00463          $term = preg_quote($term, '/');
00464          if ($term == '' || preg_match('/' . $term .'/i', $user->getFullName()) || preg_match('/' . $term .'/i', $userGroup->getLocalizedName())) {
00465             $itemList[] = array(
00466                'label' =>  sprintf('%s (%s)', $user->getFullName(), $userGroup->getLocalizedName()),
00467                'value' => $user->getId() . '-' . $stageUser->getUserGroupId()
00468             );
00469          }
00470          unset($stageUser, $userGroup);
00471       }
00472 
00473       if (count($itemList) == 0) {
00474          return $this->noAutocompleteResults();
00475       }
00476 
00477       $json = new JSONMessage(true, $itemList);
00478       return $json->getString();
00479    }
00480 
00481 
00488    function returnSignoffRow($args, &$request) {
00489       $signoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00490 
00491       if($signoff) {
00492          return DAO::getDataChangedEvent();
00493       } else {
00494          $json = new JSONMessage(false, __('common.uploadFailed'));
00495          return $json->getString();
00496       }
00497    }
00498 
00499 
00506    function deleteSignoff($args, &$request) {
00507       $signoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00508 
00509       if($signoff && !$signoff->getDateCompleted()) {
00510 
00511          $signoffUserId = $signoff->getUserId();
00512          if ($signoff->getAssocType() == ASSOC_TYPE_MONOGRAPH_FILE) {
00513             $fileId = $signoff->getAssocId();
00514          }
00515          $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00516          $monographFile =& $submissionFileDao->getLatestRevision($fileId);
00517 
00518          // Remove the signoff
00519          $signoffDao =& DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */
00520          $signoffDao->deleteObjectById($signoff->getId());
00521 
00522          // Trivial notifications.
00523          $user =& $request->getUser();
00524          NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedAuditor')));
00525 
00526          // Update NOTIFICATION_TYPE_AUDITOR_REQUEST.
00527          $notificationMgr = new NotificationManager();
00528          $notificationMgr->updateAuditorRequestNotification($signoff, $request, true);
00529 
00530          // Update NOTIFICATION_TYPE_SIGNOFF_...
00531          $notificationMgr->updateSignoffNotification($signoff, $request);
00532 
00533          // log the remove auditor event.
00534          import('classes.log.MonographFileLog');
00535          import('classes.log.MonographFileEventLogEntry'); // constants
00536          $userDao =& DAORegistry::getDAO('UserDAO');
00537          $signoffUser =& $userDao->getById($signoffUserId);
00538 
00539          if (isset($signoffUser) && isset($monographFile)) {
00540             MonographFileLog::logEvent($request, $monographFile, MONOGRAPH_LOG_FILE_AUDITOR_CLEAR, 'submission.event.fileAuditorCleared', array('file' => $monographFile->getOriginalFileName(), 'name' => $signoffUser->getFullName(), 'username' => $signoffUser->getUsername()));
00541          }
00542          return DAO::getDataChangedEvent($signoff->getId(), $signoff->getAssocId());
00543       } else {
00544          $json = new JSONMessage(false, 'manager.setup.errorDeletingItem');
00545          return $json->getString();
00546       }
00547    }
00548 
00549 
00555    function signOffsignOff($args, &$request) {
00556       $rowSignoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00557       if (!$rowSignoff) fatalError('Invalid Signoff given');
00558 
00559       $user =& $request->getUser();
00560       $signoffDao =& DAORegistry::getDAO('SignoffDAO');
00561       $signoff =& $signoffDao->build('SIGNOFF_SIGNOFF', ASSOC_TYPE_SIGNOFF, $rowSignoff->getId(), $user->getId());
00562       $signoff->setDateCompleted(Core::getCurrentDate());
00563       $signoffDao->updateObject($signoff);
00564 
00565       // Remove the notification for the Copyeditor review, if they exist.
00566       $notificationMgr = new NotificationManager();
00567       // We don't need to pass the user because anyone with access can signoff the signoff,
00568       // and we should delete the notification even if that user is not the one that
00569       // is seeing the notification.
00570       $notificationMgr->deleteCopyeditRequestNotification($rowSignoff, &$request);
00571 
00572       // log the sign off sign off
00573       import('classes.log.MonographFileLog');
00574       import('classes.log.MonographFileEventLogEntry'); // constants
00575       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00576       $monographFile =& $submissionFileDao->getLatestRevision($rowSignoff->getAssocId());
00577       if (isset($monographFile)) {
00578          MonographFileLog::logEvent($request, $monographFile, MONOGRAPH_LOG_FILE_SIGNOFF_SIGNOFF, 'submission.event.signoffSignoff', array('file' => $monographFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername()));
00579       }
00580       // Redraw the row.
00581       return DAO::getDataChangedEvent($rowSignoff->getId(), $rowSignoff->getAssocId());
00582    }
00583 
00590    function deleteSignOffSignOff($args, &$request) {
00591       $rowSignoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00592       if (!$rowSignoff) fatalError('Invalid Signoff given');
00593 
00594       $user =& $request->getUser();
00595       $signoffDao =& DAORegistry::getDAO('SignoffDAO');
00596       $signoffOnSignoffFactory = $signoffDao->getAllByAssocType(ASSOC_TYPE_SIGNOFF, $rowSignoff->getId());
00597       $signoffOnSignoff =& $signoffOnSignoffFactory->next();
00598       if (!$signoffOnSignoff) fatalError('Invalid Signoff given');
00599 
00600       $signoffDao->deleteObject($signoffOnSignoff);
00601 
00602       return DAO::getDataChangedEvent($rowSignoff->getId(), $rowSignoff->getAssocId());
00603    }
00604 
00605 
00612    function viewLibrary($args, &$request) {
00613 
00614       $templateMgr =& TemplateManager::getManager();
00615       $templateMgr->assign('canEdit', false);
00616       return $templateMgr->fetchJson('controllers/tab/settings/library.tpl');
00617    }
00618 
00625    function editReminder($args, &$request) {
00626       // Identify the signoff.
00627       $signoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00628       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00629 
00630       // Initialize form.
00631       import('controllers.grid.files.fileSignoff.form.AuditorReminderForm');
00632       $publicationFormat =& $this->getPublicationFormat();
00633       $publicationFormatId = null;
00634       if (is_a($publicationFormat, 'PublicationFormat')) {
00635          $publicationFormatId = $publicationFormat->getId();
00636       }
00637       $auditorReminderForm = new AuditorReminderForm($signoff, $monograph->getId(), $this->getStageId(), $publicationFormatId);
00638       $auditorReminderForm->initData($args, $request);
00639 
00640       // Render form.
00641       $json = new JSONMessage(true, $auditorReminderForm->fetch($request));
00642       return $json->getString();
00643    }
00644 
00651    function sendReminder($args, &$request) {
00652       $signoff =& $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF);
00653       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00654 
00655       // Form handling
00656       import('controllers.grid.files.fileSignoff.form.AuditorReminderForm');
00657       $publicationFormat =& $this->getPublicationFormat();
00658       $publicationFormatId = null;
00659       if (is_a($publicationFormat, 'PublicationFormat')) {
00660          $publicationFormatId = $publicationFormat->getId();
00661       }
00662       $auditorReminderForm = new AuditorReminderForm($signoff, $monograph->getId(), $this->getStageId(), $publicationFormatId);
00663       $auditorReminderForm->readInputData();
00664       if ($auditorReminderForm->validate()) {
00665          $auditorReminderForm->execute($args, $request);
00666          $json = new JSONMessage(true);
00667 
00668          // Insert a trivial notification to indicate the auditor was reminded successfully.
00669          $currentUser =& $request->getUser();
00670          $notificationMgr = new NotificationManager();
00671          $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.sentNotification')));
00672       } else {
00673          $json = new JSONMessage(false, __('editor.review.reminderError'));
00674       }
00675       return $json->getString();
00676    }
00677 
00678 
00679    //
00680    // Private helper methods.
00681    //
00686    function _getSignoffCapableUsersId() {
00687       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00688 
00689       // Get all the users that are assigned to the stage (managers, series editors, and assistants)
00690       // FIXME: is there a better way to do this?
00691       $userIds = array();
00692       $stageAssignmentDao = & DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
00693       $seriesEditorAssignments =& $stageAssignmentDao->getBySubmissionAndRoleId($monograph->getId(), ROLE_ID_SERIES_EDITOR, $this->getStageId());
00694       $assistantAssignments =& $stageAssignmentDao->getBySubmissionAndRoleId($monograph->getId(), ROLE_ID_PRESS_ASSISTANT, $this->getStageId());
00695 
00696       $allAssignments = array_merge(
00697          $seriesEditorAssignments->toArray(),
00698          $assistantAssignments->toArray()
00699       );
00700 
00701       foreach ($allAssignments as $assignment) {
00702          $userIds[] = $assignment->getUserId();
00703       }
00704 
00705       // We need to manually include the press editor, because he has access
00706       // to all submission and its workflow stages but not always with
00707       // an stage assignment (editorial and production stages, for example).
00708       $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
00709       $pressManagerUserGroupsFactory =& $userGroupDao->getByRoleId($monograph->getPressId(), ROLE_ID_PRESS_MANAGER);
00710       while ($userGroup =& $pressManagerUserGroupsFactory->next()) {
00711          $usersFactory =& $userGroupDao->getUsersById($userGroup->getId(), $monograph->getPressId());
00712          while ($user =& $usersFactory->next()) {
00713             $userIds[] = $user->getId();
00714             unset($user);
00715          }
00716          unset($userGroup);
00717       }
00718 
00719       return array_unique($userIds);
00720    }
00721 }
00722 
00723 ?>

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