public function editAction()
 {
     $this->view->title = "Edit album";
     $form = new Album_Form_Album();
     $form->submit->setLabel('Save');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $id = (int) $form->getValue('id');
             $artist = $form->getValue('artist');
             $title = $form->getValue('title');
             $albums = new Album_Model_DbTable_Albums();
             $albums->updateAlbum($id, $artist, $title);
             //Inicializamos el log
             $logger = new Zend_Log();
             //Aqui ponemos las salida por archivo
             $writer = new Zend_Log_Writer_Stream('../log/zfw.log');
             $logger->addWriter($writer);
             //Aqui indicamos que solo se mostraran los mensajes que sean iguales o superiores al filtro
             $filter = new Zend_Log_Filter_Priority(Zend_Log::INFO);
             $logger->addFilter($filter);
             $logger->alert('actualiza la informacion del title ' . $title);
             $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $albums = new Album_Model_DbTable_Albums();
             $form->populate($albums->getAlbum($id));
         }
     }
 }
 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;
 }
Exemple #3
0
 public function uploadAction()
 {
     if (isset($_GET['ul']) || isset($_FILES['Filedata'])) {
         return $this->_forward('upload-photo', null, null, array('format' => 'json'));
     }
     if (!$this->_helper->requireAuth()->setAuthParams('album', null, 'create')->isValid()) {
         return;
     }
     // Get navigation
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('album_main');
     // Get form
     $this->view->form = $form = new Album_Form_Album();
     if (!$this->getRequest()->isPost()) {
         if (null !== ($album_id = $this->_getParam('album_id'))) {
             $form->populate(array('album' => $album_id));
         }
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $db = Engine_Api::_()->getItemTable('album')->getAdapter();
     $db->beginTransaction();
     try {
         $album = $form->saveValues();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     $this->_helper->redirector->gotoRoute(array('action' => 'editphotos', 'album_id' => $album->album_id), 'album_specific', true);
 }