<?php
namespace Admin\Controller;
use Tool\AdminController;
class AuthController extends AdminController {
function auth() {
include ('top.php');
$info = new \Model\AuthModel();
$auth = $info->order('auth_path')->select();
$this->assign('auth',$auth);
$this->display();
}
function addauth() {
include ('top.php');
$info = new \Model\AuthModel();
$level = $info->where('auth_level=0')->select();
$this->assign('level',$level);
if ($_GET['auth_id'] != false) {
$auth = $info->where('auth_id=' . $_GET['auth_id'])->find();
$this->assign('info',$auth);
if(!empty($_POST)) {
$_POST['auth_path'] = $_POST['auth_pid'] . '-' . $_GET['auth_id'];
$_POST['auth_level'] = substr_count($_POST['auth_path'], '-');
$zz = $info->where('auth_id=' . $_GET['auth_id'])->save($_POST);
if ($zz) {
$this->redirect('Tips/tips');
}
}
} else {
if (!empty($_POST)){
$z = $info->saveauth($_POST);
if($z) {
$this->redirect('Tips/tips');
}
}
}
$this->display();
}
function delete() {
$del = M('Auth');
$zz = $del->delete($_GET['auth_id']);
if ($zz) {
$this->redirect('Tips/tips');
}
}
}