classes/registration/form/RegistrationPolicyForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 define('REGISTRATION_EXPIRY_REMINDER_BEFORE_MONTHS_MIN', '1');
00018 define('REGISTRATION_EXPIRY_REMINDER_BEFORE_MONTHS_MAX', '12');
00019 define('REGISTRATION_EXPIRY_REMINDER_BEFORE_WEEKS_MIN', '0');
00020 define('REGISTRATION_EXPIRY_REMINDER_BEFORE_WEEKS_MAX', '3');
00021 define('REGISTRATION_EXPIRY_REMINDER_AFTER_MONTHS_MIN', '1');
00022 define('REGISTRATION_EXPIRY_REMINDER_AFTER_MONTHS_MAX', '12');
00023 define('REGISTRATION_EXPIRY_REMINDER_AFTER_WEEKS_MIN', '0');
00024 define('REGISTRATION_EXPIRY_REMINDER_AFTER_WEEKS_MAX', '3');
00025 
00026 import('form.Form');
00027 
00028 
00029 class RegistrationPolicyForm extends Form {
00030 
00032    var $validNumMonthsBeforeExpiry;
00033 
00035    var $validNumWeeksBeforeExpiry;
00036 
00038    var $validNumMonthsAfterExpiry;
00039 
00041    var $validNumWeeksAfterExpiry;
00042 
00046    function RegistrationPolicyForm() {
00047       for ($i=REGISTRATION_EXPIRY_REMINDER_BEFORE_MONTHS_MIN; $i<=REGISTRATION_EXPIRY_REMINDER_BEFORE_MONTHS_MAX; $i++) {
00048          $this->validNumMonthsBeforeExpiry[$i] = $i;
00049       }
00050 
00051       for ($i=REGISTRATION_EXPIRY_REMINDER_BEFORE_WEEKS_MIN; $i<=REGISTRATION_EXPIRY_REMINDER_BEFORE_WEEKS_MAX; $i++) {
00052          $this->validNumWeeksBeforeExpiry[$i] = $i;
00053       }
00054 
00055       for ($i=REGISTRATION_EXPIRY_REMINDER_AFTER_MONTHS_MIN; $i<=REGISTRATION_EXPIRY_REMINDER_AFTER_MONTHS_MAX; $i++) {
00056          $this->validNumMonthsAfterExpiry[$i] = $i;
00057       }
00058 
00059       for ($i=REGISTRATION_EXPIRY_REMINDER_AFTER_WEEKS_MIN; $i<=REGISTRATION_EXPIRY_REMINDER_AFTER_WEEKS_MAX; $i++) {
00060          $this->validNumWeeksAfterExpiry[$i] = $i;
00061       }
00062 
00063       parent::Form('registration/registrationPolicyForm.tpl');
00064 
00065       // If provided, registration contact email is valid
00066       $this->addCheck(new FormValidatorEmail($this, 'registrationEmail', 'optional', 'manager.registrationPolicies.registrationContactEmailValid'));
00067 
00068       // If provided expiry reminder months before value is valid value
00069       $this->addCheck(new FormValidatorInSet($this, 'numMonthsBeforeRegistrationExpiryReminder', 'optional', 'manager.registrationPolicies.numMonthsBeforeRegistrationExpiryReminderValid', array_keys($this->validNumMonthsBeforeExpiry)));
00070 
00071       // If provided expiry reminder weeks before value is valid value
00072       $this->addCheck(new FormValidatorInSet($this, 'numWeeksBeforeRegistrationExpiryReminder', 'optional', 'manager.registrationPolicies.numWeeksBeforeRegistrationExpiryReminderValid', array_keys($this->validNumWeeksBeforeExpiry)));
00073 
00074       // If provided expiry reminder months after value is valid value
00075       $this->addCheck(new FormValidatorInSet($this, 'numMonthsAfterRegistrationExpiryReminder', 'optional', 'manager.registrationPolicies.numMonthsAfterRegistrationExpiryReminderValid', array_keys($this->validNumMonthsAfterExpiry)));
00076 
00077       // If provided expiry reminder weeks after value is valid value
00078       $this->addCheck(new FormValidatorInSet($this, 'numWeeksAfterRegistrationExpiryReminder', 'optional', 'manager.registrationPolicies.numWeeksAfterRegistrationExpiryReminderValid', array_keys($this->validNumWeeksAfterExpiry)));
00079 
00080       $this->addCheck(new FormValidatorPost($this));
00081    }
00082 
00086    function display() {
00087       $templateMgr =& TemplateManager::getManager();
00088       $templateMgr->assign('validNumMonthsBeforeExpiry', $this->validNumMonthsBeforeExpiry);
00089       $templateMgr->assign('validNumWeeksBeforeExpiry', $this->validNumWeeksBeforeExpiry);
00090       $templateMgr->assign('validNumMonthsAfterExpiry', $this->validNumMonthsAfterExpiry);
00091       $templateMgr->assign('validNumWeeksAfterExpiry', $this->validNumWeeksAfterExpiry);
00092 
00093       parent::display();
00094    }
00095 
00099    function initData() {
00100       $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00101       $schedConf =& Request::getSchedConf();
00102       $schedConfId = $schedConf->getId();
00103 
00104       $this->_data = array(
00105          'registrationName' => $schedConfSettingsDao->getSetting($schedConfId, 'registrationName'),
00106          'registrationEmail' => $schedConfSettingsDao->getSetting($schedConfId, 'registrationEmail'),
00107          'registrationPhone' => $schedConfSettingsDao->getSetting($schedConfId, 'registrationPhone'),
00108          'registrationFax' => $schedConfSettingsDao->getSetting($schedConfId, 'registrationFax'),
00109          'registrationMailingAddress' => $schedConfSettingsDao->getSetting($schedConfId, 'registrationMailingAddress'),
00110          'registrationAdditionalInformation' => $schedConfSettingsDao->getSetting($schedConfId, 'registrationAdditionalInformation'),
00111          'delayedOpenAccessPolicy' => $schedConfSettingsDao->getSetting($schedConfId, 'delayedOpenAccessPolicy'),
00112          'enableOpenAccessNotification' => $schedConfSettingsDao->getSetting($schedConfId, 'enableOpenAccessNotification'),
00113          'enableAuthorSelfArchive' => $schedConfSettingsDao->getSetting($schedConfId, 'enableAuthorSelfArchive'),
00114          'authorSelfArchivePolicy' => $schedConfSettingsDao->getSetting($schedConfId, 'authorSelfArchivePolicy'),
00115          'enableRegistrationExpiryReminderBeforeMonths' => $schedConfSettingsDao->getSetting($schedConfId, 'enableRegistrationExpiryReminderBeforeMonths'),
00116          'numMonthsBeforeRegistrationExpiryReminder' => $schedConfSettingsDao->getSetting($schedConfId, 'numMonthsBeforeRegistrationExpiryReminder'),
00117          'enableRegistrationExpiryReminderBeforeWeeks' => $schedConfSettingsDao->getSetting($schedConfId, 'enableRegistrationExpiryReminderBeforeWeeks'),
00118          'numWeeksBeforeRegistrationExpiryReminder' => $schedConfSettingsDao->getSetting($schedConfId, 'numWeeksBeforeRegistrationExpiryReminder'),
00119          'enableRegistrationExpiryReminderAfterMonths' => $schedConfSettingsDao->getSetting($schedConfId, 'enableRegistrationExpiryReminderAfterMonths'),
00120          'numMonthsAfterRegistrationExpiryReminder' => $schedConfSettingsDao->getSetting($schedConfId, 'numMonthsAfterRegistrationExpiryReminder'),
00121          'enableRegistrationExpiryReminderAfterWeeks' => $schedConfSettingsDao->getSetting($schedConfId, 'enableRegistrationExpiryReminderAfterWeeks'),
00122          'numWeeksAfterRegistrationExpiryReminder' => $schedConfSettingsDao->getSetting($schedConfId, 'numWeeksAfterRegistrationExpiryReminder')
00123       );
00124    }
00125 
00129    function readInputData() {
00130       $this->readUserVars(array('registrationName', 'registrationEmail', 'registrationPhone', 'registrationFax', 'registrationMailingAddress', 'registrationAdditionalInformation', 'enableDelayedOpenAccess', 'delayedOpenAccessDuration', 'delayedOpenAccessPolicy', 'enableOpenAccessNotification', 'enableAuthorSelfArchive', 'authorSelfArchivePolicy', 'enableRegistrationExpiryReminderBeforeMonths', 'numMonthsBeforeRegistrationExpiryReminder', 'enableRegistrationExpiryReminderBeforeWeeks', 'numWeeksBeforeRegistrationExpiryReminder', 'enableRegistrationExpiryReminderAfterWeeks', 'numWeeksAfterRegistrationExpiryReminder', 'enableRegistrationExpiryReminderAfterMonths', 'numMonthsAfterRegistrationExpiryReminder'));
00131 
00132       // If expiry reminder before months is selected, ensure a valid month value is provided
00133       if ($this->_data['enableRegistrationExpiryReminderBeforeMonths'] == 1) {
00134          $this->addCheck(new FormValidatorInSet($this, 'numMonthsBeforeRegistrationExpiryReminder', 'required', 'manager.registrationPolicies.numMonthsBeforeRegistrationExpiryReminderValid', array_keys($this->validNumMonthsBeforeExpiry)));
00135       }
00136 
00137       // If expiry reminder before weeks is selected, ensure a valid week value is provided
00138       if ($this->_data['enableRegistrationExpiryReminderBeforeWeeks'] == 1) {
00139          $this->addCheck(new FormValidatorInSet($this, 'numWeeksBeforeRegistrationExpiryReminder', 'required', 'manager.registrationPolicies.numWeeksBeforeRegistrationExpiryReminderValid', array_keys($this->validNumWeeksBeforeExpiry)));
00140       }
00141 
00142       // If expiry reminder after months is selected, ensure a valid month value is provided
00143       if ($this->_data['enableRegistrationExpiryReminderAfterMonths'] == 1) {
00144          $this->addCheck(new FormValidatorInSet($this, 'numMonthsAfterRegistrationExpiryReminder', 'required', 'manager.registrationPolicies.numMonthsAfterRegistrationExpiryReminderValid', array_keys($this->validNumMonthsAfterExpiry)));
00145       }
00146 
00147       // If expiry reminder after weeks is selected, ensure a valid week value is provided
00148       if ($this->_data['enableRegistrationExpiryReminderAfterWeeks'] == 1) {
00149          $this->addCheck(new FormValidatorInSet($this, 'numWeeksAfterRegistrationExpiryReminder', 'required', 'manager.registrationPolicies.numWeeksAfterRegistrationExpiryReminderValid', array_keys($this->validNumWeeksAfterExpiry)));
00150       }
00151    }
00152 
00157    function getLocaleFieldNames() {
00158       return array('registrationAdditionalInformation', 'delayedOpenAccessPolicy', 'authorSelfArchivePolicy');
00159    }
00160 
00164    function execute() {
00165       $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00166       $schedConf =& Request::getSchedConf();
00167       $schedConfId = $schedConf->getId();
00168 
00169       $schedConfSettingsDao->updateSetting($schedConfId, 'registrationName', $this->getData('registrationName'), 'string');
00170       $schedConfSettingsDao->updateSetting($schedConfId, 'registrationEmail', $this->getData('registrationEmail'), 'string');
00171       $schedConfSettingsDao->updateSetting($schedConfId, 'registrationPhone', $this->getData('registrationPhone'), 'string');
00172       $schedConfSettingsDao->updateSetting($schedConfId, 'registrationFax', $this->getData('registrationFax'), 'string');
00173       $schedConfSettingsDao->updateSetting($schedConfId, 'registrationMailingAddress', $this->getData('registrationMailingAddress'), 'string');
00174       $schedConfSettingsDao->updateSetting($schedConfId, 'registrationAdditionalInformation', $this->getData('registrationAdditionalInformation'), 'string', true); // Localized
00175       $schedConfSettingsDao->updateSetting($schedConfId, 'delayedOpenAccessPolicy', $this->getData('delayedOpenAccessPolicy'), 'string', true); // Localized
00176       $schedConfSettingsDao->updateSetting($schedConfId, 'enableOpenAccessNotification', $this->getData('enableOpenAccessNotification') == null ? 0 : $this->getData('enableOpenAccessNotification'), 'bool');
00177       $schedConfSettingsDao->updateSetting($schedConfId, 'enableAuthorSelfArchive', $this->getData('enableAuthorSelfArchive') == null ? 0 : $this->getData('enableAuthorSelfArchive'), 'bool');
00178       $schedConfSettingsDao->updateSetting($schedConfId, 'authorSelfArchivePolicy', $this->getData('authorSelfArchivePolicy'), 'string', true); // Localized
00179       $schedConfSettingsDao->updateSetting($schedConfId, 'enableRegistrationExpiryReminderBeforeMonths', $this->getData('enableRegistrationExpiryReminderBeforeMonths') == null ? 0 : $this->getData('enableRegistrationExpiryReminderBeforeMonths'), 'bool');
00180       $schedConfSettingsDao->updateSetting($schedConfId, 'numMonthsBeforeRegistrationExpiryReminder', $this->getData('numMonthsBeforeRegistrationExpiryReminder'), 'int');
00181       $schedConfSettingsDao->updateSetting($schedConfId, 'enableRegistrationExpiryReminderBeforeWeeks', $this->getData('enableRegistrationExpiryReminderBeforeWeeks') == null ? 0 : $this->getData('enableRegistrationExpiryReminderBeforeWeeks'), 'bool');
00182       $schedConfSettingsDao->updateSetting($schedConfId, 'numWeeksBeforeRegistrationExpiryReminder', $this->getData('numWeeksBeforeRegistrationExpiryReminder'), 'int');
00183       $schedConfSettingsDao->updateSetting($schedConfId, 'enableRegistrationExpiryReminderAfterMonths', $this->getData('enableRegistrationExpiryReminderAfterMonths') == null ? 0 : $this->getData('enableRegistrationExpiryReminderAfterMonths'), 'bool');
00184       $schedConfSettingsDao->updateSetting($schedConfId, 'numMonthsAfterRegistrationExpiryReminder', $this->getData('numMonthsAfterRegistrationExpiryReminder'), 'int');
00185       $schedConfSettingsDao->updateSetting($schedConfId, 'enableRegistrationExpiryReminderAfterWeeks', $this->getData('enableRegistrationExpiryReminderAfterWeeks') == null ? 0 : $this->getData('enableRegistrationExpiryReminderAfterWeeks'), 'bool');
00186       $schedConfSettingsDao->updateSetting($schedConfId, 'numWeeksAfterRegistrationExpiryReminder', $this->getData('numWeeksAfterRegistrationExpiryReminder'), 'int');
00187    }
00188 }
00189 
00190 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7