00001 <?php
00002
00019
00020
00021 import('manager.form.PKPAnnouncementForm');
00022
00023 class AnnouncementForm extends PKPAnnouncementForm {
00028 function AnnouncementForm($announcementId = null) {
00029 parent::PKPAnnouncementForm($announcementId);
00030
00031 $conference =& Request::getConference();
00032
00033
00034 $this->addCheck(new FormValidatorCustom($this, 'typeId', 'optional', 'manager.announcements.form.typeIdValid', create_function('$typeId, $conferenceId', '$announcementTypeDao =& DAORegistry::getDAO(\'AnnouncementTypeDAO\'); return $announcementTypeDao->announcementTypeExistsByTypeId($typeId, ASSOC_TYPE_CONFERENCE, $conferenceId);'), array($conference->getId())));
00035
00036
00037 $this->addCheck(new FormValidatorCustom($this, 'schedConfId', 'required', 'manager.announcements.form.schedConfIdValid', create_function('$schedConfId, $conferenceId', 'if ($schedConfId == 0) return true; $schedConfDao =& DAORegistry::getDAO(\'SchedConfDAO\'); $schedConf =& $schedConfDao->getSchedConf($schedConfId); if(!$schedConf) return false; return ($schedConf->getConferenceId() == $conferenceId);'), array($conference->getId())));
00038 }
00039
00043 function display() {
00044 $templateMgr =& TemplateManager::getManager();
00045 $templateMgr->assign('helpTopicId', 'conference.generalManagement.announcements');
00046
00047 $conference =& Request::getConference();
00048 $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00049 $schedConfs =& $schedConfDao->getSchedConfsByConferenceId($conference->getId());
00050 $templateMgr->assign('schedConfs', $schedConfs);
00051
00052 parent::display();
00053 }
00054
00058 function initData() {
00059 parent::initData();
00060
00061 if (isset($this->announcementId)) {
00062 $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
00063 $announcement =& $announcementDao->getAnnouncement($this->announcementId);
00064
00065 if ($announcement != null) {
00066 $this->_data['schedConfId'] = ($announcement->getAssocType() == ASSOC_TYPE_SCHED_CONF)?$announcement->getAssocId():null;
00067 }
00068 }
00069 }
00070
00074 function readInputData() {
00075 parent::readInputData();
00076 $this->readUserVars(array('schedConfId'));
00077 }
00078
00079 function _getAnnouncementTypesAssocId() {
00080 $conference =& Request::getConference();
00081 return array(ASSOC_TYPE_CONFERENCE, $conference->getId());
00082 }
00083
00088 function _setAnnouncementAssocId(&$announcement) {
00089 if ($this->getData('schedConfId') == 0) {
00090 $conference =& Request::getConference();
00091 $announcement->setAssocType(ASSOC_TYPE_CONFERENCE);
00092 $announcement->setAssocId($conference->getId());
00093 } else {
00094 $announcement->setAssocType(ASSOC_TYPE_SCHED_CONF);
00095 $announcement->setAssocId($this->getData('schedConfId'));
00096 }
00097 }
00098
00102 function execute() {
00103 parent::execute();
00104 $conference =& Request::getConference();
00105 $conferenceId = $conference->getId();
00106
00107
00108 import('notification.NotificationManager');
00109 $notificationManager = new NotificationManager();
00110 $roleDao =& DAORegistry::getDAO('RoleDAO');
00111 $notificationUsers = array();
00112 $allUsers = $roleDao->getUsersByConferenceId($conferenceId);
00113 while (!$allUsers->eof()) {
00114 $user =& $allUsers->next();
00115 $notificationUsers[] = array('id' => $user->getId());
00116 unset($user);
00117 }
00118
00119 $schedConfId = $this->getData('schedConfId');
00120 if ($schedConfId == 0) {
00121
00122 $url = Request::url(null, 'index', 'announcement', 'view', array(1));
00123 } else {
00124
00125 $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00126 $schedConf =& $schedConfDao->getSchedConf($schedConfId);
00127 $url = Request::url(null, $schedConf->getPath(), 'announcement', 'view', array(1));
00128 }
00129
00130 foreach ($notificationUsers as $userRole) {
00131 $notificationManager->createNotification(
00132 $userRole['id'], 'notification.type.newAnnouncement',
00133 null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT
00134 );
00135 }
00136 $notificationManager->sendToMailingList(
00137 $notificationManager->createNotification(
00138 0, 'notification.type.newAnnouncement',
00139 null, $url, 1, NOTIFICATION_TYPE_NEW_ANNOUNCEMENT
00140 )
00141 );
00142 }
00143 }
00144
00145 ?>