...
|
...
|
@@ -12,7 +12,7 @@ class InitController extends Controller |
|
|
{
|
|
|
|
|
|
/**
|
|
|
* Create init user
|
|
|
* 创建/修改后台用户
|
|
|
*/
|
|
|
public function actionAdmin()
|
|
|
{
|
...
|
...
|
@@ -80,4 +80,43 @@ class InitController extends Controller |
|
|
public function actionTest(){
|
|
|
echo "init/test";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 创建/移除后台权限标签(controller/action)
|
|
|
*/
|
|
|
public function actionRbac(){
|
|
|
|
|
|
$this->stdout("1: Create rbac permission\n2: Delete rbac permission\n");
|
|
|
$action = $this->prompt('Which:');
|
|
|
|
|
|
$auth = Yii::$app->authManager;
|
|
|
if ($action == 1){
|
|
|
echo "创建一个新权限标签 ...\n"; // 提示当前操作
|
|
|
$name = $this->prompt('Permission Name:'); // 权限名称
|
|
|
$description = $this->prompt('Description(default is as name):'); // 描述
|
|
|
|
|
|
if ($name){
|
|
|
$permission = $auth->createPermission($name);
|
|
|
$permission->description = $description ? : ucwords(strtr($name,array('/'=>' ')));
|
|
|
$r = $auth->add($permission);
|
|
|
}
|
|
|
}elseif ($action == 2){
|
|
|
echo "移除一个权限标签 ...\n"; // 提示当前操作
|
|
|
$name = $this->prompt('Permission Name:'); // 权限名称
|
|
|
|
|
|
if ($name){
|
|
|
if (!$permission = $auth->getPermission($name)){
|
|
|
$this->stderr('Not a predefined permission');
|
|
|
return 1;
|
|
|
}
|
|
|
$r = $auth->remove($permission);
|
|
|
}
|
|
|
}else{
|
|
|
$this->stderr('Not a predefined option');
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
var_dump($r);
|
|
|
return 0;
|
|
|
}
|
|
|
} |
...
|
...
|
|