Example #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;
 }
Example #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();
 }
Example #3
0
 /**
  *
  */
 private function loadImage()
 {
     $socialData = [];
     $images = new GalleryImages();
     $albums = new GalleryAlbums();
     $result = $images->getImageData($this->id);
     $view = new View(true);
     if ($result !== null) {
         $result = $result[0];
         $albumData = $albums->getAlbumData($result['albumid']);
         $likeTable = new Likes();
         $socialData['likes'] = $likeTable->getLikes($this->id, "image");
         $socialData['dislikes'] = $likeTable->getLikes($this->id, "image", 1);
         if ($result['commentcount'] > 0) {
             $comments = new Comments();
             $socialData['comments'] = $comments->get($this->id, "image", false, 13);
         } else {
             $socialData['comments'] = [];
         }
         $view->addData(array_merge($socialData, $result, ["album" => $albumData]));
     } else {
         $view->setStatus(false);
     }
     $view->sendResponse();
 }
Example #4
0
 /**
  *
  */
 private function get()
 {
     $res = $this->table->getLikes($_POST['ref_id'], $_POST['ref_name'], $_POST['dislike']);
     $this->view->setStatus($res !== false);
     $this->view->addData(["likes" => $res]);
 }
Example #5
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;
 }