示例#1
0
 public function deleteAlbumAction()
 {
     $this->_helper->layout()->disableLayout();
     $albumId = $this->_getParam('id');
     $objModelAlbum = new Album_Model_Album();
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelAlbumTag = new Album_Model_AlbumTag();
     $objModelAlbumPhotoTag = new Album_Model_AlbumPhotoTag();
     $objModelPhotoTag = new Album_Model_PhotoTag();
     $objModelComment = new Application_Model_Comment();
     // Remove all comment for album
     $whereAlbumComment = "item_type='album_comment' AND item_id='{$albumId}'";
     $objModelComment->delete($whereAlbumComment);
     // Remove all album tag
     $whereAlbumTag = "album_id='{$albumId}'";
     $objModelAlbumTag->delete($whereAlbumTag);
     // Fetch all photo of album
     $whereAlbumPhoto = "album_id='{$albumId}'";
     $arrPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto);
     if (count($arrPhoto) > 0) {
         foreach ($arrPhoto as $photo) {
             $photoId = $photo->id;
             $photoName = $photo->image;
             $imagePathT = PUBLIC_PATH . "/media/album/thumb/" . $photoName;
             $imagePathC = PUBLIC_PATH . "/media/album/custom/" . $photoName;
             $imagePathD = PUBLIC_PATH . "/media/album/default/" . $photoName;
             unlink($imagePathT);
             // Remove image from thumb folder
             unlink($imagePathC);
             // Remove image from custom folder
             unlink($imagePathD);
             // Remove image from default folder
             // Remove photo comment
             $wherePhotoComment = "item_type='photo_comment' AND item_id='{$photoId}'";
             $objModelComment->delete($wherePhotoComment);
             // Remove tagged photo
             $whereTaggedPhoto = "photo_id='{$photoId}'";
             $objModelPhotoTag->delete($whereTaggedPhoto);
             // Remove photo tag
             $whereAlbumPhotoTag = "photo_id='{$photoId}'";
             $objModelAlbumPhotoTag->delete($whereAlbumPhotoTag);
         }
     }
     // Remove all photo
     $whereAlbumPhoto = "album_id='{$albumId}'";
     $objModelAlbumPhoto->delete($whereAlbumPhoto);
     // Remove Album
     $whereAlbum = "id='{$albumId}'";
     $objModelAlbum->delete($whereAlbum);
     $this->_redirect('/album/my-photos');
     $this->_helper->viewRenderer->setNoRender(true);
 }
示例#2
0
 public function removeTaggingAction()
 {
     $this->_helper->layout()->disableLayout();
     $objModelPhotoTag = new Album_Model_PhotoTag();
     $arrPostVal = $this->getRequest()->getParams();
     $userNs = new Zend_Session_Namespace("members");
     $photoId = $arrPostVal['photoId'];
     $counter = $arrPostVal['counter'];
     $userId = $userNs->userId;
     $where = "photo_id='{$photoId}' AND user_id='{$userId}' AND counter='{$counter}'";
     $objModelPhotoTag->delete($where);
     exit;
 }