Пример #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
 /**
  *
  */
 private function handleRequest()
 {
     $view = new View();
     switch ($_POST['action']) {
         case "sendTestMail":
             $mail = new Mail();
             $mail->sendMail("TestMail from cunity", "Cunity - Testmail", ["name" => "Cunity Admin", "email" => $_POST['mail']]);
             $view->setStatus(true);
             break;
         case "loadPages":
             $pages = new Pages();
             $res = $pages->loadPages();
             $view->setStatus($res !== null);
             $view->addData(["pages" => $res->toArray()]);
             break;
         case "deletePage":
             if (isset($_POST['id']) && !empty($_POST['id'])) {
                 $pages = new Pages();
                 $status = $pages->deletePage($_POST['id']);
                 if ($status !== false && false) {
                     $comments = new Comments();
                     $status = $comments->removeAllComments($_POST['id'], "page");
                 } else {
                     $status = true;
                 }
                 $view->setStatus($status);
                 $view->sendResponse();
             } else {
                 $view->setStatus(false);
             }
             break;
         case 'addPage':
             $pages = new Pages();
             $res = $pages->addPage($_POST);
             $page = $pages->getPage($res);
             $view->setStatus($res !== null && $res !== false);
             $page->content = html_entity_decode($page->content);
             $view->addData(["page" => $page->toArray()]);
             break;
     }
     $view->sendResponse();
 }
Пример #4
0
 /**
  *
  */
 protected function get()
 {
     $res = $this->table->get($_POST['ref_id'], $_POST['ref_name'], $_POST['last'], $_POST['limit']);
     $this->view->setStatus($res !== false);
     $this->view->addData(["comments" => $res]);
 }
Пример #5
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();
 }
Пример #6
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;
 }