View | Details | Raw Unified | Return to bug 3922 | Differences between
and this patch

Collapse All | Expand All

(-)classes/core/PKPApplication.inc.php (+2 lines)
 Lines 186-191    Link Here 
186
			'CurrencyDAO' => 'currency.CurrencyDAO',
186
			'CurrencyDAO' => 'currency.CurrencyDAO',
187
			'HelpTocDAO' => 'help.HelpTocDAO',
187
			'HelpTocDAO' => 'help.HelpTocDAO',
188
			'HelpTopicDAO' => 'help.HelpTopicDAO',
188
			'HelpTopicDAO' => 'help.HelpTopicDAO',
189
			'NotificationDAO' => 'notification.NotificationDAO',
190
			'NotificationSettingsDAO' => 'notification.NotificationSettingsDAO',
189
			'ScheduledTaskDAO' => 'scheduledTask.ScheduledTaskDAO',
191
			'ScheduledTaskDAO' => 'scheduledTask.ScheduledTaskDAO',
190
			'SessionDAO' => 'session.SessionDAO',
192
			'SessionDAO' => 'session.SessionDAO',
191
			'SiteDAO' => 'site.SiteDAO',
193
			'SiteDAO' => 'site.SiteDAO',
(-)classes/notification/Notification.inc.php (+306 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @file classes/notification/Notification.inc.php
5
 *
6
 * Copyright (c) 2003-2008 John Willinsky
7
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
 *
9
 * @class Notification
10
 * @ingroup notification
11
 * @see NotificationDAO
12
 * @brief Class for Notification.
13
 */
14
15
// $Id: Notification.inc.php,v 1.10 2008/07/01 01:16:09 asmecher Exp $
16
17
18
/** Notification associative types. */
19
// Submission Events				0x10000000
20
define('NOTIFICATION_TYPE_ARTICLE_SUBMITTED', 		0x1000001);
21
define('NOTIFICATION_TYPE_METADATA_MODIFIED', 		0x1000002);
22
define('NOTIFICATION_TYPE_SUPP_FILE_ADDED', 			0x1000003);
23
define('NOTIFICATION_TYPE_SUPP_FILE_MODIFIED', 		0x1000004);
24
define('NOTIFICATION_TYPE_GALLEY_ADDED', 				0x1000005);
25
define('NOTIFICATION_TYPE_GALLEY_MODIFIED', 			0x1000006);
26
define('NOTIFICATION_TYPE_SUBMISSION_COMMENT', 		0x1000007);
27
define('NOTIFICATION_TYPE_LAYOUT_COMMENT', 			0x1000008);
28
define('NOTIFICATION_TYPE_COPYEDIT_COMMENT', 			0x1000009);
29
define('NOTIFICATION_TYPE_PROOFREAD_COMMENT', 		0x1000010);
30
define('NOTIFICATION_TYPE_REVIEWER_COMMENT', 			0x1000011);
31
define('NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT', 	0x1000012);
32
define('NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT', 	0x1000013);
33
34
// Other events
35
define('NOTIFICATION_TYPE_USER_COMMENT', 				0x2000002);
36
define('NOTIFICATION_TYPE_PUBLISHED_ISSUE', 			0x2000003);
37
38
import('notification.NotificationDAO');
39
40
class Notification extends DataObject {
41
42
	/**
43
	 * Constructor.
44
	 */
45
	function Notification() {
46
		parent::DataObject();
47
	}
48
	
49
	/**
50
	 * Create a new notification with the specified arguments and insert into DB
51
	 * This is a static method
52
	 * @param $userId int
53
	 * @param $contents string
54
	 * @param $param string
55
	 * @param $location string
56
	 * @param $isLocalized bool
57
	 * @param $assocType int
58
	 * @param $assocId int
59
	 * @return Notification object
60
	 */
61
	function createNotification($userId, $contents, $param, $location, $isLocalized, $assocType, $assocId) {
62
		$notification = new Notification();
63
		$context =& Request::getContext();
64
		$contextId = $context->getId();
65
66
		$notification->setUserId($userId);
67
		$notification->setContents($contents);
68
		$notification->setParam($param);
69
		$notification->setLocation($location);
70
		$notification->setIsLocalized($isLocalized);
71
		$notification->setAssocType($assocType);
72
		$notification->setContext($contextId);
73
		
74
		$notificationDao = &DAORegistry::getDAO('NotificationDAO');
75
		$notificationDao->insertNotification($notification);
76
		
77
		return $notification;
78
	}
79
80
	/**
81
	 * get notification id
82
	 * @return int
83
	 */
84
	function getNotificationId() {
85
		return $this->getData('notificationId');
86
	}
87
88
	/**
89
	 * set notification id
90
	 * @param $commentId int
91
	 */
92
	function setNotificationId($notificationId) {
93
		return $this->setData('notificationId', $notificationId);
94
	}
95
	
96
	/**
97
	 * get user id associated with this notification
98
	 * @return int
99
	 */
100
	function getUserId() {
101
		return $this->getData('userId');
102
	}
103
	
104
	/**
105
	 * set user id associated with this notification
106
	 * @param $userId int
107
	 */
108
	function setUserId($userId) {
109
		return $this->setData('userId', $userId);
110
	}
111
	
112
	/**
113
	 * get date notification was created
114
	 * @return date (YYYY-MM-DD HH:MM:SS)
115
	 */
116
	function getDateCreated() {
117
		return $this->getData('dateCreated');
118
	}
119
	
120
	/**
121
	 * set date notification was created
122
	 * @param $dateCreated date (YYYY-MM-DD HH:MM:SS)
123
	 */
124
	function setDateCreated($dateCreated) {
125
		return $this->setData('dateCreated', $dateCreated);
126
	}
127
	
128
	/**
129
	 * get date notification is read by user
130
	 * @return date (YYYY-MM-DD HH:MM:SS)
131
	 */
132
	function getDateRead() {
133
		return $this->getData('dateRead');
134
	}
135
	
136
	/**
137
	 * set date notification is read by user
138
	 * Also sets setisUnread() if $dateRead is null
139
	 * @param $dateRead date (YYYY-MM-DD HH:MM:SS)
140
	 */
141
	function setDateRead($dateRead) {
142
		if(!isset($dateRead)) {
143
			$this->setIsUnread(true);
144
			$notificationDao = &DAORegistry::getDAO('NotificationDAO');
145
			$notificationDao->setDateRead($this->getNotificationId());
146
		} else {
147
			$this->setIsUnread(false);
148
			return $this->setData('dateRead', $dateRead);	
149
		}
150
	}
151
	
152
	/**
153
	 * return true if reading for the first time
154
	 * @return bool
155
	 */
156
	function getIsUnread() {
157
		return $this->getData('isUnread');
158
	}
159
	
160
	/**
161
	 * set to true if notification has not been read
162
	 * @param $isUnread bool
163
	 */
164
	function setIsUnread($isUnread) {
165
		return $this->setData('isUnread', $isUnread);
166
	}
167
	
168
	/**
169
	 * get notification contents
170
	 * @return string
171
	 */
172
	function getContents() {
173
		return $this->getData('contents');
174
	}
175
	
176
	/**
177
	 * set notification contents
178
	 * @param $contents int
179
	 */
180
	function setContents($contents) {
181
		return $this->setData('contents', $contents);
182
	}
183
	
184
	/**
185
	 * get optional parameter (e.g. article title)
186
	 * @return string
187
	 */
188
	function getParam() {
189
		return $this->getData('param');
190
	}
191
	
192
	/**
193
	 * set optional parameter
194
	 * @param $param int
195
	 */
196
	function setParam($param) {
197
		return $this->setData('param', $param);
198
	}
199
	
200
	/**
201
	 * get URL that notification refers to
202
	 * @return int
203
	 */
204
	function getLocation() {
205
		return $this->getData('location');
206
	}
207
	
208
	/**
209
	 * set URL that notification refers to
210
	 * @param $location int
211
	 */
212
	function setLocation($location) {
213
		return $this->setData('location', $location);
214
	}
215
	
216
	/**
217
	 * return true if message is localized (i.e. a system message)
218
	 * @return int
219
	 */
220
	function getIsLocalized() {
221
		return $this->getData('isLocalized');
222
	}
223
	
224
	/**
225
	 * set to true if message is localized (i.e. is a system message)
226
	 * @param $isLocalized int
227
	 */
228
	function setIsLocalized($isLocalized) {
229
		return $this->setData('isLocalized', $isLocalized);
230
	}
231
232
	/**
233
	 * get notification type
234
	 * @return int
235
	 */
236
	function getAssocType() {
237
		return $this->getData('assocType');
238
	}
239
240
	/**
241
	 * set notification type
242
	 * @param $assocType int
243
	 */
244
	function setAssocType($assocType) {
245
		return $this->setData('assocType', $assocType);
246
	}
247
	
248
	/**
249
	 * get context id
250
	 * @return int
251
	 */
252
	function getContext() {
253
		return $this->getData('context');
254
	}
255
	/**
256
	 * set context id
257
	 * @param $context int
258
	 */
259
	function setContext($context) {
260
		return $this->setData('context', $context);
261
	}	
262
	
263
	/**
264
	 * return the path to the icon for this type
265
	 * @return string
266
	 */
267
	function getIconLocation() {
268
		$baseUrl = Request::getBaseUrl() . '/lib/pkp/templates/images/icons/';
269
		switch ($this->getAssocType()) {
270
			case NOTIFICATION_TYPE_ARTICLE_SUBMITTED:
271
			case NOTIFICATION_TYPE_GALLEY_ADDED:
272
			case NOTIFICATION_TYPE_SUPP_FILE_ADDED:
273
				return $baseUrl . 'page_new.png';
274
				break;
275
			case NOTIFICATION_TYPE_SUPP_FILE_MODIFIED:
276
			case NOTIFICATION_TYPE_SUPP_FILE_ADDED:
277
				return $baseUrl . 'page_attachment.png';
278
				break;
279
			
280
			case NOTIFICATION_TYPE_METADATA_MODIFIED:
281
			case NOTIFICATION_TYPE_GALLEY_MODIFIED:
282
				return $baseUrl . 'edit.png';
283
				break;
284
			case NOTIFICATION_TYPE_SUBMISSION_COMMENT:
285
			case NOTIFICATION_TYPE_LAYOUT_COMMENT:
286
			case NOTIFICATION_TYPE_COPYEDIT_COMMENT:
287
			case NOTIFICATION_TYPE_PROOFREAD_COMMENT:
288
			case NOTIFICATION_TYPE_REVIEWER_COMMENT:
289
			case NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT:
290
			case NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT:
291
			case NOTIFICATION_TYPE_USER_COMMENT:
292
				return $baseUrl . 'comment_new.png';
293
				break;
294
			case NOTIFICATION_TYPE_PUBLISHED_ISSUE:
295
				return $baseUrl . 'list_world.png';
296
				break;
297
			default:
298
				return $baseUrl . 'page_alert.png';
299
		}
300
		
301
		
302
	}
303
304
 }
305
306
?>
(-)classes/notification/NotificationDAO.inc.php (+324 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @file classes/notification/NotificationDAO.inc.php
5
 *
6
 * Copyright (c) 2003-2008 John Willinsky
7
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
 *
9
 * @class NotificationDAO
10
 * @ingroup notification
11
 * @see Notification
12
 *
13
 * @brief Operations for retrieving and modifying Notification objects.
14
 */
15
16
// $Id: NotificationDAO.inc.php,v 1.19 2008/11/05 00:46:39 mcrider Exp $
17
18
import('notification.Notification');
19
20
class NotificationDAO extends DAO {
21
	/**
22
	 * Constructor.
23
	 */
24
	function NotificationDAO() {
25
		parent::DAO();
26
	}
27
	
28
	/**
29
	 * Retrieve Notification by notification id
30
	 * @param $notificationId int
31
	 * @return Notification object
32
	 */
33
	function &getNotificationById($notificationId) {
34
		$result = &$this->retrieve(
35
			'SELECT * FROM notifications WHERE notification_id = ?', $notificationId
36
		);
37
	
38
		$notification = &$this->_returnNotificationFromRow($result->GetRowAssoc(false));
39
	
40
		$result->Close();
41
		unset($result);
42
	
43
		return $notification;
44
	}	
45
	
46
	/**
47
	 * Retrieve Notifications by user id
48
	 * @param $userId int
49
	 * @return Notification objects array
50
	 */
51
	function &getNotificationsByUserId($userId) {
52
		$application =& PKPApplication::getApplication();
53
		$productName = $application->getName();
54
		$context =& Request::getContext();
55
		$contextId = $context->getId();
56
		
57
		$notifications = array();
58
	
59
		$result = &$this->retrieve(
60
			'SELECT * FROM notifications WHERE user_id = ? AND product = ? AND context = ? ORDER BY date_created DESC',	
61
			array($userId, $productName, $contextId)
62
		);
63
	
64
		$returner = new DAOResultFactory($result, $this, '_returnNotificationFromRow');
65
		
66
		return $returner;
67
	}
68
	
69
	/**
70
	 * Retrieve Notifications by notification id
71
	 * @param $notificationId int
72
	 * @return boolean
73
	 */
74
	function setDateRead($notificationId) {
75
		$returner = $this->update(
76
			sprintf('UPDATE notifications
77
				SET date_read = %s
78
				WHERE notification_id = ?',
79
				$this->datetimeToDB(date('Y-m-d H:i:s'))),
80
			array(
81
				$notificationId
82
			)
83
		);
84
85
		return $returner;
86
	}
87
	
88
	/**
89
	 * Creates and returns an notification object from a row
90
	 * @param $row array
91
	 * @return Notification object
92
	 */
93
	function &_returnNotificationFromRow($row) {
94
		$notification = new Notification();
95
		$notification->setNotificationId($row['notification_id']);
96
		$notification->setUserId($row['user_id']);
97
		$notification->setDateCreated($row['date_created']);
98
		$notification->setDateRead($row['date_read']);
99
		$notification->setContents($row['contents']);
100
		$notification->setParam($row['param']);
101
		$notification->setLocation($row['location']);
102
		$notification->setIsLocalized($row['is_localized']);
103
		$notification->setContext($row['context']);
104
		$notification->setAssocType($row['assoc_type']);
105
		
106
		HookRegistry::call('NotificationDAO::_returnNotificationFromRow', array(&$notification, &$row));
107
	
108
		return $notification;
109
	}
110
	
111
	/**
112
	 * Inserts a new notification into notifications table
113
	 * @param Notification object
114
	 * @return int Notification Id 
115
	 */
116
	function insertNotification(&$notification) {
117
		$application =& PKPApplication::getApplication();
118
		$productName = $application->getName();
119
		
120
		if ($this->notificationAlreadyExists($notification)) {
121
			return 0;
122
		}
123
		
124
		$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
125
		$notificationSettings = $notificationSettingsDao->getNotificationSettings($notification->getUserId());
126
		$notificationEmailSettings = $notificationSettingsDao->getNotificationEmailSettings($notification->getUserId());
127
		
128
		if(in_array($notification->getAssocType(), $notificationEmailSettings)) {
129
			$this->sendNotificationEmail($notification);
130
		}
131
		
132
		if(!in_array($notification->getAssocType(), $notificationSettings)) {
133
			$this->update(
134
				sprintf('INSERT INTO notifications
135
					(user_id, date_created, contents, param, location, is_localized, context, product, assoc_type)
136
					VALUES
137
					(?, %s, ?, ?, ?, ?, ?, ?, ?)',
138
					$this->datetimeToDB(date('Y-m-d H:i:s'))),
139
				array(
140
					$notification->getUserId(),
141
					$notification->getContents(),
142
					$notification->getParam(),
143
					$notification->getLocation(),
144
					$notification->getIsLocalized(),
145
					$notification->getContext(),
146
					$productName,
147
					$notification->getAssocType(),
148
				)
149
			);
150
		
151
			$notification->setNotificationId($this->getInsertNotificationId());
152
			return $notification->getNotificationId();
153
		} else return 0;
154
	}
155
	
156
	/**
157
	 * Delete Notification by notification id
158
	 * @param $notificationId int
159
	 * @return boolean
160
	 */
161
	function deleteNotificationById($notificationId, $userId = null) {
162
		return $this->update('DELETE FROM notifications WHERE notification_id = ?' . (isset($userId) ? ' AND user_id = ?' : ''), 
163
			isset($userId) ? array($notificationId, $userId) : $notificationId
164
		);
165
	}	
166
167
	/**
168
	 * Check if the same notification was added in the last hour
169
	 * Will prevent multiple notifications to show up in a user's feed e.g.
170
	 * if a user edits a submission multiple times in a short time span
171
	 * @param notification object
172
	 * @return boolean
173
	 */
174
	function notificationAlreadyExists(&$notification) {
175
		$application =& PKPApplication::getApplication();
176
		$productName = $application->getName();
177
		$context =& Request::getContext();
178
		$contextId = $context->getId();
179
			
180
		$result = &$this->retrieve(
181
			'SELECT date_created FROM notifications WHERE user_id = ? AND contents = ? AND product = ? AND assoc_type = ? AND context = ?',
182
			array(
183
					$notification->getUserId(),
184
					$notification->getContents(),
185
					$productName,
186
					$notification->getAssocType(),
187
					$contextId
188
				)
189
		);
190
		
191
		$date = isset($result->fields[0]) ? $result->fields[0] : 0;
192
		
193
		if ($date == 0) {
194
			return false;
195
		} else {
196
			$timeDiff = strtotime($date) - time();
197
			if ($timeDiff < 3600) { // 1 hour (in seconds)
198
				return true;
199
			} else return false;
200
		}
201
	}
202
203
	/**
204
	 * Get the ID of the last inserted notification
205
	 * @return int
206
	 */
207
	function getInsertNotificationId() {
208
		return $this->getInsertId('notifications', 'notification_id');
209
	}
210
	
211
	/**
212
	 * Get the number of unread messages for a user
213
	 * @param $userId int
214
	 * @return int
215
	 */
216
	function getUnreadNotificationCount($userId) {
217
		$application =& PKPApplication::getApplication();
218
		$productName = $application->getName();
219
		$context =& Request::getContext();
220
		$contextId = $context->getId();
221
		
222
		$result = &$this->retrieve(
223
			'SELECT count(*) FROM notifications WHERE user_id = ? AND date_read IS NULL AND product = ? AND context = ?',
224
			array($userId, $productName, $contextId)
225
		);
226
227
		$returner = $result->fields[0];
228
229
		$result->Close();
230
		unset($result);
231
232
		return $returner;
233
	}
234
	
235
	/**
236
	 * Get the number of read messages for a user
237
	 * @param $userId int
238
	 * @return int
239
	 */
240
	function getReadNotificationCount($userId) {
241
		$application =& PKPApplication::getApplication();
242
		$productName = $application->getName();
243
		$context =& Request::getContext();
244
		$contextId = $context->getId();
245
		
246
		$result = &$this->retrieve(
247
			'SELECT count(*) FROM notifications WHERE user_id = ? AND date_read IS NOT NULL AND product = ? AND context = ?',
248
			array($userId, $productName, $contextId)
249
		);
250
251
		$returner = $result->fields[0];
252
253
		$result->Close();
254
		unset($result);
255
256
		return $returner;
257
	}
258
259
	/**
260
	 * Send an email to a user regarding the notification
261
	 * @param $notification object Notification
262
	 */
263
	function sendNotificationEmail($notification) {
264
		$userId = $notification->getUserId();
265
		$userDao = &DAORegistry::getDAO('UserDAO');
266
		$user = $userDao->getUser($userId);
267
		
268
		if ($notification->getIsLocalized()) {
269
			$params = array('param' => $notification->getParam());
270
			$notificationContents = Locale::translate($notification->getContents(), $params);
271
		} else {
272
			$notificationContents = $notification->getContents();
273
		}
274
		
275
		import('mail.MailTemplate');
276
		$site = &Request::getSite();
277
		$mail = new MailTemplate('NOTIFICATION');
278
		$mail->setFrom($site->getSiteContactEmail(), $site->getSiteContactName());
279
		$mail->assignParams(array(
280
			'notificationContents' => $notificationContents,
281
			'url' => $notification->getLocation(),
282
			'siteTitle' => $site->getSiteTitle()
283
		));
284
		$mail->addRecipient($user->getEmail(), $user->getFullName());
285
		$mail->send();
286
	}	
287
	
288
	/**
289
	 * Send an update to all users on the mailing list
290
	 * @param $notification object Notification
291
	 */
292
	function sendToMailingList($notification) {
293
		$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
294
		$guestList = $notificationSettingsDao->getGuestList();
295
		
296
		foreach ($guestList as $email) {
297
			if ($notification->getIsLocalized()) {
298
				$params = array('param' => $notification->getParam());
299
				$notificationContents = Locale::translate($notification->getContents(), $params);
300
			} else {
301
				$notificationContents = $notification->getContents();
302
			}
303
			
304
			import('mail.MailTemplate');
305
			$journal = Request::getJournal();
306
			$site = &Request::getSite();
307
			
308
			$mail = new MailTemplate('NOTIFICATION_MAILLIST');
309
			$mail->setFrom($site->getSiteContactEmail(), $site->getSiteContactName());
310
			$mail->assignParams(array(
311
				'notificationContents' => $notificationContents,
312
				'url' => $notification->getLocation(),
313
				'siteTitle' => $journal->getJournalTitle(),
314
				'unsubscribeLink' => Request::url(null, 'notification', 'unsubscribeMailList')
315
			));
316
			$mail->addRecipient($email);
317
			$mail->send();
318
		}
319
		
320
		
321
	}	
322
}
323
324
?>
(-)classes/notification/NotificationSettingsDAO.inc.php (+431 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @file classes/notification/NotificationSettingsDAODAO.inc.php
5
 *
6
 * Copyright (c) 2003-2008 John Willinsky
7
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
 *
9
 * @class NotificationSettingsDAO
10
 * @ingroup notification
11
 * @see Notification
12
 *
13
 * @brief Operations for retrieving and modifying user's notification settings.
14
 */
15
16
// $Id: NotificationSettingsDAO.inc.php,v 1.19 2008/11/05 00:46:39 mcrider Exp $
17
18
class NotificationSettingsDAO extends DAO {
19
	/**
20
	 * Constructor.
21
	 */
22
	function NotificationSettingsDAO() {
23
		parent::DAO();
24
	}
25
	
26
	/**
27
	 * Retrieve Notifications settings by user id
28
	 * Returns an array of notification types that the user
29
	 * does NOT want to be notified of
30
	 * @param $userId int
31
	 * @return array
32
	 */
33
	function &getNotificationSettings($userId) {
34
		$application =& PKPApplication::getApplication();
35
		$productName = $application->getName();
36
		$context =& Request::getContext();
37
		$contextId = $context->getId();
38
		
39
		$notificationSettings = array();
40
	
41
		$result = &$this->retrieve(
42
			'SELECT setting_value FROM notification_settings WHERE user_id = ? AND product = ? AND setting_name = ? AND context = ?',
43
				array($userId, $productName, 'notify', $contextId)
44
		);
45
	
46
		while (!$result->EOF) {
47
			$row = $result->GetRowAssoc(false);
48
			$notificationSettings[] = (int) $row['setting_value'];
49
			$result->moveNext();
50
		}
51
52
		$result->Close();
53
		unset($result);
54
		
55
		return $notificationSettings;
56
	}
57
	
58
	/**
59
	 * Retrieve Notifications email settings by user id
60
	 * Returns an array of notification types that the user
61
	 * DOES want to be emailed about
62
	 * @param $userId int
63
	 * @return array
64
	 */
65
	function &getNotificationEmailSettings($userId) {
66
		$application =& PKPApplication::getApplication();
67
		$productName = $application->getName();
68
		$context =& Request::getContext();
69
		$contextId = $context->getId();
70
		
71
		$emailSettings = array();
72
	
73
		$result = &$this->retrieve(
74
			'SELECT setting_value FROM notification_settings WHERE user_id = ? AND product = ? AND setting_name = ? AND context = ?',
75
				array($userId, $productName, 'email', $contextId)
76
		);
77
	
78
		while (!$result->EOF) {
79
			$row = $result->GetRowAssoc(false);
80
			$emailSettings[] = (int) $row['setting_value'];
81
			$result->moveNext();
82
		}
83
84
		$result->Close();
85
		unset($result);
86
		
87
		return $emailSettings;
88
	}
89
	
90
	/**
91
	 * Update a user's notification settings
92
	 * @param $notificationSettings array
93
	 * @param $userId int
94
	 */
95
	function updateNotificationSettings($notificationSettings, $userId) {
96
		$application =& PKPApplication::getApplication();
97
		$productName = $application->getName();
98
		$context =& Request::getContext();
99
		$contextId = $context->getId();		
100
		
101
		// Delete old settings first, then insert new settings
102
		$this->update('DELETE FROM notification_settings WHERE user_id = ? AND product = ? AND setting_name = ? AND context = ?',
103
			array($userId, $productName, 'notify', $contextId));
104
	
105
		for ($i=0; $i<count($notificationSettings); $i++) {
106
			$this->update(
107
				'INSERT INTO notification_settings
108
					(setting_name, setting_value, user_id, product, context)
109
					VALUES
110
					(?, ?, ?, ?, ?)',
111
				array(
112
					"notify",
113
					$notificationSettings[$i],
114
					$userId,
115
					$productName,
116
					$contextId
117
				)
118
			);
119
		}
120
	}
121
	
122
	/**
123
	 * Update a user's notification email settings
124
	 * @param $notificationEmailSettings array
125
	 * @param $userId int
126
	 */
127
	function updateNotificationEmailSettings($emailSettings, $userId) {
128
		$application =& PKPApplication::getApplication();
129
		$productName = $application->getName();
130
		$context =& Request::getContext();
131
		$contextId = $context->getId();
132
		
133
		// Delete old settings first, then insert new settings
134
		$this->update('DELETE FROM notification_settings WHERE user_id = ? AND product = ? AND setting_name = ? AND context = ?',
135
			array($userId, $productName, 'email', $contextId));
136
	
137
		for ($i=0; $i<count($emailSettings); $i++) {
138
			$this->update(
139
				'INSERT INTO notification_settings
140
					(setting_name, setting_value, user_id, product, context)
141
					VALUES
142
					(?, ?, ?, ?, ?)',
143
				array(
144
					"email",
145
					$emailSettings[$i],
146
					$userId,
147
					$productName,
148
					$contextId
149
				)
150
			);
151
		}
152
	}
153
	
154
	/**
155
	 * Gets a user id by an RSS token value
156
	 * @param $token int
157
	 * @return int
158
	 */
159
	function getUserIdByRSSToken($token) {
160
		$application =& PKPApplication::getApplication();
161
		$productName = $application->getName();
162
		$context =& Request::getContext();
163
		$contextId = $context->getId();
164
	
165
		$result = &$this->retrieve(
166
			'SELECT user_id FROM notification_settings WHERE setting_value = ? AND setting_name = ? AND product = ? AND context = ?',
167
				array($token, 'token', $productName, $contextId)
168
		);
169
170
		$row = $result->GetRowAssoc(false);
171
		$userId = $row['user_id'];
172
173
		$result->Close();
174
		unset($result);
175
		
176
		return $userId;
177
	}
178
179
	/**
180
	 * Gets an RSS token for a user id
181
	 * @param $userId int
182
	 * @return int
183
	 */
184
	function getRSSTokenByUserId($userId) {
185
		$application =& PKPApplication::getApplication();
186
		$productName = $application->getName();
187
		$context =& Request::getContext();
188
		$contextId = $context->getId();
189
	
190
		$result = &$this->retrieve(
191
			'SELECT setting_value FROM notification_settings WHERE user_id = ? AND setting_name = ? AND product = ? AND context = ?',
192
				array($userId, 'token', $productName, $contextId)
193
		);
194
195
		$row = $result->GetRowAssoc(false);
196
		$userId = $row['setting_value'];
197
198
		$result->Close();
199
		unset($result);
200
		
201
		return $userId;
202
	}
203
204
	/**
205
	 * Generates and inserts a new token for a user's RSS feed
206
	 * @param $userId int
207
	 * @return int
208
	 */
209
	function insertNewRSSToken($userId) {
210
		$application =& PKPApplication::getApplication();
211
		$productName = $application->getName();
212
		$context =& Request::getContext();
213
		$contextId = $context->getId();
214
		
215
		$token = uniqid(rand());
216
	
217
		$this->update(
218
			'INSERT INTO notification_settings
219
				(setting_name, setting_value, user_id, product, context)
220
				VALUES
221
				(?, ?, ?, ?, ?)',
222
			array(
223
				'token',
224
				$token,
225
				$userId,
226
				$productName,
227
				$contextId
228
			)
229
		);
230
231
		return $token;
232
	}
233
	
234
	/**
235
	 * Generates an access key for the guest user and adds them to the settings table
236
	 * @param $userId int
237
	 * @return int
238
	 */
239
	function subscribeGuest($email) {
240
		$application =& PKPApplication::getApplication();
241
		$productName = $application->getName();
242
		$context =& Request::getContext();
243
		$contextId = $context->getId();
244
		
245
		
246
		// Check that the email doesn't already exist
247
		$result = &$this->retrieve(
248
			'SELECT * FROM notification_settings WHERE setting_name = ? AND setting_value = ? AND product = ? AND context = ?',
249
			array(
250
				'guestList',
251
				$email,
252
				$productName,
253
				$contextId
254
			)
255
		);
256
		
257
		if ($result->RecordCount() != 0) {
258
			return false;
259
		} else {		
260
			$this->update(
261
				'INSERT INTO notification_settings
262
					(setting_name, setting_value, user_id, product, context)
263
					VALUES
264
					(?, ?, ?, ?, ?)',
265
				array(
266
					'guestList',
267
					$email,
268
					0,
269
					$productName,
270
					$contextId
271
				)
272
			);
273
		}	
274
		
275
		// Get assoc_id into notification_settings table, also used as user_id for access key
276
		$assocId = $this->getInsertNotificationSettingId();
277
278
		import('security.AccessKeyManager');
279
		$accessKeyManager = new AccessKeyManager();
280
		
281
		$password = $accessKeyManager->createKey('MailListContext', $assocId, $assocId, 10000);
282
		return $password;
283
	}
284
	
285
	
286
	
287
	/**
288
	 * Removes an email address and associated access key from email notifications
289
	 * @param $email string
290
	 * @param $password string
291
	 * @return boolean
292
	 */
293
	function unsubscribeGuest($email, $password) {
294
		$application =& PKPApplication::getApplication();
295
		$productName = $application->getName();
296
		$context =& Request::getContext();
297
		$contextId = $context->getId();
298
		
299
		$result = &$this->retrieve(
300
			'SELECT setting_id FROM notification_settings WHERE setting_name = ? AND product = ? AND context = ?',
301
			array(
302
				'guestList',
303
				$productName,
304
				$contextId
305
			)
306
		);
307
308
		$row = $result->GetRowAssoc(false);
309
		$userId = $row['setting_id'];
310
311
		$result->Close();
312
		unset($result);
313
314
		import('security.AccessKeyManager');
315
		$accessKeyManager = new AccessKeyManager();
316
		$accessKeyHash = AccessKeyManager::generateKeyHash($password);
317
		$accessKey = $accessKeyManager->validateKey('MailListContext', $userId, $accessKeyHash);
318
319
		if ($accessKey) {
320
			$this->update(
321
				'DELETE FROM notification_settings WHERE setting_name = ? AND setting_value = ? AND product = ? AND context = ?',
322
				array(
323
					'guestList',
324
					$email,
325
					$productName,
326
					$contextId
327
				)
328
			);
329
			$accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
330
			$accessKeyDao->deleteAccessKey($accessKey);
331
			return true;
332
		} else return false;
333
		
334
		
335
	}
336
337
	/**
338
	 * Gets a list of email addresses of users subscribed to the mailing list
339
	 * @return array
340
	 */
341
	function getGuestList() {
342
		$application =& PKPApplication::getApplication();
343
		$productName = $application->getName();
344
		$context =& Request::getContext();
345
		$contextId = $context->getId();
346
		$guestList = array();
347
		
348
		$result = &$this->retrieve(
349
			'SELECT setting_value FROM notification_settings WHERE setting_name = ? AND product = ? AND context = ?',
350
			array(
351
				'guestList',
352
				$productName,
353
				$contextId
354
			)
355
		);
356
357
		while (!$result->EOF) {
358
			$row = $result->GetRowAssoc(false);
359
			$guestList[] = $row['setting_value'];
360
			$result->moveNext();
361
		}
362
363
		$result->Close();
364
		unset($result);
365
		
366
		return $guestList;
367
	}
368
369
	/**
370
	 * Generates and inserts a new password for a mailing list user
371
	 * @param $email string
372
	 * @return string
373
	 */
374
	function resetPassword($email) {
375
		$application =& PKPApplication::getApplication();
376
		$productName = $application->getName();
377
		$context =& Request::getContext();
378
		$contextId = $context->getId();
379
		
380
		$result = &$this->retrieve(
381
			'SELECT setting_id FROM notification_settings WHERE setting_name = ? AND setting_value = ? AND product = ? AND context = ?',
382
			array(
383
				'guestList',
384
				$email,
385
				$productName,
386
				$contextId
387
			)
388
		);
389
390
		$row = $result->GetRowAssoc(false);
391
		$settingId = $row['setting_id'];
392
393
		$result->Close();
394
		unset($result);
395
396
		$accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
397
		$accessKey = $accessKeyDao->getAccessKeyByUserId('MailListContext', $settingId);
398
399
		if ($accessKey) {
400
			$key = Validation::generatePassword();
401
			$accessKey->setKeyHash(md5($key));
402
			
403
			$accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
404
			$accessKeyDao->updateAccessKey($accessKey);
405
			return $key;
406
		} else return false;
407
	}
408
	
409
	
410
	
411
	
412
	
413
	
414
	
415
	
416
	
417
	
418
	
419
	
420
421
	/**
422
	 * Get the ID of the last inserted notification
423
	 * @return int
424
	 */
425
	function getInsertNotificationSettingId() {
426
		return $this->getInsertId('notification_settings', 'setting_id');
427
	}
428
429
}
430
431
?>
(-)classes/security/AccessKeyDAO.inc.php (-1 / +25 lines)
 Lines 41-46    Link Here 
41
		unset($result);
41
		unset($result);
42
		return $accessKey;
42
		return $accessKey;
43
	}
43
	}
44
	
45
	/**
46
	 * Retrieve a accessKey object user ID.
47
	 * @param $context string
48
	 * @param $userId int
49
	 * @return AccessKey
50
	 */
51
	function &getAccessKeyByUserId($context, $userId) {
52
		$result =& $this->retrieve(
53
			sprintf(
54
				'SELECT * FROM access_keys WHERE context = ? AND user_id = ? AND expiry_date > %s',
55
				$this->datetimeToDB(Core::getCurrentDate())
56
			),
57
			array($context, $userId)
58
		);
59
60
		$returner = null;
61
		if ($result->RecordCount() != 0) {
62
			$returner =& $this->_returnAccessKeyFromRow($result->GetRowAssoc(false));
63
		}
64
		$result->Close();
65
		unset($result);
66
		return $returner;
67
	}
44
68
45
	/**
69
	/**
46
	 * Retrieve a accessKey object by key.
70
	 * Retrieve a accessKey object by key.
 Lines 118-124    Link Here 
118
	 */
142
	 */
119
	function updateAccessKey(&$accessKey) {
143
	function updateAccessKey(&$accessKey) {
120
		return $this->update(
144
		return $this->update(
121
			sprintf('UPDATE accessKeys
145
			sprintf('UPDATE access_keys
122
				SET
146
				SET
123
					key_hash = ?,
147
					key_hash = ?,
124
					expiry_date = %s,
148
					expiry_date = %s,
(-)classes/template/PKPTemplateManager.inc.php (-2 / +2 lines)
 Lines 414-422    Link Here 
414
			if (isset($params['name'])) {
414
			if (isset($params['name'])) {
415
				// build image tag with standarized size of 16x16
415
				// build image tag with standarized size of 16x16
416
				$disabled = (isset($params['disabled']) && !empty($params['disabled']));
416
				$disabled = (isset($params['disabled']) && !empty($params['disabled']));
417
				if (!isset($params['path'])) $params['path'] = 'templates/images/icons/';
417
				if (!isset($params['path'])) $params['path'] = 'lib/pkp/templates/images/icons/';
418
				$iconHtml = '<img src="' . $smarty->get_template_vars('baseUrl') . '/' . $params['path'];
418
				$iconHtml = '<img src="' . $smarty->get_template_vars('baseUrl') . '/' . $params['path'];
419
				$iconHtml .= $params['name'] . ($disabled ? '_disabled' : '') . '.gif" width="16" height="14" alt="';
419
				$iconHtml .= $params['name'] . ($disabled ? '_disabled' : '') . '.png" width="16" height="14" alt="';
420
420
421
				// if alt parameter specified use it, otherwise use localization version
421
				// if alt parameter specified use it, otherwise use localization version
422
				if (isset($params['alt'])) {
422
				if (isset($params['alt'])) {
(-)locale/en_US/common.xml (+40 lines)
 Lines 245-250    Link Here 
245
	<message key="navigation.stepNumber">Step {$step}</message>
245
	<message key="navigation.stepNumber">Step {$step}</message>
246
	<message key="navigation.userHome">User Home</message>
246
	<message key="navigation.userHome">User Home</message>
247
	<message key="navigation.user">User</message>
247
	<message key="navigation.user">User</message>
248
	<message key="notification.allow">Allow these types of notifications to appear in my notification feed.</message>
249
	<message key="notification.email">Also send me an email for these types of notifications.</message>
250
	<message key="notification.location">Go To URL</message>
251
	<message key="notification.mailList">Notification mailing list</message>
252
	<message key="notification.mailListDescription">Enter your email address to receive immediate notifications of important new content added to the journal.</message>
253
	<message key="notification.mailList.privacyProtection">Privacy protection policy</message>
254
	<message key="notification.mailList.protectedContent"><![CDATA[<a href="{$subscribeUrl}">Subscribe</a> to protected content.]]></message>
255
	<message key="notification.mailList.submit"><![CDATA[Or <a href="{$submitUrl}">submit</a> an article?]]></message>
256
	<message key="notification.mailList.review"><![CDATA[Want to also <a href="{$reviewUrl}">review</a>?]]></message>
257
	<message key="notification.noneExist">You have no notifications at this time.</message>
258
	<message key="notification.notification">Notification</message>	
259
	<message key="notification.notifications">Notifications</message>	
260
	<message key="notification.notificationsDescription">You have {$unreadCount} unread notifications and {$readCount} read notifications.<![CDATA[  <a href="{$settingsUrl}">Click here</a> to change your notification settings.]]></message>
261
	<message key="notification.notificationsPublicDescription">This page shows important updates associated with this journal such as new issues or announcements.  You may subscribe to these notifications through RSS feeds (by clicking on the images to the right), or <![CDATA[  <a href="{$emailUrl}">through email.</a>]]></message>
262
	<message key="notification.settings">Notification Settings</message>
263
	<message key="notification.settingsDescription">Select the system events that you wish to be notified about.  Unchecking an item will prevent notifications of the event from showing up in your notification feed.</message>
264
	<message key="notification.subscribeError">Your email address is already subscribed to notifications.</message>
265
	<message key="notification.subscribeSuccess">Your email address has been successfully added to the mailing list.</message>
266
	<message key="notification.reminderError">There was an error sending your password, please ensure you've entered your email address correctly.</message>
267
	<message key="notification.reminderSent">Your new password has been sent to the email address provided.</message>
268
	<message key="notification.type.articleSubmitted">A new article, "{$param}", has been submitted.</message>
269
	<message key="notification.type.copyeditComment">A copyeditor has left a comment on "{$param}".</message>
270
	<message key="notification.type.editorDecisionComment">A comment has been left on the editor decision for "{$param}".</message>
271
	<message key="notification.type.galleyAdded">A galley has been added for "{$param}".</message>
272
	<message key="notification.type.galleyModified">An galley has been modified for "{$param}".</message>
273
	<message key="notification.type.issuePublished">An issue has been published.</message>
274
	<message key="notification.type.layoutComment">A comment has been left about "{$param}'s" layout.</message>
275
	<message key="notification.type.metadataModified">"{$param}'s" metadata has been modified.</message>
276
	<message key="notification.type.other">Other Events</message>
277
	<message key="notification.type.proofreadComment">A comment has been left by a proofreader on "{$param}".</message>
278
	<message key="notification.type.reviewerComment">A reviewer has commented on "{$param}".</message>
279
	<message key="notification.type.reviewerFormComment">A review form review has been submitted for "{$param}".</message>
280
	<message key="notification.type.submissionComment">An editor has made a comment on "{$param}".</message>
281
	<message key="notification.type.submissions">Submission Events</message>
282
	<message key="notification.type.suppFileAdded">A supplementary file has been added to "{$param}".</message>
283
	<message key="notification.type.suppFileModified">"{$param}'s" supplementary file(s) has been modified.</message>
284
	<message key="notification.type.userComment">A reader has made a comment on "{$param}"</message>
285
	<message key="notification.unsubscribeDescription">Enter your email address and password below to unsubscribe from email notifications.  If you do not remember your password, leave the password field blank and a new one will be emailed to you at the given email address.</message>	
286
	<message key="notification.unsubscribeError">There was an error unsubscribing you.  Please ensure your email address and password are correct.</message>
287
	<message key="notification.unsubscribeSuccess">You were successfully unsubscribed.</message>	
248
	<message key="search.abstract">Abstract</message>
288
	<message key="search.abstract">Abstract</message>
249
	<message key="search.allFields">All</message>
289
	<message key="search.allFields">All</message>
250
	<message key="search.coverage">Coverage</message>
290
	<message key="search.coverage">Coverage</message>
(-)pages/notification/NotificationHandler.inc.php (+319 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @file NotificationHandler.inc.php
5
 *
6
 * Copyright (c) 2000-2008 John Willinsky
7
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
 *
9
 * @class NotificationHandler
10
 * @ingroup pages_help
11
 *
12
 * @brief Handle requests for viewing notifications. 
13
 */
14
15
import('core.PKPHandler');
16
import('notification.Notification');
17
18
class NotificationHandler extends PKPHandler {
19
20
	/**
21
	 * Display help table of contents.
22
	 */
23
	function index() {
24
		parent::validate();
25
		parent::setupTemplate();
26
		$templateMgr =& TemplateManager::getManager();
27
		
28
		$user = Request::getUser();
29
		if(isset($user)) {
30
			$userId = $user->getUserId();
31
			$templateMgr->assign('isUserLoggedIn', true);
32
		} else {
33
			$userId = 0;
34
			$templateMgr->assign('emailUrl', Request::url(null, 'notification', 'subscribeMailList'));
35
			$templateMgr->assign('isUserLoggedIn', false);
36
		}
37
38
		$notificationDao = &DAORegistry::getDAO('NotificationDAO');
39
		$notifications = $notificationDao->getNotificationsByUserId($userId);
40
		
41
		$templateMgr->assign('notifications', $notifications);
42
		$templateMgr->assign('unread', $notificationDao->getUnreadNotificationCount($userId));
43
		$templateMgr->assign('read', $notificationDao->getReadNotificationCount($userId));
44
		$templateMgr->assign('url', Request::url(null, 'notification', 'settings'));
45
		$templateMgr->display('notification/index.tpl');
46
	}
47
	
48
	/**
49
	 * Delete a notification
50
	 */
51
	function delete($args) {
52
		parent::validate();
53
		
54
		$user = Request::getUser();
55
		if(isset($user)) {
56
			$userId = $user->getUserId();
57
			$notificationDao = &DAORegistry::getDAO('NotificationDAO');
58
			$notifications = $notificationDao->deleteNotificationById($args[0], $userId);
59
		}
60
		
61
		Request::redirect(null, 'notification');
62
	}
63
	
64
	/**
65
	 * Delete a notification
66
	 */
67
	function deleteAjax($args) {
68
		parent::validate();
69
		
70
		$user = Request::getUser();
71
		if(isset($user)) {
72
			$userId = $user->getUserId();
73
			$notificationDao = &DAORegistry::getDAO('NotificationDAO');
74
			$notifications = $notificationDao->deleteNotificationById($args[0], $userId);
75
		}
76
	}
77
	
78
	/**
79
	 * View and modify notification settings
80
	 */
81
	function settings() {
82
		parent::validate();
83
				
84
		$user = Request::getUser();
85
		if(isset($user)) {
86
			$userId = $user->getUserId();
87
					
88
			$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
89
			$notificationSettings = $notificationSettingsDao->getNotificationSettings($userId);
90
			$emailSettings = $notificationSettingsDao->getNotificationEmailSettings($userId);
91
92
			$templateMgr = &TemplateManager::getManager();
93
			$templateMgr->assign('notificationSettings', $notificationSettings);
94
			$templateMgr->assign('emailSettings', $emailSettings);
95
			$templateMgr->assign('titleVar', Locale::translate('common.title'));
96
			$templateMgr->assign('userVar', Locale::translate('common.user'));
97
			$templateMgr->display('notification/settings.tpl');
98
		} else Request::redirect(null, 'notification');
99
	}
100
	
101
	/**
102
	 * Save user notification settings
103
	 */
104
	function saveSettings() {
105
		parent::validate();
106
		
107
		$settings = array();
108
		
109
		$user = Request::getUser();
110
		if(isset($user)) {
111
			$userId = $user->getUserId();
112
			$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
113
			
114
			// Notification settings
115
			$settings = array();
116
			if(!Request::getUserVar('notificationArticleSubmitted')) $settings[] = NOTIFICATION_TYPE_ARTICLE_SUBMITTED;
117
			if(!Request::getUserVar('notificationMetadataModified')) $settings[] = NOTIFICATION_TYPE_METADATA_MODIFIED;
118
			if(!Request::getUserVar('notificationSuppFileAdded')) $settings[] = NOTIFICATION_TYPE_SUPP_FILE_ADDED;
119
			if(!Request::getUserVar('notificationSuppFileModified')) $settings[] = NOTIFICATION_TYPE_SUPP_FILE_MODIFIED;
120
			if(!Request::getUserVar('notificationGalleyAdded')) $settings[] = NOTIFICATION_TYPE_GALLEY_ADDED;
121
			if(!Request::getUserVar('notificationGalleyModified')) $settings[] = NOTIFICATION_TYPE_GALLEY_MODIFIED;
122
			if(!Request::getUserVar('notificationSubmissionComment')) $settings[] = NOTIFICATION_TYPE_SUBMISSION_COMMENT;
123
			if(!Request::getUserVar('notificationLayoutComment')) $settings[] = NOTIFICATION_TYPE_LAYOUT_COMMENT;
124
			if(!Request::getUserVar('notificationCopyeditComment')) $settings[] = NOTIFICATION_TYPE_COPYEDIT_COMMENT;
125
			if(!Request::getUserVar('notificationProofreadComment')) $settings[] = NOTIFICATION_TYPE_PROOFREAD_COMMENT;
126
			if(!Request::getUserVar('notificationReviewerComment')) $settings[] = NOTIFICATION_TYPE_REVIEWER_COMMENT;
127
			if(!Request::getUserVar('notificationReviewerFormComment')) $settings[] = NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT;
128
			if(!Request::getUserVar('notificationEditorDecisionComment')) $settings[] = NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT; 
129
			if(!Request::getUserVar('notificationPublishedIssue')) $settings[] = NOTIFICATION_TYPE_PUBLISHED_ISSUE;
130
			if(!Request::getUserVar('notificationUserComment')) $settings[] = NOTIFICATION_TYPE_USER_COMMENT;
131
			
132
			// Email settings
133
			$emailSettings = array();
134
			if(Request::getUserVar('emailNotificationArticleSubmitted')) $emailSettings[] = NOTIFICATION_TYPE_ARTICLE_SUBMITTED;
135
			if(Request::getUserVar('emailNotificationMetadataModified')) $emailSettings[] = NOTIFICATION_TYPE_METADATA_MODIFIED;
136
			if(Request::getUserVar('emailNotificationSuppFileAdded')) $emailSettings[] = NOTIFICATION_TYPE_SUPP_FILE_ADDED;
137
			if(Request::getUserVar('emailNotificationSuppFileModified')) $emailSettings[] = NOTIFICATION_TYPE_SUPP_FILE_MODIFIED;
138
			if(Request::getUserVar('emailNotificationGalleyAdded')) $emailSettings[] = NOTIFICATION_TYPE_GALLEY_ADDED;
139
			if(Request::getUserVar('emailNotificationGalleyModified')) $emailSettings[] = NOTIFICATION_TYPE_GALLEY_MODIFIED;
140
			if(Request::getUserVar('emailNotificationSubmissionComment')) $emailSettings[] = NOTIFICATION_TYPE_SUBMISSION_COMMENT;
141
			if(Request::getUserVar('emailNotificationLayoutComment')) $emailSettings[] = NOTIFICATION_TYPE_LAYOUT_COMMENT;
142
			if(Request::getUserVar('emailNotificationCopyeditComment')) $emailSettings[] = NOTIFICATION_TYPE_COPYEDIT_COMMENT;
143
			if(Request::getUserVar('emailNotificationProofreadComment')) $emailSettings[] = NOTIFICATION_TYPE_PROOFREAD_COMMENT;
144
			if(Request::getUserVar('emailNotificationReviewerComment')) $emailSettings[] = NOTIFICATION_TYPE_REVIEWER_COMMENT;
145
			if(Request::getUserVar('emailNotificationReviewerFormComment')) $emailSettings[] = NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT;
146
			if(Request::getUserVar('emailNotificationEditorDecisionComment')) $emailSettings[] = NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT; 
147
			if(Request::getUserVar('emailNotificationPublishedIssue')) $emailSettings[] = NOTIFICATION_TYPE_PUBLISHED_ISSUE;
148
			if(Request::getUserVar('emailNotificationUserComment')) $emailSettings[] = NOTIFICATION_TYPE_USER_COMMENT;
149
			
150
			$notificationSettingsDao->updateNotificationSettings($settings, $userId);
151
			$notificationSettingsDao->updateNotificationEmailSettings($emailSettings, $userId);
152
			Request::redirect(null, 'notification');
153
		} else Request::redirect(null, 'notification');
154
	}
155
	
156
	/**
157
	 * Fetch the existing or create a new URL for the user's RSS feed
158
	 */
159
	function getNotificationFeedUrl($args) {
160
		$user = Request::getUser();
161
		if(isset($user)) {
162
			$userId = $user->getUserId();
163
			$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
164
			$feedType = $args[0];
165
166
			$token = $notificationSettingsDao->getRSSTokenByUserId($userId);
167
			
168
			if ($token) {
169
				Request::redirect(null, 'notification', 'notificationFeed', array($feedType, $token));
170
			} else {
171
				$token = $notificationSettingsDao->insertNewRSSToken($userId);
172
				Request::redirect(null, 'notification', 'notificationFeed', $feedType, $token);
173
			}
174
		} else Request::redirect(null, 'notification');
175
	}
176
	
177
	/**
178
	 * Fetch the actual RSS feed
179
	 */
180
	function notificationFeed($args) {
181
		if(isset($args[0]) && isset($args[1])) {
182
			$type = $args[0];
183
			$token = $args[1];
184
		} else return false;
185
186
		$application = PKPApplication::getApplication();
187
		$appName = $application->getNameKey();
188
		
189
		$site =& Request::getSite();
190
		$siteTitle = $site->getSiteTitle();
191
	
192
		$notificationDao = &DAORegistry::getDAO('NotificationDAO');
193
		$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
194
		
195
		$userId = $notificationSettingsDao->getUserIdByRSSToken($token);
196
		$notifications = $notificationDao->getNotificationsByUserId($userId);
197
198
		// Make sure the feed type is specified and valid
199
		$typeMap = array(
200
			'rss' => 'rss.tpl',
201
			'rss2' => 'rss2.tpl',
202
			'atom' => 'atom.tpl'
203
		);
204
		$mimeTypeMap = array(
205
			'rss' => 'application/rdf+xml',
206
			'rss2' => 'application/rss+xml',
207
			'atom' => 'application/atom+xml'
208
		);
209
		if (!isset($typeMap[$type])) return false;
210
211
		$versionDao =& DAORegistry::getDAO('VersionDAO');
212
		$version = $versionDao->getCurrentVersion();
213
214
		$templateMgr = &TemplateManager::getManager();
215
		$templateMgr->assign('version', $version->getVersionString());
216
		$templateMgr->assign('selfUrl', Request::getCompleteUrl()); 
217
		$templateMgr->assign('locale', Locale::getPrimaryLocale()); 
218
		$templateMgr->assign('appName', $appName);
219
		$templateMgr->assign('siteTitle', $siteTitle);
220
		$templateMgr->assign_by_ref('notifications', $notifications->toArray());
221
222
		$templateMgr->display(Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 
223
			'pkp' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'notification' . DIRECTORY_SEPARATOR . $typeMap[$type], $mimeTypeMap[$type]);
224
225
		return true;
226
	}
227
	
228
229
	/**
230
	 * Display the public notification email subscription form
231
	 */
232
	function subscribeMailList() {
233
		$templateMgr = &TemplateManager::getManager();
234
		$templateMgr->assign('new', true);
235
236
		$user = Request::getUser();
237
	//	FIXME: Need to abstract subscription enabled check
238
	//	import('payment.PaymentManager');
239
	//	$subscriptionEnabled = PaymentManager::isConfigured();
240
				
241
		if(!isset($user)) {
242
			// $templateMgr->assign('subscriptionEnabled', $subscriptionEnabled);
243
			
244
			if($userEmail = Request::getUserVar('email')) {
245
				$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
246
				if($password = $notificationSettingsDao->subscribeGuest($userEmail)) {
247
					NotificationHandler::sendMailingListEmail($userEmail, $password, 'NOTIFICATION_MAILLIST_WELCOME');
248
					$templateMgr->assign('success', "notification.subscribeSuccess");
249
					$templateMgr->display('notification/maillist.tpl');
250
				} else {
251
					$templateMgr->assign('error', "notification.subscribeError");
252
					$templateMgr->display('notification/maillist.tpl');
253
				
254
				}
255
			} else {
256
				$templateMgr->display('notification/maillist.tpl');
257
			}
258
		} else Request::redirect(null, 'notification');
259
	}
260
261
	/**
262
	 * Display the public notification email subscription form
263
	 */
264
	function unsubscribeMailList() {
265
		$templateMgr = &TemplateManager::getManager();
266
		$templateMgr->assign('remove', true);
267
		
268
		$user = Request::getUser();
269
		if(!isset($user)) {
270
			$userEmail = Request::getUserVar('email');
271
			$userPassword = Request::getUserVar('password');
272
			
273
			if($userEmail != '' && $userPassword != '') {
274
				$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
275
				if($notificationSettingsDao->unsubscribeGuest($userEmail, $userPassword)) {
276
					$templateMgr->assign('success', "notification.unsubscribeSuccess");
277
					$templateMgr->display('notification/maillist.tpl');
278
				} else {
279
					$templateMgr->assign('error', "notification.unsubscribeError");
280
					$templateMgr->display('notification/maillist.tpl');
281
				}
282
			} else if($userEmail != '' && $userPassword == '') {
283
				$notificationSettingsDao = &DAORegistry::getDAO('NotificationSettingsDAO');
284
				if($newPassword = $notificationSettingsDao->resetPassword($userEmail)) {
285
					NotificationHandler::sendMailingListEmail($userEmail, $userPassword, 'NOTIFICATION_MAILLIST_PASSWORD');
286
					$templateMgr->assign('success', "notification.reminderSent");
287
					$templateMgr->display('notification/maillist.tpl');
288
				} else {
289
					$templateMgr->assign('error', "notification.reminderError");
290
					$templateMgr->display('notification/maillist.tpl');
291
				}
292
			} else {		
293
				$templateMgr->assign('remove', true);
294
				$templateMgr->display('notification/maillist.tpl');
295
			}
296
		} else Request::redirect(null, 'notification');
297
	}
298
	
299
	/**
300
	 * Send an email to a mailing list user regarding signup or a lost password
301
	 */
302
	function sendMailingListEmail($email, $password, $template) {
303
		import('mail.MailTemplate');
304
		$journal = Request::getJournal();
305
		$site = Request::getSite();
306
		
307
		$mail = new MailTemplate($template);
308
		$mail->setFrom($site->getSiteContactEmail(), $site->getSiteContactName());
309
		$mail->assignParams(array(
310
			'password' => $password,
311
			'siteTitle' => $journal->getJournalTitle(),
312
			'unsubscribeLink' => Request::url(null, 'notification', 'unsubscribeMailList')
313
		));
314
		$mail->addRecipient($email);
315
		$mail->send();
316
	}	
317
}
318
319
?>
(-)pages/notification/index.php (+23 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @defgroup pages_notification
5
 */
6
 
7
/**
8
 * @file pages/notification/index.php
9
 *
10
 * Copyright (c) 2000-2008 John Willinsky
11
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
12
 *
13
 * @ingroup pages_notification
14
 * @brief Handle requests for viewing notifications. 
15
 *
16
 */
17
18
19
define('HANDLER_CLASS', 'NotificationHandler');
20
21
import('pages.notification.NotificationHandler');
22
23
?>
(-)templates/notification/atom.tpl (+43 lines)
Added Link Here 
1
{**
2
 * atom.tpl
3
 *
4
 * Copyright (c) 2003-2008 John Willinsky
5
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
6
 *
7
 * Atom feed template
8
 *
9
 * $Id: atom.tpl,v 1.3 2008/06/11 21:52:26 asmecher Exp $
10
 *}
11
<?xml version="1.0" encoding="{$defaultCharset|escape}"?>
12
<feed xmlns="http://www.w3.org/2005/Atom">
13
	<id>{$selfUrl}</id>
14
	<title>{$siteTitle} {translate key="notification.notifications"}</title>
15
16
	<link rel="self" type="application/atom+xml" href="{$selfUrl}" />
17
18
	<generator uri="http://pkp.sfu.ca/ojs/" version="{$version|escape}">{translate key=$appName}</generator>
19
20
{foreach from=$notifications item=notification}
21
	<entry>
22
		<id>$notification->getNotificationId()</id>
23
		<title>{translate key="notification.notification"} : {$notification->getDateCreated()|date_format:"%a, %d %b %Y %T %z"}</title>
24
		{if $notification->getLocation() != null}
25
			<link rel="alternate" href="{$notification->getLocation()}" />					
26
		{else}
27
			<link rel="alternate" href="{url page="notification"}" />					
28
		{/if}
29
30
		<summary type="html" xml:base="{if $notification->getLocation() != null}{$notification->getLocation()}{else}{url page="notification"}{/if}">
31
			{if $notification->getIsLocalized()}
32
				{translate key=$notification->getContents() param=$notification->getParam()}
33
			{else}
34
				{$notification->getContents()}
35
			{/if}
36
		</summary>
37
38
		<published>{$notification->getDateCreated()|date_format:"%Y-%m-%dT%T%z"|regex_replace:"/00$/":":00"}</published>
39
	</entry>
40
{/foreach}
41
</feed>
42
43
(-)templates/notification/index.tpl (+83 lines)
Added Link Here 
1
{**
2
 * index.tpl
3
 *
4
 * Copyright (c) 2000-2008 John Willinsky
5
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
6
 *
7
 * Display list of notifications. 
8
 *
9
 *}
10
{strip}
11
{assign var="pageTitle" value="notification.notifications"}
12
{include file="common/header.tpl"}
13
{/strip}
14
15
<table width="100%">
16
	<tr>
17
		<td>{if $isUserLoggedIn}
18
				<p>{translate key="notification.notificationsDescription" unreadCount=$unread readCount=$read settingsUrl=$url}</p>
19
			{else}
20
				<p>{translate key="notification.notificationsPublicDescription" emailUrl=$emailUrl}</p>
21
			{/if}
22
		</td>
23
		<td><ul class="plain">
24
			<li><a href="{url op="getNotificationFeedUrl" path="rss"}" class="icon"><img src="{$baseUrl}/lib/pkp/templates/images/rss10_logo.png" alt="RSS 1.0"/></a></li>
25
			<li><a href="{url op="getNotificationFeedUrl" path="rss2"}" class="icon"><img src="{$baseUrl}/lib/pkp/templates/images/rss20_logo.png" alt="RSS 2.0"/></a></li>
26
			<li><a href="{url op="getNotificationFeedUrl" path="atom"}" class="icon"><img src="{$baseUrl}/lib/pkp/templates/images/atom10_logo.png" alt="Atom 1.0"/></a></li>
27
		</ul></td>
28
	</tr>
29
</table>
30
31
<br/>
32
33
<div id="notifications">
34
{iterate from=notifications item=notification}
35
	<table width="100%" class="notifications">
36
		<tr>
37
			<td width="25"><img src="{$notification->getIconLocation()}" alt="&#187"/></td>
38
			<td class="notificationContent" colspan="2" width="80%">
39
				{$notification->getDateCreated()}
40
			</td>
41
			{if $notification->getLocation() != null}
42
				<td id="notificationLink" class="notificationFunction" style="min-width:60px"><a href="{$notification->getLocation()}">{translate key="notification.location"}</a></td>
43
			{else}
44
				<td id="notificationLink" class="notificationFunction"></td>
45
			{/if}
46
			<td id="notificationDelete" class="notificationFunction"><a id="notificationDeleteLink" href="{url op="delete" path=$notification->getNotificationId()}">{translate key="common.delete"}</a></td>
47
		</tr>
48
		<tr>
49
			<td width="25">&nbsp;</td>
50
			<td class="notificationContent">
51
				{if $notification->getIsUnread()}
52
					{if $notification->getIsLocalized()}<p style="font-weight: bold">{translate key=$notification->getContents() param=$notification->getParam()}</p>
53
					{else}<p style="font-weight: bold">{$notification->getContents()}{/if}
54
				{else}
55
					{if $notification->getIsLocalized()}<p>{translate key=$notification->getContents() param=$notification->getParam()}</p>
56
					{else}<p>{$notification->getContents()}</p>{/if}	
57
				{/if}
58
			</td>
59
		</tr>
60
	</table>
61
	<div class="separator" style="margin-left:25px"></div>
62
{/iterate}
63
{if $notifications->wasEmpty()}
64
	<table class="notifications">
65
		<tr>
66
			<td colspan="2" class="nodata"><h5>{translate key="notification.noneExist"}</h5></td>
67
		</tr>
68
		<tr>
69
			<td colspan="2" class="endseparator">&nbsp;</td>
70
		</tr>
71
	</table>
72
{else}
73
	<table class="notifications">
74
		<tr>
75
			<td align="left">{page_info iterator=$notifications}</td>
76
			<td align="right">{page_links anchor="notifications" name="notifications" iterator=$notifications}</td>
77
		</tr>
78
	</table>
79
{/if}
80
81
</div>
82
83
{include file="common/footer.tpl"}
(-)templates/notification/maillist.tpl (+85 lines)
Added Link Here 
1
{**
2
 * index.tpl
3
 *
4
 * Copyright (c) 2000-2008 John Willinsky
5
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
6
 *
7
 * Displays the notification settings page and unchecks  
8
 *
9
 *}
10
{strip}
11
{assign var="pageTitle" value="notification.mailList"}
12
{include file="common/header.tpl"}
13
{/strip}
14
15
{if $new}
16
	<p><span class="instruct">{translate key="notification.mailListDescription"}</span></p>
17
	<br />
18
19
	{if $error}
20
		<p><span class="formError">{translate key="$error"}</span></p>
21
	{/if}
22
	
23
	{if $success}
24
		<p><span class="formSuccess">{translate key="$success"}</span></p>
25
	{/if}
26
27
	<form id="notificationSettings" method="post" action="{url op="subscribeMailList"}">
28
	
29
	<table class="data" width="100%">
30
		<tr valign="top">
31
			<td class="label" width="5%">{translate key="email.email"}</td>
32
			<td class="value" width="45%"><input type="text" name="email" size="30" maxlength="90" class="textField" /></td>
33
		</tr>
34
		<tr valign="top">
35
			<td width="5%">&nbsp;</td>
36
			<td><p><input type="submit" value="{translate key="form.submit"}" class="button defaultButton" /></p></td>
37
		</tr>
38
	</table>
39
	</form>
40
	
41
	<ul class="plain" style="margin-left:10%">
42
		{url|assign:"url" page="user" op="register"}
43
		<li>&#187; {translate key="notification.mailList.review" reviewUrl=$url} </li>
44
		{url|assign:"url" page="information" op="authors"}
45
		<li>&#187; {translate key="notification.mailList.submit" submitUrl=$url} </li>
46
		{** need to abstract subscription enabled check
47
		* assign var=subscribeUrl value="url op="subscriptions""
48
		* if $subscriptionEnabled <li>&#187; translate key="notification.mailList.protectedContent" subscribeUrl=$subscribeUrl
49
		*}
50
		<li>&#187; <a href="{url op="protectionPolicy"}">{translate key="notification.mailList.privacyProtection"}</a></li>
51
	<ul>
52
{else if $remove}
53
	<p><span class="instruct">{translate key="notification.unsubscribeDescription"}</span></p>
54
	<br />
55
56
	{if $error}
57
		<p><span class="formError">{translate key="$error"}</span></p>
58
	{/if}
59
	
60
	{if $success}
61
		<p><span class="formSuccess">{translate key="$success"}</span></p>
62
	{/if}
63
	
64
	<form id="notificationSettings" method="post" action="{url op="unsubscribeMailList"}">
65
	<table class="data" width="100%">
66
		<tr valign="top">
67
			<td class="label" width="5%">{translate key="email.email"}</td>
68
			<td class="value" width="45%"><input type="text" name="email" size="30" maxlength="90" class="textField" /></td>
69
		</tr>
70
		<tr valign="top">
71
			<td class="label" width="5%">{translate key="user.password"}</td>
72
			<td class="value" width="45%"><input type="text" name="password" size="30" maxlength="90" class="textField" /></td>
73
		</tr>
74
		<tr valign="top">
75
			<td width="5%">&nbsp;</td>
76
			<td><p><input type="submit" value="{translate key="form.submit"}" class="button defaultButton" /></p></td>
77
		</tr>
78
	</table>
79
	
80
	</form>
81
{/if}
82
83
</form>
84
85
{include file="common/footer.tpl"}
(-)templates/notification/rss.tpl (+53 lines)
Added Link Here 
1
{**
2
 * rss.tpl
3
 *
4
 * Copyright (c) 2003-2008 John Willinsky
5
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
6
 *
7
 * RSS feed template
8
 *
9
 * $Id: rss.tpl,v 1.3 2008/06/11 21:52:26 asmecher Exp $
10
 *}
11
<?xml version="1.0" encoding="{$defaultCharset|escape}"?>
12
<rdf:RDF
13
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
14
	xmlns="http://purl.org/rss/1.0/"
15
	xmlns:dc="http://purl.org/dc/elements/1.1/"
16
	xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/">
17
    
18
	<channel rdf:about="{$baseUrl}">
19
		<title>{$siteTitle} {translate key="notification.notifications"}</title>
20
		<link>{$selfUrl}</link>
21
		<language>{$locale|replace:'_':'-'|strip|escape:"html"}</language>
22
		<items>
23
			{foreach from=$notifications item=notification}
24
			<rdf:Seq>
25
				<rdf:li rdf:resource="{url page="notification"}"/>
26
			</rdf:Seq>
27
			{/foreach}
28
		</items>
29
	</channel>
30
31
	{foreach from=$notifications item=notification}
32
	<item rdf:about="{url page="notification"}">
33
		<title>{translate key="notification.notification"} : {$notification->getDateCreated()|date_format:"%a, %d %b %Y %T %z"}</title>
34
		<link>
35
			{if $notification->getLocation() != null}
36
				{$notification->getLocation()}
37
			{else}
38
				{url page="notification"}
39
			{/if}
40
		</link>
41
		<description>
42
			{if $notification->getIsLocalized()}
43
				{translate key=$notification->getContents() param=$notification->getParam()}
44
			{else}
45
				{$notification->getContents()}
46
			{/if}
47
		</description>	
48
		<dc:creator>{$siteTitle|strip|escape:"html"}</dc:creator>
49
		<dc:date>{$notification->getDateCreated()|date_format:"%Y-%m-%d"}</dc:date>
50
	</item>
51
	{/foreach}
52
53
</rdf:RDF>
(-)templates/notification/rss2.tpl (+45 lines)
Added Link Here 
1
{**
2
 * rss2.tpl
3
 *
4
 * Copyright (c) 2003-2008 John Willinsky
5
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
6
 *
7
 * RSS 2 feed template
8
 *
9
 * $Id: rss2.tpl,v 1.3 2008/06/11 21:52:26 asmecher Exp $
10
 *}
11
<?xml version="1.0" encoding="{$defaultCharset|escape}"?>
12
<rss version="2.0">
13
	<channel>
14
		{* required elements *}
15
		<title>{$siteTitle} {translate key="notification.notifications"}</title>
16
		<link>{$selfUrl}</link>
17
18
		{* optional elements *}
19
	    <language>{$locale|replace:'_':'-'|strip|escape:"html"}</language>
20
		<generator>{translate key=$appName} {$version|escape}</generator>
21
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
22
		<ttl>60</ttl>
23
24
		{foreach from=$notifications item=notification}
25
			<item>
26
				<title>{translate key="notification.notification"} : {$notification->getDateCreated()|date_format:"%a, %d %b %Y %T %z"}</title>
27
				<link>
28
					{if $notification->getLocation() != null}
29
						{$notification->getLocation()}
30
					{else}
31
						{url page="notification"}
32
					{/if}
33
				</link>
34
				<description>
35
					{if $notification->getIsLocalized()}
36
						{translate key=$notification->getContents() param=$notification->getParam()}
37
					{else}
38
						{$notification->getContents()}
39
					{/if}
40
				</description>		
41
				<pubDate>{$notification->getDateCreated()|date_format:"%a, %d %b %Y %T %z"}</pubDate>
42
			</item>
43
		{/foreach}
44
	</channel>
45
</rss>
(-)templates/notification/settings.tpl (+241 lines)
Added Link Here 
1
{**
2
 * index.tpl
3
 *
4
 * Copyright (c) 2000-2008 John Willinsky
5
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
6
 *
7
 * Displays the notification settings page and unchecks  
8
 *
9
 *}
10
{strip}
11
{assign var="pageTitle" value="notification.settings"}
12
{include file="common/header.tpl"}
13
{/strip}
14
15
<p>{translate key="notification.settingsDescription"}</p>
16
17
<form id="notificationSettings" method="post" action="{url op="saveSettings"}">
18
19
20
<h4>{translate key="notification.type.submissions"}</h4>
21
22
<ul>
23
	<li>{translate key="notification.type.articleSubmitted" param=$titleVar}</li>
24
	<ul class="plain">
25
		<li><span>
26
				<input type="checkbox" name="notificationArticleSubmitted"{if !$smarty.const.NOTIFICATION_TYPE_ARTICLE_SUBMITTED|in_array:$notificationSettings} checked="checked"{/if} />
27
				{translate key="notification.allow"}
28
			</span></li>
29
		<li><span>
30
				<input type="checkbox" name="emailNotificationArticleSubmitted"{if $smarty.const.NOTIFICATION_TYPE_ARTICLE_SUBMITTED|in_array:$emailSettings} checked="checked"{/if} />
31
				{translate key="notification.email"}
32
			</span></li>
33
	</ul>
34
</ul>
35
			
36
<ul>
37
	<li>{translate key="notification.type.metadataModified" param=$titleVar}</li>
38
	<ul class="plain">
39
		<li><span>
40
				<input type="checkbox" name="notificationMetadataModified"{if !$smarty.const.NOTIFICATION_TYPE_METADATA_MODIFIED|in_array:$notificationSettings} checked="checked"{/if} />
41
				{translate key="notification.allow"}
42
			</span></li>
43
		<li><span>
44
				<input type="checkbox" name="emailNotificationMetadataModified"{if $smarty.const.NOTIFICATION_TYPE_METADATA_MODIFIED|in_array:$emailSettings} checked="checked"{/if} />
45
				{translate key="notification.email"}
46
			</span></li>
47
	</ul>
48
</ul>	
49
50
<ul>
51
	<li>{translate key="notification.type.suppFileAdded" param=$titleVar}</li>
52
	<ul class="plain">
53
		<li><span>
54
				<input type="checkbox" name="notificationSuppFileAdded"{if !$smarty.const.NOTIFICATION_TYPE_SUPP_FILE_ADDED|in_array:$notificationSettings} checked="checked"{/if} />
55
				{translate key="notification.allow"}
56
			</span></li>
57
		<li><span>
58
				<input type="checkbox" name="emailNotificationSuppFileAdded"{if $smarty.const.NOTIFICATION_TYPE_SUPP_FILE_ADDED|in_array:$emailSettings} checked="checked"{/if} />
59
				{translate key="notification.email"}
60
			</span></li>
61
	</ul>
62
</ul>
63
64
<ul>
65
	<li>{translate key="notification.type.suppFileModified" param=$titleVar}</li>
66
	<ul class="plain">
67
		<li><span>
68
				<input type="checkbox" name="notificationSuppFileModified"{if !$smarty.const.NOTIFICATION_TYPE_SUPP_FILE_MODIFIED|in_array:$notificationSettings} checked="checked"{/if} />
69
				{translate key="notification.allow"}
70
			</span></li>
71
		<li><span>
72
				<input type="checkbox" name="emailNotificationSuppFileModified"{if $smarty.const.NOTIFICATION_TYPE_SUPP_FILE_MODIFIED|in_array:$emailSettings} checked="checked"{/if} />
73
				{translate key="notification.email"}
74
			</span></li>
75
	</ul>
76
</ul>
77
78
<ul>
79
	<li>{translate key="notification.type.galleyAdded" param=$titleVar}</li>
80
	<ul class="plain">
81
		<li><span>
82
				<input type="checkbox" name="notificationGalleyAdded"{if !$smarty.const.NOTIFICATION_TYPE_GALLEY_ADDED|in_array:$notificationSettings} checked="checked"{/if} />
83
				{translate key="notification.allow"}
84
			</span></li>
85
		<li><span>
86
				<input type="checkbox" name="emailNotificationGalleyAdded"{if $smarty.const.NOTIFICATION_TYPE_GALLEY_ADDED|in_array:$emailSettings} checked="checked"{/if} />
87
				{translate key="notification.email"}
88
			</span></li>
89
	</ul>
90
</ul>
91
92
<ul>
93
	<li>{translate key="notification.type.galleyModified" param=$titleVar}</li>
94
	<ul class="plain">
95
		<li><span>
96
				<input type="checkbox" name="notificationGalleyModified"{if !$smarty.const.NOTIFICATION_TYPE_GALLEY_MODIFIED|in_array:$notificationSettings} checked="checked"{/if} />
97
				{translate key="notification.allow"}
98
			</span></li>
99
		<li><span>
100
				<input type="checkbox" name="emailNotificationGalleyModified"{if $smarty.const.NOTIFICATION_TYPE_GALLEY_MODIFIED|in_array:$emailSettings} checked="checked"{/if} />
101
				{translate key="notification.email"}
102
			</span></li>
103
	</ul>
104
</ul>
105
106
<ul>
107
	<li>{translate key="notification.type.submissionComment" param=$titleVar}</li>
108
	<ul class="plain">
109
		<li><span>
110
				<input type="checkbox" name="notificationSubmissionComment"{if !$smarty.const.NOTIFICATION_TYPE_SUBMISSION_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
111
				{translate key="notification.allow"}
112
			</span></li>
113
		<li><span>
114
				<input type="checkbox" name="emailNotificationSubmissionComment"{if $smarty.const.NOTIFICATION_TYPE_SUBMISSION_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
115
				{translate key="notification.email"}
116
			</span></li>
117
	</ul>
118
</ul>
119
120
<ul>
121
	<li>{translate key="notification.type.layoutComment" param=$titleVar}</li>
122
	<ul class="plain">
123
		<li><span>
124
				<input type="checkbox" name="notificationLayoutComment"{if !$smarty.const.NOTIFICATION_TYPE_LAYOUT_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
125
				{translate key="notification.allow"}
126
			</span></li>
127
		<li><span>
128
				<input type="checkbox" name="emailNotificationLayoutComment"{if $smarty.const.NOTIFICATION_TYPE_LAYOUT_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
129
				{translate key="notification.email"}
130
			</span></li>
131
	</ul>
132
</ul>
133
134
<ul>
135
	<li>{translate key="notification.type.copyeditComment" param=$titleVar}</li>
136
	<ul class="plain">
137
		<li><span>
138
				<input type="checkbox" name="notificationCopyeditComment"{if !$smarty.const.NOTIFICATION_TYPE_COPYEDIT_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
139
				{translate key="notification.allow"}
140
			</span></li>
141
		<li><span>
142
				<input type="checkbox" name="emailNotificationCopyeditComment"{if $smarty.const.NOTIFICATION_TYPE_COPYEDIT_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
143
				{translate key="notification.email"}
144
			</span></li>
145
	</ul>
146
</ul>
147
148
<ul>
149
	<li>{translate key="notification.type.proofreadComment" param=$titleVar}</li>
150
	<ul class="plain">
151
		<li><span>
152
				<input type="checkbox" name="notificationProofreadComment"{if !$smarty.const.NOTIFICATION_TYPE_PROOFREAD_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
153
				{translate key="notification.allow"}
154
			</span></li>
155
		<li><span>
156
				<input type="checkbox" name="emailNotificationProofreadComment"{if $smarty.const.NOTIFICATION_TYPE_PROOFREAD_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
157
				{translate key="notification.email"}
158
			</span></li>
159
	</ul>
160
</ul>
161
162
<ul>
163
	<li>{translate key="notification.type.reviewerComment" param=$titleVar}</li>
164
	<ul class="plain">
165
		<li><span>
166
				<input type="checkbox" name="notificationReviewerComment"{if !$smarty.const.NOTIFICATION_TYPE_REVIEWER_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
167
				{translate key="notification.allow"}
168
			</span></li>
169
		<li><span>
170
				<input type="checkbox" name="emailNotificationReviewerComment"{if $smarty.const.NOTIFICATION_TYPE_REVIEWER_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
171
				{translate key="notification.email"}
172
			</span></li>
173
	</ul>
174
</ul>
175
176
<ul>
177
	<li>{translate key="notification.type.reviewerFormComment" param=$titleVar}</li>
178
	<ul class="plain">
179
		<li><span>
180
				<input type="checkbox" name="notificationReviewerFormComment"{if !$smarty.const.NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
181
				{translate key="notification.allow"}
182
			</span></li>
183
		<li><span>
184
				<input type="checkbox" name="emailNotificationReviewerFormComment"{if $smarty.const.NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
185
				{translate key="notification.email"}
186
			</span></li>
187
	</ul>
188
</ul>
189
190
<ul>
191
	<li>{translate key="notification.type.editorDecisionComment" param=$titleVar}</li>
192
	<ul class="plain">
193
		<li><span>
194
				<input type="checkbox" name="notificationEditorDecisionComment"{if !$smarty.const.NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
195
				{translate key="notification.allow"}
196
			</span></li>
197
		<li><span>
198
				<input type="checkbox" name="emailNotificationEditorDecisionComment"{if $smarty.const.NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
199
				{translate key="notification.email"}
200
			</span></li>
201
	</ul>
202
</ul>
203
	
204
<br />
205
206
<!-- Other events -->
207
<h4>{translate key="notification.type.other"}</h4>
208
209
<ul>
210
	<li>{translate key="notification.type.userComment" param=$titleVar}</li>
211
	<ul class="plain">
212
		<li><span>
213
				<input type="checkbox" name="notificationUserComment"{if !$smarty.const.NOTIFICATION_TYPE_USER_COMMENT|in_array:$notificationSettings} checked="checked"{/if} />
214
				{translate key="notification.allow"}
215
			</span></li>
216
		<li><span>
217
				<input type="checkbox" name="emailNotificationUserComment"{if $smarty.const.NOTIFICATION_TYPE_USER_COMMENT|in_array:$emailSettings} checked="checked"{/if} />
218
				{translate key="notification.email"}
219
			</span></li>
220
	</ul>
221
</ul>
222
223
<ul>
224
	<li>{translate key="notification.type.issuePublished" param=$userVar}</li>
225
	<ul class="plain">
226
		<li><span>
227
				<input type="checkbox" name="notificationPublishedIssue"{if !$smarty.const.NOTIFICATION_TYPE_PUBLISHED_ISSUE|in_array:$notificationSettings} checked="checked"{/if} />
228
				{translate key="notification.allow"}
229
			</span></li>
230
		<li><span>
231
				<input type="checkbox" name="emailNotificationPublishedIssue"{if $smarty.const.NOTIFICATION_TYPE_PUBLISHED_ISSUE|in_array:$emailSettings} checked="checked"{/if} />
232
				{translate key="notification.email"}
233
			</span></li>
234
	</ul>
235
</ul>
236
237
<p><input type="submit" value="{translate key="form.submit"}" class="button defaultButton" />  <input type="button" value="{translate key="common.cancel"}" class="button" onclick="document.location.href='{url op="notification" escape=false}'" /></p>
238
239
</form>
240
241
{include file="common/footer.tpl"}

Return to bug 3922