public function actionDelete($id) { if ($_POST['action'] == 1) { if ($id == 1) { echo json_encode(array('id' => array(0), 'class' => 'alert-error', 'message' => __('supper user can not delete'))); exit; } if ($id === uid()) { echo json_encode(array('id' => array(0), 'class' => 'alert-error', 'message' => __('you can not remove yourself'))); exit; } $model = \app\modules\auth\models\User::find($id); $model->delete(); echo json_encode(array('id' => array($id), 'class' => 'alert-success', 'message' => __('delete user success'))); exit; } }
/** * 用户绑定到组 */ public function actionBind($id) { $id = (int) $id; $model = \app\modules\auth\models\User::find($id); foreach ($model->groups as $g) { $groups[] = $g->group_id; } $rows = Group::find()->all(); if ($rows) { $rows = Arr::model_tree($rows); } if ($_POST) { $group = $_POST['group']; //绑定用户到组 UserGroup::UserGroupSave($id, $group); flash('success', __('bin user group success') . " # " . $id); redirect(url('auth/group/bind', array('id' => $id))); } echo $this->render('bind', array('rows' => $rows, 'groups' => $groups, 'model' => $model, 'id' => $id, 'self' => $model->yourself)); }