2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class LibraryController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
2012-03-12 15:32:24 +01:00
|
|
|
$ajaxContext->addActionContext('contents-feed', 'json')
|
2021-10-11 16:10:47 +02:00
|
|
|
->addActionContext('delete', 'json')
|
|
|
|
->addActionContext('duplicate', 'json')
|
|
|
|
->addActionContext('duplicate-block', 'json')
|
|
|
|
->addActionContext('delete-group', 'json')
|
|
|
|
->addActionContext('context-menu', 'json')
|
|
|
|
->addActionContext('get-file-metadata', 'html')
|
|
|
|
->addActionContext('set-num-entries', 'json')
|
|
|
|
->addActionContext('edit-file-md', 'json')
|
|
|
|
->addActionContext('publish-dialog', 'html')
|
2022-01-23 19:15:55 +01:00
|
|
|
->initContext();
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2012-08-21 17:12:33 +02:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->_redirect('showbuilder');
|
2012-08-22 20:03:11 +02:00
|
|
|
}
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
protected function playlistNotFound($p_type)
|
2012-08-22 20:03:11 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->error = sprintf(_('%s not found'), $p_type);
|
2012-08-22 20:03:11 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::info("{$p_type} not found");
|
2012-08-22 20:03:11 +02:00
|
|
|
Application_Model_Library::changePlaylist(null, $p_type);
|
|
|
|
$this->createFullResponse(null);
|
|
|
|
}
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
protected function playlistUnknownError($e)
|
2012-08-22 20:03:11 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->error = _('Something went wrong.');
|
2012-09-13 18:15:51 +02:00
|
|
|
Logging::info($e->getMessage());
|
2012-08-22 20:03:11 +02:00
|
|
|
}
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
protected function createFullResponse($obj = null, $isJson = false)
|
2012-08-22 20:03:11 +02:00
|
|
|
{
|
|
|
|
$isBlock = false;
|
|
|
|
$viewPath = 'playlist/playlist.phtml';
|
|
|
|
if ($obj instanceof Application_Model_Block) {
|
|
|
|
$isBlock = true;
|
|
|
|
$viewPath = 'playlist/smart-block.phtml';
|
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
if (isset($obj)) {
|
|
|
|
$formatter = new LengthFormatter($obj->getLength());
|
|
|
|
$this->view->length = $formatter->format();
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
if ($isBlock) {
|
|
|
|
$form = new Application_Form_SmartBlockCriteria();
|
|
|
|
$form->removeDecorator('DtDdWrapper');
|
|
|
|
$form->startForm($obj->getId());
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
$this->view->form = $form;
|
|
|
|
$this->view->obj = $obj;
|
|
|
|
$this->view->id = $obj->getId();
|
|
|
|
if ($isJson) {
|
|
|
|
return $this->view->render($viewPath);
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->html = $this->view->render($viewPath);
|
2012-08-22 20:03:11 +02:00
|
|
|
} else {
|
|
|
|
$this->view->obj = $obj;
|
|
|
|
$this->view->id = $obj->getId();
|
|
|
|
$this->view->html = $this->view->render($viewPath);
|
|
|
|
unset($this->view->obj);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->view->html = $this->view->render($viewPath);
|
2012-08-21 17:12:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
public function contextMenuAction()
|
|
|
|
{
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2010-12-30 23:26:44 +01:00
|
|
|
$id = $this->_getParam('id');
|
2011-04-18 18:43:04 +02:00
|
|
|
$type = $this->_getParam('type');
|
2022-03-14 11:15:04 +01:00
|
|
|
// playlist||timeline
|
2012-02-05 18:19:22 +01:00
|
|
|
$screen = $this->_getParam('screen');
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu = [];
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2011-07-18 19:48:20 +02:00
|
|
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
2011-09-23 23:00:55 +02:00
|
|
|
$user = new Application_Model_User($userInfo->id);
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// Open a jPlayer window and play the audio clip.
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['play'] = ['name' => _('Preview'), 'icon' => 'play', 'disabled' => false];
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$isAdminOrPM = $user->isUserType([UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER]);
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-08-22 22:08:51 +02:00
|
|
|
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($type === 'audioclip') {
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['play']['mime'] = $file->getPropelOrm()->getDbMime();
|
2012-09-12 23:32:19 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if (isset($obj_sess->id) && $screen == 'playlist') {
|
2012-07-25 23:08:22 +02:00
|
|
|
// if the user is not admin or pm, check the creator and see if this person owns the playlist or Block
|
2012-08-22 21:34:59 +02:00
|
|
|
if ($obj_sess->type == 'playlist') {
|
|
|
|
$obj = new Application_Model_Playlist($obj_sess->id);
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($obj_sess->type == 'block') {
|
2012-08-22 21:34:59 +02:00
|
|
|
$obj = new Application_Model_Block($obj_sess->id);
|
2012-07-25 23:08:22 +02:00
|
|
|
}
|
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($obj_sess->type === 'playlist') {
|
|
|
|
$menu['pl_add'] = ['name' => _('Add to Playlist'), 'icon' => 'add-playlist', 'icon' => 'copy'];
|
|
|
|
} elseif ($obj_sess->type === 'block' && $obj->isStatic()) {
|
|
|
|
$menu['pl_add'] = ['name' => _('Add to Smart Block'), 'icon' => 'add-playlist', 'icon' => 'copy'];
|
2012-07-26 19:16:29 +02:00
|
|
|
}
|
2012-06-06 23:31:51 +02:00
|
|
|
}
|
2012-02-24 15:07:04 +01:00
|
|
|
}
|
2012-10-31 21:01:17 +01:00
|
|
|
if ($isAdminOrPM || $file->getFileOwnerId() == $user->getId()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['del'] = ['name' => _('Delete'), 'icon' => 'delete', 'url' => $baseUrl . 'library/delete'];
|
|
|
|
$menu['edit'] = ['name' => _('Edit...'), 'icon' => 'edit', 'url' => $baseUrl . "library/edit-file-md/id/{$id}"];
|
2021-09-06 14:40:40 +02:00
|
|
|
// Disable My podcasts
|
2022-03-29 13:07:38 +02:00
|
|
|
// See https://github.com/libretime/libretime/issues/1320
|
2021-09-06 14:40:40 +02:00
|
|
|
// $menu["publish"] = array("name"=> _("Publish..."), "url" => $baseUrl."library/publish/id/{$id}");
|
2011-04-18 18:43:04 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$url = $baseUrl . "api/get-media/file/{$id}/download/true";
|
|
|
|
$menu['download'] = ['name' => _('Download'), 'icon' => 'download', 'url' => $url];
|
|
|
|
} elseif ($type === 'playlist' || $type === 'block') {
|
2012-07-25 23:08:22 +02:00
|
|
|
if ($type === 'playlist') {
|
|
|
|
$obj = new Application_Model_Playlist($id);
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['duplicate'] = ['name' => _('Duplicate Playlist'), 'icon' => 'edit', 'url' => $baseUrl . 'library/duplicate'];
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type === 'block') {
|
2012-07-25 23:08:22 +02:00
|
|
|
$obj = new Application_Model_Block($id);
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['duplicate'] = ['name' => _('Duplicate Smartblock'), 'icon' => 'edit', 'url' => $baseUrl . 'library/duplicate-block'];
|
2012-08-10 18:40:28 +02:00
|
|
|
if (!$obj->isStatic()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
unset($menu['play']);
|
2012-08-02 22:36:12 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == 'playlist') {
|
|
|
|
if ($obj_sess->type === 'playlist') {
|
|
|
|
$menu['pl_add'] = ['name' => _('Add to Playlist'), 'icon' => 'add-playlist', 'icon' => 'copy'];
|
2012-07-26 19:16:29 +02:00
|
|
|
}
|
2012-07-26 18:45:31 +02:00
|
|
|
}
|
2012-07-25 23:08:22 +02:00
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($obj_sess->id !== $id && $screen == 'playlist') {
|
2012-07-25 23:08:22 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['edit'] = ['name' => _('Edit...'), 'icon' => 'edit'];
|
2012-06-06 23:31:51 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-19 17:09:34 +02:00
|
|
|
|
2012-07-25 23:08:22 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['del'] = ['name' => _('Delete'), 'icon' => 'delete', 'url' => $baseUrl . 'library/delete'];
|
2011-04-18 18:43:04 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($type == 'stream') {
|
2012-08-10 18:40:28 +02:00
|
|
|
$webstream = CcWebstreamQuery::create()->findPK($id);
|
|
|
|
$obj = new Application_Model_Webstream($webstream);
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['play']['mime'] = $webstream->getDbMime();
|
2013-01-02 22:09:32 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if (isset($obj_sess->id) && $screen == 'playlist') {
|
2012-07-31 03:48:04 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($obj_sess->type === 'playlist') {
|
|
|
|
$menu['pl_add'] = ['name' => _('Add to Playlist'), 'icon' => 'add-playlist', 'icon' => 'copy'];
|
2012-07-31 03:48:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($screen == 'playlist') {
|
|
|
|
$menu['edit'] = ['name' => _('Edit...'), 'icon' => 'edit', 'url' => $baseUrl . "library/edit-file-md/id/{$id}"];
|
2012-10-19 17:09:34 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['del'] = ['name' => _('Delete'), 'icon' => 'delete', 'url' => $baseUrl . 'library/delete'];
|
2012-08-13 20:58:11 +02:00
|
|
|
}
|
2011-04-18 18:43:04 +02:00
|
|
|
}
|
2010-12-30 00:43:17 +01:00
|
|
|
|
2012-08-09 23:50:43 +02:00
|
|
|
if (empty($menu)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$menu['noaction'] = ['name' => _('No action available')];
|
2012-08-09 23:50:43 +02:00
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-02-05 13:56:07 +01:00
|
|
|
$this->view->items = $menu;
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteAction()
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// array containing id and type of media to delete.
|
2012-02-05 18:19:22 +01:00
|
|
|
$mediaItems = $this->_getParam('media', null);
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
$user = Application_Model_User::getCurrentUser();
|
2022-03-14 11:15:04 +01:00
|
|
|
// $isAdminOrPM = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$files = [];
|
|
|
|
$playlists = [];
|
|
|
|
$blocks = [];
|
|
|
|
$streams = [];
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
$message = null;
|
2012-11-15 18:55:45 +01:00
|
|
|
$noPermissionMsg = _("You don't have permission to delete selected items.");
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
foreach ($mediaItems as $media) {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($media['type'] === 'audioclip') {
|
|
|
|
$files[] = intval($media['id']);
|
|
|
|
} elseif ($media['type'] === 'playlist') {
|
|
|
|
$playlists[] = intval($media['id']);
|
|
|
|
} elseif ($media['type'] === 'block') {
|
|
|
|
$blocks[] = intval($media['id']);
|
|
|
|
} elseif ($media['type'] === 'stream') {
|
|
|
|
$streams[] = intval($media['id']);
|
2011-05-17 23:30:17 +02:00
|
|
|
}
|
2012-02-05 18:19:22 +01:00
|
|
|
}
|
2011-04-18 18:43:04 +02:00
|
|
|
|
2012-07-10 23:24:57 +02:00
|
|
|
try {
|
2012-07-31 03:48:04 +02:00
|
|
|
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
|
2012-07-10 23:24:57 +02:00
|
|
|
} catch (PlaylistNoPermissionException $e) {
|
2012-10-31 22:19:27 +01:00
|
|
|
$message = $noPermissionMsg;
|
2012-02-05 18:19:22 +01:00
|
|
|
}
|
2012-01-16 09:56:57 +01:00
|
|
|
|
2012-07-31 03:48:04 +02:00
|
|
|
try {
|
|
|
|
Application_Model_Block::deleteBlocks($blocks, $user->getId());
|
2012-10-31 22:19:27 +01:00
|
|
|
} catch (BlockNoPermissionException $e) {
|
|
|
|
$message = $noPermissionMsg;
|
2012-07-31 03:48:04 +02:00
|
|
|
} catch (Exception $e) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// TODO: warn user that not all blocks could be deleted.
|
2012-07-31 03:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Application_Model_Webstream::deleteStreams($streams, $user->getId());
|
2012-10-31 22:19:27 +01:00
|
|
|
} catch (WebstreamNoPermissionException $e) {
|
|
|
|
$message = $noPermissionMsg;
|
2012-07-31 03:48:04 +02:00
|
|
|
} catch (Exception $e) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// TODO: warn user that not all streams could be deleted.
|
2012-08-22 00:55:38 +02:00
|
|
|
Logging::info($e);
|
2012-07-31 03:48:04 +02:00
|
|
|
}
|
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
foreach ($files as $id) {
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2012-02-05 18:19:22 +01:00
|
|
|
if (isset($file)) {
|
|
|
|
try {
|
2012-11-02 22:49:32 +01:00
|
|
|
$res = $file->delete();
|
2012-10-31 21:51:29 +01:00
|
|
|
} catch (FileNoPermissionException $e) {
|
2012-10-31 22:19:27 +01:00
|
|
|
$message = $noPermissionMsg;
|
2015-04-01 22:16:46 +02:00
|
|
|
} catch (DeleteScheduledFileException $e) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$message = _('Could not delete file because it is scheduled in the future.');
|
2012-07-31 03:48:04 +02:00
|
|
|
} catch (Exception $e) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// could throw a scheduled in future exception.
|
2021-10-11 16:10:47 +02:00
|
|
|
$message = _('Could not delete file(s).');
|
|
|
|
Logging::info($message . ': ' . $e->getMessage());
|
2012-01-08 05:37:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-05 18:19:22 +01:00
|
|
|
|
|
|
|
if (isset($message)) {
|
|
|
|
$this->view->message = $message;
|
|
|
|
}
|
2012-01-08 05:37:37 +01:00
|
|
|
}
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
// duplicate playlist
|
2021-10-11 16:10:47 +02:00
|
|
|
public function duplicateAction()
|
|
|
|
{
|
2012-12-28 22:17:58 +01:00
|
|
|
$params = $this->getRequest()->getParams();
|
|
|
|
$id = $params['id'];
|
2017-08-17 05:32:54 +02:00
|
|
|
Logging::info($params);
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$originalPl = new Application_Model_Playlist($id);
|
|
|
|
$newPl = new Application_Model_Playlist();
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$contents = $originalPl->getContents();
|
|
|
|
foreach ($contents as &$c) {
|
|
|
|
if ($c['type'] == '0') {
|
|
|
|
$c[1] = 'audioclip';
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($c['type'] == '2') {
|
2012-12-28 22:17:58 +01:00
|
|
|
$c[1] = 'block';
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($c['type'] == '1') {
|
2012-12-28 22:17:58 +01:00
|
|
|
$c[1] = 'stream';
|
|
|
|
}
|
|
|
|
$c[0] = $c['item_id'];
|
|
|
|
}
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2013-05-30 21:36:55 +02:00
|
|
|
$newPl->addAudioClips($contents, null, 'before');
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$newPl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
|
|
|
$newPl->setDescription($originalPl->getDescription());
|
2013-08-20 05:19:13 +02:00
|
|
|
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$plFadeIn] = $originalPl->getFadeInfo(0);
|
|
|
|
[, $plFadeOut] = $originalPl->getFadeInfo($originalPl->getSize() - 1);
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$newPl->setfades($plFadeIn, $plFadeOut);
|
2021-10-11 16:10:47 +02:00
|
|
|
$newPl->setName(sprintf(_('Copy of %s'), $originalPl->getName()));
|
2012-12-28 22:17:58 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2017-08-17 05:32:54 +02:00
|
|
|
// duplicate smartblock
|
2021-10-11 16:10:47 +02:00
|
|
|
public function duplicateBlockAction()
|
|
|
|
{
|
|
|
|
Logging::info('duplicate smartblock functionality not yet implemented');
|
2017-08-17 05:32:54 +02:00
|
|
|
$params = $this->getRequest()->getParams();
|
|
|
|
$id = $params['id'];
|
|
|
|
Logging::info($params);
|
|
|
|
|
|
|
|
$originalBl = new Application_Model_Block($id);
|
|
|
|
$newBl = new Application_Model_Block();
|
|
|
|
$newBl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
|
|
|
$newBl->setDescription($originalBl->getDescription());
|
2017-08-17 07:21:26 +02:00
|
|
|
if ($originalBl->isStatic()) {
|
|
|
|
$newBl->saveType('static');
|
2021-10-11 16:10:47 +02:00
|
|
|
} else {
|
2017-08-17 07:21:26 +02:00
|
|
|
$newBl->saveType('dynamic');
|
|
|
|
}
|
|
|
|
// the issue here is that the format that getCriteria provides is different from the format the saveCriteria
|
|
|
|
// expects due to the useage of startForm. So we either need to write new code that simply copies the database
|
|
|
|
// or figure out a way to instantiate a form inside of here and save it without modifying it.
|
2022-03-14 11:15:04 +01:00
|
|
|
// $newBlForm = new Application_Form_SmartBlockCriteria;
|
|
|
|
// $newBlForm->startForm($id);
|
2017-08-17 07:21:26 +02:00
|
|
|
$criteria = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($id);
|
|
|
|
foreach ($criteria as &$c) {
|
|
|
|
$row = new CcBlockcriteria();
|
|
|
|
$row->setDbCriteria($c->getDbCriteria());
|
|
|
|
$row->setDbModifier($c->getDbModifier());
|
|
|
|
$row->setDbValue($c->getDbValue());
|
|
|
|
$row->setDbExtra($c->getDbExtra());
|
|
|
|
$row->setDbBlockId($newBl->getId());
|
|
|
|
$row->save();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$newBl->setName(sprintf(_('Copy of %s'), $originalBl->getName()));
|
2017-08-17 05:32:54 +02:00
|
|
|
}
|
|
|
|
|
2012-03-12 15:32:24 +01:00
|
|
|
public function contentsFeedAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-01-27 21:06:04 +01:00
|
|
|
$params = $this->getRequest()->getParams();
|
2012-07-25 23:08:22 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// terrible name for the method below. it does not only search files.
|
2012-03-12 15:32:24 +01:00
|
|
|
$r = Application_Model_StoredFile::searchLibraryFiles($params);
|
2012-01-16 09:56:57 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->sEcho = $r['sEcho'];
|
|
|
|
$this->view->iTotalDisplayRecords = $r['iTotalDisplayRecords'];
|
|
|
|
$this->view->iTotalRecords = $r['iTotalRecords'];
|
|
|
|
$this->view->files = SecurityHelper::htmlescape_recursive($r['aaData']);
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
public function editFileMdAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-07-11 00:51:32 +02:00
|
|
|
$user = Application_Model_User::getCurrentUser();
|
2021-10-11 16:10:47 +02:00
|
|
|
$isAdminOrPM = $user->isUserType([UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER]);
|
|
|
|
$isAdmin = $user->isUserType([UTYPE_SUPERADMIN, UTYPE_ADMIN]);
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
$request = $this->getRequest();
|
2011-11-29 16:20:09 +01:00
|
|
|
|
2011-02-24 17:06:19 +01:00
|
|
|
$file_id = $this->_getParam('id', null);
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($file_id);
|
2012-10-31 21:01:17 +01:00
|
|
|
|
|
|
|
$form = new Application_Form_EditAudioMD();
|
2012-12-05 19:16:25 +01:00
|
|
|
$form->startForm($file_id);
|
2011-08-30 22:50:46 +02:00
|
|
|
$form->populate($file->getDbColMetadata());
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2015-08-28 19:40:38 +02:00
|
|
|
$this->view->permissionDenied = false;
|
|
|
|
if (!$isAdminOrPM && $file->getFileOwnerId() != $user->getId()) {
|
|
|
|
$form->makeReadOnly();
|
|
|
|
$form->removeActionButtons();
|
|
|
|
$this->view->permissionDenied = true;
|
|
|
|
}
|
2019-03-05 16:00:54 +01:00
|
|
|
// only admins should be able to edit the owner of a file
|
|
|
|
if (!$isAdmin) {
|
|
|
|
$form->removeOwnerEdit();
|
|
|
|
}
|
2015-08-28 19:40:38 +02:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
if ($request->isPost()) {
|
2013-06-06 23:02:01 +02:00
|
|
|
$js = $this->_getParam('data');
|
2021-10-11 16:10:47 +02:00
|
|
|
$serialized = [];
|
2022-03-14 11:15:04 +01:00
|
|
|
// need to convert from serialized jQuery array.
|
2013-06-06 23:02:01 +02:00
|
|
|
foreach ($js as $j) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// on edit, if no artwork is set and audiofile has image, automatically add it
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($j['name'] == 'artwork') {
|
|
|
|
if ($j['value'] == null || $j['value'] == '') {
|
|
|
|
$serialized['artwork'] = FileDataHelper::resetArtwork($file_id);
|
2019-10-30 04:50:01 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($j['name'] == 'set_artwork') {
|
|
|
|
if ($j['value'] != null || $j['value'] != '') {
|
|
|
|
$serialized['artwork'] = FileDataHelper::setArtwork($file_id, $j['value']);
|
2019-10-30 04:50:01 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($j['name'] == 'remove_artwork') {
|
|
|
|
if ($j['value'] == 1) {
|
2019-10-30 04:50:01 +01:00
|
|
|
$remove_artwork = true;
|
2021-10-11 16:10:47 +02:00
|
|
|
$serialized['artwork'] = FileDataHelper::removeArtwork($file_id);
|
2019-09-20 02:07:50 +02:00
|
|
|
}
|
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$serialized[$j['name']] = $j['value'];
|
2019-09-20 02:07:50 +02:00
|
|
|
}
|
2013-06-06 23:02:01 +02:00
|
|
|
}
|
|
|
|
|
2015-02-18 22:29:08 +01:00
|
|
|
// Sanitize any wildly incorrect metadata before it goes to be validated.
|
|
|
|
FileDataHelper::sanitizeData($serialized);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2013-06-06 23:02:01 +02:00
|
|
|
if ($form->isValid($serialized)) {
|
2015-02-17 21:09:18 +01:00
|
|
|
$file->setDbColMetadata($serialized);
|
2015-10-21 16:58:22 +02:00
|
|
|
$this->view->status = true;
|
|
|
|
} else {
|
|
|
|
$this->view->status = false;
|
2010-12-30 23:26:44 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 17:06:19 +01:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
$this->view->form = $form;
|
2015-08-07 01:16:04 +02:00
|
|
|
$this->view->id = $file_id;
|
2015-08-28 02:23:53 +02:00
|
|
|
$this->view->title = $file->getPropelOrm()->getDbTrackTitle();
|
2019-09-20 02:07:50 +02:00
|
|
|
$this->view->artist_name = $file->getPropelOrm()->getDbArtistName();
|
|
|
|
$this->view->artwork = $file->getPropelOrm()->getDbArtwork();
|
2024-04-21 11:13:43 +02:00
|
|
|
$this->view->replay_gain = $file->getPropelOrm()->getDbReplayGain();
|
|
|
|
$this->view->cuein = $file->getPropelOrm()->getDbCuein();
|
|
|
|
$this->view->cueout = $file->getPropelOrm()->getDbCueout();
|
|
|
|
$this->view->format = $file->getPropelOrm()->getDbFormat();
|
|
|
|
$this->view->bit_rate = $file->getPropelOrm()->getDbBitRate();
|
|
|
|
$this->view->sample_rate = $file->getPropelOrm()->getDbSampleRate();
|
2024-10-13 09:45:54 +02:00
|
|
|
$filePath = $file->getPropelOrm()->getDbFilepath();
|
|
|
|
if ($isAdmin) {
|
|
|
|
$this->view->file_name = $filePath;
|
|
|
|
} else {
|
|
|
|
$fileParts = explode(DIRECTORY_SEPARATOR, $filePath);
|
|
|
|
$filename = end($fileParts);
|
|
|
|
$this->view->file_name = $filename;
|
|
|
|
}
|
|
|
|
// 1000 B in KB and 1000 KB in MB and 1000 MB in GB
|
|
|
|
$size = $file->getPropelOrm()->getFileSize();
|
|
|
|
if ($size < 1000) {
|
|
|
|
// Use B up to 1 KB
|
|
|
|
$this->view->file_size = $size . ' B';
|
|
|
|
} elseif ($size < (500 * 1000)) {
|
|
|
|
// Use KB up to 500 KB
|
|
|
|
$this->view->file_size = round($size / 1000, 1) . ' KB';
|
|
|
|
} elseif ($size < (1 * 1000 * 1000 * 1000)) {
|
|
|
|
// Use MB up to 1 GB
|
|
|
|
$this->view->file_size = round($size / 1000 / 1000, 1) . ' MB';
|
|
|
|
} else {
|
|
|
|
$this->view->file_size = round($size / 1000 / 1000 / 1000, 1) . ' GB';
|
|
|
|
}
|
2015-08-07 01:16:04 +02:00
|
|
|
$this->view->html = $this->view->render('library/edit-file-md.phtml');
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
2011-02-04 06:15:56 +01:00
|
|
|
|
2012-07-31 03:48:04 +02:00
|
|
|
public function getFileMetadataAction()
|
2011-02-04 06:15:56 +01:00
|
|
|
{
|
2011-02-04 07:28:55 +01:00
|
|
|
$id = $this->_getParam('id');
|
|
|
|
$type = $this->_getParam('type');
|
2011-02-04 06:15:56 +01:00
|
|
|
|
2012-02-06 11:59:20 +01:00
|
|
|
try {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($type == 'audioclip') {
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2012-02-06 11:59:20 +01:00
|
|
|
$this->view->type = $type;
|
2012-02-27 12:23:22 +01:00
|
|
|
$md = $file->getMetadata();
|
2022-04-18 20:34:38 +02:00
|
|
|
$storagePath = Config::getStoragePath();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-05-02 22:52:49 +02:00
|
|
|
foreach ($md as $key => $value) {
|
2014-07-28 21:17:46 +02:00
|
|
|
if ($key == 'MDATA_KEY_DIRECTORY' && !is_null($value)) {
|
2022-04-18 20:34:38 +02:00
|
|
|
$md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($storagePath, $md['MDATA_KEY_FILEPATH']);
|
2012-05-02 22:52:49 +02:00
|
|
|
}
|
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatter = new SamplerateFormatter($md['MDATA_KEY_SAMPLERATE']);
|
|
|
|
$md['MDATA_KEY_SAMPLERATE'] = $formatter->format();
|
2012-02-27 12:23:22 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatter = new BitrateFormatter($md['MDATA_KEY_BITRATE']);
|
|
|
|
$md['MDATA_KEY_BITRATE'] = $formatter->format();
|
2012-02-27 12:23:22 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatter = new LengthFormatter($md['MDATA_KEY_DURATION']);
|
|
|
|
$md['MDATA_KEY_DURATION'] = $formatter->format();
|
2012-02-27 12:23:22 +01:00
|
|
|
|
|
|
|
$this->view->md = $md;
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($type == 'playlist') {
|
2012-02-06 11:59:20 +01:00
|
|
|
$file = new Application_Model_Playlist($id);
|
|
|
|
$this->view->type = $type;
|
2012-02-27 12:23:22 +01:00
|
|
|
$md = $file->getAllPLMetaData();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatter = new LengthFormatter($md['dcterms:extent']);
|
|
|
|
$md['dcterms:extent'] = $formatter->format();
|
2012-02-27 12:23:22 +01:00
|
|
|
|
|
|
|
$this->view->md = $md;
|
2012-02-06 11:59:20 +01:00
|
|
|
$this->view->contents = $file->getContents();
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($type == 'block') {
|
2012-08-02 22:36:12 +02:00
|
|
|
$block = new Application_Model_Block($id);
|
2012-08-01 18:04:48 +02:00
|
|
|
$this->view->type = $type;
|
2012-08-02 22:36:12 +02:00
|
|
|
$md = $block->getAllPLMetaData();
|
2012-08-01 18:04:48 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatter = new LengthFormatter($md['dcterms:extent']);
|
|
|
|
$md['dcterms:extent'] = $formatter->format();
|
2012-08-01 18:04:48 +02:00
|
|
|
|
|
|
|
$this->view->md = $md;
|
2012-08-02 22:36:12 +02:00
|
|
|
if ($block->isStatic()) {
|
2013-01-17 22:19:35 +01:00
|
|
|
$this->view->blType = 'Static';
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->view->contents = $block->getContents();
|
2012-08-01 18:04:48 +02:00
|
|
|
} else {
|
2013-01-17 22:19:35 +01:00
|
|
|
$this->view->blType = 'Dynamic';
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->view->contents = $block->getCriteria();
|
2012-08-01 18:04:48 +02:00
|
|
|
}
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->view->block = $block;
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($type == 'stream') {
|
2012-08-10 18:40:28 +02:00
|
|
|
$webstream = CcWebstreamQuery::create()->findPK($id);
|
2012-08-10 20:37:32 +02:00
|
|
|
$ws = new Application_Model_Webstream($webstream);
|
2012-07-31 03:48:04 +02:00
|
|
|
|
2012-08-10 20:37:32 +02:00
|
|
|
$md = $ws->getMetadata();
|
2012-07-31 03:48:04 +02:00
|
|
|
|
|
|
|
$this->view->md = $md;
|
|
|
|
$this->view->type = $type;
|
2012-02-06 11:59:20 +01:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
} catch (Exception $e) {
|
2012-08-22 00:55:38 +02:00
|
|
|
Logging::info($e->getMessage());
|
2011-02-04 06:15:56 +01:00
|
|
|
}
|
|
|
|
}
|
2015-09-23 00:33:27 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public function publishDialogAction()
|
|
|
|
{
|
2015-09-23 00:33:27 +02:00
|
|
|
$this->_helper->layout->disableLayout();
|
2022-03-14 11:15:04 +01:00
|
|
|
// This just spits out publish-dialog.phtml!
|
2015-09-23 00:33:27 +02:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|