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; }
public function albumEditAction() { $this->_helper->layout()->disableLayout(); /********************** Check user free space **************************************/ $uploadAllowed = 1; //allowed upload $AlbumM = new Album_Model_Album(); $usersNs = new Zend_Session_Namespace("members"); $userId = $usersNs->userId; $arrAlbumCapacity = $AlbumM->albumCapacity($userId); if ($arrAlbumCapacity[1] >= 100) { $uploadAllowed = 0; //not allowed upload } $this->view->uploadAllowed = $uploadAllowed; /********************** End here **************************************/ $objModelFriendGroup = new Application_Model_FriendGroup(); $objModelAlbum = new Album_Model_Album(); $objModelAlbumTag = new Album_Model_AlbumTag(); $objModelTags = new Application_Model_Tags(); $arrPostVal = $this->getRequest()->getParams(); $albumId = $arrPostVal['albumId']; $valAlbum = $objModelAlbum->find($albumId); $this->view->name = $valAlbum->getName(); $this->view->description = strip_tags(stripslashes($valAlbum->getDescription())); $this->view->location = $valAlbum->getLocation(); $this->view->permission = $valAlbum->getPermission(); /*--------------------- ALL PERMISSION ----------------------------*/ $arrFriendGroup = $objModelFriendGroup->getPermissions(); $this->view->arrFriendGroup = $arrFriendGroup; /*-------------------- GETTING TAGS -------------------------------*/ $this->view->albumTag = $albumTag = $this->getAlbumTags($albumId); $this->view->albumId = $albumId; }
public function albumUploadPhotoAction() { $this->_helper->layout()->disableLayout(); $albumId = $this->_getParam('album_id'); // For uploade photo on edit time of Album $this->view->albumId = $albumId; // For uploade photo on edit time of Album $review_edit = $this->_getParam('review_edit'); // For uploade photo on Album create time $this->view->review_edit = $review_edit; // For uploade photo on Album create time $objModelAlbum = new Album_Model_Album(); $usersNs = new Zend_Session_Namespace("members"); $userId = $usersNs->userId; /*---------------------- GET USED PHOTO SIZE OF USER --------------------------*/ $arrAlbumCapacity = $objModelAlbum->albumCapacity($userId); $this->view->capacityImage = $arrAlbumCapacity[0]; $this->view->capacityPercent = $arrAlbumCapacity[1]; $whereAlbum = "status=1 AND user_id='{$userId}'"; $orderAlbum = "addedon DESC"; $arrAlbum = $objModelAlbum->fetchAll($whereAlbum, $orderAlbum); $this->view->arrAlbum = $arrAlbum; /*---------------------------------------------------------------------*/ // no output before this declaration $form = new Album_Form_Upload(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { if (method_exists($form->getElement('file'), 'isUploadify')) { if (!$form->getElement('file')->isUploadify()) { // Uploadify was not used even it was meant to be, f.e. javascript was disabled $form->getElement('file')->addFilter('rename', $form->getElement('file')->getRandomFileName())->receive(); } /** * Here you can rename/copy/process files * ideal situation is, that you upload file to temporary directory, * than processes it, copy it to directory, where you want to store it * and maybe rename to original filename or something else */ // filename on HDD after upload was processed //echo $form->getElement('file')->getFileName() . '<br/>'; // if was used rename filter in library/My/Form/Element/File.php, this will return original file name //echo $form->getElement('file')->getOriginalFileName() . '<br/>'; } else { /** * Uplodify was not used, Zend_Form_Element_File was used instead. * You dont need this code when you decide to use My_Form_Element_File. * If you use this code, replace "random" with your custom random file name, to prevent file collision. */ $form->getElement('file')->addFilter('rename', 'random')->receive(); } $this->_redirect('/test-upload'); } } $this->view->form = $form; }