Beispiel #1
0
 public function addNew()
 {
     if (in_array(Auth::getCapability(), array(CAPABILITY_ADMINISTRATOR))) {
         Model::autoloadModel('country');
         $model = new CountryModel($this->db);
         $this->para = new stdClass();
         if (isset($_POST['action']) && $_POST['action'] == "addNew") {
             $this->para->action = $_POST['action'];
             if (isset($_POST['name'])) {
                 $this->para->name = $_POST['name'];
             }
             if (isset($_POST['slug'])) {
                 $this->para->slug = $_POST['slug'];
             }
             if (isset($_POST['description'])) {
                 $this->para->description = $_POST['description'];
             }
             if (isset($_POST['parent'])) {
                 $this->para->parent = $_POST['parent'];
             }
             if (isset($_POST['overview'])) {
                 $this->para->overview = $_POST['overview'];
             }
             if (isset($_POST['history'])) {
                 $this->para->history = $_POST['history'];
             }
             if (isset($_POST['weather'])) {
                 $this->para->weather = $_POST['weather'];
             }
             if (isset($_POST['passport_visa'])) {
                 $this->para->passport_visa = $_POST['passport_visa'];
             }
             if (isset($_POST['currency'])) {
                 $this->para->currency = $_POST['currency'];
             }
             if (isset($_POST['phone_internet_service'])) {
                 $this->para->phone_internet_service = $_POST['phone_internet_service'];
             }
             if (isset($_POST['transportation'])) {
                 $this->para->transportation = $_POST['transportation'];
             }
             if (isset($_POST['food_drink'])) {
                 $this->para->food_drink = $_POST['food_drink'];
             }
             if (isset($_POST['public_holiday'])) {
                 $this->para->public_holiday = $_POST['public_holiday'];
             }
             if (isset($_POST['predeparture_check_list'])) {
                 $this->para->predeparture_check_list = $_POST['predeparture_check_list'];
             }
             if (isset($_POST['tag_list'])) {
                 $this->para->tag_list = $_POST['tag_list'];
             }
             if (isset($_FILES['image_weathers']) && count($_FILES['image_weathers']) > 0 && isset($_FILES['image_weathers']['name']) && isset($_FILES['image_weathers']['name'][0]) && $_FILES['image_weathers']['name'][0] != "") {
                 $this->para->image_weathers = $_FILES['image_weathers'];
             }
             $result = $model->addToDatabase($this->para);
             if (!$result) {
                 $this->view->para = $this->para;
             }
         }
         $this->view->parentList = new SplDoublyLinkedList();
         $model->getAllSorted($this->view->parentList, $model->buildTree($model->getAll("country")), -1);
         if (isset($_POST['ajax']) && !is_null($_POST['ajax'])) {
             $this->view->renderAdmin(RENDER_VIEW_COUNTRY_ADD_NEW, TRUE);
         } else {
             $this->view->renderAdmin(RENDER_VIEW_COUNTRY_ADD_NEW);
         }
     } else {
         $this->login();
     }
 }