<?php
/*
 +----------------------------------------------------------------------
 | TEMMOKUMVC [ NO BEST , ONLY BETTER ]
 +----------------------------------------------------------------------
 | Copyright (c) 2018~2019 https://www.temmoku.cn All rights reserved.
 +----------------------------------------------------------------------
 | Author: 张宗强 Email:webmaster@temmoku.cn QQ:158726877 516669373 TEL:17895221001 微信:temmokumvc
 +---------------------------------------------------------------------- 
*/
namespace admin\controller;
use admin\model\group AS model;
use \temmoku\db;
use \temmoku\admin;
use admin\public_class\cache;
class group extends admin
{
    public function add()
    {
    	if('post'===$_POST['post']['step']){
    		(new model)->add($_POST['post']);
    		cache::User_group();
    		$this->success('创建成功');
    	}
    	$this->display(tpl('group/add'));
    }
    public function edit()
    {
    	if('edit'=== $_POST['step']){
    		(new model)->edit();
    		cache::User_group();
    		$this->Success('修改成功');
    	}
		
      	$group=db::select('*')->from(jab.'user_group')->where("id='$_GET[id]'")->row();
      	//获取所有已安装模块
      	$modular = db::select('*')->from(jab.'modular')->query();
    	if($modular){
    		foreach($modular AS $R){
	    		@extract(@include_once APP_PATH.$R['dir']."/admin/power.php");
	    		$R['POWER']=$POWER;
	    		$Modular_DB[]=$R;
	    	}
    	}
    	
    	//获取所有已安装的插件
      	$plugin = db::select('*')->from(jab.'plugin')->query();
    	if($plugin){
    		foreach($plugin AS $P){
	    		@extract(@include_once APP_PATH.'plugin/'.$P['dir']."/admin/power.php");
	    		$P['POWER']=$POWER;
	    		$plugin_DB[]=$P;
	    	}
    	}
    	$this->assign('plugin_DB', $plugin_DB);
      	$this->assign('Modular_DB', $Modular_DB);
      	$this->assign('group', $group);
      	$setting=unserialize($group['setting']);
      	$this->assign('setting', $setting);
      	$this->assign('allcidDB', $allcidDB);
      	$this->assign('id', $_GET['id']);
      	$this->display(tpl('group/edit'));
    }
    public function del(){
    	(new model)->del($_GET['id']);
    	cache::User_group();
    	$this->Success('删除成功', '/admin/group/power');
    }
    
    public function power()
    {
    	$return=(new model)->get_all();
       	$this->assign('user_groupDB', $return);
       	$this->display(tpl('group/power'));
    }
}
?>

