From b2327472e897b4ab4d8e6c464da5ccc9f17e43ef Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 28 Aug 2012 23:04:55 -0400 Subject: [PATCH] CC-4090: Make code style PSR compliant - part 4 -forms directory --- .../forms/AddShowAbsoluteRebroadcastDates.php | 29 +- .../application/forms/AddShowLiveStream.php | 12 +- airtime_mvc/application/forms/AddShowRR.php | 10 +- .../forms/AddShowRebroadcastDates.php | 31 +- .../application/forms/AddShowRepeats.php | 19 +- .../application/forms/AddShowStyle.php | 17 +- airtime_mvc/application/forms/AddShowWhat.php | 10 +- airtime_mvc/application/forms/AddShowWhen.php | 51 +- airtime_mvc/application/forms/AddShowWho.php | 10 +- airtime_mvc/application/forms/AddUser.php | 10 +- airtime_mvc/application/forms/EditAudioMD.php | 2 - .../forms/EmailServerPreferences.php | 14 +- .../application/forms/GeneralPreferences.php | 15 +- .../forms/LiveStreamingPreferences.php | 43 +- airtime_mvc/application/forms/Login.php | 13 +- .../application/forms/PasswordChange.php | 4 +- .../application/forms/PasswordRestore.php | 8 +- .../application/forms/RegisterAirtime.php | 10 +- .../application/forms/ScheduleShow.php | 2 - airtime_mvc/application/forms/ShowBuilder.php | 5 +- .../application/forms/SmartBlockCriteria.php | 571 +++++++++--------- .../forms/SoundcloudPreferences.php | 2 - .../application/forms/StreamSetting.php | 22 +- .../forms/StreamSettingSubForm.php | 63 +- .../application/forms/SupportSettings.php | 14 +- .../forms/WatchedDirPreferences.php | 10 +- .../forms/customfilters/ImageSize.php | 8 +- .../customvalidators/ConditionalNotEmpty.php | 13 +- .../customvalidators/PasswordNotEmpty.php | 6 +- 29 files changed, 505 insertions(+), 519 deletions(-) diff --git a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php index a0ab05169..8bfa71b2f 100644 --- a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -9,7 +9,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast-absolute.phtml')) )); - for($i=1; $i<=10; $i++) { + for ($i=1; $i<=10; $i++) { $text = new Zend_Form_Element_Text("add_show_rebroadcast_date_absolute_$i"); $text->setAttrib('class', 'input_text'); @@ -30,43 +30,41 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm } } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } - public function checkReliantFields($formData) { - + public function checkReliantFields($formData) + { $noError = true; - for($i=1; $i<=10; $i++) { + for ($i=1; $i<=10; $i++) { $valid = true; $day = $formData['add_show_rebroadcast_date_absolute_'.$i]; $time = $formData['add_show_rebroadcast_time_absolute_'.$i]; - if(trim($day) == "" && trim($time) == "") { + if (trim($day) == "" && trim($time) == "") { continue; } - if (trim($day) == ""){ + if (trim($day) == "") { $this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array("Day must be specified")); $valid = false; } - - if (trim($time) == ""){ + if (trim($time) == "") { $this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Time must be specified")); $valid = false; } - if($valid === false) { + if ($valid === false) { $noError = false; continue; } @@ -84,7 +82,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm $rebroad_start = $day." ".$formData['add_show_rebroadcast_time_absolute_'.$i]; $rebroad_start = new DateTime($rebroad_start); - if($rebroad_start < $show_end) { + if ($rebroad_start < $show_end) { $this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast")); $valid = false; $noError = false; @@ -94,4 +92,3 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm return $noError; } } - diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index ecaf7a226..b241a54f0 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -44,7 +44,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm $this->addElement($custom_password); $connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL(); - if(trim($connection_url) == ""){ + if (trim($connection_url) == "") { $connection_url = "N/A"; } @@ -53,21 +53,23 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm )); } - public function isValid($data){ + public function isValid($data) + { $isValid = parent::isValid($data); - if($data['cb_custom_auth'] == 1){ - if(trim($data['custom_username']) == ''){ + if ($data['cb_custom_auth'] == 1) { + if (trim($data['custom_username']) == '') { $element = $this->getElement("custom_username"); $element->addError("Username field cannot be empty."); $isValid = false; } - if(trim($data['custom_password']) == ''){ + if (trim($data['custom_password']) == '') { $element = $this->getElement("custom_password"); $element->addError("Password field cannot be empty."); $isValid = false; } } + return $isValid; } } diff --git a/airtime_mvc/application/forms/AddShowRR.php b/airtime_mvc/application/forms/AddShowRR.php index cbc113467..5c33723b6 100644 --- a/airtime_mvc/application/forms/AddShowRR.php +++ b/airtime_mvc/application/forms/AddShowRR.php @@ -18,16 +18,14 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm )); } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } } - diff --git a/airtime_mvc/application/forms/AddShowRebroadcastDates.php b/airtime_mvc/application/forms/AddShowRebroadcastDates.php index d946c1a37..7bf0ea3a4 100644 --- a/airtime_mvc/application/forms/AddShowRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowRebroadcastDates.php @@ -11,11 +11,11 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $relativeDates = array(); $relativeDates[""] = ""; - for($i=0; $i<=30; $i++) { + for ($i=0; $i<=30; $i++) { $relativeDates["$i days"] = "+$i days"; } - for($i=1; $i<=10; $i++) { + for ($i=1; $i<=10; $i++) { $select = new Zend_Form_Element_Select("add_show_rebroadcast_date_$i"); $select->setAttrib('class', 'input_select'); @@ -35,43 +35,41 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm } } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } - public function checkReliantFields($formData) { - + public function checkReliantFields($formData) + { $noError = true; - for($i=1; $i<=10; $i++) { + for ($i=1; $i<=10; $i++) { $valid = true; $days = $formData['add_show_rebroadcast_date_'.$i]; $time = $formData['add_show_rebroadcast_time_'.$i]; - if(trim($days) == "" && trim($time) == "") { + if (trim($days) == "" && trim($time) == "") { continue; } - if (trim($days) == ""){ + if (trim($days) == "") { $this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array("Day must be specified")); $valid = false; } - - if (trim($time) == ""){ + if (trim($time) == "") { $this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Time must be specified")); $valid = false; } - if($valid === false) { + if ($valid === false) { $noError = false; continue; } @@ -93,7 +91,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm $rebroad_start = new DateTime($rebroad_start); $rebroad_start->add(new DateInterval("P".$day."D")); - if($rebroad_start < $show_end) { + if ($rebroad_start < $show_end) { $this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast")); $valid = false; $noError = false; @@ -103,4 +101,3 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm return $noError; } } - diff --git a/airtime_mvc/application/forms/AddShowRepeats.php b/airtime_mvc/application/forms/AddShowRepeats.php index ffaacb47b..85bb7cb44 100644 --- a/airtime_mvc/application/forms/AddShowRepeats.php +++ b/airtime_mvc/application/forms/AddShowRepeats.php @@ -56,28 +56,28 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm )); } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } - public function checkReliantFields($formData) { - - if (!$formData['add_show_no_end']){ + public function checkReliantFields($formData) + { + if (!$formData['add_show_no_end']) { $start_timestamp = $formData['add_show_start_date']; $end_timestamp = $formData['add_show_end_date']; $start_epoch = strtotime($start_timestamp); $end_epoch = strtotime($end_timestamp); - if($end_epoch < $start_epoch) { + if ($end_epoch < $start_epoch) { $this->getElement('add_show_end_date')->setErrors(array('End date must be after start date')); + return false; } } @@ -86,4 +86,3 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm } } - diff --git a/airtime_mvc/application/forms/AddShowStyle.php b/airtime_mvc/application/forms/AddShowStyle.php index c60c1da81..6ea301874 100644 --- a/airtime_mvc/application/forms/AddShowStyle.php +++ b/airtime_mvc/application/forms/AddShowStyle.php @@ -24,7 +24,6 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm array('stringLength', false, array(6, 6)) )); - // Add show color input $this->addElement('text', 'add_show_color', array( 'label' => 'Text Colour:', @@ -39,22 +38,20 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm 'class' => 'big' )))); - $c->setValidators(array( - 'Hex', - array('stringLength', false, array(6, 6)) + $c->setValidators(array( + 'Hex', + array('stringLength', false, array(6, 6)) )); } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } } - diff --git a/airtime_mvc/application/forms/AddShowWhat.php b/airtime_mvc/application/forms/AddShowWhat.php index 14e75dd97..7a092f4b5 100644 --- a/airtime_mvc/application/forms/AddShowWhat.php +++ b/airtime_mvc/application/forms/AddShowWhat.php @@ -66,15 +66,13 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } } - diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 4ad36f31a..53a545dca 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -83,7 +83,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } - public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null) { + public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null) + { $valid = true; $hours; @@ -96,14 +97,14 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $nowDateTime = new DateTime(); $showStartDateTime = new DateTime($start_time); $showEndDateTime = new DateTime($end_time); - if ($validateStartDate){ - if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { + if ($validateStartDate) { + if ($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); $valid = false; } // if edit action, check if original show start time is in the past. CC-3864 - if($originalStartDate){ - if($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) { + if ($originalStartDate) { + if ($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) { $this->getElement('add_show_start_time')->setValue($originalStartDate->format("H:i")); $this->getElement('add_show_start_date')->setValue($originalStartDate->format("Y-m-d")); $this->getElement('add_show_start_time')->setErrors(array('Cannot modify start date/time of the show that is already started')); @@ -114,7 +115,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } // if end time is in the past, return error - if($showEndDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { + if ($showEndDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { $this->getElement('add_show_end_time')->setErrors(array('End date/time cannot be in the past')); $valid = false; } @@ -124,20 +125,19 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm if (preg_match($pattern, $formData['add_show_duration'], $matches) && count($matches) == 3) { $hours = $matches[1]; $minutes = $matches[2]; - if( $formData["add_show_duration"] == "00h 00m" ) { + if ($formData["add_show_duration"] == "00h 00m") { $this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00h 00m')); $valid = false; - }elseif(strpos($formData["add_show_duration"], 'h') !== false && $hours >= 24) { + } elseif (strpos($formData["add_show_duration"], 'h') !== false && $hours >= 24) { if ($hours > 24 || ($hours == 24 && $minutes > 0)) { $this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h')); $valid = false; } - }elseif( strstr($formData["add_show_duration"], '-') ){ + } elseif ( strstr($formData["add_show_duration"], '-') ) { $this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m')); $valid = false; } - } - else { + } else { $valid = false; } @@ -188,11 +188,11 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm */ if (!$overlapping) { $startDow = date("w", $show_start->getTimestamp()); - foreach($formData["add_show_day_check"] as $day) { + foreach ($formData["add_show_day_check"] as $day) { $repeatShowStart = clone $show_start; $repeatShowEnd = clone $show_end; $daysAdd=0; - if ($startDow !== $day){ + if ($startDow !== $day) { if ($startDow > $day) $daysAdd = 6 - $startDow + 1 + $day; else @@ -263,34 +263,31 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm return $valid; } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } - public function disableRepeatCheckbox(){ + public function disableRepeatCheckbox() + { $element = $this->getElement('add_show_repeats'); - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } - public function disableStartDateAndTime(){ + public function disableStartDateAndTime() + { $elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time')); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } } - diff --git a/airtime_mvc/application/forms/AddShowWho.php b/airtime_mvc/application/forms/AddShowWho.php index 316d1a78b..71d9f9fcc 100644 --- a/airtime_mvc/application/forms/AddShowWho.php +++ b/airtime_mvc/application/forms/AddShowWho.php @@ -27,15 +27,13 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm $this->addElement($hosts); } - public function disable(){ + public function disable() + { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib('disabled','disabled'); } } } } - diff --git a/airtime_mvc/application/forms/AddUser.php b/airtime_mvc/application/forms/AddUser.php index 00040cfbd..059dbe8af 100644 --- a/airtime_mvc/application/forms/AddUser.php +++ b/airtime_mvc/application/forms/AddUser.php @@ -92,13 +92,14 @@ class Application_Form_AddUser extends Zend_Form $this->addElement($submit); } - public function validateLogin($data){ - - if (strlen($data['user_id']) == 0){ + public function validateLogin($data) + { + if (strlen($data['user_id']) == 0) { $count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count(); - if ($count != 0){ + if ($count != 0) { $this->getElement('login')->setErrors(array("Login name is not unique.")); + return false; } } @@ -106,4 +107,3 @@ class Application_Form_AddUser extends Zend_Form return true; } } - diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php index 06627898d..92ddcdf0d 100644 --- a/airtime_mvc/application/forms/EditAudioMD.php +++ b/airtime_mvc/application/forms/EditAudioMD.php @@ -151,6 +151,4 @@ class Application_Form_EditAudioMD extends Zend_Form )); } - } - diff --git a/airtime_mvc/application/forms/EmailServerPreferences.php b/airtime_mvc/application/forms/EmailServerPreferences.php index ef24ba0e7..601cfb319 100644 --- a/airtime_mvc/application/forms/EmailServerPreferences.php +++ b/airtime_mvc/application/forms/EmailServerPreferences.php @@ -41,13 +41,13 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm 'viewHelper' ) )); - + $this->addElement('checkbox', 'msRequiresAuth', array( 'label' => 'Requires Authentication', 'required' => false, 'value' => Application_Model_Preference::GetMailServerRequiresAuth(), 'decorators' => array( - 'viewHelper' + 'viewHelper' ) )); @@ -60,7 +60,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm 'allowEmpty' => false, 'validators' => array( new ConditionalNotEmpty(array( - 'configureMailServer' => '1' + 'configureMailServer' => '1' )) ) )); @@ -74,7 +74,7 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm 'allowEmpty' => false, 'validators' => array( new ConditionalNotEmpty(array( - 'configureMailServer' => '1', + 'configureMailServer' => '1', 'msRequiresAuth' => '1' )) ) @@ -89,8 +89,8 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm 'allowEmpty' => false, 'validators' => array( new ConditionalNotEmpty(array( - 'configureMailServer' => '1', - 'msRequiresAuth' => '1' + 'configureMailServer' => '1', + 'msRequiresAuth' => '1' )) ), 'renderPassword' => true @@ -108,6 +108,4 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm } - } - diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 78b72b0d5..59bf8a0f8 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -14,7 +14,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm )); $defaultFade = Application_Model_Preference::GetDefaultFade(); - if($defaultFade == ""){ + if ($defaultFade == "") { $defaultFade = '0.500000'; } @@ -70,7 +70,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $this->addElement($week_start_day); } - private function getTimezones(){ + private function getTimezones() + { $regions = array( 'Africa' => DateTimeZone::AFRICA, 'America' => DateTimeZone::AMERICA, @@ -86,9 +87,9 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $tzlist = array(); - foreach ($regions as $name => $mask){ + foreach ($regions as $name => $mask) { $ids = DateTimeZone::listIdentifiers($mask); - foreach ($ids as $id){ + foreach ($ids as $id) { $tzlist[$id] = str_replace("_", " ", $id); } } @@ -96,8 +97,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm return $tzlist; } - - private function getWeekStartDays() { + private function getWeekStartDays() + { $days = array( 'Sunday', 'Monday', @@ -107,7 +108,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm 'Friday', 'Saturday' ); + return $days; } } - diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index 2b7e47256..8f7ac95c0 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -11,7 +11,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $defaultFade = Application_Model_Preference::GetDefaultTransitionFade(); - if($defaultFade == ""){ + if ($defaultFade == "") { $defaultFade = '00.000000'; } @@ -50,9 +50,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($master_username); //Master password - if($isDemo){ + if ($isDemo) { $master_password = new Zend_Form_Element_Text('master_password'); - }else{ + } else { $master_password = new Zend_Form_Element_Password('master_password'); $master_password->setAttrib('renderPassword','true'); } @@ -121,19 +121,18 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($live_dj_mount); } // demo only code - if(!$isStreamConfigable){ + if (!$isStreamConfigable) { $elements = $this->getElements(); - foreach ($elements as $element) - { - if ($element->getType() != 'Zend_Form_Element_Hidden') - { + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib("disabled", "disabled"); } } } } - public function updateVariables(){ + public function updateVariables() + { global $CC_CONFIG; $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; @@ -146,50 +145,52 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm )); } - public function isValid($data){ + public function isValid($data) + { $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $isValid = parent::isValid($data); if (!$isSaas) { $master_harbor_input_port = $data['master_harbor_input_port']; $dj_harbor_input_port = $data['dj_harbor_input_port']; - if($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != ""){ + if ($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != "") { $element = $this->getElement("dj_harbor_input_port"); $element->addError("You cannot use same port as Master DJ port."); } - if($master_harbor_input_port != ""){ - if(is_numeric($master_harbor_input_port)){ - if($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()){ + if ($master_harbor_input_port != "") { + if (is_numeric($master_harbor_input_port)) { + if ($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()) { $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $res = socket_bind($sock, 0, $master_harbor_input_port); - if(!$res){ + if (!$res) { $element = $this->getElement("master_harbor_input_port"); $element->addError("Port '$master_harbor_input_port' is not available."); $isValid = false; } socket_close($sock); } - }else{ + } else { $isValid = false; } } - if($dj_harbor_input_port != ""){ - if(is_numeric($dj_harbor_input_port)){ - if($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()){ + if ($dj_harbor_input_port != "") { + if (is_numeric($dj_harbor_input_port)) { + if ($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()) { $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $res = socket_bind($sock, 0, $dj_harbor_input_port); - if(!$res){ + if (!$res) { $element = $this->getElement("dj_harbor_input_port"); $element->addError("Port '$dj_harbor_input_port' is not available."); $isValid = false; } socket_close($sock); } - }else{ + } else { $isValid = false; } } } + return $isValid; } diff --git a/airtime_mvc/application/forms/Login.php b/airtime_mvc/application/forms/Login.php index b7da46cb9..3761ff939 100644 --- a/airtime_mvc/application/forms/Login.php +++ b/airtime_mvc/application/forms/Login.php @@ -10,8 +10,8 @@ class Application_Form_Login extends Zend_Form // Set the method for the display form to POST $this->setMethod('post'); - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/login.phtml')) + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/login.phtml')) )); // Add username element @@ -45,10 +45,10 @@ class Application_Form_Login extends Zend_Form )); $recaptchaNeeded = false; - if(Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3){ + if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) { $recaptchaNeeded = true; } - if($recaptchaNeeded){ + if ($recaptchaNeeded) { // recaptcha $this->addRecaptcha(); } @@ -65,7 +65,8 @@ class Application_Form_Login extends Zend_Form } - public function addRecaptcha(){ + public function addRecaptcha() + { $pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG'; $privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv'; @@ -84,6 +85,4 @@ class Application_Form_Login extends Zend_Form $this->addElement($captcha); } - } - diff --git a/airtime_mvc/application/forms/PasswordChange.php b/airtime_mvc/application/forms/PasswordChange.php index 0f36350c5..48efae5ff 100644 --- a/airtime_mvc/application/forms/PasswordChange.php +++ b/airtime_mvc/application/forms/PasswordChange.php @@ -6,8 +6,8 @@ class Application_Form_PasswordChange extends Zend_Form { public function init() { - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/password-change.phtml')) + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/password-change.phtml')) )); $this->addElement('password', 'password', array( diff --git a/airtime_mvc/application/forms/PasswordRestore.php b/airtime_mvc/application/forms/PasswordRestore.php index eaa42ba1f..584e767ad 100644 --- a/airtime_mvc/application/forms/PasswordRestore.php +++ b/airtime_mvc/application/forms/PasswordRestore.php @@ -6,8 +6,8 @@ class Application_Form_PasswordRestore extends Zend_Form { public function init() { - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/password-restore.phtml')) + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/password-restore.phtml')) )); $this->addElement('text', 'email', array( @@ -20,7 +20,7 @@ class Application_Form_PasswordRestore extends Zend_Form 'ViewHelper' ) )); - + $this->addElement('text', 'username', array( 'label' => 'Username', 'required' => false, @@ -49,4 +49,4 @@ class Application_Form_PasswordRestore extends Zend_Form ->setDecorators(array('ViewHelper')); $this->addElement($cancel); } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/forms/RegisterAirtime.php b/airtime_mvc/application/forms/RegisterAirtime.php index 3ce794190..a789556fc 100644 --- a/airtime_mvc/application/forms/RegisterAirtime.php +++ b/airtime_mvc/application/forms/RegisterAirtime.php @@ -13,7 +13,7 @@ class Application_Form_RegisterAirtime extends Zend_Form $country_list = Application_Model_Preference::GetCountryList(); $privacyChecked = false; - if(Application_Model_Preference::GetPrivacyPolicyCheck() == 1){ + if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) { $privacyChecked = true; } @@ -151,17 +151,17 @@ class Application_Form_RegisterAirtime extends Zend_Form public function isValid ($data) { $isValid = parent::isValid($data); - if($data['Publicise'] != 1){ + if ($data['Publicise'] != 1) { $isValid = true; } - if(isset($data["Privacy"])){ + if (isset($data["Privacy"])) { $checkPrivacy = $this->getElement('Privacy'); - if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){ + if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") { $checkPrivacy->addError("You have to agree to privacy policy."); $isValid = false; } } + return $isValid; } } - diff --git a/airtime_mvc/application/forms/ScheduleShow.php b/airtime_mvc/application/forms/ScheduleShow.php index 85c7c91fb..5ec6f8174 100644 --- a/airtime_mvc/application/forms/ScheduleShow.php +++ b/airtime_mvc/application/forms/ScheduleShow.php @@ -8,6 +8,4 @@ class Application_Form_ScheduleShow extends Zend_Form /* Form Elements & Other Definitions Here ... */ } - } - diff --git a/airtime_mvc/application/forms/ShowBuilder.php b/airtime_mvc/application/forms/ShowBuilder.php index 3e551fa24..465d2dd71 100644 --- a/airtime_mvc/application/forms/ShowBuilder.php +++ b/airtime_mvc/application/forms/ShowBuilder.php @@ -67,7 +67,6 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm $endTime->setAttrib('alt', 'time'); $this->addElement($endTime); - // add a select to choose a show. $showSelect = new Zend_Form_Element_Select("sb_show_filter"); $showSelect->setLabel("Show:"); @@ -84,8 +83,8 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm } } - private function getShowNames() { - + private function getShowNames() + { $showNames = array("0" => "-------------------------"); $shows = CcShowQuery::create() diff --git a/airtime_mvc/application/forms/SmartBlockCriteria.php b/airtime_mvc/application/forms/SmartBlockCriteria.php index bbc751593..55ff54705 100644 --- a/airtime_mvc/application/forms/SmartBlockCriteria.php +++ b/airtime_mvc/application/forms/SmartBlockCriteria.php @@ -1,93 +1,93 @@ "Select criteria", - "album_title" => "Album", - "bit_rate" => "Bit Rate (Kbps)", - "bpm" => "Bpm", - "comments" => "Comments", - "composer" => "Composer", - "conductor" => "Conductor", - "artist_name" => "Creator", - "disc_number" => "Disc Number", - "genre" => "Genre", - "isrc_number" => "ISRC", - "label" => "Label", - "language" => "Language", - "mtime" => "Last Modified", - "lptime" => "Last Played", - "length" => "Length", - "lyricist" => "Lyricist", - "mood" => "Mood", - "name" => "Name", - "orchestra" => "Orchestra", - "rating" => "Rating", - "sample_rate" => "Sample Rate (kHz)", - "track_title" => "Title", - "track_number" => "Track Number", - "utime" => "Uploaded", - "year" => "Year" - ); - - private $criteriaTypes = array( - 0 => "", - "album_title" => "s", - "artist_name" => "s", - "bit_rate" => "n", - "bpm" => "n", - "comments" => "s", - "composer" => "s", - "conductor" => "s", - "utime" => "n", - "mtime" => "n", - "lptime" => "n", - "disc_number" => "n", - "genre" => "s", - "isrc_number" => "s", - "label" => "s", - "language" => "s", - "length" => "n", - "lyricist" => "s", - "mood" => "s", - "name" => "s", - "orchestra" => "s", - "rating" => "n", - "sample_rate" => "n", - "track_title" => "s", - "track_number" => "n", - "year" => "n" - ); - - private $stringCriteriaOptions = array( - "0" => "Select modifier", - "contains" => "contains", - "does not contain" => "does not contain", - "is" => "is", - "is not" => "is not", - "starts with" => "starts with", - "ends with" => "ends with" - ); - - private $numericCriteriaOptions = array( - "0" => "Select modifier", - "is" => "is", - "is not" => "is not", - "is greater than" => "is greater than", - "is less than" => "is less than", - "is in the range" => "is in the range" - ); - - private $limitOptions = array( - "hours" => "hours", - "minutes" => "minutes", - "items" => "items" + private $criteriaOptions = array( + 0 => "Select criteria", + "album_title" => "Album", + "bit_rate" => "Bit Rate (Kbps)", + "bpm" => "Bpm", + "comments" => "Comments", + "composer" => "Composer", + "conductor" => "Conductor", + "artist_name" => "Creator", + "disc_number" => "Disc Number", + "genre" => "Genre", + "isrc_number" => "ISRC", + "label" => "Label", + "language" => "Language", + "mtime" => "Last Modified", + "lptime" => "Last Played", + "length" => "Length", + "lyricist" => "Lyricist", + "mood" => "Mood", + "name" => "Name", + "orchestra" => "Orchestra", + "rating" => "Rating", + "sample_rate" => "Sample Rate (kHz)", + "track_title" => "Title", + "track_number" => "Track Number", + "utime" => "Uploaded", + "year" => "Year" ); - - public function init(){ - + + private $criteriaTypes = array( + 0 => "", + "album_title" => "s", + "artist_name" => "s", + "bit_rate" => "n", + "bpm" => "n", + "comments" => "s", + "composer" => "s", + "conductor" => "s", + "utime" => "n", + "mtime" => "n", + "lptime" => "n", + "disc_number" => "n", + "genre" => "s", + "isrc_number" => "s", + "label" => "s", + "language" => "s", + "length" => "n", + "lyricist" => "s", + "mood" => "s", + "name" => "s", + "orchestra" => "s", + "rating" => "n", + "sample_rate" => "n", + "track_title" => "s", + "track_number" => "n", + "year" => "n" + ); + + private $stringCriteriaOptions = array( + "0" => "Select modifier", + "contains" => "contains", + "does not contain" => "does not contain", + "is" => "is", + "is not" => "is not", + "starts with" => "starts with", + "ends with" => "ends with" + ); + + private $numericCriteriaOptions = array( + "0" => "Select modifier", + "is" => "is", + "is not" => "is not", + "is greater than" => "is greater than", + "is less than" => "is less than", + "is in the range" => "is in the range" + ); + + private $limitOptions = array( + "hours" => "hours", + "minutes" => "minutes", + "items" => "items" + ); + + public function init() + { } - + public function startForm($p_blockId, $p_isValid = false) { // load type @@ -97,8 +97,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm } else { $blockType = 1; } - - + $spType = new Zend_Form_Element_Radio('sp_type'); $spType->setLabel('Set smart block type:') ->setDecorators(array('viewHelper')) @@ -108,7 +107,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm )) ->setValue($blockType); $this->addElement($spType); - + $bl = new Application_Model_Block($p_blockId); $storedCrit = $bl->getCriteria(); @@ -117,12 +116,12 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm * We need to know this so we display the form elements properly */ $modRowMap = array(); - + $openSmartBlockOption = false; if (!empty($storedCrit)) { $openSmartBlockOption = true; } - + $criteriaKeys = array(); if (isset($storedCrit["crit"])) { $criteriaKeys = array_keys($storedCrit["crit"]); @@ -130,15 +129,15 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $numElements = count($this->criteriaOptions); for ($i = 0; $i < $numElements; $i++) { $criteriaType = ""; - + if (isset($criteriaKeys[$i])) { $critCount = count($storedCrit["crit"][$criteriaKeys[$i]]); } else { $critCount = 1; } - + $modRowMap[$i] = $critCount; - + /* Loop through all criteria with the same field * Ex: all criteria for 'Album' */ @@ -149,7 +148,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm } else { $invisible = ''; } - + $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j); $criteria->setAttrib('class', 'input_select sp_input_select'.$invisible) ->setValue('Select criteria') @@ -158,13 +157,13 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm if ($i != 0 && !isset($criteriaKeys[$i])) { $criteria->setAttrib('disabled', 'disabled'); } - + if (isset($criteriaKeys[$i])) { $criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]]; $criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); } $this->addElement($criteria); - + /****************** MODIFIER ***********/ $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j); $criteriaModifers->setValue('Select modifier') @@ -174,29 +173,29 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $criteriaModifers->setAttrib('disabled', 'disabled'); } if (isset($criteriaKeys[$i])) { - if($criteriaType == "s"){ + if ($criteriaType == "s") { $criteriaModifers->setMultiOptions($this->stringCriteriaOptions); - }else{ + } else { $criteriaModifers->setMultiOptions($this->numericCriteriaOptions); } $criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]); - }else{ + } else { $criteriaModifers->setMultiOptions(array('0' => 'Select modifier')); } $this->addElement($criteriaModifers); - + /****************** VALUE ***********/ $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j); $criteriaValue->setAttrib('class', 'input_text sp_input_text') ->setDecorators(array('viewHelper')); - if ($i != 0 && !isset($criteriaKeys[$i])){ + if ($i != 0 && !isset($criteriaKeys[$i])) { $criteriaValue->setAttrib('disabled', 'disabled'); } if (isset($criteriaKeys[$i])) { $criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); } $this->addElement($criteriaValue); - + /****************** EXTRA ***********/ $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j); $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') @@ -204,15 +203,15 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); - }else{ + } else { $criteriaExtra->setAttrib('disabled', 'disabled'); } $this->addElement($criteriaExtra); - + }//for - + }//for - + $limit = new Zend_Form_Element_Select('sp_limit_options'); $limit->setAttrib('class', 'sp_input_select') ->setDecorators(array('viewHelper')) @@ -221,7 +220,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $limit->setValue($storedCrit["limit"]["modifier"]); } $this->addElement($limit); - + $limitValue = new Zend_Form_Element_Text('sp_limit_value'); $limitValue->setAttrib('class', 'sp_input_text_limit') ->setLabel('Limit to') @@ -233,7 +232,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm // setting default to 1 hour $limitValue->setValue(1); } - + //getting block content candidate count that meets criteria $bl = new Application_Model_Block($p_blockId); if ($p_isValid) { @@ -243,7 +242,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $files = null; $showPoolCount = false; } - + $generate = new Zend_Form_Element_Button('generate_button'); $generate->setAttrib('class', 'ui-button ui-state-default sp-button'); $generate->setAttrib('title', 'Generate playlist content and save criteria'); @@ -251,7 +250,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $generate->setLabel('Generate'); $generate->setDecorators(array('viewHelper')); $this->addElement($generate); - + $shuffle = new Zend_Form_Element_Button('shuffle_button'); $shuffle->setAttrib('class', 'ui-button ui-state-default sp-button'); $shuffle->setAttrib('title', 'Shuffle playlist content'); @@ -266,143 +265,146 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm 'showPoolCount' => $showPoolCount)) )); } - - function preValidation($params) { + + public function preValidation($params) + { $data = Application_Model_Block::organizeSmartPlyalistCriteria($params['data']); - // add elelments that needs to be added + // add elelments that needs to be added // set multioption for modifier according to creiteria_field $modRowMap = array(); foreach ($data['criteria'] as $critKey=>$d) { $count = 1; - foreach($d as $modKey=>$modInfo) { + foreach ($d as $modKey=>$modInfo) { if ($modKey == 0) { $eleCrit = $this->getElement("sp_criteria_field_".$critKey."_".$modKey); $eleCrit->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]); $eleCrit->setAttrib("disabled", null); - + $eleMod = $this->getElement("sp_criteria_modifier_".$critKey."_".$modKey); $criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']]; if ($criteriaType == "s") { $eleMod->setMultiOptions($this->stringCriteriaOptions); - } else if ($criteriaType == "n") { + } elseif ($criteriaType == "n") { $eleMod->setMultiOptions($this->numericCriteriaOptions); } else { $eleMod->setMultiOptions(array('0' => 'Select modifier')); } - $eleMod->setValue($modInfo['sp_criteria_modifier']); + $eleMod->setValue($modInfo['sp_criteria_modifier']); $eleMod->setAttrib("disabled", null); - + $eleValue = $this->getElement("sp_criteria_value_".$critKey."_".$modKey); - $eleValue->setValue($modInfo['sp_criteria_value']); + $eleValue->setValue($modInfo['sp_criteria_value']); $eleValue->setAttrib("disabled", null); - + if (isset($modInfo['sp_criteria_extra'])) { - $eleExtra = $this->getElement("sp_criteria_extra_".$critKey."_".$modKey); + $eleExtra = $this->getElement("sp_criteria_extra_".$critKey."_".$modKey); $eleExtra->setValue($modInfo['sp_criteria_extra']); - $eleValue->setAttrib('class', 'input_text sp_extra_input_text'); + $eleValue->setAttrib('class', 'input_text sp_extra_input_text'); $eleExtra->setAttrib("disabled", null); } - + } else { - $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$critKey."_".$modKey); - $criteria->setAttrib('class', 'input_select sp_input_select sp-invisible') - ->setValue('Select criteria') - ->setDecorators(array('viewHelper')) - ->setMultiOptions($this->criteriaOptions); - - $criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']]; - $criteria->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]); - $this->addElement($criteria); - - /****************** MODIFIER ***********/ - $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$critKey."_".$modKey); - $criteriaModifers->setValue('Select modifier') - ->setAttrib('class', 'input_select sp_input_select') + $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$critKey."_".$modKey); + $criteria->setAttrib('class', 'input_select sp_input_select sp-invisible') + ->setValue('Select criteria') + ->setDecorators(array('viewHelper')) + ->setMultiOptions($this->criteriaOptions); + + $criteriaType = $this->criteriaTypes[$modInfo['sp_criteria_field']]; + $criteria->setValue($this->criteriaOptions[$modInfo['sp_criteria_field']]); + $this->addElement($criteria); + + /****************** MODIFIER ***********/ + $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$critKey."_".$modKey); + $criteriaModifers->setValue('Select modifier') + ->setAttrib('class', 'input_select sp_input_select') ->setDecorators(array('viewHelper')); - - if ($criteriaType == "s") { - $criteriaModifers->setMultiOptions($this->stringCriteriaOptions); - } else if ($criteriaType == "n") { - $criteriaModifers->setMultiOptions($this->numericCriteriaOptions); - } else { - $criteriaModifers->setMultiOptions(array('0' => 'Select modifier')); + + if ($criteriaType == "s") { + $criteriaModifers->setMultiOptions($this->stringCriteriaOptions); + } elseif ($criteriaType == "n") { + $criteriaModifers->setMultiOptions($this->numericCriteriaOptions); + } else { + $criteriaModifers->setMultiOptions(array('0' => 'Select modifier')); + } + $criteriaModifers->setValue($modInfo['sp_criteria_modifier']); + $this->addElement($criteriaModifers); + + /****************** VALUE ***********/ + $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$critKey."_".$modKey); + $criteriaValue->setAttrib('class', 'input_text sp_input_text') + ->setDecorators(array('viewHelper')); + $criteriaValue->setValue($modInfo['sp_criteria_value']); + $this->addElement($criteriaValue); + + /****************** EXTRA ***********/ + $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$critKey."_".$modKey); + $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') + ->setDecorators(array('viewHelper')); + if (isset($modInfo['sp_criteria_extra'])) { + $criteriaExtra->setValue($modInfo['sp_criteria_extra']); + $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); + } else { + $criteriaExtra->setAttrib('disabled', 'disabled'); } - $criteriaModifers->setValue($modInfo['sp_criteria_modifier']); - $this->addElement($criteriaModifers); - - /****************** VALUE ***********/ - $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$critKey."_".$modKey); - $criteriaValue->setAttrib('class', 'input_text sp_input_text') - ->setDecorators(array('viewHelper')); - $criteriaValue->setValue($modInfo['sp_criteria_value']); - $this->addElement($criteriaValue); - - /****************** EXTRA ***********/ - $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$critKey."_".$modKey); - $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') - ->setDecorators(array('viewHelper')); - if (isset($modInfo['sp_criteria_extra'])) { - $criteriaExtra->setValue($modInfo['sp_criteria_extra']); - $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); - }else{ - $criteriaExtra->setAttrib('disabled', 'disabled'); - } $this->addElement($criteriaExtra); $count++; } } $modRowMap[$critKey] = $count; } - + $decorator = $this->getDecorator("ViewScript"); $existingModRow = $decorator->getOption("modRowMap"); foreach ($modRowMap as $key=>$v) { $existingModRow[$key] = $v; } - $decorator->setOption("modRowMap", $existingModRow); - - // reconstruct the params['criteria'] so we can populate the form - $formData = array(); - foreach ($params['data'] as $ele) { - $formData[$ele['name']] = $ele['value']; + $decorator->setOption("modRowMap", $existingModRow); + + // reconstruct the params['criteria'] so we can populate the form + $formData = array(); + foreach ($params['data'] as $ele) { + $formData[$ele['name']] = $ele['value']; } - + $this->populate($formData); + return $data; } - - function isValid($params){ + + public function isValid($params) + { $isValid = true; $data = $this->preValidation($params); - $criteria2PeerMap = array( - 0 => "Select criteria", - "album_title" => "DbAlbumTitle", - "artist_name" => "DbArtistName", - "bit_rate" => "DbBitRate", - "bpm" => "DbBpm", - "comments" => "DbComments", - "composer" => "DbComposer", - "conductor" => "DbConductor", - "utime" => "DbUtime", - "mtime" => "DbMtime", - "lptime" => "DbLPtime", - "disc_number" => "DbDiscNumber", - "genre" => "DbGenre", - "isrc_number" => "DbIsrcNumber", - "label" => "DbLabel", - "language" => "DbLanguage", - "length" => "DbLength", - "lyricist" => "DbLyricist", - "mood" => "DbMood", - "name" => "DbName", - "orchestra" => "DbOrchestra", - "rating" => "DbRating", - "sample_rate" => "DbSampleRate", - "track_title" => "DbTrackTitle", - "track_number" => "DbTrackNumber", - "year" => "DbYear" + $criteria2PeerMap = array( + 0 => "Select criteria", + "album_title" => "DbAlbumTitle", + "artist_name" => "DbArtistName", + "bit_rate" => "DbBitRate", + "bpm" => "DbBpm", + "comments" => "DbComments", + "composer" => "DbComposer", + "conductor" => "DbConductor", + "utime" => "DbUtime", + "mtime" => "DbMtime", + "lptime" => "DbLPtime", + "disc_number" => "DbDiscNumber", + "genre" => "DbGenre", + "isrc_number" => "DbIsrcNumber", + "label" => "DbLabel", + "language" => "DbLanguage", + "length" => "DbLength", + "lyricist" => "DbLyricist", + "mood" => "DbMood", + "name" => "DbName", + "orchestra" => "DbOrchestra", + "rating" => "DbRating", + "sample_rate" => "DbSampleRate", + "track_title" => "DbTrackTitle", + "track_number" => "DbTrackNumber", + "year" => "DbYear" ); - + // things we need to check // 1. limit value shouldn't be empty and has upperbound of 24 hrs // 2. sp_criteria or sp_criteria_modifier shouldn't be 0 @@ -411,107 +413,108 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $result = 0; $errors = array(); $error = array(); - - // validation start - if ($data['etc']['sp_limit_options'] == 'hours') { - $multiplier = 60; - } + + // validation start + if ($data['etc']['sp_limit_options'] == 'hours') { + $multiplier = 60; + } if ($data['etc']['sp_limit_options'] == 'hours' || $data['etc']['sp_limit_options'] == 'mins') { - $element = $this->getElement("sp_limit_value"); - if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) { - $element->addError("Limit cannot be empty or smaller than 0"); - $isValid = false; - } else { - $mins = floatval($data['etc']['sp_limit_value']) * $multiplier; + $element = $this->getElement("sp_limit_value"); + if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) { + $element->addError("Limit cannot be empty or smaller than 0"); + $isValid = false; + } else { + $mins = floatval($data['etc']['sp_limit_value']) * $multiplier; if ($mins > 1440) { $element->addError("Limit cannot be more than 24 hrs"); - $isValid = false; - } - } + $isValid = false; + } + } } else { - $element = $this->getElement("sp_limit_value"); + $element = $this->getElement("sp_limit_value"); if ($data['etc']['sp_limit_value'] == "" || floatval($data['etc']['sp_limit_value']) <= 0) { - $element->addError("Limit cannot be empty or smaller than 0"); - $isValid = false; - } else if (!ctype_digit($data['etc']['sp_limit_value'])) { - $element->addError("The value should be an integer"); - $isValid = false; - } else if (intval($data['etc']['sp_limit_value']) > 500) { - $element->addError("500 is the max item limit value you can set"); - $isValid = false; - } + $element->addError("Limit cannot be empty or smaller than 0"); + $isValid = false; + } elseif (!ctype_digit($data['etc']['sp_limit_value'])) { + $element->addError("The value should be an integer"); + $isValid = false; + } elseif (intval($data['etc']['sp_limit_value']) > 500) { + $element->addError("500 is the max item limit value you can set"); + $isValid = false; + } } - + $criteriaFieldsUsed = array(); - + if (isset($data['criteria'])) { foreach ($data['criteria'] as $rowKey=>$row) { - foreach ($row as $key=>$d){ - $element = $this->getElement("sp_criteria_field_".$rowKey."_".$key); - $error = array(); - // check for not selected select box - if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){ - $element->addError("You must select Criteria and Modifier"); - $isValid = false; - } else { - $column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]); - // validation on type of column - if ($d['sp_criteria_field'] == 'length') { + foreach ($row as $key=>$d) { + $element = $this->getElement("sp_criteria_field_".$rowKey."_".$key); + $error = array(); + // check for not selected select box + if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0") { + $element->addError("You must select Criteria and Modifier"); + $isValid = false; + } else { + $column = CcFilesPeer::getTableMap()->getColumnByPhpName($criteria2PeerMap[$d['sp_criteria_field']]); + // validation on type of column + if ($d['sp_criteria_field'] == 'length') { if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) { - $element->addError("'Length' should be in '00:00:00' format"); - $isValid = false; - } - } else if ($column->getType() == PropelColumnTypes::TIMESTAMP) { + $element->addError("'Length' should be in '00:00:00' format"); + $isValid = false; + } + } elseif ($column->getType() == PropelColumnTypes::TIMESTAMP) { if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) { - $element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"); - $isValid = false; - } else { - $result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']); - if (!$result["success"]) { + $element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"); + $isValid = false; + } else { + $result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']); + if (!$result["success"]) { // check for if it is in valid range( 1753-01-01 ~ 12/31/9999 ) - $element->addError($result["errMsg"]); - $isValid = false; - } - } - - if (isset($d['sp_criteria_extra'])) { + $element->addError($result["errMsg"]); + $isValid = false; + } + } + + if (isset($d['sp_criteria_extra'])) { if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) { - $element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"); - $isValid = false; - } else { - $result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']); - if (!$result["success"]) { - // check for if it is in valid range( 1753-01-01 ~ 12/31/9999 ) + $element->addError("The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"); + $isValid = false; + } else { + $result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']); + if (!$result["success"]) { + // check for if it is in valid range( 1753-01-01 ~ 12/31/9999 ) $element->addError($result["errMsg"]); - $isValid = false; - } - } - } - } else if ($column->getType() == PropelColumnTypes::INTEGER) { + $isValid = false; + } + } + } + } elseif ($column->getType() == PropelColumnTypes::INTEGER) { if (!is_numeric($d['sp_criteria_value'])) { - $element->addError("The value has to be numeric"); - $isValid = false; - } - // length check + $element->addError("The value has to be numeric"); + $isValid = false; + } + // length check if (intval($d['sp_criteria_value']) >= pow(2,31)) { - $element->addError("The value should be less then 2147483648"); - $isValid = false; - } - } else if ($column->getType() == PropelColumnTypes::VARCHAR) { + $element->addError("The value should be less then 2147483648"); + $isValid = false; + } + } elseif ($column->getType() == PropelColumnTypes::VARCHAR) { if (strlen($d['sp_criteria_value']) > $column->getSize()) { - $element->addError("The value should be less ".$column->getSize()." characters"); - $isValid = false; - } - } - } - + $element->addError("The value should be less ".$column->getSize()." characters"); + $isValid = false; + } + } + } + if ($d['sp_criteria_value'] == "") { - $element->addError("Value cannot be empty"); - $isValid = false; - } - }//end foreach - }//for loop + $element->addError("Value cannot be empty"); + $isValid = false; + } + }//end foreach + }//for loop }//if + return $isValid; } } diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index d74fa6e8c..d3840cbbf 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -149,6 +149,4 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm $this->addElement($select); } - } - diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index 38f77043d..c3443a3e0 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -9,19 +9,21 @@ class Application_Form_StreamSetting extends Zend_Form } - public function setSetting($setting){ + public function setSetting($setting) + { $this->setting = $setting; } - public function startFrom() { + public function startFrom() + { $setting = $this->setting; - if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ + if (Application_Model_Preference::GetPlanLevel() == 'disabled') { $output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device'); $output_sound_device->setLabel('Hardware Audio Output') ->setRequired(false) ->setValue(($setting['output_sound_device'] == "true")?1:0) ->setDecorators(array('ViewHelper')); - if (Application_Model_Preference::GetEnableStreamConf() == "false"){ + if (Application_Model_Preference::GetEnableStreamConf() == "false") { $output_sound_device->setAttrib("readonly", true); } $this->addElement($output_sound_device); @@ -32,7 +34,7 @@ class Application_Form_StreamSetting extends Zend_Form ->setMultiOptions($output_types) ->setValue($setting['output_sound_device_type']) ->setDecorators(array('ViewHelper')); - if($setting['output_sound_device'] != "true"){ + if ($setting['output_sound_device'] != "true") { $output_type->setAttrib("disabled", "disabled"); } $this->addElement($output_type); @@ -43,7 +45,7 @@ class Application_Form_StreamSetting extends Zend_Form ->setRequired(false) ->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0) ->setDecorators(array('ViewHelper')); - if (Application_Model_Preference::GetEnableStreamConf() == "false"){ + if (Application_Model_Preference::GetEnableStreamConf() == "false") { $icecast_vorbis_metadata->setAttrib("readonly", true); } $this->addElement($icecast_vorbis_metadata); @@ -58,18 +60,20 @@ class Application_Form_StreamSetting extends Zend_Form $this->addElement($stream_format); } - public function isValid($data){ - if(isset($data['output_sound_device'])){ + public function isValid($data) + { + if (isset($data['output_sound_device'])) { $d = array(); $d["output_sound_device"] = $data['output_sound_device']; $d["icecast_vorbis_metadata"] = $data['icecast_vorbis_metadata']; - if(isset($data['output_sound_device_type'])){ + if (isset($data['output_sound_device_type'])) { $d["output_sound_device_type"] = $data['output_sound_device_type']; } $d["streamFormat"] = $data['streamFormat']; $this->populate($d); } $isValid = parent::isValid($data); + return $isValid; } } diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index dba70c7c6..dbdc41fba 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -1,5 +1,6 @@ prefix = $prefix; } - public function setSetting($setting){ + public function setSetting($setting) + { $this->setting = $setting; } - public function setStreamTypes($stream_types){ + public function setStreamTypes($stream_types) + { $this->stream_types = $stream_types; } - public function setStreamBitrates($stream_bitrates){ + public function setStreamBitrates($stream_bitrates) + { $this->stream_bitrates = $stream_bitrates; } - public function startForm(){ + public function startForm() + { $prefix = "s".$this->prefix; $stream_number = $this->prefix; $setting = $this->setting; @@ -36,16 +42,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ $this->setIsArray(true); $this->setElementsBelongTo($prefix."_data"); - $disable_all = false; - if(Application_Model_Preference::GetEnableStreamConf() == "false"){ - $disable_all = true; - } + $disable_all = Application_Model_Preference::GetEnableStreamConf() == "false"; $enable = new Zend_Form_Element_Checkbox('enable'); $enable->setLabel('Enabled:') ->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $enable->setAttrib("disabled", "disabled"); } $this->addElement($enable); @@ -55,7 +58,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setMultiOptions($stream_types) ->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $type->setAttrib("disabled", "disabled"); } $this->addElement($type); @@ -65,7 +68,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setMultiOptions($stream_bitrates) ->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $bitrate->setAttrib("disabled", "disabled"); } $this->addElement($bitrate); @@ -75,7 +78,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast")) ->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast") ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $output->setAttrib("disabled", "disabled"); } $this->addElement($output); @@ -86,7 +89,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setValidators(array( array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $host->setAttrib("disabled", "disabled"); } $host->setAttrib('alt', 'domain'); @@ -98,7 +101,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $port->setAttrib("disabled", "disabled"); } $this->addElement($port); @@ -109,7 +112,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $pass->setAttrib("disabled", "disabled"); } $pass->setAttrib('alt', 'regular_text'); @@ -119,7 +122,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ $genre->setLabel("Genre") ->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"") ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $genre->setAttrib("disabled", "disabled"); } $this->addElement($genre); @@ -130,7 +133,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setValidators(array( array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $url->setAttrib("disabled", "disabled"); } $url->setAttrib('alt', 'url'); @@ -140,7 +143,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ $name->setLabel("Name") ->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"") ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $name->setAttrib("disabled", "disabled"); } $this->addElement($name); @@ -149,7 +152,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ $description->setLabel("Description") ->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"") ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $description->setAttrib("disabled", "disabled"); } $this->addElement($description); @@ -160,7 +163,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $mount->setAttrib("disabled", "disabled"); } $mount->setAttrib('alt', 'regular_text'); @@ -172,7 +175,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - if($disable_all){ + if ($disable_all) { $user->setAttrib("disabled", "disabled"); } $user->setAttrib('alt', 'regular_text'); @@ -185,28 +188,30 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ )); } - public function isValid ($data){ + public function isValid ($data) + { $f_data = $data['s'.$this->prefix."_data"]; $isValid = parent::isValid($f_data); - if($f_data['enable'] == 1){ - if($f_data['host'] == ''){ + if ($f_data['enable'] == 1) { + if ($f_data['host'] == '') { $element = $this->getElement("host"); $element->addError("Server cannot be empty."); $isValid = false; } - if($f_data['port'] == ''){ + if ($f_data['port'] == '') { $element = $this->getElement("port"); $element->addError("Port cannot be empty."); $isValid = false; } - if($f_data['output'] == 'icecast'){ - if($f_data['mount'] == ''){ + if ($f_data['output'] == 'icecast') { + if ($f_data['mount'] == '') { $element = $this->getElement("mount"); $element->addError("Mount cannot be empty with Icecast server."); $isValid = false; } } } + return $isValid; } } diff --git a/airtime_mvc/application/forms/SupportSettings.php b/airtime_mvc/application/forms/SupportSettings.php index d03428f1c..fe996b89d 100644 --- a/airtime_mvc/application/forms/SupportSettings.php +++ b/airtime_mvc/application/forms/SupportSettings.php @@ -109,7 +109,7 @@ class Application_Form_SupportSettings extends Zend_Form $upload->setAttrib('accept', 'image/*'); $this->addElement($upload); - if(!$isSass){ + if (!$isSass) { //enable support feedback $this->addElement('checkbox', 'SupportFeedback', array( 'label' => 'Send support feedback', @@ -126,7 +126,7 @@ class Application_Form_SupportSettings extends Zend_Form ->setRequired(false) ->setDecorators(array('ViewHelper')) ->setValue(Application_Model_Preference::GetPublicise()); - if(Application_Model_Preference::GetSupportFeedback() == '0'){ + if (Application_Model_Preference::GetSupportFeedback() == '0') { $checkboxPublicise->setAttrib("disabled", "disabled"); } $this->addElement($checkboxPublicise); @@ -165,19 +165,19 @@ class Application_Form_SupportSettings extends Zend_Form public function isValid ($data) { $isValid = parent::isValid($data); - if(!$this->isSass){ - if($data['Publicise'] != 1){ + if (!$this->isSass) { + if ($data['Publicise'] != 1) { $isValid = true; } - if(isset($data["Privacy"])){ + if (isset($data["Privacy"])) { $checkPrivacy = $this->getElement('Privacy'); - if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){ + if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") { $checkPrivacy->addError("You have to agree to privacy policy."); $isValid = false; } } } + return $isValid; } } - diff --git a/airtime_mvc/application/forms/WatchedDirPreferences.php b/airtime_mvc/application/forms/WatchedDirPreferences.php index 9e8021839..7fcf00893 100644 --- a/airtime_mvc/application/forms/WatchedDirPreferences.php +++ b/airtime_mvc/application/forms/WatchedDirPreferences.php @@ -32,20 +32,20 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm )); } - public function verifyChosenFolder($p_form_element_id) { - + public function verifyChosenFolder($p_form_element_id) + { $element = $this->getElement($p_form_element_id); if (!is_dir($element->getValue())) { $element->setErrors(array('Not a valid Directory')); + return false; - } - else { + } else { $element->setValue(""); + return true; } } } - diff --git a/airtime_mvc/application/forms/customfilters/ImageSize.php b/airtime_mvc/application/forms/customfilters/ImageSize.php index 58a47d01a..402c07e24 100644 --- a/airtime_mvc/application/forms/customfilters/ImageSize.php +++ b/airtime_mvc/application/forms/customfilters/ImageSize.php @@ -1,7 +1,9 @@ diff --git a/airtime_mvc/application/forms/customvalidators/ConditionalNotEmpty.php b/airtime_mvc/application/forms/customvalidators/ConditionalNotEmpty.php index 5e361f03d..bd3ae5723 100644 --- a/airtime_mvc/application/forms/customvalidators/ConditionalNotEmpty.php +++ b/airtime_mvc/application/forms/customvalidators/ConditionalNotEmpty.php @@ -3,8 +3,8 @@ /** * Check if a field is empty but only when specific fields have specific values */ -class ConditionalNotEmpty extends Zend_Validate_Abstract { - +class ConditionalNotEmpty extends Zend_Validate_Abstract +{ const KEY_IS_EMPTY = 'keyIsEmpty'; protected $_messageTemplates = array( @@ -32,8 +32,8 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract { * this function returns true if the expected values doesn't match the actual user input, * or if $value is not empty. Returns false otherwise. * - * @param String $value - this field's value - * @param array $context - names and values of the rest of the fields in this form + * @param String $value - this field's value + * @param array $context - names and values of the rest of the fields in this form * @return boolean - true if valid; false otherwise */ public function isValid($value, $context = null) @@ -43,7 +43,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract { } if (is_array($context)) { - foreach($this->_fieldValues as $fieldName=>$fieldValue) { + foreach ($this->_fieldValues as $fieldName=>$fieldValue) { if (!isset($context[$fieldName]) || $context[$fieldName] != $fieldValue) { return true; } @@ -55,8 +55,7 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract { } $this->_error(self::KEY_IS_EMPTY); + return false; } } - -?> diff --git a/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php b/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php index 11e62b933..5073c5d80 100644 --- a/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php +++ b/airtime_mvc/application/forms/customvalidators/PasswordNotEmpty.php @@ -1,6 +1,7 @@