4 * @file ManagerHandler.inc.php
6 * Copyright (c) 2003-2008 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9 * @class ManagerHandler
10 * @ingroup pages_manager
12 * @brief Handle requests for press management functions.
15 // $Id: ManagerHandler.inc.php,v 1.11 2009/09/22 19:22:10 asmecher Exp $
18 import('handler.Handler');
20 class ManagerHandler
extends Handler
{
24 function ManagerHandler() {
27 $this->addCheck(new HandlerValidatorPress($this));
28 $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_SITE_ADMIN
, ROLE_ID_PRESS_MANAGER
)));
32 * Display press management index page.
36 $this->setupTemplate();
38 $press =& Request
::getPress();
39 $pressSettingsDao =& DAORegistry
::getDAO('PressSettingsDAO');
40 $announcementsEnabled = $pressSettingsDao->getSetting($press->getId(), 'enableAnnouncements');
41 $customSignoffInternal = $pressSettingsDao->getSetting($press->getId(), 'useCustomInternalReviewSignoff');
42 $customSignoffExternal = $pressSettingsDao->getSetting($press->getId(), 'useCustomExternalReviewSignoff');
44 $templateMgr =& TemplateManager
::getManager();
45 $templateMgr->assign('customSingoffEnabled', $customSignoffInternal ||
$customSignoffExternal );
47 $session =& Request
::getSession();
48 $session->unsetSessionVar('enrolmentReferrer');
50 $templateMgr->assign('announcementsEnabled', $announcementsEnabled);
51 $templateMgr->assign('helpTopicId','press.index');
52 $templateMgr->display('manager/index.tpl');
56 * Send an email to a user or group of users.
58 function email($args) {
61 $this->setupTemplate(true);
62 $templateMgr =& TemplateManager
::getManager();
63 $templateMgr->assign('helpTopicId', 'press.users.emailUsers');
65 $userDao =& DAORegistry
::getDAO('UserDAO');
67 $site =& Request
::getSite();
68 $press =& Request
::getPress();
69 $user =& Request
::getUser();
71 import('mail.MailTemplate');
72 $email = new MailTemplate(Request
::getUserVar('template'), Request
::getUserVar('locale'));
74 if (Request
::getUserVar('send') && !$email->hasErrors()) {
76 Request
::redirect(null, Request
::getRequestedPage());
78 $email->assignParams(); // FIXME Forces default parameters to be assigned (should do this automatically in MailTemplate?)
79 if (!Request
::getUserVar('continued')) {
80 if (($groupId = Request
::getUserVar('toGroup')) != '') {
81 // Special case for emailing entire groups:
82 // Check for a group ID and add recipients.
83 $groupDao =& DAORegistry
::getDAO('GroupDAO');
84 $group =& $groupDao->getGroup($groupId);
85 if ($group && $group->getPressId() == $press->getId()) {
86 $groupMembershipDao =& DAORegistry
::getDAO('GroupMembershipDAO');
87 $memberships =& $groupMembershipDao->getMemberships($group->getId());
88 $memberships =& $memberships->toArray();
89 foreach ($memberships as $membership) {
90 $user =& $membership->getUser();
91 $email->addRecipient($user->getEmail(), $user->getFullName());
95 if (count($email->getRecipients())==0) $email->addRecipient($user->getEmail(), $user->getFullName());
97 $email->displayEditForm(Request
::url(null, null, 'email'), array(), 'manager/people/email.tpl');
102 * Setup common template variables.
103 * @param $subclass boolean set to true if caller is below this handler in the hierarchy
105 function setupTemplate($subclass = false) {
106 parent
::setupTemplate();
107 Locale
::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER
, LOCALE_COMPONENT_OMP_MANAGER
));
109 $templateMgr =& TemplateManager
::getManager();
110 $templateMgr->assign('pageHierarchy',
111 $subclass ?
array(array(Request
::url(null, 'user'), 'navigation.user'), array(Request
::url(null, 'manager'), 'manager.pressManagement'))
112 : array(array(Request
::url(null, 'user'), 'navigation.user'))