From 4cdfd330443fdaae715013492279528e5418bf4f Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Wed, 25 Apr 2012 11:32:43 +0200 Subject: [PATCH] CC-3667 : Preferences pages should have an option to enable/disable password recovery option --- .../application/forms/GeneralPreferences.php | 19 ++++++++++++++++++- airtime_mvc/application/models/Preference.php | 8 ++++++++ .../scripts/form/preferences_general.phtml | 16 ++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 5ee581c9d..aae6cc7b5 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -65,6 +65,16 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $week_start_day->setDecorators(array('ViewHelper')); $this->addElement($week_start_day); + //enable system emails. + $this->addElement('checkbox', 'enableSystemEmail', array( + 'label' => 'Enable System Emails (Password Reset)', + 'required' => false, + 'value' => Application_Model_Preference::GetEnableSystemEmail(), + 'decorators' => array( + 'ViewHelper' + ) + )); + // Add end date element $systemEmail = new Zend_Form_Element_Text('systemEmail'); $systemEmail->class = 'input_text'; @@ -74,7 +84,14 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm ->setFilters(array('StringTrim')) ->setValidators(array( 'NotEmpty', - 'EmailAddress' + 'EmailAddress', + new Zend_Validate_Callback(function ($value, $context) { + if ($context['enableSystemEmail']) { + return true; + } + + return false; + }) )) ->setDecorators(array('ViewHelper')); $this->addElement($systemEmail); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 0e728d56c..801180bf5 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -789,6 +789,14 @@ class Application_Model_Preference return self::GetValue("live_dj_source_connection_url"); } + public static function SetEnableSystemEmail($upload) { + self::SetValue("enable_system_email", $upload); + } + + public static function GetEnableSystemEmail() { + return self::GetValue("enable_system_email"); + } + public static function SetSystemEmail($value) { self::SetValue("system_email", $value, false); } diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index d331ed9ae..b62531480 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -93,6 +93,22 @@ + +
+ +
+
+ element->getElement('enableSystemEmail') ?> + element->getElement('enableSystemEmail')->hasErrors()) : ?> + + +
+