Ejemplo n.º 1
0
 function afterLoad()
 {
     $ui_model = new UserInterestsModel();
     //$this->interest = implode(", ", $ui_model -> getInterests($this -> id));
     $country_model = new CountryModel();
     $country_model->load($this->country_id);
     $this->country = $country_model->name;
     $state_model = new StateModel();
     $state_model->load($this->state_id);
     $this->state = $state_model->name;
     $city_model = new CityModel();
     $city_model->load($this->city_id);
     $this->city = $city_model->name;
 }
Ejemplo n.º 2
0
 public function AddEntityAction()
 {
     $request = Project::getRequest();
     $this->setViewVars();
     $this->setFormParams();
     $geo_type = new GeoTypeModel();
     $geo_type->load($this->session->geo_type_id);
     $this->_view->assign('geo_type_name', $geo_type->name);
     $city = new CityModel();
     $city->load($this->session->city_id);
     $this->_view->assign('city_name', $city->name);
     $country = new CountryModel();
     $country->load($this->session->country_id);
     $this->_view->assign('country_name', $country->name);
     $place = new GeoPlaceModel();
     $place->loadById($this->session->geo_place_id);
     $this->_view->assign('place_name', $place->name);
     // Creating type
     if ($request->create_type) {
         $this->_view->clearFlashMessages();
         if ($request->type_name) {
             // Creating type
             $obj = new GeoSubtypeModel();
             $obj->name = htmlspecialchars($request->type_name);
             $obj->geo_type_id = $this->session->geo_type_id;
             $obj->save();
             Project::getResponse()->redirect(Project::getRequest()->createUrl("Places", "Index"));
         } else {
             $this->_view->addFlashMessage(FM::ERROR, 'Введите название типа');
         }
     }
     // Creating place
     if ($request->create_place) {
         $this->_view->clearFlashMessages();
         if ($request->place_name) {
             // Creating type
             $obj = new GeoPlaceModel();
             $obj->name = htmlspecialchars($request->place_name);
             $obj->geo_subtype_id = $this->session->geo_subtype_id;
             $obj->city_id = $this->session->city_id;
             $obj->user_id = $this->user->id;
             $obj->creation_date = date("Y-m-d H:i:s");
             $obj->save();
             Project::getResponse()->redirect(Project::getRequest()->createUrl("Places", "Index"));
         } else {
             $this->_view->addFlashMessage(FM::ERROR, 'Введите название места');
         }
     }
     // Adding place to user
     if ($request->create_object_at_user) {
         $obj = new UsersGeoPlaceModel();
         $obj->user_id = $this->user->id;
         $obj->geo_place_id = $this->session->geo_place_id;
         $obj->date_start = htmlspecialchars($request->year_begin);
         $obj->date_end = htmlspecialchars($request->year_end);
         $obj->surname = htmlspecialchars($request->surname);
         $obj->save();
         Project::getResponse()->redirect(Project::getRequest()->createUrl("Places", "Index"));
     }
     // Editing place at user
     if ($request->edit_object_at_user) {
         $obj = new UsersGeoPlaceModel();
         $obj->load($request->id);
         $obj->date_start = htmlspecialchars($request->year_begin);
         $obj->date_end = htmlspecialchars($request->year_end);
         $obj->surname = htmlspecialchars($request->surname);
         $obj->save();
         Project::getResponse()->redirect(Project::getRequest()->createUrl("Places", "Index"));
     }
     $this->_view->ListPlaces();
     $this->_view->parse();
 }