/**
  * Display the form.
  */
 function display()
 {
     $press =& Request::getPress();
     $user =& Request::getUser();
     $templateMgr =& TemplateManager::getManager();
     // Get series for this press
     $seriesDao =& DAORegistry::getDAO('SeriesDAO');
     // FIXME: If this user is a series editor or an editor, they are
     // allowed to submit to series flagged as "editor-only" for
     // submissions. Otherwise, display only series they are allowed
     // to submit to.
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $isEditor = $roleDao->userHasRole($press->getId(), $user->getId(), ROLE_ID_EDITOR) || $roleDao->userHasRole($press->getId(), $user->getId(), ROLE_ID_SERIES_EDITOR);
     $seriesOptions = array('0' => Locale::translate('submission.submit.selectSeries')) + $seriesDao->getTitlesByPressId($press->getId());
     $templateMgr->assign('seriesOptions', $seriesOptions);
     // Provide available submission languages. (Convert the array
     // of locale symbolic names xx_XX into an associative array
     // of symbolic names => readable names.)
     $supportedSubmissionLocales = $press->getSetting('supportedSubmissionLocales');
     if (empty($supportedSubmissionLocales)) {
         $supportedSubmissionLocales = array($press->getPrimaryLocale());
     }
     $templateMgr->assign('supportedSubmissionLocaleNames', array_flip(array_intersect(array_flip(Locale::getAllLocales()), $supportedSubmissionLocales)));
     parent::display();
 }
 /**
  * Initialize form data from current monograph.
  */
 function initData()
 {
     $seriesDao =& DAORegistry::getDAO('SeriesDAO');
     if (isset($this->monograph)) {
         $monograph =& $this->monograph;
         $this->_data = array('title' => $monograph->getTitle(null), 'abstract' => $monograph->getAbstract(null), 'discipline' => $monograph->getDiscipline(null), 'subjectClass' => $monograph->getSubjectClass(null), 'subject' => $monograph->getSubject(null), 'coverageGeo' => $monograph->getCoverageGeo(null), 'coverageChron' => $monograph->getCoverageChron(null), 'coverageSample' => $monograph->getCoverageSample(null), 'type' => $monograph->getType(null), 'language' => $monograph->getLanguage(), 'sponsor' => $monograph->getSponsor(null), 'series' => $seriesDao->getById($monograph->getSeriesId()), 'citations' => $monograph->getCitations());
     }
     return parent::initData();
 }
 /**
  * Fetch the form.
  */
 function fetch($request)
 {
     $user = $request->getUser();
     $templateMgr = TemplateManager::getManager($request);
     $templateMgr->assign('supportedSubmissionLocaleNames', $this->context->getSupportedSubmissionLocaleNames());
     // if this context has a copyright notice that the author must agree to, present the form items.
     if ((bool) $this->context->getSetting('copyrightNoticeAgree')) {
         $templateMgr->assign('copyrightNotice', $this->context->getLocalizedSetting('copyrightNotice'));
         $templateMgr->assign('copyrightNoticeAgree', true);
     }
     // Get list of user's author user groups.  If its more than one, we'll need to display an author user group selector
     $userGroupAssignmentDao = DAORegistry::getDAO('UserGroupAssignmentDAO');
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $authorUserGroupAssignments = $userGroupAssignmentDao->getByUserId($user->getId(), $this->context->getId(), ROLE_ID_AUTHOR);
     $userGroupNames = array();
     if (!$authorUserGroupAssignments->wasEmpty()) {
         while ($authorUserGroupAssignment = $authorUserGroupAssignments->next()) {
             $authorUserGroup = $userGroupDao->getById($authorUserGroupAssignment->getUserGroupId());
             if ($userGroupDao->userGroupAssignedToStage($authorUserGroup->getId(), WORKFLOW_STAGE_ID_SUBMISSION)) {
                 $userGroupNames[$authorUserGroup->getId()] = $authorUserGroup->getLocalizedName();
             }
         }
         $templateMgr->assign('authorUserGroupOptions', $userGroupNames);
     } else {
         // The user doesn't have any author user group assignments.  They should be either a manager.
         // Add all manager user groups
         $managerUserGroupAssignments = $userGroupAssignmentDao->getByUserId($user->getId(), $this->context->getId(), ROLE_ID_MANAGER);
         if ($managerUserGroupAssignments) {
             while ($managerUserGroupAssignment = $managerUserGroupAssignments->next()) {
                 $managerUserGroup = $userGroupDao->getById($managerUserGroupAssignment->getUserGroupId());
                 $userGroupNames[$managerUserGroup->getId()] = $managerUserGroup->getLocalizedName();
             }
         }
         $templateMgr->assign('authorUserGroupOptions', $userGroupNames);
     }
     return parent::fetch($request);
 }
 /**
  * Constructor.
  * @param $context Context
  * @param $submission Submission
  */
 function PKPSubmissionSubmitStep2Form($context, $submission)
 {
     parent::SubmissionSubmitForm($context, $submission, 2);
 }
 /**
  * Constructor.
  */
 function SubmissionSubmitStep2Form($monograph)
 {
     parent::SubmissionSubmitForm($monograph, 2);
 }
 /**
  * Save changes to submission.
  * @param $args array
  * @param $request PKPRequest
  * @return int the submission ID
  */
 function execute($args, $request)
 {
     // Execute submission metadata related operations.
     $this->_metadataFormImplem->execute($this->submission, $request);
     // Get an updated version of the submission.
     $submissionDao = Application::getSubmissionDAO();
     $submission = $submissionDao->getById($this->submissionId);
     // Set other submission data.
     if ($submission->getSubmissionProgress() <= $this->step) {
         $submission->setSubmissionProgress($this->step + 1);
         $submission->stampStatusModified();
     }
     parent::execute($submission);
     // Save the submission.
     $submissionDao->updateObject($submission);
     return $this->submissionId;
 }
 /**
  * Display the form
  */
 function display($request)
 {
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('isEditedVolume', $this->monograph->getWorkType() == WORK_TYPE_EDITED_VOLUME);
     return parent::display($request);
 }
 /**
  * Save changes to submission.
  * @param $args array
  * @param $request PKPRequest
  * @return int the submission ID
  */
 function execute($args, $request)
 {
     $submissionDao = Application::getSubmissionDAO();
     // Set other submission data.
     if ($this->submission->getSubmissionProgress() <= $this->step) {
         $this->submission->setDateSubmitted(Core::getCurrentDate());
         $this->submission->stampStatusModified();
         $this->submission->setSubmissionProgress(0);
     }
     parent::execute($this->submission);
     // Save the submission.
     $submissionDao->updateObject($this->submission);
     // Assign the default stage participants.
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     // Assistant roles -- For each assistant role user group assigned to this
     //  stage in setup, iff there is only one user for the group,
     //  automatically assign the user to the stage
     // But skip authors and reviewers, since these are very submission specific
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $submissionStageGroups = $userGroupDao->getUserGroupsByStage($this->submission->getContextId(), WORKFLOW_STAGE_ID_SUBMISSION, true, true);
     $managerFound = false;
     while ($userGroup = $submissionStageGroups->next()) {
         $users = $userGroupDao->getUsersById($userGroup->getId(), $this->submission->getContextId());
         if ($users->getCount() == 1) {
             $user = $users->next();
             $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $user->getId());
             if ($userGroup->getRoleId() == ROLE_ID_MANAGER) {
                 $managerFound = true;
             }
         }
     }
     // Author roles
     // Assign only the submitter in whatever ROLE_ID_AUTHOR capacity they were assigned previously
     $user = $request->getUser();
     $submitterAssignments = $stageAssignmentDao->getBySubmissionAndStageId($this->submission->getId(), null, null, $user->getId());
     while ($assignment = $submitterAssignments->next()) {
         $userGroup = $userGroupDao->getById($assignment->getUserGroupId());
         if ($userGroup->getRoleId() == ROLE_ID_AUTHOR) {
             $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $assignment->getUserId());
             // Only assign them once, since otherwise we'll one assignment for each previous stage.
             // And as long as they are assigned once, they will get access to their submission.
             break;
         }
     }
     $notificationManager = new NotificationManager();
     // Assign sub editors for that section
     $submissionSubEditorFound = false;
     $subEditorsDao = DAORegistry::getDAO('SubEditorsDAO');
     $subEditors = $subEditorsDao->getBySectionId($this->submission->getSectionId(), $this->submission->getContextId());
     foreach ($subEditors as $subEditor) {
         $userGroups = $userGroupDao->getByUserId($subEditor->getId(), $this->submission->getContextId());
         while ($userGroup = $userGroups->next()) {
             if ($userGroup->getRoleId() != ROLE_ID_SUB_EDITOR) {
                 continue;
             }
             $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $subEditor->getId());
             // If we assign a stage assignment in the Submission stage to a sub editor, make note.
             if ($userGroupDao->userGroupAssignedToStage($userGroup->getId(), WORKFLOW_STAGE_ID_SUBMISSION)) {
                 $submissionSubEditorFound = true;
             }
         }
     }
     // Update assignment notifications
     import('classes.workflow.EditorDecisionActionsManager');
     $notificationManager->updateNotification($request, EditorDecisionActionsManager::getStageNotifications(), null, ASSOC_TYPE_SUBMISSION, $this->submission->getId());
     // Send a notification to associated users if an editor needs assigning
     if (!$managerFound && !$submissionSubEditorFound) {
         $roleDao = DAORegistry::getDAO('RoleDAO');
         /* @var $roleDao RoleDAO */
         // Get the managers.
         $managers = $roleDao->getUsersByRoleId(ROLE_ID_MANAGER, $this->submission->getContextId());
         $managersArray = $managers->toAssociativeArray();
         $allUserIds = array_keys($managersArray);
         foreach ($allUserIds as $userId) {
             $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_SUBMISSION_SUBMITTED, $this->submission->getContextId(), ASSOC_TYPE_SUBMISSION, $this->submission->getId());
             // Add TASK notification indicating that a submission is unassigned
             $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED, $this->submission->getContextId(), ASSOC_TYPE_SUBMISSION, $this->submission->getId(), NOTIFICATION_LEVEL_TASK);
         }
     }
     $notificationManager->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_SUBMISSION, $this->submission->getId());
     return $this->submissionId;
 }
 /**
  * Constructor.
  * @param $context Context
  * @param $submission Submission
  */
 function __construct($context, $submission)
 {
     parent::__construct($context, $submission, 2);
 }
 /**
  * Initialize form data from current submission.
  */
 function initData()
 {
     $this->_metadataFormImplem->initData($this->submission);
     return parent::initData();
 }