CC-4757: Duplicate playlist

- done
- we still need a icon for context menu
This commit is contained in:
James 2012-12-28 16:17:58 -05:00
parent 6e77f2637a
commit f26778ee72
2 changed files with 42 additions and 0 deletions

View file

@ -12,6 +12,7 @@ class LibraryController extends Zend_Controller_Action
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('contents-feed', 'json')
->addActionContext('delete', 'json')
->addActionContext('duplicate', 'json')
->addActionContext('delete-group', 'json')
->addActionContext('context-menu', 'json')
->addActionContext('get-file-metadata', 'html')
@ -215,6 +216,7 @@ class LibraryController extends Zend_Controller_Action
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."/library/delete");
}
$menu["duplicate"] = array("name" => _("Duplicate Playlist"), "icon" => "edit", "url" => $baseUrl."/library/duplicate");
} elseif ($type == "stream") {
$webstream = CcWebstreamQuery::create()->findPK($id);
@ -340,6 +342,36 @@ class LibraryController extends Zend_Controller_Action
}
}
// duplicate playlist
public function duplicateAction(){
$params = $this->getRequest()->getParams();
$id = $params['id'];
$originalPl = new Application_Model_Playlist($id);
$newPl = new Application_Model_Playlist();
$contents = $originalPl->getContents();
foreach ($contents as &$c) {
if ($c['type'] == '0') {
$c[1] = 'audioclip';
} else if ($c['type'] == '2') {
$c[1] = 'block';
} else if ($c['type'] == '1') {
$c[1] = 'stream';
}
$c[0] = $c['item_id'];
}
$newPl->addAudioClips($contents, null, 'begining');
$newPl->setCreator(Application_Model_User::getCurrentUser()->getId());
$newPl->setDescription($originalPl->getDescription());
list($plFadeIn, ) = $originalPl->getFadeInfo(0);
list($plFadeOut, ) = $originalPl->getFadeInfo($originalPl->getSize()-1);
$newPl->setfades($plFadeIn, $plFadeOut);
$newPl->setName("Copy of ".$originalPl->getName());
}
public function contentsFeedAction()
{
$params = $this->getRequest()->getParams();

View file

@ -915,6 +915,16 @@ var AIRTIME = (function(AIRTIME) {
soundcloud.view.callback = callback;
}
}
// add callbacks for duplicate menu items.
if (oItems.duplicate !== undefined) {
var url = oItems.duplicate.url;
callback = function() {
$.post(url, {format: "json", id: data.id }, function(json){
oTable.fnStandingRedraw();
});
};
oItems.duplicate.callback = callback;
}
// remove 'Add to smart block' option if the current
// block is dynamic
if ($('input:radio[name=sp_type]:checked').val() === "1") {