예제 #1
0
 public function processImageAction()
 {
     $this->_helper->layout()->disableLayout();
     $objModelAlbum = new Album_Model_Album();
     /*----------- GET LOGGEDIN USER INFORMATION ----------------------*/
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     $arrPostVal = $this->getRequest()->getParams();
     $fileName = $arrPostVal['fileName'];
     $fileSize = $arrPostVal['fileSize'];
     $fileType = $arrPostVal['fileType'];
     $album = $arrPostVal['album'];
     $quality = $arrPostVal['quality'];
     /*-------------------- GET EXTENSION OF FILE ----------------------*/
     $arrExtension = explode(".", $fileName);
     $arrExtensionSize = count($arrExtension);
     $fileType = "." . $arrExtension[$arrExtensionSize - 1];
     /*------------------- CHECK AVAILABLE USER PHOTO CAPACITY ---------*/
     $arrAlbumCapacity = $objModelAlbum->albumCapacity($userId);
     $maximumCapacity = 5368709120;
     // 5 GB
     //$maximumCapacity = 47185920;	// 45 MB
     $availableCapacity = $maximumCapacity - $arrAlbumCapacity[2];
     if ($availableCapacity < $fileSize) {
         echo 'completed';
         exit;
     } else {
         /*------------------- END AVAILABLE CHECK USER PHOTO CAPACITY -----*/
         $this->view->uploading_type = $arrPostVal['uploadingType'];
         $this->view->review_edit = $arrPostVal['review_edit'];
         $uploadedCount = $arrPostVal['uploadedCount'];
         $newPhotoName = "album_" . time() . "_" . rand(10, 99) . $fileType;
         $imagePath = PUBLIC_PATH . "/media/album/default/" . $fileName;
         $targetPath = PUBLIC_PATH . "/media/album/default/" . $newPhotoName;
         $targetPathR = PUBLIC_PATH . "/media/album/custom/" . $newPhotoName;
         $targetPathT = PUBLIC_PATH . "/media/album/thumb/" . $newPhotoName;
         set_time_limit(0);
         copy($imagePath, $targetPathR);
         rename($imagePath, $targetPath);
         $mageSize = $this->getImageSize($quality, $targetPath);
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize($mageSize['width'], $mageSize['height']);
         $thumb->save($targetPathR);
         $thumb->resize(131, 98);
         // Thumb Image
         $thumb->save($targetPathT);
         //---> Fetch Album Permission
         $valAlbum = $objModelAlbum->find($album);
         $this->view->albumPermission = $albumPermission = $valAlbum->getPermission();
         /*----------- CAPTURE TO DATABASE --------------------------------*/
         $option['albumId'] = $album;
         $option['userId'] = $userId;
         $option['image'] = $newPhotoName;
         $option['name'] = $newPhotoName;
         $option['type'] = $fileType;
         $option['size'] = filesize($targetPath);
         $option['status'] = 1;
         $option['permission'] = $albumPermission;
         $option['addedon'] = time();
         $objModelAlbumPhoto = new Album_Model_AlbumPhoto($option);
         $objModelAlbumPhoto->save();
         $objModelFriendGroup = new Application_Model_FriendGroup();
         $arrFriendGroup = $objModelFriendGroup->getPermissions();
         $this->view->arrFriendGroup = $arrFriendGroup;
         $this->view->uploadedCount = $uploadedCount;
         $this->view->album = $album;
         $objModelUserPermission = new Application_Model_UserPermission();
         $whereUserPermission = "permission_id='5' AND user_id='{$userId}'";
         $arrUserPermission = $objModelUserPermission->fetchRow($whereUserPermission);
     }
 }
예제 #2
0
 private function setModel($row)
 {
     $permission = $row->findParentRow('Application_Model_DbTable_Permission', 'Permission');
     $model = new Application_Model_UserPermission();
     $model->setId($row->id)->setPermissionId($row->permission_id)->setFriendGroupId($row->friend_group_id)->setAddedon($row->addedon)->setUpdatedon($row->updatedon)->setUserId($row->user_id)->setPermissionName($permission->name);
     return $model;
 }
