• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/notification/form/NotificationSettingsForm.inc.php

00001 <?php
00019 import('lib.pkp.classes.notification.form.PKPNotificationSettingsForm');
00020 
00021 class NotificationSettingsForm extends PKPNotificationSettingsForm {
00025    function NotificationSettingsForm() {
00026       parent::PKPNotificationSettingsForm();
00027    }
00028 
00032    function readInputData() {
00033       $userVars = array();
00034       foreach($this->_getNotificationSettingsMap() as $notificationSetting) {
00035          $userVars[] = $notificationSetting['settingName'];
00036          $userVars[] = $notificationSetting['emailSettingName'];
00037       }
00038 
00039       $this->readUserVars($userVars);
00040    }
00041 
00046    function _getNotificationSettingsMap() {
00047       return array(
00048          NOTIFICATION_TYPE_MONOGRAPH_SUBMITTED => array('settingName' => 'notificationMonographSubmitted',
00049             'emailSettingName' => 'emailNotificationMonographSubmitted',
00050             'settingKey' => 'notification.type.monographSubmitted'),
00051          NOTIFICATION_TYPE_METADATA_MODIFIED => array('settingName' => 'notificationMetadataModified',
00052             'emailSettingName' => 'emailNotificationMetadataModified',
00053             'settingKey' => 'notification.type.metadataModified'),
00054          NOTIFICATION_TYPE_REVIEWER_COMMENT => array('settingName' => 'notificationReviewerComment',
00055             'emailSettingName' => 'emailNotificationReviewerComment',
00056             'settingKey' => 'notification.type.reviewerComment')
00057       );
00058    }
00059 
00065    function _getNotificationSettingCategories() {
00066       return array(
00067          array('categoryKey' => 'notification.type.submissions',
00068             'settings' => array(NOTIFICATION_TYPE_MONOGRAPH_SUBMITTED, NOTIFICATION_TYPE_METADATA_MODIFIED)),
00069          array('categoryKey' => 'notification.type.reviewing',
00070             'settings' => array(NOTIFICATION_TYPE_REVIEWER_COMMENT))
00071       );
00072    }
00073 
00074    /*
00075     * Display the form
00076     */
00077    function display(&$request) {
00078       $templateMgr =& TemplateManager::getManager();
00079       $templateMgr->assign('notificationSettingCategories', $this->_getNotificationSettingCategories());
00080       $templateMgr->assign('notificationSettings',  $this->_getNotificationSettingsMap());
00081       return parent::display($request);
00082    }
00083 
00087    function execute(&$request) {
00088       $user = $request->getUser();
00089       $userId = $user->getId();
00090       $press =& $request->getPress();
00091 
00092       $blockedNotifications = array();
00093       $emailSettings = array();
00094       foreach($this->_getNotificationSettingsMap() as $settingId => $notificationSetting) {
00095          // Get notifications that the user wants blocked
00096          if(!$this->getData($notificationSetting['settingName'])) $blockedNotifications[] = $settingId;
00097          // Get notifications that the user wants to be notified of by email
00098          if($this->getData($notificationSetting['emailSettingName'])) $emailSettings[] = $settingId;
00099       }
00100 
00101       $notificationSubscriptionSettingsDao =& DAORegistry::getDAO('NotificationSubscriptionSettingsDAO');
00102       $notificationSubscriptionSettingsDao->updateNotificationSubscriptionSettings('blocked_notification', $blockedNotifications, $userId, $press->getId());
00103       $notificationSubscriptionSettingsDao->updateNotificationSubscriptionSettings('emailed_notification', $emailSettings, $userId, $press->getId());
00104 
00105       return true;
00106    }
00107 
00108 
00109 }
00110 
00111 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1