|
|
| 1 |
<?php |
| 2 |
/** |
| 3 |
* @defgroup notification_form |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* @file classes/notification/form/NotificationSettingsForm.inc.php |
| 8 |
* |
| 9 |
* Copyright (c) 2000-2008 John Willinsky |
| 10 |
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. |
| 11 |
* |
| 12 |
* @class NotificationSettingsForm |
| 13 |
* @ingroup notification_form |
| 14 |
* |
| 15 |
* @brief Form to edit notification settings. |
| 16 |
*/ |
| 17 |
|
| 18 |
// $Id: NotificationSettingsForm.inc.php,v 1.5 2008/11/05 00:45:13 mcrider Exp $ |
| 19 |
|
| 20 |
|
| 21 |
import('notification.form.PKPNotificationSettingsForm'); |
| 22 |
|
| 23 |
class NotificationSettingsForm extends PKPNotificationSettingsForm { |
| 24 |
/** |
| 25 |
* Constructor. |
| 26 |
*/ |
| 27 |
function NotificationSettingsForm() { |
| 28 |
parent::PKPNotificationSettingsForm(); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Assign form data to user-submitted data. |
| 33 |
*/ |
| 34 |
function readInputData() { |
| 35 |
$this->readUserVars( |
| 36 |
array('notificationArticleSubmitted', |
| 37 |
'notificationMetadataModified', |
| 38 |
'notificationSuppFileAdded', |
| 39 |
'notificationSuppFileModified', |
| 40 |
'notificationGalleyAdded', |
| 41 |
'notificationGalleyModified', |
| 42 |
'notificationSubmissionComment', |
| 43 |
'notificationLayoutComment', |
| 44 |
'notificationCopyeditComment', |
| 45 |
'notificationProofreadComment', |
| 46 |
'notificationReviewerComment', |
| 47 |
'notificationReviewerFormComment', |
| 48 |
'notificationEditorDecisionComment', |
| 49 |
'notificationPublishedIssue', |
| 50 |
'notificationUserComment', |
| 51 |
'notificationNewAnnouncement', |
| 52 |
'emailNotificationArticleSubmitted', |
| 53 |
'emailNotificationMetadataModified', |
| 54 |
'emailNotificationSuppFileAdded', |
| 55 |
'emailNotificationSuppFileModified', |
| 56 |
'emailNotificationGalleyAdded', |
| 57 |
'emailNotificationGalleyModified', |
| 58 |
'emailNotificationSubmissionComment', |
| 59 |
'emailNotificationLayoutComment', |
| 60 |
'emailNotificationCopyeditComment', |
| 61 |
'emailNotificationProofreadComment', |
| 62 |
'emailNotificationReviewerComment', |
| 63 |
'emailNotificationReviewerFormComment', |
| 64 |
'emailNotificationEditorDecisionComment', |
| 65 |
'emailNotificationPublishedIssue', |
| 66 |
'emailNotificationUserComment', |
| 67 |
'emailNotificationNewAnnouncement') |
| 68 |
); |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Display the form. |
| 73 |
*/ |
| 74 |
function display() { |
| 75 |
$journalDao = &DAORegistry::getDAO('JournalDAO'); |
| 76 |
$journals = &$journalDao->getJournalTitles(); |
| 77 |
|
| 78 |
$canOnlyRead = true; |
| 79 |
$canOnlyReview = false; |
| 80 |
|
| 81 |
if (Validation::isReviewer()) { |
| 82 |
$canOnlyRead = false; |
| 83 |
$canOnlyReview = true; |
| 84 |
} |
| 85 |
if (Validation::isSiteAdmin() || Validation::isJournalManager() || Validation::isEditor() || |
| 86 |
Validation::isSectionEditor() || Validation::isLayoutEditor() || Validation::isCopyeditor() || Validation::isProofreader()) { |
| 87 |
$canOnlyRead = false; |
| 88 |
$canOnlyReview = false; |
| 89 |
} |
| 90 |
|
| 91 |
$templateMgr = &TemplateManager::getManager(); |
| 92 |
$templateMgr->assign('canOnlyRead', $canOnlyRead); |
| 93 |
$templateMgr->assign('canOnlyReview', $canOnlyReview); |
| 94 |
return parent::display(); |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Save site settings. |
| 99 |
*/ |
| 100 |
function execute() { |
| 101 |
$user = Request::getUser(); |
| 102 |
$userId = $user->getUserId(); |
| 103 |
|
| 104 |
// Notification settings |
| 105 |
$settings = array(); |
| 106 |
if(!$this->getData('notificationArticleSubmitted')) $settings[] = NOTIFICATION_TYPE_ARTICLE_SUBMITTED; |
| 107 |
if(!$this->getData('notificationMetadataModified')) $settings[] = NOTIFICATION_TYPE_METADATA_MODIFIED; |
| 108 |
if(!$this->getData('notificationSuppFileAdded')) $settings[] = NOTIFICATION_TYPE_SUPP_FILE_ADDED; |
| 109 |
if(!$this->getData('notificationSuppFileModified')) $settings[] = NOTIFICATION_TYPE_SUPP_FILE_MODIFIED; |
| 110 |
if(!$this->getData('notificationGalleyAdded')) $settings[] = NOTIFICATION_TYPE_GALLEY_ADDED; |
| 111 |
if(!$this->getData('notificationGalleyModified')) $settings[] = NOTIFICATION_TYPE_GALLEY_MODIFIED; |
| 112 |
if(!$this->getData('notificationSubmissionComment')) $settings[] = NOTIFICATION_TYPE_SUBMISSION_COMMENT; |
| 113 |
if(!$this->getData('notificationLayoutComment')) $settings[] = NOTIFICATION_TYPE_LAYOUT_COMMENT; |
| 114 |
if(!$this->getData('notificationCopyeditComment')) $settings[] = NOTIFICATION_TYPE_COPYEDIT_COMMENT; |
| 115 |
if(!$this->getData('notificationProofreadComment')) $settings[] = NOTIFICATION_TYPE_PROOFREAD_COMMENT; |
| 116 |
if(!$this->getData('notificationReviewerComment')) $settings[] = NOTIFICATION_TYPE_REVIEWER_COMMENT; |
| 117 |
if(!$this->getData('notificationReviewerFormComment')) $settings[] = NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT; |
| 118 |
if(!$this->getData('notificationEditorDecisionComment')) $settings[] = NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT; |
| 119 |
if(!$this->getData('notificationPublishedIssue')) $settings[] = NOTIFICATION_TYPE_PUBLISHED_ISSUE; |
| 120 |
if(!$this->getData('notificationUserComment')) $settings[] = NOTIFICATION_TYPE_USER_COMMENT; |
| 121 |
if(!$this->getData('notificationNewAnnouncement')) $settings[] = NOTIFICATION_TYPE_NEW_ANNOUNCEMENT; |
| 122 |
|
| 123 |
// Email settings |
| 124 |
$emailSettings = array(); |
| 125 |
if($this->getData('emailNotificationArticleSubmitted')) $emailSettings[] = NOTIFICATION_TYPE_ARTICLE_SUBMITTED; |
| 126 |
if($this->getData('emailNotificationMetadataModified')) $emailSettings[] = NOTIFICATION_TYPE_METADATA_MODIFIED; |
| 127 |
if($this->getData('emailNotificationSuppFileAdded')) $emailSettings[] = NOTIFICATION_TYPE_SUPP_FILE_ADDED; |
| 128 |
if($this->getData('emailNotificationSuppFileModified')) $emailSettings[] = NOTIFICATION_TYPE_SUPP_FILE_MODIFIED; |
| 129 |
if($this->getData('emailNotificationGalleyAdded')) $emailSettings[] = NOTIFICATION_TYPE_GALLEY_ADDED; |
| 130 |
if($this->getData('emailNotificationGalleyModified')) $emailSettings[] = NOTIFICATION_TYPE_GALLEY_MODIFIED; |
| 131 |
if($this->getData('emailNotificationSubmissionComment')) $emailSettings[] = NOTIFICATION_TYPE_SUBMISSION_COMMENT; |
| 132 |
if($this->getData('emailNotificationLayoutComment')) $emailSettings[] = NOTIFICATION_TYPE_LAYOUT_COMMENT; |
| 133 |
if($this->getData('emailNotificationCopyeditComment')) $emailSettings[] = NOTIFICATION_TYPE_COPYEDIT_COMMENT; |
| 134 |
if($this->getData('emailNotificationProofreadComment')) $emailSettings[] = NOTIFICATION_TYPE_PROOFREAD_COMMENT; |
| 135 |
if($this->getData('emailNotificationReviewerComment')) $emailSettings[] = NOTIFICATION_TYPE_REVIEWER_COMMENT; |
| 136 |
if($this->getData('emailNotificationReviewerFormComment')) $emailSettings[] = NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT; |
| 137 |
if($this->getData('emailNotificationEditorDecisionComment')) $emailSettings[] = NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT; |
| 138 |
if($this->getData('emailNotificationPublishedIssue')) $emailSettings[] = NOTIFICATION_TYPE_PUBLISHED_ISSUE; |
| 139 |
if($this->getData('emailNotificationUserComment')) $emailSettings[] = NOTIFICATION_TYPE_USER_COMMENT; |
| 140 |
if($this->getData('emailNotificationNewAnnouncement')) $emailSettings[] = NOTIFICATION_TYPE_NEW_ANNOUNCEMENT; |
| 141 |
|
| 142 |
$notificationSettingsDao =& DAORegistry::getDAO('NotificationSettingsDAO'); |
| 143 |
$notificationSettingsDao->updateNotificationSettings($settings, $userId); |
| 144 |
$notificationSettingsDao->updateNotificationEmailSettings($emailSettings, $userId); |
| 145 |
|
| 146 |
return true; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
} |
| 151 |
|
| 152 |
?> |