Exemplo n.º 1
0
 public function editInfo($term_taxonomy_id = NULL)
 {
     if (in_array(Auth::getCapability(), array(CAPABILITY_ADMINISTRATOR, CAPABILITY_AUTHOR, CAPABILITY_CONTRIBUTOR, CAPABILITY_EDITOR))) {
         Model::autoloadModel('tag');
         $model = new TagModel($this->db);
         $this->para = new stdClass();
         if (isset($_POST['tag'])) {
             $this->para->term_taxonomy_id = $_POST['tag'];
         } 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->tagBO = $model->get($this->para->term_taxonomy_id);
             $this->view->parentList = new SplDoublyLinkedList();
             $model->getAllSorted($this->view->parentList, $model->buildTree($model->getAll("tag")), -1);
             if (isset($term_taxonomy_id) && !is_null($term_taxonomy_id)) {
                 $this->view->renderAdmin(RENDER_VIEW_TAG_EDIT);
             } else {
                 $this->view->renderAdmin(RENDER_VIEW_TAG_EDIT, TRUE);
             }
         } else {
             header('location: ' . URL . CONTEXT_PATH_TAG_INDEX);
         }
     } else {
         $this->login();
     }
 }