diff --git a/.zfproject.xml b/.zfproject.xml index 873f96251..c849f233f 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -84,6 +84,10 @@ + + + + @@ -100,10 +104,12 @@ + + @@ -270,6 +276,12 @@ + + + + + + @@ -313,6 +325,7 @@ + diff --git a/application/Bootstrap.php b/application/Bootstrap.php index cce62ae14..52c0a8d11 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -64,9 +64,16 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript'); $view->headScript()->appendFile('/js/airtime/common/common.js','text/javascript'); - - //TODO: Find better place to put this in. + } + + protected function _initViewHelpers(){ + $view = $this->getResource('view'); $view->addHelperPath('../application/views/helpers', 'Airtime_View_Helper'); } + + protected function _initTitle(){ + $view = $this->getResource('view'); + $view->headTitle(Application_Model_Preference::GetStationName()); + } } diff --git a/application/configs/ACL.php b/application/configs/ACL.php index 092957d14..6800e806b 100644 --- a/application/configs/ACL.php +++ b/application/configs/ACL.php @@ -19,7 +19,8 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('api')) ->add(new Zend_Acl_Resource('nowplaying')) - ->add(new Zend_Acl_Resource('search')); + ->add(new Zend_Acl_Resource('search')) + ->add(new Zend_Acl_Resource('preference')); /** Creating permissions */ $ccAcl->allow('guest', 'index') @@ -33,7 +34,8 @@ $ccAcl->allow('guest', 'index') ->allow('host', 'playlist') ->allow('host', 'sideplaylist') ->allow('host', 'schedule') - ->allow('admin', 'user'); + ->allow('admin', 'user') + ->allow('admin', 'preference'); $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); diff --git a/application/configs/navigation.php b/application/configs/navigation.php index 42f9f447c..9b7676553 100644 --- a/application/configs/navigation.php +++ b/application/configs/navigation.php @@ -56,7 +56,7 @@ $pages = array( array( 'label' => 'Preferences', 'module' => 'default', - 'controller' => 'Nowplaying' + 'controller' => 'Preference' ), array( 'label' => 'Manage Users', diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php new file mode 100644 index 000000000..07fd3ad48 --- /dev/null +++ b/application/controllers/PreferenceController.php @@ -0,0 +1,43 @@ +view->form = $form; + } + + public function updateAction() + { + $request = $this->getRequest(); + if (!$this->getRequest()->isPost()) { + return $this->_forward('Preference/index'); + } + + $form = new Application_Form_Preferences(); + if (!$form->isValid($request->getPost())) { + // Failed validation; redisplay form + $this->view->form = $form; + return $this->render('index'); //render the phtml file + } + + $auth = Zend_Auth::getInstance(); + $id = $auth->getIdentity()->id; + + $values = $form->getValues(); + Application_Model_Preference::UpdateStationName($values["stationName"], $id); + $this->view->form = $form; + } + + +} + + + diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php new file mode 100644 index 000000000..32d59bded --- /dev/null +++ b/application/forms/Preferences.php @@ -0,0 +1,34 @@ +setAction('/Preference/update')->setMethod('post'); + + // Add login element + $this->addElement('text', 'stationName', array( + 'label' => 'Station Name:', + 'required' => true, + 'filters' => array('StringTrim'), + 'validators' => array('NotEmpty') + )); + + /* + $this->addElement('select', 'test', array( + 'label' => 'Live Stream Button: ', + 'multiOptions' => array( + "e" => "enabled", + "d" => "disabled" + )) + ); + */ + + $this->addElement('submit', 'submit', array( + 'ignore' => true, + 'label' => 'Submit', + )); + } +} + diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index 4c694de6e..d08fb0020 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -3,7 +3,7 @@ - Airtime + headTitle() ?> headScript() ?> headLink() ?> diff --git a/application/layouts/scripts/library.phtml b/application/layouts/scripts/library.phtml index 1ed4618a2..9af9fdc21 100644 --- a/application/layouts/scripts/library.phtml +++ b/application/layouts/scripts/library.phtml @@ -3,7 +3,7 @@ - Airtime + headTitle() ?> headScript() ?> headLink() ?> diff --git a/application/layouts/scripts/login.phtml b/application/layouts/scripts/login.phtml index cf47b1b82..512da3aa9 100644 --- a/application/layouts/scripts/login.phtml +++ b/application/layouts/scripts/login.phtml @@ -3,7 +3,7 @@ - Airtime + headTitle() ?> headScript() ?> headLink() ?> diff --git a/application/layouts/scripts/search.phtml b/application/layouts/scripts/search.phtml index c98c352a6..8704c615a 100644 --- a/application/layouts/scripts/search.phtml +++ b/application/layouts/scripts/search.phtml @@ -3,7 +3,7 @@ - Airtime + headTitle() ?> headScript() ?> headLink() ?> diff --git a/application/models/Preference.php b/application/models/Preference.php new file mode 100644 index 000000000..e56d006aa --- /dev/null +++ b/application/models/Preference.php @@ -0,0 +1,44 @@ +GetOne($sql); + + if ($result == 1){ + $sql = "UPDATE cc_pref" + ." SET subjid = $id, valstr = '$name'" + ." WHERE keystr = 'station_name'"; + } else { + $sql = "INSERT INTO cc_pref (subjid, keystr, valstr)" + ." VALUES ($id, 'station_name', '$name')"; + } + return $CC_DBC->query($sql); + } + + public static function GetStationName(){ + global $CC_CONFIG, $CC_DBC; + //Check if key already exists + $sql = "SELECT COUNT(*) FROM cc_pref" + ." WHERE keystr = 'station_name'"; + $result = $CC_DBC->GetOne($sql); + + if ($result == 0) + return "Airtime"; + else { + $sql = "SELECT valstr FROM cc_pref" + ." WHERE keystr = 'station_name'"; + $result = $CC_DBC->GetOne($sql); + return $result." - Airtime"; + } + + } + +} + diff --git a/application/views/scripts/preference/index.phtml b/application/views/scripts/preference/index.phtml new file mode 100644 index 000000000..c7fd9eb7e --- /dev/null +++ b/application/views/scripts/preference/index.phtml @@ -0,0 +1,3 @@ +form; +?> diff --git a/application/views/scripts/preference/update.phtml b/application/views/scripts/preference/update.phtml new file mode 100644 index 000000000..63d962812 --- /dev/null +++ b/application/views/scripts/preference/update.phtml @@ -0,0 +1,4 @@ +Preferences Updated. +form; +?> diff --git a/public/css/images/schedule-show_progressbar_bg.png b/public/css/images/schedule-show_progressbar_bg.png new file mode 100644 index 000000000..b1d7b3bc7 Binary files /dev/null and b/public/css/images/schedule-show_progressbar_bg.png differ diff --git a/tests/application/controllers/PreferenceControllerTest.php b/tests/application/controllers/PreferenceControllerTest.php new file mode 100644 index 000000000..41bb531eb --- /dev/null +++ b/tests/application/controllers/PreferenceControllerTest.php @@ -0,0 +1,20 @@ +