Merge branch '2.1.x' of dev.sourcefabric.org:airtime into 2.1.x
This commit is contained in:
commit
be02906565
|
@ -42,32 +42,38 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
//Open a jPlayer window and play the audio clip.
|
||||
$menu["play"] = array("name"=> "Play", "icon" => "play");
|
||||
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
|
||||
if ($type === "audioclip") {
|
||||
|
||||
$file = Application_Model_StoredFile::Recall($id);
|
||||
|
||||
if (isset($this->pl_sess->id) && $screen == "playlist") {
|
||||
$menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
|
||||
// if the user is not admin or pm, check the creator and see if this person owns the playlist
|
||||
$playlist = new Application_Model_Playlist($this->pl_sess->id);
|
||||
if($isAdminOrPM || $playlist->getCreatorId() == $user->getId()){
|
||||
$menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$menu["edit"] = array("name"=> "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
if ($isAdminOrPM) {
|
||||
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||
$menu["edit"] = array("name"=> "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
|
||||
}
|
||||
|
||||
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
|
||||
$menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url);
|
||||
$menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url);
|
||||
}
|
||||
else if ($type === "playlist") {
|
||||
|
||||
$playlist = new Application_Model_Playlist($id);
|
||||
if ($this->pl_sess->id !== $id && $screen == "playlist") {
|
||||
$menu["edit"] = array("name"=> "Edit", "icon" => "edit");
|
||||
if($isAdminOrPM || $playlist->getCreatorId() == $user->getId()){
|
||||
$menu["edit"] = array("name"=> "Edit", "icon" => "edit");
|
||||
}
|
||||
}
|
||||
if($isAdminOrPM || $playlist->getCreatorId() == $user->getId()){
|
||||
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||
}
|
||||
|
||||
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,6 +112,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$mediaItems = $this->_getParam('media', null);
|
||||
|
||||
$user = Application_Model_User::GetCurrentUser();
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
|
||||
$files = array();
|
||||
$playlists = array();
|
||||
|
@ -122,12 +129,27 @@ class LibraryController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
$hasPermission = true;
|
||||
if (count($playlists)) {
|
||||
Application_Model_Playlist::DeletePlaylists($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 (!$user->isAdmin()) {
|
||||
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.";
|
||||
return;
|
||||
}else{
|
||||
Application_Model_Playlist::DeletePlaylists($playlists);
|
||||
}
|
||||
|
||||
foreach ($files as $id) {
|
||||
|
@ -182,6 +204,12 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
public function editFileMdAction()
|
||||
{
|
||||
$user = Application_Model_User::GetCurrentUser();
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
if(!$isAdminOrPM){
|
||||
return;
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_EditAudioMD();
|
||||
|
||||
|
|
|
@ -760,7 +760,8 @@ class ScheduleController extends Zend_Controller_Action
|
|||
}
|
||||
$data['add_show_record'] = $show->isRecorded();
|
||||
|
||||
$success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate);
|
||||
$origianlShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime());
|
||||
$success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate, $origianlShowStartDateTime);
|
||||
|
||||
if ($success){
|
||||
$this->view->addNewShow = true;
|
||||
|
|
|
@ -83,7 +83,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData, $validateStartDate) {
|
||||
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=false) {
|
||||
$valid = true;
|
||||
|
||||
$start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
|
||||
|
@ -91,12 +91,19 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
//DateTime stores $start_time in the current timezone
|
||||
$nowDateTime = new DateTime();
|
||||
$showStartDateTime = new DateTime($start_time);
|
||||
|
||||
if ($validateStartDate){
|
||||
if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
||||
$valid = false;
|
||||
}
|
||||
// if edit action, check if original show start time is in the past. CC-3864
|
||||
if($originalStartDate){
|
||||
if($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) {
|
||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot modify start date/time of the show that is already started'));
|
||||
$this->disableStartDateAndTime();
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pattern = '/([0-9][0-9])h ([0-9][0-9])m/';
|
||||
|
|
|
@ -121,6 +121,10 @@ class Application_Model_Playlist {
|
|||
|
||||
return $this->pl->getCcSubjs()->getDbLogin();
|
||||
}
|
||||
|
||||
public function getCreatorId() {
|
||||
return $this->pl->getCcSubjs()->getDbId();
|
||||
}
|
||||
|
||||
public function setCreator($p_id) {
|
||||
|
||||
|
|
|
@ -750,7 +750,7 @@ class Application_Model_Schedule {
|
|||
* Another clean-up is to move all the form manipulation to the proper form class.....
|
||||
* -Martin
|
||||
*/
|
||||
public static function addUpdateShow($data, $controller, $validateStartDate){
|
||||
public static function addUpdateShow($data, $controller, $validateStartDate, $originalStartDate=null){
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
@ -777,7 +777,7 @@ class Application_Model_Schedule {
|
|||
$when = $formWhen->isValid($data);
|
||||
$live = $formLive->isValid($data);
|
||||
if($when) {
|
||||
$when = $formWhen->checkReliantFields($data, $validateStartDate);
|
||||
$when = $formWhen->checkReliantFields($data, $validateStartDate, $originalStartDate);
|
||||
}
|
||||
|
||||
//The way the following code works is that is parses the hour and
|
||||
|
|
Loading…
Reference in New Issue