Пример #1
0
 /**
  * @return bool
  * @throws \Exception
  * @throws \Zend_Db_Table_Exception
  * @throws \Zend_Db_Table_Row_Exception
  */
 public function deleteImage()
 {
     if ($this->owner_id == $_SESSION['user']->userid && $this->owner_type === null) {
         $albums = new GalleryAlbums();
         $album = $albums->find($this->albumid);
         /** @noinspection PhpUndefinedMethodInspection */
         $album->current()->removeImage($this->id);
         $settings = Cunity::get("settings");
         $likes = new Likes();
         $comments = new Comments();
         $posts = new Posts();
         $posts->delete([$posts->getAdapter()->quote("type=`image`"), $posts->getAdapter()->quoteInto("content=?", $this->id)]);
         $comments->delete($this->_getTable()->getAdapter()->quoteInto("ref_id=? AND ref_name='image'", $this->id));
         $likes->delete($this->_getTable()->getAdapter()->quoteInto("ref_id=? AND ref_name='image'", $this->id));
         $filename = "../data/uploads/" . $settings->getSetting("core.filesdir") . "/" . $this->filename;
         $filenameThumb = "../data/uploads/" . $settings->getSetting("core.filesdir") . "/thumb_" . $this->filename;
         $filenameCr = "../data/uploads/" . $settings->getSetting("core.filesdir") . "/cr_" . $this->filename;
         if (file_exists($filename)) {
             unlink($filename);
         }
         if (file_exists($filenameThumb)) {
             unlink($filenameThumb);
         }
         if (file_exists($filenameCr)) {
             unlink($filenameCr);
         }
         return $this->delete() == 1;
     }
     return false;
 }
Пример #2
0
 /**
  * @return bool
  * @throws \Exception
  * @throws \Zend_Db_Table_Row_Exception
  */
 public function deleteAlbum()
 {
     $images = new GalleryImages();
     $imageslist = $images->getImages($this->id);
     $settings = Cunity::get("settings");
     foreach ($imageslist as $image) {
         $likes = new Likes();
         $comments = new Comments();
         $comments->delete($this->getTable()->getAdapter()->quoteInto("ref_id=? AND ref_name='image'", $image['id']));
         $likes->delete($this->getTable()->getAdapter()->quoteInto("ref_id=? AND ref_name='image'", $image['id']));
         unlink("../data/uploads/" . $settings->getSetting("core.filesdir") . "/" . $image['filename']);
         unlink("../data/uploads/" . $settings->getSetting("core.filesdir") . "/thumb_" . $image['filename']);
         if (file_exists("../data/uploads/" . $settings->getSetting("core.filesdir") . "/cr_" . $image['filename'])) {
             unlink("../data/uploads/" . $settings->getSetting("core.filesdir") . "/cr_" . $image['filename']);
         }
     }
     $images->delete($images->getAdapter()->quoteInto("albumid=?", $this->id));
     return 0 < $this->delete();
 }
Пример #3
0
 /**
  * @param $postid
  * @return bool
  */
 public function deletePost($postid)
 {
     $res = [];
     $thispost = $this->getPostData($postid);
     if ($thispost['userid'] == $_SESSION['user']->userid || $thispost['owner_id'] == $_SESSION['user']->userid && $thispost['owner_type'] == "profile") {
         $likes = new Likes();
         $comments = new Comments();
         $res[] = $this->delete($this->getAdapter()->quoteInto("id=?", $postid)) !== false;
         $res[] = $comments->delete($this->getAdapter()->quoteInto("ref_id=? AND ref_name='post'", $postid)) !== false;
         $res[] = $likes->delete($this->getAdapter()->quoteInto("ref_id=? AND ref_name='post'", $postid)) !== false;
         return !in_array(false, $res);
     }
     return false;
 }