Merge branch 'devel' into mediamonitor2

Conflicts:
	python_apps/api_clients/api_client.py
This commit is contained in:
Rudi Grinberg 2012-07-16 17:41:36 -04:00
commit 20e32b98ba
31 changed files with 253 additions and 143 deletions

View file

@ -262,30 +262,28 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$type = $request->getParam('type');
if ($type == "endofday") {
// make getNextShows use end of day
$limit = $request->getParam('limit');
if($limit == "" || !is_numeric($limit)) {
$limit = "5";
}
// make GetNextShows use end of day
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
$result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, 5, $utcTimeEnd));
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd));
Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
} else {
$limit = $request->getParam('limit');
if ($limit == "" || !is_numeric($limit)) {
$limit = "5";
}
$result = Application_Model_Schedule::GetPlayOrderRange();
//Convert from UTC to localtime for user.
//Convert from UTC to localtime for Web Browser.
Application_Model_Show::convertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
}
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
//echo json_encode($result);
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
} else {

View file

@ -125,28 +125,11 @@ class LibraryController extends Zend_Controller_Action
}
}
$hasPermission = true;
if (count($playlists)) {
// make sure use has permission to delete all playslists in the list
if (!$isAdminOrPM) {
foreach ($playlists as $pid) {
$pl = new Application_Model_Playlist($pid);
if ($pl->getCreatorId() != $user->getId()) {
$hasPermission = false;
}
}
}
}
if (!$isAdminOrPM && count($files)) {
$hasPermission = false;
}
if (!$hasPermission) {
$this->view->message = "You don't have a permission to delete all playlists/files that are selected.";
try {
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
} catch (PlaylistNoPermissionException $e) {
$this->view->message = "You don't have permission to delete selected playlists/files.";
return;
} else {
Application_Model_Playlist::DeletePlaylists($playlists);
}
foreach ($files as $id) {

View file

@ -82,7 +82,7 @@ class PlaylistController extends Zend_Controller_Action
}
}
private function playlistOutdated($pl, $e)
private function playlistOutdated($e)
{
$this->view->error = $e->getMessage();
}
@ -95,6 +95,10 @@ class PlaylistController extends Zend_Controller_Action
$this->changePlaylist(null);
$this->createFullResponse(null);
}
private function playlistNoPermission(){
$this->view->error = "You don't have permission to delete selected playlist(s).";
}
private function playlistUnknownError($e)
{
@ -137,7 +141,13 @@ class PlaylistController extends Zend_Controller_Action
try {
if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id);
$this->view->pl = $pl;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
if($isAdminOrPM || $pl->getCreatorId() == $userInfo->id){
$this->view->pl = $pl;
}
$formatter = new LengthFormatter($pl->getLength());
$this->view->length = $formatter->format();
@ -186,6 +196,9 @@ class PlaylistController extends Zend_Controller_Action
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$pl = null;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
try {
@ -198,9 +211,13 @@ class PlaylistController extends Zend_Controller_Action
$pl = new Application_Model_Playlist($this->pl_sess->id);
}
Application_Model_Playlist::DeletePlaylists($ids);
Application_Model_Playlist::deletePlaylists($ids, $userInfo->id);
$this->createFullResponse($pl);
} catch (PlaylistNotFoundException $e) {
}
catch (PlaylistNoPermissionException $e) {
$this->playlistNoPermission();
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
$this->playlistUnknownError($e);
@ -219,7 +236,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->addAudioClips($ids, $afterItem, $addType);
$this->createUpdateResponse($pl);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -239,7 +256,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->moveAudioClips($ids, $afterItem);
$this->createUpdateResponse($pl);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -258,7 +275,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->delAudioClips($ids);
$this->createUpdateResponse($pl);
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -283,7 +300,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->cue_error = $response["error"];
}
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -308,7 +325,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->fade_error = $response["error"];
}
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -326,7 +343,7 @@ class PlaylistController extends Zend_Controller_Action
$fades = $pl->getFadeInfo($pl->getSize()-1);
$this->view->fadeOut = $fades[1];
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -349,7 +366,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->setPlaylistfades($fadeIn, $fadeOut);
$this->view->modified = $pl->getLastModified("U");
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -367,7 +384,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->playlistName = $name;
$this->view->modified = $pl->getLastModified("U");
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {
@ -385,7 +402,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
$this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
} catch (Exception $e) {