예제 #3
0
 public function indexAction()
 {
     if (isset($_SESSION['msg'])) {
         $this->view->msg = $_SESSION['msg'];
         unset($_SESSION['msg']);
     }
     $userNs = new Zend_Session_Namespace('members');
     $userId = $userNs->userId;
     $form = new Album_Form_Album();
     $objModelAlbum = new Album_Model_Album();
     $objModelGapperLocation = new Application_Model_GapperLocation();
     /*------------- GET GAPPER LOCATION ---------------*/
     $yesterday = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
     $whereGapperLocation = "user_id='{$userId}' and latest=1 AND addedon >= '{$yesterday}'";
     $arrGapperLocation = $objModelGapperLocation->fetchAll($whereGapperLocation);
     if (!empty($arrGapperLocation)) {
         $this->view->myLatitude = $arrGapperLocation[0]->latitude;
         $this->view->myLongitude = $arrGapperLocation[0]->longitude;
     } else {
         $this->view->myLatitude = "";
         $this->view->myLongitude = "";
     }
     /*-------------------------------------------------*/
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
     }
     /*---------------------- GET USED PHOTO SIZE OF USER --------------------------*/
     $arrAlbumCapacity = $objModelAlbum->albumCapacity($userId);
     $this->view->capacityImage = $arrAlbumCapacity[0];
     $this->view->capacityPercent = $arrAlbumCapacity[1];
     $request = $this->getRequest();
     // Get posted value
     if ($request->isPost()) {
         $params = $request->getParams();
         // Get all posted value
         if ($form->isValid($params)) {
             $option['userId'] = $userId;
             // LoggedIn UserId
             $arrLatLang = explode(",", $params['latlang']);
             $latitude = substr($arrLatLang[0], 1, strlen($arrLatLang[0]));
             // Longitude of location
             $longitude = substr($arrLatLang[1], 0, -1);
             //	Latitude of location
             $option['name'] = $params['name'];
             $option['description'] = $params['description'];
             $option['location'] = $params['address'];
             $option['permission'] = $params['permissions'];
             $option['longitude'] = $longitude;
             $option['latitude'] = $latitude;
             $option['status'] = 1;
             $albumM = new Album_Model_Album($option);
             $album_id = $albumM->save();
             if ($album_id > 0) {
                 /*----- start tags--------*/
                 if ($params['tags'] != "" && $params['tags'] != 'Separate Tags by a comma. For example: \' Holiday, London, Travel\'') {
                     $arrTags = explode(",", $params['tags']);
                     foreach ($arrTags as $_tag) {
                         $_tag = trim($_tag);
                         $tagsM = new Application_Model_Tags();
                         $tag = $tagsM->fetchRow("tag='{$_tag}'");
                         if (false === $tag) {
                             $tagsM->setTag($_tag);
                             $tag_id = $tagsM->save();
                         } else {
                             $tag_id = $tag->getId();
                         }
                         $albumTagM = new Album_Model_AlbumTag();
                         $albumTagM->setAlbumId($album_id);
                         $albumTagM->setTagId($tag_id);
                         $albumTagM->save();
                     }
                 }
                 $redirectUrl = "/album/my-photos/album-photos/id/" . $album_id;
                 /*---------- end tags-------*/
                 //$this->_helper->redirector('index','create-album',"album");
                 $_SESSION['msg'] = "Album created successfully.";
                 $this->_redirect($redirectUrl);
                 $form->reset();
             } else {
                 $_SESSION['msg'] = "Faild to create Album. Please try again.";
                 $this->_redirect('/album/create-album');
             }
         }
     }
     $objModelUserPermission = new Application_Model_UserPermission();
     $whereUserPermission = "permission_id='5' AND user_id='{$userId}'";
     $arrUserPermission = $objModelUserPermission->fetchRow($whereUserPermission);
     $form->getElement('permissions')->setValue($arrUserPermission->friendGroupId);
     $this->view->form = $form;
 }
예제 #4
0
파일: User.php 프로젝트: riteshsahu1981/we
 /**
  * @Created By 	: Mahipal Singh Adhikari
  * @Created On 	: 17-Nov-2010
  * @Description	: Check user privacy settings for his profile
  * @Input		: $user_id(int), $friend_id(int), $permission_id(int)
  * @Return		: boolean(True or False)
  **/
 public function checkUserPrivacySettings($user_id, $friend_id = 0, $permission_id)
 {
     $permit = false;
     //echo "<br />user_id=".$user_id." friend_id=".$friend_id." permission_id=".$permission_id."<br />";
     //if no parameters sent, return false
     if (!isset($user_id) && $user_id == "" || !isset($permission_id) && $permission_id == "") {
         return false;
     }
     //if logged in user viewing own
     if ($user_id == $friend_id) {
         return true;
     }
     //now get user permission settings
     $UserPermissionObj = new Application_Model_UserPermission();
     $wherePerCond = "user_id='{$user_id}' AND permission_id={$permission_id}";
     $permission = $UserPermissionObj->fetchRow($wherePerCond);
     if (false == $permission) {
         return false;
     }
     $permissionId = $permission->getId();
     $permission = $permission->getFriendGroupId();
     //echo "<br />permission=".$permission." for id=".$friend_id."<br />";
     //if permission is private(Just me) return false
     if ($permission == 4) {
         return false;
         //do not display to anyone
     }
     //if permission is public return true
     if ($permission == 5) {
         return true;
         //display to public
     }
     //now if user is logged in i.e. $friend_id is not null, check connection with user
     //if((isset($friend_id) && is_numeric($friend_id)))
     if (is_numeric($friend_id) && $friend_id != 0) {
         //if permission is Gap Daemon Community return true
         if ($permission == 1) {
             return true;
             //display to all LoggeIn users
         }
         $friendM = new Application_Model_Friend();
         $friend_cond = "user_id='{$user_id}' AND friend_id='{$friend_id}' AND status='accept'";
         $conTypeObj = $friendM->fetchRow($friend_cond);
         //if logged in user connected with this user
         if (false !== $conTypeObj) {
             $con_type = $conTypeObj->getConnectionType();
             //echo "<br />connection type=".$con_type."<br />";
             /*
             				if($con_type=="friend" && ($permission==2 || $permission==4))
             				{
             					$permit = true; //display to Friends & Family AND Friends, Family and Mates
             				}
             				else if($con_type=="family" && ($permission==2 || $permission==4))
             				{
             					$permit = true; //display to Friends & Family AND Friends, Family and Mates
             				}
             				else if($con_type=="travelmate" && ($permission==3 || $permission==4))
             				{
             					$permit = true; //display to Travel Mates AND Friends, Family and Mates
             				}*/
             if ($con_type == "friend" && ($permission == 2 || $permission == 6)) {
                 $permit = true;
                 //display to Friends, Friends & Family
             } else {
                 if ($con_type == "family" && ($permission == 3 || $permission == 6)) {
                     $permit = true;
                     //display to Family, Friends & Family
                 } else {
                     if ($con_type == "travelmate" && $permission == 2) {
                         $permit = true;
                         //display to Travel Mates Friends
                     } else {
                         $permit = false;
                     }
                 }
             }
         } else {
             $permit = false;
         }
     }
     //end if
     return $permit;
 }