Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
74e8abe820
4 changed files with 116 additions and 23 deletions
|
@ -9,7 +9,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$context = $this->_helper->getHelper('contextSwitch');
|
||||
$context->addActionContext('version', 'json')
|
||||
->addActionContext('recorded-shows', 'json')
|
||||
->addActionContext('server-timestamp', 'json')
|
||||
->addActionContext('calendar-init', 'json')
|
||||
->addActionContext('upload-file', 'json')
|
||||
->addActionContext('upload-recorded', 'json')
|
||||
->addActionContext('media-monitor-setup', 'json')
|
||||
|
@ -62,10 +62,26 @@ class ApiController extends Zend_Controller_Action
|
|||
echo $jsonStr;
|
||||
}
|
||||
|
||||
public function serverTimestampAction(){
|
||||
|
||||
$this->view->serverTimestamp = array("timestamp"=>time(), "timezoneOffset"=> date("Z"));
|
||||
|
||||
/**
|
||||
* Sets up and send init values used in the Calendar.
|
||||
* This is only being used by schedule.js at the moment.
|
||||
*/
|
||||
public function calendarInitAction(){
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
if(is_null(Zend_Auth::getInstance()->getStorage()->read())) {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->calendarInit = array(
|
||||
"timestamp"=>time(),
|
||||
"timezoneOffset"=> date("Z"),
|
||||
"timeScale"=>Application_Model_Preference::GetCalendarTimeScale()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,6 +179,7 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timeNow = $date->getTimestamp();
|
||||
|
||||
$result = array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||
"currentShow"=>Application_Model_Show::GetCurrentShow($timeNow),
|
||||
|
|
|
@ -28,6 +28,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
->addActionContext('get-form', 'json')
|
||||
->addActionContext('upload-to-sound-cloud', 'json')
|
||||
->addActionContext('content-context-menu', 'json')
|
||||
->addActionContext('set-time-scale', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
||||
|
@ -728,6 +729,14 @@ class ScheduleController extends Zend_Controller_Action
|
|||
//returns format jjmenu is looking for.
|
||||
die(json_encode($menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user specific preference for which time scale to use in Calendar.
|
||||
* This is only being used by schedule.js at the moment.
|
||||
*/
|
||||
public function setTimeScaleAction() {
|
||||
Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
class Application_Model_Preference
|
||||
{
|
||||
|
||||
public static function SetValue($key, $value){
|
||||
public static function SetValue($key, $value, $isUserValue = false){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
//called from a daemon process
|
||||
if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
||||
if(!Zend_Auth::getInstance()->hasIdentity()) {
|
||||
$id = NULL;
|
||||
}
|
||||
else {
|
||||
|
@ -21,6 +21,12 @@ class Application_Model_Preference
|
|||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
|
||||
//For user specific preference, check if id matches as well
|
||||
if($isUserValue) {
|
||||
$sql .= " AND subjid = '$id'";
|
||||
}
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($result == 1 && is_null($id)){
|
||||
|
@ -29,9 +35,15 @@ class Application_Model_Preference
|
|||
." WHERE keystr = '$key'";
|
||||
}
|
||||
else if ($result == 1 && !is_null($id)){
|
||||
$sql = "UPDATE cc_pref"
|
||||
." SET subjid = $id, valstr = '$value'"
|
||||
." WHERE keystr = '$key'";
|
||||
if($isUserValue) {
|
||||
$sql = "UPDATE cc_pref"
|
||||
." SET valstr = '$value'"
|
||||
." WHERE keystr = '$key' AND subjid = $id";
|
||||
} else {
|
||||
$sql = "UPDATE cc_pref"
|
||||
." SET subjid = $id, valstr = '$value'"
|
||||
." WHERE keystr = '$key'";
|
||||
}
|
||||
}
|
||||
else if(is_null($id)) {
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
||||
|
@ -44,11 +56,21 @@ class Application_Model_Preference
|
|||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public static function GetValue($key){
|
||||
public static function GetValue($key, $isUserValue = false){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
|
||||
//For user specific preference, check if id matches as well
|
||||
if($isUserValue) {
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity()) {
|
||||
$id = $auth->getIdentity()->id;
|
||||
$sql .= " AND subjid = '$id'";
|
||||
}
|
||||
}
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($result == 0)
|
||||
|
@ -56,6 +78,12 @@ class Application_Model_Preference
|
|||
else {
|
||||
$sql = "SELECT valstr FROM cc_pref"
|
||||
." WHERE keystr = '$key'";
|
||||
|
||||
//For user specific preference, check if id matches as well
|
||||
if($isUserValue && $auth->hasIdentity()) {
|
||||
$sql .= " AND subjid = '$id'";
|
||||
}
|
||||
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
return $result;
|
||||
}
|
||||
|
@ -441,7 +469,7 @@ class Application_Model_Preference
|
|||
public static function GetAirtimeVersion(){
|
||||
return self::GetValue("system_version");
|
||||
}
|
||||
|
||||
|
||||
public static function SetUploadToSoundcloudOption($upload) {
|
||||
self::SetValue("soundcloud_upload_option", $upload);
|
||||
}
|
||||
|
@ -449,7 +477,7 @@ class Application_Model_Preference
|
|||
public static function GetUploadToSoundcloudOption() {
|
||||
return self::GetValue("soundcloud_upload_option");
|
||||
}
|
||||
|
||||
|
||||
public static function SetSoundCloudDownloadbleOption($upload) {
|
||||
self::SetValue("soundcloud_downloadable", $upload);
|
||||
}
|
||||
|
@ -457,5 +485,21 @@ class Application_Model_Preference
|
|||
public static function GetSoundCloudDownloadbleOption() {
|
||||
return self::GetValue("soundcloud_downloadable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time scale preference (day/week/month) in Calendar.
|
||||
*
|
||||
* @param $timeScale new time scale
|
||||
*/
|
||||
public static function SetCalendarTimeScale($timeScale) {
|
||||
return self::SetValue("calendar_time_scale", $timeScale, true /* user specific */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the time scale preference for the current user.
|
||||
*/
|
||||
public static function GetCalendarTimeScale() {
|
||||
return self::GetValue("calendar_time_scale", true /* user specific */);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue