PKPStageParticipantNotifyForm::fetch PHP Method

fetch() public method

public fetch ( $request )
    function fetch($request)
    {
        $submissionDao = Application::getSubmissionDAO();
        $submission = $submissionDao->getById($this->_submissionId);
        // All stages can choose the default template
        $templateKeys = array('NOTIFICATION_CENTER_DEFAULT');
        // Determine if the current user can use any custom templates defined.
        $user = $request->getUser();
        $roleDao = DAORegistry::getDAO('RoleDAO');
        $userRoles = $roleDao->getByUserId($user->getId(), $submission->getContextId());
        foreach ($userRoles as $userRole) {
            if (in_array($userRole->getId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) {
                $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO');
                $customTemplates = $emailTemplateDao->getCustomTemplateKeys(Application::getContextAssocType(), $submission->getContextId());
                $templateKeys = array_merge($templateKeys, $customTemplates);
                break;
            }
        }
        $stageTemplates = $this->_getStageTemplates();
        $currentStageId = $this->getStageId();
        if (array_key_exists($currentStageId, $stageTemplates)) {
            $templateKeys = array_merge($templateKeys, $stageTemplates[$currentStageId]);
        }
        foreach ($templateKeys as $templateKey) {
            $template = $this->_getMailTemplate($submission, $templateKey);
            $template->assignParams(array());
            $template->replaceParams();
            $templates[$templateKey] = $template->getSubject();
        }
        $templateMgr = TemplateManager::getManager($request);
        $templateMgr->assign(array('templates' => $templates, 'stageId' => $currentStageId, 'includeNotifyUsersListbuilder' => $this->includeNotifyUsersListbuilder(), 'submissionId' => $this->_submissionId, 'itemId' => $this->_itemId, 'userId' => (int) $request->getUserVar('userId')));
        return parent::fetch($request);
    }