Merge branch 'cc-5709-airtime-analyzer' into cc-5709-airtime-analyzer-saas

This commit is contained in:
Albert Santoni 2014-06-23 15:28:50 -04:00
commit 72ef576f03
16 changed files with 11781 additions and 53 deletions

View file

@ -14,9 +14,11 @@ class LoginController extends Zend_Controller_Action
$request = $this->getRequest();
Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', 'en_CA'));
if (Zend_Auth::getInstance()->hasIdentity())
$auth = Zend_Auth::getInstance();
Application_Model_Auth::pinSessionToClient($auth);
if ($auth->hasIdentity())
{
$this->_redirect('Showbuilder');
}
@ -52,8 +54,7 @@ class LoginController extends Zend_Controller_Action
//pass to the adapter the submitted username and password
$authAdapter->setIdentity($username)
->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
//all info about this user from the login table omit only the password
@ -65,15 +66,13 @@ class LoginController extends Zend_Controller_Action
Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']);
Application_Model_Subjects::resetLoginAttempts($username);
$tempSess = new Zend_Session_Namespace("referrer");
$tempSess->referrer = 'login';
//set the user locale in case user changed it in when logging in
Application_Model_Preference::SetUserLocale($locale);
$this->_redirect('Showbuilder');
} else {
$message = _("Wrong username or password provided. Please try again.");
Application_Model_Subjects::increaseLoginAttempts($username);
Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']);
@ -96,7 +95,9 @@ class LoginController extends Zend_Controller_Action
public function logoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
$auth = Zend_Auth::getInstance();
Application_Model_Auth::pinSessionToClient($auth);
$auth->clearIdentity();
$this->_redirect('showbuilder/index');
}
@ -188,6 +189,7 @@ class LoginController extends Zend_Controller_Action
$auth->invalidateTokens($user, 'password.restore');
$zend_auth = Zend_Auth::getInstance();
Application_Model_Auth::pinSessionToClient($zend_auth);
$zend_auth->clearIdentity();
$authAdapter = Application_Model_Auth::getAuthAdapter();

View file

@ -109,6 +109,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = strtolower($request->getControllerName());
Application_Model_Auth::pinSessionToClient(Zend_Auth::getInstance());
//Ignore authentication for all access to the rest API. We do auth via API keys for this
//and/or by OAuth.

View file

@ -110,4 +110,13 @@ class Application_Model_Auth
return $string;
}
/** It is essential to do this before interacting with Zend_Auth otherwise sessions could be shared between
* different copies of Airtime on the same webserver. This essentially pins this session to this hostname and client ID.
* @param Zend_Auth $auth Get this with Zend_Auth::getInstance().
*/
public static function pinSessionToClient($auth)
{
$auth->setStorage(new Zend_Auth_Storage_Session('Airtime' . $_SERVER['SERVER_NAME'] . Application_Model_Preference::GetClientId()));
}
}

View file

@ -303,10 +303,10 @@ SQL;
$p_start_str = $p_start->format("Y-m-d H:i:s");
$p_end_str = $p_end->format("Y-m-d H:i:s");
//We need to search 24 hours before and after the show times so that that we
//We need to search 48 hours before and after the show times so that that we
//capture all of the show's contents.
$p_track_start= $p_start->sub(new DateInterval("PT24H"))->format("Y-m-d H:i:s");
$p_track_end = $p_end->add(new DateInterval("PT24H"))->format("Y-m-d H:i:s");
$p_track_start= $p_start->sub(new DateInterval("PT48H"))->format("Y-m-d H:i:s");
$p_track_end = $p_end->add(new DateInterval("PT48H"))->format("Y-m-d H:i:s");
$templateSql = <<<SQL
SELECT DISTINCT sched.starts AS sched_starts,

View file

@ -85,32 +85,31 @@ class Application_Service_CalendarService
$currentShow = Application_Model_Show::getCurrentShow();
$currentShowId = count($currentShow) == 1 ? $currentShow[0]["id"] : null;
$showIsLinked = $this->ccShow->isLinked();
if ($now < $end && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded()) {
//if the show is not linked the user can add/remove content
if (!$showIsLinked) {
$menu["schedule"] = array(
"name"=> _("Add / Remove Content"),
"icon" => "add-remove-content",
"url" => $baseUrl."showbuilder/builder-dialog/");
//if the show is linked and it's not currently playing the user can add/remove content
} elseif ($showIsLinked && $currentShowId != $this->ccShow->getDbId()) {
//user can add/remove content if the show has not ended
if ($now < $end && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded()) {
//if the show is not linked OR if the show is linked AND not the current playing show
//the user can add/remove content
if (!$showIsLinked || ($showIsLinked && $currentShowId != $this->ccShow->getDbId())) {
$menu["schedule"] = array(
"name"=> _("Add / Remove Content"),
"icon" => "add-remove-content",
"url" => $baseUrl."showbuilder/builder-dialog/");
}
}
if ($now < $start && ($isAdminOrPM || $isHostOfShow) &&
!$this->ccShowInstance->isRecorded() ) {
$menu["clear"] = array(
"name"=> _("Remove All Content"),
"icon" => "remove-all-content",
"url" => $baseUrl."schedule/clear-show");
//user can remove all content if the show has not started
if ($now < $start && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded() ) {
//if the show is not linked OR if the show is linked AND not the current playing show
//the user can remove all content
if (!$showIsLinked || ($showIsLinked && $currentShowId != $this->ccShow->getDbId())) {
$menu["clear"] = array(
"name"=> _("Remove All Content"),
"icon" => "remove-all-content",
"url" => $baseUrl."schedule/clear-show");
}
}
//"Show Content" should be a menu item at all times except when