Beispiel #1
0
 public function init()
 {
     parent::init();
     $this->setTitle('Edit Living Place');
     $this->addPlace->setLabel('Save Changes');
 }
Beispiel #2
0
 public function addLivePlaceAction()
 {
     $this->view->user = $user = Engine_Api::_()->core()->getSubject();
     $this->view->form = $form = new Ynmember_Form_LivePlace_Create();
     // Check method and data validity.
     $posts = $this->getRequest()->getPost();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($posts)) {
         return;
     }
     $values = $form->getValues();
     $tableLive = Engine_Api::_()->getItemTable('ynmember_liveplace');
     $place = $tableLive->createRow();
     //$place -> location = $values['location_address'];
     $place->location = isset($_POST['location']) && $_POST['location'] != '' ? $_POST['location'] : $values['location_address'];
     $place->longitude = $values['long'];
     $place->latitude = $values['lat'];
     $place->current = $this->_getParam('current', 0);
     $place->creation_date = date("Y-m-d H:i:s");
     $place->modified_date = date("Y-m-d H:i:s");
     $place->user_id = $user->getIdentity();
     $place->save();
     // Auth
     $auth = Engine_Api::_()->authorization()->context;
     $roles = array('owner', 'owner_member', 'registered', 'everyone');
     if (empty($values['auth_view'])) {
         $values['auth_view'] = 'everyone';
     }
     $viewMax = array_search($values['auth_view'], $roles);
     foreach ($roles as $i => $role) {
         $auth->setAllowed($place, $role, 'view', $i <= $viewMax);
     }
     return $this->_forward('success', 'utility', 'core', array('messages' => array(Zend_Registry::get('Zend_Translate')->_('Living place added.')), 'format' => 'smoothbox', 'smoothboxClose' => true, 'parentRefresh' => true));
 }