<?php
namespace Admin\Controller;
use Tool\AdminController;
class RoleController extends AdminController {
function role() {
include ('top.php');
$info = D('Role')->select();
$this->assign('info',$info);
if (!empty($_POST)) {
$role_name = $_POST['role_name'];
$sql = "insert into ts_role(role_name) value('$role_name')";
$z = D('Role')->execute($sql);
if ($z) {
$this->redirect( 'Tips/tips' );
}
}
$this->display();
}
function auth() {
include ('top.php');
$role = D('Role');
$role_id = $_GET['id'];
$info = $role->find($_GET['id']);
$this->assign('info',$info);
$ids = explode(',',$info[role_auth_ids]);
$this->assign('ids',$ids);
$auth1 = D('Auth')->where("auth_level=0")->select();
$auth2 = D('Auth')->where("auth_level=1")->select();
$this->assign('auth1',$auth1);
$this->assign('auth2',$auth2);
if (!empty($_POST)) {
$auth_ids = implode(',', $_POST['auth_id']);
$authinfo = D('Auth')->select($auth_ids);
$s = '';
foreach ($authinfo as $k=>$v) {
if (!empty($v['auth_c'])&&!empty($v['auth_a'])) {
$s .= $v['auth_c'] . '-' . $v['auth_a'] . ',';
}
}
$s = rtrim($s,',');
dump($s);
$sql = "update ts_role set role_auth_ids='$auth_ids',role_auth_ac='$s' where role_id='$role_id'";
$z = $role->execute($sql);
if ($z) {
$this->redirect('Tips/tips');
}
}
$this->display();
}
}