SAAS-945: Language + Timezone Setup Popup

This commit is contained in:
drigato 2015-07-27 07:06:22 -04:00
parent ce7765a8cb
commit ee2bfe7664
8 changed files with 164 additions and 3 deletions

View file

@ -0,0 +1,48 @@
<?php
class SetupController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('setup-language-timezone', 'json');
}
public function setupLanguageTimezoneAction()
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$form = new Application_Form_SetupLanguageTimezone();
if ($request->isPost()) {
$postData = $request->getPost();
$formData = array();
foreach ($postData["data"] as $key => $value) {
if ($value["name"] == "csrf") continue;
$formData[$value["name"]] = $value["value"];
}
if ($form->isValid($formData)) {
$userService = new Application_Service_UserService();
$currentUser = $userService->getCurrentUser();
$currentUserId = $currentUser->getDbId();
Application_Model_Preference::SetUserTimezone($formData["timezone"], $currentUserId);
Application_Model_Preference::SetDefaultTimezone($formData["timezone"]);
Application_Model_Preference::SetUserLocale($formData["language"], $currentUserId);
Application_Model_Preference::SetDefaultLocale($formData["language"]);
Application_Model_Preference::setLangTimezoneSetupComplete(true);
$this->_helper->json->sendJson(null);
} else {
$this->_helper->json->sendJson($form->get);
}
} else {
$this->_helper->json->sendJson($form);
}
}
}

View file

@ -55,8 +55,23 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$refer_sses = new Zend_Session_Namespace('referrer');
$setupComplete = Application_Model_Preference::getLangTimezoneSetupComplete();
$previousPage = $request->getHeader('Referer');
$userService = new Application_Service_UserService();
$currentUser = $userService->getCurrentUser();
// If current user is Super Admin, and they came from the login page,
// and they have not seen the setup popup before
if ($currentUser->getDbType() == "S" && strpos(strtolower($previousPage), 'login') !== false
&& empty($setupComplete)) {
Logging::info("hello");
$lang_tz_popup_form = new Application_Form_SetupLanguageTimezone();
$this->view->lang_tz_popup_form = $lang_tz_popup_form;
$this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/lang-timezone-setup.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
//TODO: is it safe to remove this??
/*
if ($request->isPost()) {
$form = new Application_Form_RegisterAirtime();
@ -115,6 +130,7 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->dialog = $form;
$this->view->headScript()->appendFile($baseUrl.'js/airtime/nowplaying/register.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
}
*/
//determine whether to remove/hide/display the library.
$showLib = false;