示例#1
0
文件: Image.php 项目: rcrrich/cunity
 /**
  * @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
 /**
  *
  */
 private function createEvent()
 {
     $events = new Events();
     $result = false;
     $res = $events->addEvent(["userid" => $_SESSION['user']->userid, "title" => $_POST['title'], "description" => $_POST['description'], "place" => $_POST['place'], "start" => $_POST['start'], "imageId" => 0, "type" => "event", "privacy" => $_POST['privacy'], "guest_invitation" => isset($_POST['guest_invitation']) ? 1 : 0]);
     if ($res > 0) {
         $guests = new Guests();
         $walls = new Walls();
         $gallery_albums = new GalleryAlbums();
         $guests->addGuests($res, $_SESSION['user']->userid, 2, false);
         $result = $walls->createWall($res, "event") && $gallery_albums->insert(["title" => "", "description" => "", "owner_id" => $res, "owner_type" => "event", "type" => "event", "user_upload" => 0, "privacy" => 2]);
     }
     $view = new View($result);
     if ($result) {
         $view->addData($events->getEventData($res));
     }
     $view->sendResponse();
 }
示例#3
0
 /**
  * @param $user
  * @return mixed|void
  */
 public static function onUnregister($user)
 {
     parent::onUnregister($user);
     $albums = new Models\Db\Table\GalleryAlbums();
     $albums->deleteAlbumsByUser($user->userid);
 }
示例#4
0
 /**
  * @param $eventid
  * @return array|bool|mixed
  */
 public function uploadEventImage($eventid)
 {
     $albums = new GalleryAlbums();
     $res = $albums->fetchRow($albums->select()->where("type=?", "event")->where("owner_type = 'event'")->where("owner_id=?", $eventid));
     $result = $this->uploadImage($res->id, false, [$eventid, "event"]);
     /** @var Album $res */
     $res->addImage($result['imageid']);
     if (is_array($result)) {
         return $result;
     }
     return false;
 }
示例#5
0
 /**
  * @throws \Cunity\Core\Exception
  */
 private function loadAlbum()
 {
     $albums = new GalleryAlbums();
     $album = $albums->getAlbumData($_GET['action']);
     if ($album !== false) {
         $view = new Album();
         $view->setMetaData(["title" => $album['title'], "description" => $album['description']]);
         $view->assign("album", $album);
         if ($album['privacy'] == 1 && $album['owner_id'] != $_SESSION['user']->userid && !in_array($album['owner_id'], $_SESSION['user']->getFriendList())) {
             new PageNotFound();
         }
         if ($album->owner_id == $_SESSION['userid'] && $album->owner_type === null) {
             $view->registerScript("gallery", "album-edit");
         }
         $view->show();
     } else {
         new PageNotFound();
     }
 }