Example #1
0
 public function getTaggesPhotoInfo($photoId)
 {
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelVote = new Application_Model_Vote();
     $objModelPhotoTag = new Album_Model_PhotoTag();
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     $userFullName = $usersNs->userFullName;
     /*--------- START CHECK NEXT TAGGED IMAGE EXIST OR NOT ---------------*/
     $whereTaggedPhoto = "photo_id='{$photoId}'";
     $arrTaggedPhoto = $objModelPhotoTag->fetchRow($whereTaggedPhoto);
     if (empty($arrTaggedPhoto)) {
         $this->_redirect('/album/my-photos');
     }
     /*--------- END CHECK NEXT TAGGED IMAGE EXIST OR NOT ---------------*/
     $arrPhotoIds = array();
     $valAlbumPhoto = $objModelAlbumPhoto->find($photoId);
     $this->view->photo = $valAlbumPhoto->getImage();
     $this->view->name = $valAlbumPhoto->getName();
     $this->view->caption = stripslashes($valAlbumPhoto->getCaption());
     $this->view->location = $valAlbumPhoto->getLocation();
     $this->view->permission = $valAlbumPhoto->getPermission();
     $albumId = $valAlbumPhoto->getAlbumId();
     $this->view->myLatitude = $latitude = $valAlbumPhoto->getLatitude();
     $this->view->myLongitude = $longitude = $valAlbumPhoto->getLongitude();
     $this->getAlbumInfo($albumId);
     // Get album info
     $this->view->albumId = $albumId;
     $this->view->photoId = $photoId;
     /*-----------------------------------------------------------------------*/
     $db = Zend_Registry::get('db');
     $where = "tagged_id='{$userId}'";
     $query = $db->select()->from(array("pt" => "photo_tag"), array("pt.photo_id"))->join(array("ap" => "album_photo"), "pt.photo_id=ap.id", array("ap.image", "ap.id"))->where($where)->order(array('pt.created DESC'));
     $recordSet = $db->query($query);
     $arrRecord = $recordSet->fetchAll();
     $this->view->numRecord = $numRecord = count($arrRecord);
     foreach ($arrRecord as $photo) {
         $arrPhotoIds[] = $photo->id;
     }
     $position = array_search($photoId, $arrPhotoIds);
     $nextPosition = $position + 1;
     $prevPosition = $position - 1;
     $arrSize = count($arrPhotoIds);
     $this->view->photoPosition = $nextPosition;
     $this->view->numPhotoAlbum = $arrSize;
     if (array_key_exists($nextPosition, $arrPhotoIds)) {
         $this->view->nextId = $arrPhotoIds[$nextPosition];
     } else {
         $this->view->nextId = $arrPhotoIds[0];
     }
     if (array_key_exists($prevPosition, $arrPhotoIds)) {
         $this->view->prevId = $arrPhotoIds[$prevPosition];
     } else {
         $this->view->prevId = $arrPhotoIds[$arrSize - 1];
     }
     /*------------------ CHECK LIKED-UNLIKED ALBUM ------------------*/
     $this->view->userFullName = $userFullName;
     $whereVote = "item_type='album_photo' AND item_id='{$photoId}' AND user_id='{$userId}' AND vote='1'";
     $arrVote = $objModelVote->fetchAll($whereVote);
     if (count($arrVote) > 0) {
         $this->view->numVote = 1;
     } else {
         $this->view->numVote = 0;
     }
     /*----------------- GET TAGGED PHOTO COUNTER ---------------------*/
     $whereTagged = "tagged_id='{$userId}' AND photo_id='{$photoId}'";
     $queryTagged = $db->select()->from(array("pt" => "photo_tag"), array("pt.counter"))->where($whereTagged);
     $recordSetTagged = $db->query($queryTagged);
     $arrRecordTaggedCounter = $recordSetTagged->fetchAll();
     $this->view->counter = $arrRecordTaggedCounter[0]->counter;
     /*----------------- GET ALL TAGE FOR PHOTO -------------------------*/
     $objAlbumPhotoTag = new Album_Model_AlbumPhotoTag();
     $objTag = new Application_Model_Tags();
     $allTagId = $objAlbumPhotoTag->fetchAll("photo_id='{$photoId}'");
     $tagStr = "";
     foreach ($allTagId as $tagId) {
         $valTag = $objTag->find($tagId->tagId);
         $tagStr .= $valTag->getTag();
     }
     $this->view->tagStr = $tagStr;
     $this->view->likeSrcUrl = Zend_Registry::get('siteurl') . "%2Falbum%2Fmy-photos%2Ftagged-photo%2Fid%2F" . $photoId;
 }
Example #2
0
 private function setModel($row)
 {
     $model = new Album_Model_AlbumPhotoTag();
     $model->setId($row->id)->setPhotoId($row->photo_id)->setTagId($row->tag_id);
     return $model;
 }
Example #3
0
 public function getAlbumPhotoTags($photoId)
 {
     $objModelAlbumTag = new Album_Model_AlbumPhotoTag();
     $objModelTag = new Application_Model_Tags();
     $whereAlbumPhotoTag = "photo_id='{$photoId}'";
     $arrTagId = $objModelAlbumTag->fetchAll($whereAlbumPhotoTag);
     $strTag = "";
     if (!empty($arrTagId)) {
         foreach ($arrTagId as $tagId) {
             $tId = $tagId->tagId;
             $whereTag = "id='{$tId}'";
             $arrTag = $objModelTag->fetchRow($whereTag);
             $strTag = $strTag . ',' . $arrTag->tag;
         }
         $strTag = substr($strTag, 1, strlen($strTag));
     }
     return $strTag;
 }
Example #4
0
 public function albumPhotoDeleteAction()
 {
     $this->_helper->layout()->disableLayout();
     $objModelAlbumPhotoTag = new Album_Model_AlbumPhotoTag();
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelVote = new Application_Model_Vote();
     $objModelComment = new Application_Model_Comment();
     $arrPostVal = $this->getRequest()->getParams();
     $photoId = $arrPostVal['photoId'];
     $albumId = !empty($arrPostVal['id']) ? $arrPostVal['id'] : "";
     $page = !empty($arrPostVal['page']) ? $arrPostVal['page'] : "";
     /*----------------- GET PHOTO NAME --------------------------------*/
     $valPhoto = $objModelAlbumPhoto->find($photoId);
     $photoName = $valPhoto->getName();
     /*----------------- REMOVE PHOTO DETAIL ---------------------------*/
     $whereAlbumPhotoTag = "photo_id='{$photoId}'";
     $whereComment = "item_type='photo_comment' AND item_id='{$photoId}'";
     $whereVote = "item_type='album_photo' AND item_id='{$photoId}'";
     $whereAlbumPhoto = "id='{$photoId}'";
     $objModelAlbumPhotoTag->delete($whereAlbumPhotoTag);
     $objModelComment->delete($whereComment);
     $objModelVote->delete($whereVote);
     $objModelAlbumPhoto->delete($whereAlbumPhoto);
     /*---------------------- REMOVE PHOTO FROM FILE --------------------------------*/
     unlink(PUBLIC_PATH . "/images/album/thumb/{$photoName}");
     // Remove thumb image
     unlink(PUBLIC_PATH . "/images/album/custom/{$photoName}");
     // Remove resized image
     unlink(PUBLIC_PATH . "/images/album/default/{$photoName}");
     // Remove default image
     /*------------------------------------------------------------------------------*/
     if ($albumId != "" && $page != "") {
         header("location:/album/my-photos/review-edit-image/id/{$albumId}/page/{$page}");
     }
     exit;
 }