Commit 577be8df authored by rlgy's avatar rlgy

update

parent 30517063
...@@ -76,62 +76,39 @@ class AdminController extends BaseController ...@@ -76,62 +76,39 @@ class AdminController extends BaseController
* 用户授权 * 用户授权
* --------------------------------------- * ---------------------------------------
*/ */
// public function actionAuth() public function actionAuth()
// { {
// /* 获取用户信息 */ /* 获取用户信息 */
// $uid = Yii::$app->request->get('uid'); $uid = Yii::$app->request->get('uid');
// if (!is_numeric($uid) || !($model = Admin::findOne($uid)) ) { if (!is_numeric($uid) || !($model = Admin::findOne($uid))) {
// $this->error('操作对象不合法'); $this->error('操作对象不合法');
// } }
//
// $auth = Yii::$app->authManager; $auth = Yii::$app->authManager;
// if (Yii::$app->request->isPost) { if (Yii::$app->request->isPost) {
// $data = Yii::$app->request->post(); $data = Yii::$app->request->post();
//
// //更新Fxee权限 /* 用户权限组 */
// try { $item_name = $data['param'];
// $ret = FxeeBusiness::updateMemberGroup($uid,isset($data['param_fxee']) ? $data['param_fxee'] : null);
// } catch (Exception $e) { /* 先删除 用户组-用户 记录 */
// $ret = $e->getMessage(); $auth->revokeAll($uid);
// } /* 再添加记录 */
// $role = $auth->getRole($item_name);
// /* 用户权限组 */ $auth->assign($role, $uid);
// $item_name = $data['param'];
// $this->success('授权成功!', $this->getForward());
// /* 先删除 用户组-用户 记录 */
// $auth->revokeAll($uid); }
// /* 再添加记录 */
// $role = $auth->getRole($item_name); $roles = $auth->getRoles();
// $auth->assign($role, $uid); $group = array_keys($auth->getAssignments($uid));
//
// //fxee用户权限操作 return $this->render('auth', [
// 'model' => $model,
// if ($ret == true) { 'roles' => $roles,
// $this->success('授权成功!', $this->getForward()); 'group' => $group,
// } else if (is_string($ret)) { ]);
// $this->error($ret); }
// }
// exit;
// }
//
// $roles = $auth->getRoles();
// $group = array_keys($auth->getAssignments($uid));
//
// $one = Admin::findOne(['uid' => $uid]);
// if (isset($one['bind_uid']) && is_numeric($one['bind_uid'])) {
// $fxeeRoles = Member::getRoles();
// $fxeeGroup = Member::find()->select('group')->where(['id' => $one['bind_uid']])->scalar();
// } else {
// $fxeeRoles = $fxeeGroup = null;
// }
//
// return $this->render('auth', [
// 'model' => $model,
// 'roles' => $roles,
// 'group' => $group,
// 'fxee_roles' => $fxeeRoles,
// 'fxee_group' => $fxeeGroup,
// ]);
// }
} }
...@@ -22,7 +22,7 @@ use common\core\ActiveForm; ...@@ -22,7 +22,7 @@ use common\core\ActiveForm;
<div class="portlet light bordered"> <div class="portlet light bordered">
<div class="portlet-body form"> <div class="portlet-body form">
<!-- BEGIN FORM--> <!-- BEGIN FORM-->
<form action="<?=\yii\helpers\Url::toRoute(['auth','uid'=>$model->uid])?>" method="post" class="form-aaa "> <form action="<?= \yii\helpers\Url::toRoute(['auth', 'uid' => $model->uid]) ?>" method="post" class="form-aaa ">
<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>"> <input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
<div class="form-group"> <div class="form-group">
...@@ -30,31 +30,16 @@ use common\core\ActiveForm; ...@@ -30,31 +30,16 @@ use common\core\ActiveForm;
<div class="mt-radio-list"> <div class="mt-radio-list">
<?php if ($roles) foreach ($roles as $role) : ?> <?php if ($roles) foreach ($roles as $role) : ?>
<label class="mt-radio mt-radio-outline"> <label class="mt-radio mt-radio-outline">
<input type="radio" name="param" value="<?=$role->name?>" <?php echo in_array($role->name, $group) ?'checked':''; ?> /> <input type="radio" name="param" value="<?= $role->name ?>" <?php echo in_array($role->name, $group) ? 'checked' : ''; ?> />
<span></span> <span></span>
<?=$role->name?> (<?=$role->description?>) <?= $role->name ?> (<?= $role->description ?>)
</label> </label>
<?php endforeach ?> <?php endforeach ?>
</div> </div>
<?= $fxee_roles ? '<hr>fxee角色<label style="color: #858423">【操作】</label>' : '' ?>
<div class="mt-radio-list">
<?php if ($fxee_roles) foreach ($fxee_roles as $k => $v) : ?>
<label class="mt-radio mt-radio-outline">
<input type="radio" name="param_fxee" value="<?=$k?>" <?php echo $k==$fxee_group ?'checked':''; ?> />
<span></span>
<?=$k?> (<?=$v?>)
</label>
<?php endforeach ?>
</div>
</div>
<div class="form-actions"> <div class="form-actions">
<?= Html::submitButton('确定', ['class' => 'btn blue ajax-post','target-form'=>'form-aaa']) ?>&nbsp;&nbsp;&nbsp; <?= Html::submitButton('确定', ['class' => 'btn blue ajax-post', 'target-form' => 'form-aaa']) ?>&nbsp;&nbsp;&nbsp;
<?= Html::button('返回', ['class' => 'btn ','onclick'=>"javascript:history.go(-1);"]) ?> <?= Html::button('返回', ['class' => 'btn ', 'onclick' => "javascript:history.go(-1);"]) ?>
</div> </div>
</form> </form>
<!-- END FORM--> <!-- END FORM-->
......
<?php <?php
namespace common\core\rbac; namespace common\core\rbac;
use yii\rbac\Item; use yii\rbac\Item;
...@@ -16,7 +17,8 @@ class DbManager extends \yii\rbac\DbManager ...@@ -16,7 +17,8 @@ class DbManager extends \yii\rbac\DbManager
* @param object $rule 规则对象 * @param object $rule 规则对象
* --------------------------------------- * ---------------------------------------
*/ */
public function saveRule($name) { public function saveRule($name)
{
/* 判断auth_rule表是否存在 */ /* 判断auth_rule表是否存在 */
if ($rule = $this->getRule($name)) { if ($rule = $this->getRule($name)) {
/* 更新 */ /* 更新 */
...@@ -49,7 +51,8 @@ class DbManager extends \yii\rbac\DbManager ...@@ -49,7 +51,8 @@ class DbManager extends \yii\rbac\DbManager
* @param string $child 权限name * @param string $child 权限name
* --------------------------------------- * ---------------------------------------
*/ */
public function saveChild($parent, $child){ public function saveChild($parent, $child)
{
/* 判断auth_item_child表是否存在 */ /* 判断auth_item_child表是否存在 */
$parent = $this->getRole($parent); $parent = $this->getRole($parent);
$child = $this->getItem($child); $child = $this->getItem($child);
...@@ -62,18 +65,16 @@ class DbManager extends \yii\rbac\DbManager ...@@ -62,18 +65,16 @@ class DbManager extends \yii\rbac\DbManager
/** /**
* --------------------------------------- * ---------------------------------------
* 更新auth_item * 更新auth_item
* @throws \Exception
* --------------------------------------- * ---------------------------------------
*/ */
protected function updateRule($name, $rule) protected function updateRule($name, $rule)
{ {
if ($rule->name !== $name && !$this->supportsCascadeUpdate()) { if ($rule->name !== $name && !$this->supportsCascadeUpdate()) {
$this->db->createCommand() $this->db->createCommand()->update($this->itemTable, [
->update($this->itemTable, [
'rule_name' => $rule->name, 'rule_name' => $rule->name,
'name' => $rule->name, 'name' => $rule->name,
], [ ], ['rule_name' => $name])->execute();
'rule_name' => $name
])->execute();
} }
$rule->updatedAt = time(); $rule->updatedAt = time();
...@@ -83,9 +84,7 @@ class DbManager extends \yii\rbac\DbManager ...@@ -83,9 +84,7 @@ class DbManager extends \yii\rbac\DbManager
'name' => $rule->name, 'name' => $rule->name,
'data' => serialize($rule), 'data' => serialize($rule),
'updated_at' => $rule->updatedAt, 'updated_at' => $rule->updatedAt,
], [ ], ['name' => $name,])->execute();
'name' => $name,
])->execute();
$this->invalidateCache(); $this->invalidateCache();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment