Example #1
0
 public function editInfo($term_taxonomy_id = NULL)
 {
     if (in_array(Auth::getCapability(), array(CAPABILITY_ADMINISTRATOR))) {
         Model::autoloadModel('type');
         $model = new TypeModel($this->db);
         $this->para = new stdClass();
         if (isset($_POST['type'])) {
             $this->para->term_taxonomy_id = $_POST['type'];
         } 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)) {
             if (isset($_POST['action']) && $_POST['action'] == "update") {
                 $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'];
                 }
                 $result = $model->updateInfo($this->para);
                 if (!$result) {
                     $this->view->para = $this->para;
                 } else {
                     $update_success = TRUE;
                 }
             }
             $this->view->typeBO = $model->get($this->para->term_taxonomy_id);
             $this->view->parentList = new SplDoublyLinkedList();
             $model->getAllSorted($this->view->parentList, $model->buildTree($model->getAll("type")), -1);
             if (isset($term_taxonomy_id) && !is_null($term_taxonomy_id)) {
                 $this->view->renderAdmin(RENDER_VIEW_TYPE_EDIT);
             } else {
                 $this->view->renderAdmin(RENDER_VIEW_TYPE_EDIT, TRUE);
             }
         } else {
             header('location: ' . URL . CONTEXT_PATH_TYPE_INDEX);
         }
     } else {
         $this->login();
     }
 }