/** * @see Form::fetch() */ function fetch($request) { // Retrieve available monograph file genres. $genreList =& $this->_retrieveGenreList($request); $this->setData('monographFileGenres', $genreList); return parent::fetch($request); }
/** * @copydoc Form::fetch() */ function fetch($request) { // Retrieve available submission file genres. $genreList = $this->_retrieveGenreList($request); $this->setData('submissionFileGenres', $genreList); // Retrieve the current context. $router = $request->getRouter(); $context = $router->getContext($request); assert(is_a($context, 'Context')); // Retrieve the user's user groups. $user = $request->getUser(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $assignedUserGroups = $userGroupDao->getByUserId($user->getId(), $context->getId()); // Check which of these groups make sense in the context // from which the uploader was instantiated. // FIXME: The sub editor role may only be displayed if the // user is assigned to the current submission as a sub // editor, see #6000. $uploaderRoles = $this->getUploaderRoles(); $uploaderUserGroups = $this->getUploaderGroupIds(); $uploaderUserGroupOptions = array(); $highestAuthorityUserGroupId = null; $highestAuthorityRoleId = null; while ($userGroup = $assignedUserGroups->next()) { /* @var $userGroup UserGroup */ // Exclude groups outside of the uploader roles. if (!in_array($userGroup->getRoleId(), $uploaderRoles)) { continue; } // If a specific subset of user groups was specified // and the current one is outside the set, exclude it. if ($uploaderUserGroups !== null && !in_array($userGroup->getId(), $uploaderUserGroups)) { continue; } $uploaderUserGroupOptions[$userGroup->getId()] = $userGroup->getLocalizedName(); // Identify the first of the user groups that belongs // to the role with the lowest role id (=highest authority // level). We'll need this information to identify the default // selection, see below. if (is_null($highestAuthorityUserGroupId) || $userGroup->getRoleId() <= $highestAuthorityRoleId) { $highestAuthorityRoleId = $userGroup->getRoleId(); if (is_null($highestAuthorityUserGroupId) || $userGroup->getId() < $highestAuthorityUserGroupId) { $highestAuthorityUserGroupId = $userGroup->getId(); } } } if (empty($uploaderUserGroupOptions)) { fatalError('Invalid uploader roles!'); } $this->setData('uploaderUserGroupOptions', $uploaderUserGroupOptions); // Identify the default user group (only required when there is // more than one group). $defaultUserGroupId = null; if (count($uploaderUserGroupOptions) > 1) { // See whether the current user has been assigned as // a workflow stage participant. $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($this->getData('submissionId'), $this->getStageId(), null, $user->getId()); while ($stageAssignment = $stageAssignments->next()) { if (isset($uploaderUserGroupOptions[$stageAssignment->getUserGroupId()])) { $defaultUserGroupId = $stageAssignment->getUserGroupId(); break; } } // If we didn't find a corresponding stage assignment then // use the user group with the highest authority as default. if (is_null($defaultUserGroupId)) { $defaultUserGroupId = $highestAuthorityUserGroupId; } } $this->setData('defaultUserGroupId', $defaultUserGroupId); return parent::fetch($request); }
/** * @see Form::fetch() */ function fetch($request) { // Retrieve available monograph file genres. $genreList =& $this->_retrieveGenreList($request); $this->setData('monographFileGenres', $genreList); // Retrieve the current context. $router =& $request->getRouter(); $context =& $router->getContext($request); assert(is_a($context, 'Press')); // Retrieve the user's user groups. $user =& $request->getUser(); $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $assignedUserGroups =& $userGroupDao->getByUserId($user->getId(), $context->getId()); // Check which of these groups make sense in the context // from which the uploader was instantiated. // FIXME: The series editor role may only be displayed if the user // is assigned to the current submission as a series editor, see #6000. $uploaderRoles = $this->getUploaderRoles(); $uploaderUserGroups = array(); $highestAuthorityUserGroupId = null; while ($userGroup =& $assignedUserGroups->next()) { /* @var $userGroup UserGroup */ // Add all user groups that belong to any of the uploader roles. if (in_array($userGroup->getRoleId(), $uploaderRoles)) { $uploaderUserGroups[$userGroup->getId()] = $userGroup->getLocalizedName(); // Identify the first of the user groups that belongs // to the role with the lowest role id (=highest authority // level). We'll need this information to identify the default // selection, see below. if (is_null($highestAuthorityUserGroupId) || $userGroup->getRoleId() <= $highestAuthorityRoleId) { $highestAuthorityRoleId = $userGroup->getRoleId(); if (is_null($highestAuthorityUserGroupId) || $userGroup->getId() < $highestAuthorityUserGroupId) { $highestAuthorityUserGroupId = $userGroup->getId(); } } } unset($userGroup); } if (empty($uploaderUserGroups)) { fatalError('Invalid uploader roles!'); } $this->setData('uploaderUserGroups', $uploaderUserGroups); // Identify the default user group (only required when there is // more than one group). $defaultUserGroupId = null; if (count($uploaderUserGroups) > 1) { // See whether the current user has been assigned as // a workflow stage participant. $stageId = $this->getStageId(); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */ $stageSignoffs =& $signoffDao->getAllBySymbolic('SIGNOFF_STAGE', ASSOC_TYPE_MONOGRAPH, $this->getData('monographId'), $user->getId(), $stageId); while ($stageSignoff =& $stageSignoffs->next()) { /* @var $stageSignoff Signoff */ if (isset($uploaderUserGroups[$stageSignoff->getUserGroupId()])) { $defaultUserGroupId = $stageSignoff->getUserGroupId(); break; } } // If we didn't find a corresponding stage signoff then // use the user group with the highest authority as default. if (is_null($defaultUserGroupId)) { $defaultUserGroupId = $highestAuthorityUserGroupId; } } $this->setData('defaultUserGroupId', $defaultUserGroupId); return parent::fetch($request); }