CC-4095: Media Library -> Playlist: dj user can delete the playlist owned by

others on some situation.
This commit is contained in:
James 2012-07-10 17:24:57 -04:00
parent f174a2bcf3
commit 24a90700a1
3 changed files with 12 additions and 12 deletions

View file

@ -129,10 +129,10 @@ class LibraryController extends Zend_Controller_Action
} }
} }
try{ try {
Application_Model_Playlist::DeletePlaylists($playlists, $user->getId()); Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
}catch (PlaylistNoPermissionException $e){ } catch (PlaylistNoPermissionException $e) {
$this->view->message = "You don't have a permission to delete all playlists/files that are selected."; $this->view->message = "You don't have permission to delete selected playlists/files.";
return; return;
} }

View file

@ -98,7 +98,7 @@ class PlaylistController extends Zend_Controller_Action
} }
private function playlistNoPermission(){ private function playlistNoPermission(){
$this->view->error = "You don't have permission to deleted playlist(s)"; $this->view->error = "You don't have permission to delete selected playlist(s).";
} }
private function playlistUnknownError($e) private function playlistUnknownError($e)
@ -217,10 +217,10 @@ class PlaylistController extends Zend_Controller_Action
$pl = new Application_Model_Playlist($this->pl_sess->id); $pl = new Application_Model_Playlist($this->pl_sess->id);
} }
Application_Model_Playlist::DeletePlaylists($ids, $userInfo->id); Application_Model_Playlist::deletePlaylists($ids, $userInfo->id);
$this->createFullResponse($pl); $this->createFullResponse($pl);
} }
catch (PlaylistNoPermissionException $e){ catch (PlaylistNoPermissionException $e) {
$this->playlistNoPermission(); $this->playlistNoPermission();
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {

View file

@ -804,12 +804,12 @@ class Application_Model_Playlist {
* Delete playlists that match the ids.. * Delete playlists that match the ids..
* @param array $p_ids * @param array $p_ids
*/ */
public static function DeletePlaylists($p_ids, $p_userId) public static function deletePlaylists($p_ids, $p_userId)
{ {
$leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId); $leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId);
if(count($leftOver) == 0){ if (count($leftOver) == 0) {
CcPlaylistQuery::create()->findPKs($p_ids)->delete(); CcPlaylistQuery::create()->findPKs($p_ids)->delete();
}else{ } else {
throw new PlaylistNoPermissionException; throw new PlaylistNoPermissionException;
} }
} }
@ -819,8 +819,8 @@ class Application_Model_Playlist {
$ownedByUser = CcPlaylistQuery::create()->filterByDbCreatorId($p_userId)->find()->getData(); $ownedByUser = CcPlaylistQuery::create()->filterByDbCreatorId($p_userId)->find()->getData();
$selectedPls = $p_ids; $selectedPls = $p_ids;
$ownedPls = array(); $ownedPls = array();
foreach($ownedByUser as $pl){ foreach ($ownedByUser as $pl) {
if( in_array($pl->getDbId(), $selectedPls) ){ if (in_array($pl->getDbId(), $selectedPls)) {
$ownedPls[] = $pl->getDbId(); $ownedPls[] = $pl->getDbId();
} }
} }