Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
NotificationSettingsForm.inc.php
1 <?php
2 
17 import('lib.pkp.classes.notification.form.PKPNotificationSettingsForm');
18 
24  parent::PKPNotificationSettingsForm();
25  }
26 
30  function readInputData() {
31  $userVars = array();
32  foreach($this->_getNotificationSettingsMap() as $notificationSetting) {
33  $userVars[] = $notificationSetting['settingName'];
34  $userVars[] = $notificationSetting['emailSettingName'];
35  }
36 
37  $this->readUserVars($userVars);
38  }
39 
45  return array(
46  NOTIFICATION_TYPE_SUBMISSION_SUBMITTED => array('settingName' => 'notificationMonographSubmitted',
47  'emailSettingName' => 'emailNotificationMonographSubmitted',
48  'settingKey' => 'notification.type.submissionSubmitted'),
49  NOTIFICATION_TYPE_METADATA_MODIFIED => array('settingName' => 'notificationMetadataModified',
50  'emailSettingName' => 'emailNotificationMetadataModified',
51  'settingKey' => 'notification.type.metadataModified'),
52  NOTIFICATION_TYPE_REVIEWER_COMMENT => array('settingName' => 'notificationReviewerComment',
53  'emailSettingName' => 'emailNotificationReviewerComment',
54  'settingKey' => 'notification.type.reviewerComment')
55  );
56  }
57 
64  return array(
65  array('categoryKey' => 'notification.type.submissions',
66  'settings' => array(NOTIFICATION_TYPE_SUBMISSION_SUBMITTED, NOTIFICATION_TYPE_METADATA_MODIFIED)),
67  array('categoryKey' => 'notification.type.reviewing',
68  'settings' => array(NOTIFICATION_TYPE_REVIEWER_COMMENT))
69  );
70  }
71 
72  /*
73  * Display the form
74  */
75  function display($request) {
76  $templateMgr = TemplateManager::getManager($request);
77  $templateMgr->assign('notificationSettingCategories', $this->_getNotificationSettingCategories());
78  $templateMgr->assign('notificationSettings', $this->_getNotificationSettingsMap());
79  return parent::display($request);
80  }
81 
85  function execute($request) {
86  $user = $request->getUser();
87  $userId = $user->getId();
88  $press = $request->getPress();
89 
90  $blockedNotifications = array();
91  $emailSettings = array();
92  foreach($this->_getNotificationSettingsMap() as $settingId => $notificationSetting) {
93  // Get notifications that the user wants blocked
94  if(!$this->getData($notificationSetting['settingName'])) $blockedNotifications[] = $settingId;
95  // Get notifications that the user wants to be notified of by email
96  if($this->getData($notificationSetting['emailSettingName'])) $emailSettings[] = $settingId;
97  }
98 
99  $notificationSubscriptionSettingsDao = DAORegistry::getDAO('NotificationSubscriptionSettingsDAO');
100  $notificationSubscriptionSettingsDao->updateNotificationSubscriptionSettings('blocked_notification', $blockedNotifications, $userId, $press->getId());
101  $notificationSubscriptionSettingsDao->updateNotificationSubscriptionSettings('emailed_notification', $emailSettings, $userId, $press->getId());
102 
103  return true;
104  }
105 
106 
107 }
108 
109 ?>
static & getDAO($name, $dbconn=null)
readUserVars($vars)
Definition: Form.inc.php:364
getData($key)
Definition: Form.inc.php:210
Form to edit notification settings.
Form to edit notification settings.