CC-1990: Widget to display schedule and "Now Playing" on any website

-admin can now enable/disable access to scheduling information to remote widgets via the preferences page.
This commit is contained in:
martin 2011-03-30 15:34:35 -04:00
parent db3134cea8
commit 32c28046ef
4 changed files with 63 additions and 29 deletions

View file

@ -103,7 +103,9 @@ class ApiController extends Zend_Controller_Action
exit; exit;
} }
public function liveInfoAction(){ public function liveInfoAction()
{
if (Application_Model_Preference::GetAllow3rdPartyApi()){
// disable the view and the layout // disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
@ -122,9 +124,16 @@ class ApiController extends Zend_Controller_Action
//echo json_encode($result); //echo json_encode($result);
header("Content-type: text/javascript"); header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')'; echo $_GET['callback'].'('.json_encode($result).')';
} else {
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';
exit;
}
} }
public function weekInfoAction(){ public function weekInfoAction()
{
if (Application_Model_Preference::GetAllow3rdPartyApi()){
// disable the view and the layout // disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
@ -138,6 +147,11 @@ class ApiController extends Zend_Controller_Action
header("Content-type: text/javascript"); header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')'; echo $_GET['callback'].'('.json_encode($result).')';
} else {
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';
exit;
}
} }
public function scheduleAction() public function scheduleAction()

View file

@ -30,13 +30,13 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]); Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]);
Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]); Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]);
Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]); Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]);
Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]); Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]); Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>"; $this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
} }
$this->view->form = $form; $this->view->form = $form;

View file

@ -42,6 +42,13 @@ class Application_Form_Preferences extends Zend_Form
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
$this->addElement($stream_format); $this->addElement($stream_format);
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
$third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info');
$third_party_api->setMultiOptions(array("Disabled",
"Enabled"));
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
$this->addElement($third_party_api);
$this->addElement('checkbox', 'UseSoundCloud', array( $this->addElement('checkbox', 'UseSoundCloud', array(
'label' => 'Automatically Upload Recorded Shows To SoundCloud', 'label' => 'Automatically Upload Recorded Shows To SoundCloud',

View file

@ -132,5 +132,18 @@ class Application_Model_Preference
return Application_Model_Preference::GetValue("soundcloud_tags"); return Application_Model_Preference::GetValue("soundcloud_tags");
} }
public static function SetAllow3rdPartyApi($bool) {
Application_Model_Preference::SetValue("third_party_api", $bool);
}
public static function GetAllow3rdPartyApi() {
$val = Application_Model_Preference::GetValue("third_party_api");
if (strlen($val) == 0){
return "0";
} else {
return $val;
}
}
} }