Пример #1
0
 public function init()
 {
     parent::init();
     $this->setTitle('Edit a school');
     $this->addPlace->setLabel('Save Changes');
 }
Пример #2
0
 public function addStudyPlaceAction()
 {
     $this->view->user = $user = Engine_Api::_()->core()->getSubject();
     $this->view->form = $form = new Ynmember_Form_StudyPlace_Create();
     // Check method and data validity.
     $posts = $this->getRequest()->getPost();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($posts)) {
         return;
     }
     $values = $form->getValues();
     $tableStudy = Engine_Api::_()->getItemTable('ynmember_studyplace');
     $place = $tableStudy->createRow();
     $place->name = $values['name'];
     //$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 = $values['current'];
     $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();
     if ($values['current'] == 1) {
         $select = $tableStudy->select()->where('studyplace_id <> ?', $place->getIdentity())->where('user_id = ?', $user->getIdentity());
         $results = $tableStudy->fetchAll($select);
         foreach ($results as $row) {
             $row->current = 0;
             $row->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')->_('Study place added.')), 'format' => 'smoothbox', 'smoothboxClose' => true, 'parentRefresh' => true));
 }