コード例 #1
0
 public function update_world()
 {
     $this->form_validation->set_rules('jm-world-title', 'World', 'required|max_length[45]');
     $this->form_validation->set_rules('jm-world-description', 'World Description', 'required|max_length[2000]');
     $this->form_validation->set_rules('jm-world-status', 'World Status', '');
     $this->form_validation->set_rules('jm-unique-title', 'Unique', 'required|max_length[45]');
     $this->form_validation->set_rules('jm-unique-description', 'Unique Description', 'required|max_length[2000]');
     $this->form_validation->set_rules('jm-unique-status', 'Unique Status', '');
     $company = $this->session->userdata(UserModel::$SESSION_ID);
     if ($this->form_validation->run() == FALSE) {
         $data = array();
         $data["page"] = "Office World";
         $data["menu"] = "office";
         $data["content"] = "website/pages/company/office_world";
         $data["world"] = $this->section_model->read(7, $company);
         $data["unique"] = $this->section_model->read(8, $company);
         $data["operation"] = "warning";
         $data["message"] = validation_errors();
         $this->load->view("website/template", $data);
     } else {
         $data_world = array("cst_title" => $this->input->post("jm-world-title"), "cst_description" => $this->input->post("jm-world-description"), "cst_active" => $this->input->post("jm-world-status"));
         $data_unique = array("cst_title" => $this->input->post("jm-unique-title"), "cst_description" => $this->input->post("jm-unique-description"), "cst_active" => $this->input->post("jm-unique-status"));
         $upload = true;
         $config = array("allowed_types" => UploaderModel::$TYPE_IMAGE, "upload_path" => "./assets/img/office", "file_name" => $this->session->userdata(UserModel::$SESSION_ID), "overwrite" => TRUE, "max_width" => 2000, "max_height" => 2000);
         if ($_FILES["jm-world-featured"]["size"] != 0 && $_FILES["jm-world-featured"]["name"] != "") {
             $config["input_source"] = "jm-world-featured";
             $config["file_name"] = "world-" . $this->session->userdata(UserModel::$SESSION_ID);
             $uploader = new UploaderModel();
             $uploader->config($config);
             $upload = $uploader->start_upload();
             if ($upload) {
                 $data_world["cst_featured"] = $config["file_name"] . $uploader->upload_data()["file_ext"];
             } else {
                 $this->alert->warning_alert($uploader->upload_error());
             }
         }
         $result_world = $this->section_model->update($data_world, 7, $company);
         if ($_FILES["jm-unique-featured"]["size"] != 0 && $_FILES["jm-unique-featured"]["name"] != "") {
             $config["input_source"] = "jm-unique-featured";
             $config["file_name"] = "unique-" . $this->session->userdata(UserModel::$SESSION_ID);
             $uploader = new UploaderModel();
             $uploader->config($config);
             $upload = $uploader->start_upload();
             if ($upload) {
                 $data_unique["cst_featured"] = $config["file_name"] . $uploader->upload_data()["file_ext"];
             } else {
                 $this->alert->warning_alert($uploader->upload_error());
             }
         }
         $result_unique = $this->section_model->update($data_unique, 8, $company);
         if ($result_world && $result_unique && $upload) {
             $this->alert->success_alert("Company office has been updated successfully");
         } else {
             if (!$result_world || !$result_unique) {
                 $this->alert->danger_alert("Something is getting wrong");
             }
         }
         redirect("office/world");
     }
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: lilhorse/cocoa
 private function uploadFile()
 {
     if (!isset($_FILES['ImageFile']) || !is_uploaded_file($_FILES['ImageFile']['tmp_name'])) {
         die("ERROR");
     }
     $discuzPath = dirname(dirname(dirname(dirname(__FILE__))));
     $savepath = "{$discuzPath}/uploadtemp/";
     $uploaderModel = new UploaderModel();
     $filename = $uploaderModel->savetoTempDir("ImageFile", $savepath);
     echo $filename;
 }
コード例 #3
0
 public function update_opinion()
 {
     $this->form_validation->set_rules('jm-expectation-expecting', 'Expectation', 'required|max_length[45]');
     $this->form_validation->set_rules('jm-expectation-description', 'Expectation Description', 'required|max_length[2000]');
     $this->form_validation->set_rules('jm-expectation-status', 'Expectation Status', '');
     $this->form_validation->set_rules('jm-opinion-feeling', 'Opinion', 'required|max_length[45]');
     $this->form_validation->set_rules('jm-opinion-description', 'Opinion Description', 'required|max_length[2000]');
     $this->form_validation->set_rules('jm-opinion-status', 'Opinion Status', '');
     $company = $this->session->userdata(UserModel::$SESSION_ID);
     if ($this->form_validation->run() == FALSE) {
         $data = array();
         $data["page"] = "Profile Opinion";
         $data["menu"] = "profile";
         $data["content"] = "website/pages/company/profile_opinion";
         $data["expectation"] = $this->section_model->read(3, $company);
         $data["opinion"] = $this->section_model->read(4, $company);
         $data["operation"] = "warning";
         $data["message"] = validation_errors();
         $this->load->view("website/template", $data);
     } else {
         $data_expectation = array("cst_title" => $this->input->post("jm-expectation-expecting"), "cst_description" => $this->input->post("jm-expectation-description"), "cst_active" => $this->input->post("jm-expectation-status"));
         $data_opinion = array("cst_title" => $this->input->post("jm-opinion-feeling"), "cst_description" => $this->input->post("jm-opinion-description"), "cst_active" => $this->input->post("jm-opinion-status"));
         $upload = true;
         $config = array("allowed_types" => UploaderModel::$TYPE_IMAGE, "upload_path" => "./assets/img/office", "file_name" => $this->session->userdata(UserModel::$SESSION_ID), "overwrite" => TRUE, "max_width" => 2000, "max_height" => 2000);
         if ($_FILES["jm-expectation-featured"]["size"] != 0 && $_FILES["jm-expectation-featured"]["name"] != "") {
             $config["input_source"] = "jm-expectation-featured";
             $config["file_name"] = "expectation-" . $this->session->userdata(UserModel::$SESSION_ID);
             $uploader = new UploaderModel();
             $uploader->config($config);
             $upload = $uploader->start_upload();
             if ($upload) {
                 $data_expectation["cst_featured"] = $config["file_name"] . $uploader->upload_data()["file_ext"];
             } else {
                 $this->alert->warning_alert($uploader->upload_error());
             }
         }
         $result_expectation = $this->section_model->update($data_expectation, 3, $company);
         if ($_FILES["jm-opinion-featured"]["size"] != 0 && $_FILES["jm-opinion-featured"]["name"] != "") {
             $config["input_source"] = "jm-opinion-featured";
             $config["file_name"] = "opinion-" . $this->session->userdata(UserModel::$SESSION_ID);
             $uploader = new UploaderModel();
             $uploader->config($config);
             $upload = $uploader->start_upload();
             if ($upload) {
                 $data_opinion["cst_featured"] = $config["file_name"] . $uploader->upload_data()["file_ext"];
             } else {
                 $this->alert->warning_alert($uploader->upload_error());
             }
         }
         $result_opinion = $this->section_model->update($data_opinion, 4, $company);
         if ($result_expectation && $result_opinion && $upload) {
             $this->alert->success_alert("Company opinion has been updated successfully");
         } else {
             if (!$result_expectation || !$result_opinion) {
                 $this->alert->danger_alert("Something is getting wrong");
             }
         }
         redirect("profile/opinion");
     }
 }