<?php
require("CommonAction.class.php");
class configAction extends CommonAction
{

    public function add_user() {
	   
       $this->display();   
    }
	
   //修改密码
   public function changeP()
   {
     
      $this->display();
   }
   
   //用户列表
   public function userlist()
   {
      $user = M("user");
	  $map["del"] = array("eq","0");
	  $map["status"] = array("lt",$_SESSION["status"]);
	  $map["type_id"] = array("eq",$_SESSION["type_id"]);
	  $data = $user->where($map)->field("id,account,nickname,type_id,login_count,last_login_ip,create_time,status")->select();
	  $this->assign("data",$data);
      $this->display();
   }
   
   //部门管理
   public function index()
   {
      $category = M("category");
	  $map["parentid"] = array("eq","0");
	  $map["del"] = array("eq","0");
	  $category = $category->where($map)->field("id,name")->findall();
	  $this->assign("category",$category);
	  $this->assign("newsid",c('0.newid'));
	  $this->assign("categoryid",c('0.categoryid'));
	  $this->assign("subjectid",c('0.subjectid'));
      $this->display();
   }
   
   //配置更新
   public function updateConfig()
   {
      $config = M("config");
      if(empty($_GET["id"]))
	  {
	     //表示第一次添加
		
		if ($config->create()) {
            if (false !== $config->add()) {
			    $this->assign("jumpUrl",__URL__."/index");
                $this->success('配置更新成功！');
            } else {
			    $this->assign("jumpUrl",__URL__."/index");
                $this->error('配置更新错误');
            }
        } else {
            // 字段验证错误
            $this->error($config->getError());
        }
	  }
	  else
	  {
	     //表示要更新
		$map["id"] = array("eq",$_GET["id"]);
		 if ($config->where($map)->save($_POST)) {
			    $this->assign("jumpUrl",__URL__."/index");
                $this->success('配置更新成功！');
            } else {
			    $this->assign("jumpUrl",__URL__."/index");
                $this->error('配置更新错误');
            }
	  }
   
   }
}
?>