public function deleteAction()
 {
     $ids = $this->_getParam('ids');
     $ids = !is_array($ids) ? array($ids) : $ids;
     $type = $this->_getParam('type');
     $obj = null;
     $objInfo = Application_Model_Library::getObjInfo($type);
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
     try {
         Logging::info("Currently active {$type} {$obj_sess->id}");
         if (in_array($obj_sess->id, $ids)) {
             Logging::info("Deleting currently active {$type}");
             Application_Model_Library::changePlaylist(null, $type);
         } else {
             Logging::info("Not deleting currently active {$type}");
             $obj = new $objInfo['className']($obj_sess->id);
         }
         if (strcmp($objInfo['className'], 'Application_Model_Playlist') == 0) {
             Application_Model_Playlist::deletePlaylists($ids, $userInfo->id);
         } else {
             Application_Model_Block::deleteBlocks($ids, $userInfo->id);
         }
         $this->createFullResponse($obj);
     } catch (PlaylistNoPermissionException $e) {
         $this->playlistNoPermission($type);
     } catch (BlockNoPermissionException $e) {
         $this->playlistNoPermission($type);
     } catch (PlaylistNotFoundException $e) {
         $this->playlistNotFound($type);
     } catch (Exception $e) {
         $this->playlistUnknownError($e);
     }
 }
예제 #2
0
 public function deleteAction()
 {
     //array containing id and type of media to delete.
     $mediaItems = $this->_getParam('media', null);
     $user = Application_Model_User::getCurrentUser();
     //$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     $files = array();
     $playlists = array();
     $blocks = array();
     $streams = array();
     $message = null;
     foreach ($mediaItems as $media) {
         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"]);
         }
     }
     try {
         Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
     } catch (PlaylistNoPermissionException $e) {
         $this->view->message = "You don't have permission to delete selected items.";
         return;
     }
     try {
         Application_Model_Block::deleteBlocks($blocks, $user->getId());
     } catch (Exception $e) {
         //TODO: warn user that not all blocks could be deleted.
     }
     try {
         Application_Model_Webstream::deleteStreams($streams, $user->getId());
     } catch (Exception $e) {
         //TODO: warn user that not all streams could be deleted.
         Logging::info($e);
     }
     foreach ($files as $id) {
         $file = Application_Model_StoredFile::Recall($id);
         if (isset($file)) {
             try {
                 $res = $file->delete(true);
             } catch (Exception $e) {
                 //could throw a scheduled in future exception.
                 $message = "Could not delete some scheduled files.";
                 Logging::debug($e->getMessage());
             }
         }
     }
     if (isset($message)) {
         $this->view->message = $message;
     }
 }