Ejemplo n.º 1
0
 /**
  * 文章栏目更新
  * updateSort
  */
 public function updateSort()
 {
     $id = I('post.id');
     $title = I('post.text');
     if (empty($title)) {
         $this->error('标题不能为空');
     }
     $sort_id = I('post.sort_id');
     if ($sort_id === '') {
         $this->error('所属栏目不能为空');
     }
     //父级分类限定
     $models = 'ArticleSort';
     $check = checkParent($id, $sort_id, $models);
     if ($check['status'] == false) {
         $this->error("{$check['msg']}");
     }
     if ($sort_id == 0) {
         $path = ',';
     } else {
         $models = 'ArticleSort';
         $path = getPathByParentId($sort_id, $models);
     }
     $data['path'] = $path;
     $data['text'] = $title;
     $data['parent_id'] = $sort_id;
     $data['status'] = $_POST['status'][0];
     $data['keywords'] = I('post.keywords');
     $data['description'] = I('post.description');
     $data['updatetime'] = time();
     $ArticleSortModel = D('ArticleSort');
     $condition['id'] = array('eq', $id);
     $result = $ArticleSortModel->updateArticleSort($condition, $data);
     updatePathByParentId($id, $path, $models);
     //更新子类path
     if ($result) {
         $this->success('栏目更新成功');
     } else {
         $this->error('栏目更新失败');
     }
 }
Ejemplo n.º 2
0
 /**
  * 导航信息修改
  *
  */
 public function update()
 {
     $id = I('post.id');
     if (empty($id)) {
         $this->error('操作不合法');
     }
     $navigationModel = D('navigation');
     $name = I('post.name');
     if (empty($name)) {
         $this->error('导航名称不能为空');
         exit;
     }
     $url = I('post.url');
     if (empty($url)) {
         $this->error('导航路径不能为空');
         exit;
     }
     //父级分类限定
     $parent_id = I('post.parent');
     $models = 'navigation';
     $check = checkParent($id, $parent_id, $models);
     if ($check['status'] == false) {
         $this->error("{$check['msg']}");
     }
     //获取path
     if ($parent_id == 0) {
         $path = ',';
     } else {
         $path = getPathByParentId($parent_id, $models);
     }
     $status = $_POST['status'][0];
     $data['name'] = $name;
     $data['url'] = $url;
     $data['status'] = $status;
     $data['parent_id'] = $parent_id;
     $data['path'] = $path;
     $data['updatetime'] = time();
     $data['remark'] = I('post.remark');
     $condition['id'] = array('eq', $id);
     $result = $navigationModel->updateNav($condition, $data);
     updatePathByParentId($id, $path, $models);
     //更新子类path
     if ($result) {
         $this->success('修改成功');
     } else {
         $this->error('修改失败');
     }
 }