CC2646: Set a calendar view default (Day/week/month) that's remembered

Updated the calendar page so that when user chooses a different time scale to display(day/week/month),
the new setting is stored in the pref database. Each user id has its own entry in the database.

When visiting the calendar, we retrieves the entry from database for current user
and show that time scale; defaults to monthly view if no entry found.
This commit is contained in:
Yuchen Wang 2011-10-14 14:17:06 -04:00
parent 5a83c5b81e
commit 8b2a23b88a
4 changed files with 116 additions and 23 deletions

View file

@ -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),

View file

@ -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'));
}
}