4 * @defgroup manager_form
8 * @file classes/manager/form/AnnouncementForm.inc.php
10 * Copyright (c) 2003-2009 John Willinsky
11 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
13 * @class AnnouncementForm
14 * @ingroup manager_form
16 * @brief Form for press managers to create/edit announcements.
19 // $Id: AnnouncementForm.inc.php,v 1.2 2009/10/07 00:36:11 asmecher Exp $
21 import('manager.form.PKPAnnouncementForm');
23 class AnnouncementForm
extends PKPAnnouncementForm
{
26 * @param announcementId int leave as default for new announcement
28 function AnnouncementForm($announcementId = null) {
29 parent
::PKPAnnouncementForm($announcementId);
30 $press =& Request
::getPress();
32 // If provided, announcement type is valid
33 $this->addCheck(new FormValidatorCustom($this, 'typeId', 'optional', 'manager.announcements.form.typeIdValid', create_function('$typeId, $pressId', '$announcementTypeDao =& DAORegistry::getDAO(\'AnnouncementTypeDAO\'); return $announcementTypeDao->announcementTypeExistsByTypeId($typeId, ASSOC_TYPE_PRESS, $pressId);'), array($press->getId())));
40 $templateMgr =& TemplateManager
::getManager();
41 $templateMgr->assign('helpTopicId', 'press.managementPages.announcements');
45 function _getAnnouncementTypesAssocId() {
46 $press =& Request
::getPress();
47 return array(ASSOC_TYPE_PRESS
, $press->getId());
51 * Helper function to assign the AssocType and the AssocId
52 * @param Announcement the announcement to be modified
54 function _setAnnouncementAssocId(&$announcement) {
55 $press =& Request
::getPress();
56 $announcement->setAssocType(ASSOC_TYPE_PRESS
);
57 $announcement->setAssocId($press->getId());
65 $press =& Request
::getPress();
66 $pressId = $press->getId();
68 // Send a notification to associated users
69 import('notification.Notification');
70 $roleDao =& DAORegistry
::getDAO('RoleDAO');
71 $notificationUsers = array();
72 $allUsers = $roleDao->getUsersByPressId($pressId);
73 while (!$allUsers->eof()) {
74 $user =& $allUsers->next();
75 $notificationUsers[] = array('id' => $user->getId());
78 $url = Request
::url(null, 'announcement', 'view', array(1));
79 foreach ($notificationUsers as $userRole) {
80 Notification
::createNotification($userRole['id'], "notification.type.newAnnouncement",
81 null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT
);
83 $notificationDao =& DAORegistry
::getDAO('NotificationDAO');
84 $notificationDao->sendToMailingList(Notification
::createNotification(0, "notification.type.newAnnouncement",
85 null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT
));