Esempio n. 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;
 }
Esempio n. 2
0
 /**
  *
  */
 private function loadPost()
 {
     $table = new Db\Table\Posts();
     $res = $table->loadPost($_POST['postid']);
     $view = new View($res !== null);
     $view->addData($res);
     $view->sendResponse();
 }
Esempio n. 3
0
 /**
  * @param $albumid
  * @param bool $newsfeed_post
  * @param array $uploader_data
  * @return array|bool|mixed
  */
 public function uploadImage($albumid, $newsfeed_post = false, $uploader_data = [])
 {
     if (isset($_FILES) && isset($_FILES['file']) && $albumid > 0) {
         $uploader = new Uploader();
         $file = $uploader->upload($albumid . sha1($_SESSION['user']->userhash . time()) . rand());
         if (empty($uploader_data)) {
             list($owner_id, $owner_type) = [$_SESSION['user']->userid, null];
         } else {
             list($owner_id, $owner_type) = $uploader_data;
         }
         $imageid = $this->insert(["owner_id" => $owner_id, "owner_type" => $owner_type, "albumid" => $albumid, "filename" => $file, "caption" => !empty($_POST['content']) ? $_POST['content'] : ""]);
         if ($newsfeed_post) {
             $posts = new Posts();
             return $posts->post(["wall_owner_id" => $_POST['wall_owner_id'], "wall_owner_type" => $_POST['wall_owner_type'], "wall_id" => $_POST['wall_id'], "privacy" => $_POST['privacy'], "userid" => $owner_id, "content" => $imageid, "type" => "image"]);
         }
         return ["filename" => $file, "imageid" => $imageid];
     }
     return false;
 }
Esempio n. 4
0
 /**
  * @param $ownerid
  * @param $ownertype
  */
 public function deleteWallByOwner($ownerid, $ownertype)
 {
     $wallid = $this->getWallId($ownerid, $ownertype);
     $this->delete($this->getAdapter()->quoteInto("wall_id = ?", $wallid));
     $posts = new Posts();
     $posts->deletebyOwner($ownerid, $wallid);
 }