diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 5ee581c9d..fd61cf957 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'; @@ -75,8 +85,22 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm ->setValidators(array( 'NotEmpty', 'EmailAddress' - )) - ->setDecorators(array('ViewHelper')); + )) + ->setDecorators(array('ViewHelper')); + + $systemEmail->addValidator('Callback', true, array( + 'callback' => function($value, $context) { + if ($context['enableSystemEmail']) { + return true; + } + return false; + }, + 'messages' => array( + Zend_Validate_Callback::INVALID_VALUE => 'Email must be enabled' + ), + )); + + $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 @@ + +