/**
  * validateUpdateInfo
  *
  * Validate para for update info of internalflight
  *
  * @param stdClass $para para for update info of internalflight
  */
 public function validateUpdateInfo($para)
 {
     if ($para == null || !is_object($para)) {
         $_SESSION["fb_error"][] = ERROR_UPDATE_INFO_INTERNALFLIGHT;
         return false;
     }
     if (!(isset($para->post_title) && $para->post_title != "")) {
         $_SESSION["fb_error"][] = ERROR_INTERNALFLIGHT_TITLE_EMPTY;
         return false;
     }
     $post_name = strtolower(preg_replace('/\\s+/', '-', $para->post_title));
     if (!(isset($post_name) && $post_name != "")) {
         $_SESSION["fb_error"][] = ERROR_INTERNALFLIGHT_TITLE_EMPTY;
         return false;
     }
     $para->post_name = $post_name;
     if (!(isset($para->city_id) && $para->city_id != "0")) {
         $_SESSION["fb_error"][] = ERROR_INTERNALFLIGHT_CITY_EMPTY;
         return false;
     } else {
         Model::autoloadModel("city");
         $cityModel = new CityModel($this->db);
         $cityBO = $cityModel->get($para->city_id);
         if ($cityBO == NULL || !(isset($cityBO->taxonomy) && $cityBO->taxonomy == "city")) {
             $_SESSION["fb_error"][] = ERROR_INTERNALFLIGHT_CITY_NOT_EXIST;
             return false;
         }
     }
     if (!(isset($para->country_id) && $para->country_id != "0")) {
         $_SESSION["fb_error"][] = ERROR_COUNTRY_EMPTY;
         return false;
     } else {
         Model::autoloadModel("country");
         $countryModel = new CityModel($this->db);
         $countryBO = $countryModel->get($para->country_id);
         if ($countryBO == NULL || !(isset($countryBO->taxonomy) && $countryBO->taxonomy == "country")) {
             $_SESSION["fb_error"][] = ERROR_COUNTRY_NOT_IMPOSSIBLE;
             return false;
         }
     }
     if (!(isset($para->post_content) && $para->post_content != "")) {
         $_SESSION["fb_error"][] = ERROR_INTERNALFLIGHT_CONTENT_EMPTY;
         return false;
     }
     if (isset($para->image)) {
         $validExts = array(".jpg", ".png", ".jpeg");
         $fileExt = $para->image['name'];
         $fileExt = strtolower(substr($fileExt, strrpos($fileExt, ".")));
         if (!in_array($fileExt, $validExts)) {
             $_SESSION["fb_error"][] = ERROR_INTERNALFLIGHT_IMAGE_INVALID;
             return false;
         }
     }
     if (isset($para->tag_list) && $para->tag_list != NULL && $para->tag_list != "") {
         $tag_array = explode(",", $para->tag_list);
         $para->tag_array = $tag_array;
     }
     if (isset($para->current_rating) && $para->current_rating != "" && !is_numeric($para->current_rating)) {
         $_SESSION["fb_error"][] = ERROR_CURRENT_RATING_INVALID;
         return false;
     }
     if (isset($para->vote_times) && $para->vote_times != "" && !is_numeric($para->vote_times)) {
         $_SESSION["fb_error"][] = ERROR_VOTE_TIMES_INVALID;
         return false;
     }
     return true;
 }
Example #2
0
 public function view($term_taxonomy_id = NULL)
 {
     Model::autoloadModel('city');
     $model = new CityModel($this->db);
     $this->para = new stdClass();
     if (isset($_POST['city'])) {
         $this->para->term_taxonomy_id = $_POST['city'];
     } elseif (isset($term_taxonomy_id) && !is_null($term_taxonomy_id)) {
         $this->para->term_taxonomy_id = $term_taxonomy_id;
     }
     if (isset($this->para->term_taxonomy_id)) {
         $this->view->cityBO = $model->get($this->para->term_taxonomy_id);
         $this->view->countryList = new SplDoublyLinkedList();
         $model->getAllSorted($this->view->countryList, $model->buildTree($model->getAll("country")), -1);
         if (isset($term_taxonomy_id) && !is_null($term_taxonomy_id)) {
             $this->view->render(RENDER_VIEW_CITY);
         } else {
             $this->view->render(RENDER_VIEW_CITY, TRUE);
         }
     } else {
         header('location: ' . URL);
     }
 }