|
@@ -4,6 +4,11 @@ namespace app\admin\controller\user; |
|
@@ -4,6 +4,11 @@ namespace app\admin\controller\user; |
4
|
|
4
|
|
5
|
use app\common\controller\Backend;
|
5
|
use app\common\controller\Backend;
|
6
|
use app\common\library\Auth;
|
6
|
use app\common\library\Auth;
|
|
|
7
|
+use think\Db;
|
|
|
8
|
+use think\Exception;
|
|
|
9
|
+use think\exception\DbException;
|
|
|
10
|
+use think\exception\PDOException;
|
|
|
11
|
+use think\exception\ValidateException;
|
7
|
|
12
|
|
8
|
/**
|
13
|
/**
|
9
|
* 会员管理
|
14
|
* 会员管理
|
|
@@ -82,7 +87,43 @@ class User extends Backend |
|
@@ -82,7 +87,43 @@ class User extends Backend |
82
|
$this->error(__('No Results were found'));
|
87
|
$this->error(__('No Results were found'));
|
83
|
}
|
88
|
}
|
84
|
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
|
89
|
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
|
85
|
- return parent::edit($ids);
|
90
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
91
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
92
|
+ $this->error(__('You have no permission'));
|
|
|
93
|
+ }
|
|
|
94
|
+ if (false === $this->request->isPost()) {
|
|
|
95
|
+ $this->view->assign('row', $row);
|
|
|
96
|
+ return $this->view->fetch();
|
|
|
97
|
+ }
|
|
|
98
|
+ $params = $this->request->post('row/a');
|
|
|
99
|
+ if (empty($params)) {
|
|
|
100
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
101
|
+ }
|
|
|
102
|
+ $params = $this->preExcludeFields($params);
|
|
|
103
|
+ $result = false;
|
|
|
104
|
+ Db::startTrans();
|
|
|
105
|
+ try {
|
|
|
106
|
+ //是否采用模型验证
|
|
|
107
|
+ if ($this->modelValidate) {
|
|
|
108
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
109
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
110
|
+ $row->validateFailException()->validate($validate);
|
|
|
111
|
+ }
|
|
|
112
|
+ if ($params['is_teach'] == 1){
|
|
|
113
|
+ $params['teach_phone'] = $params['mobile'];
|
|
|
114
|
+ }else{
|
|
|
115
|
+ $params['teach_phone'] = null;
|
|
|
116
|
+ }
|
|
|
117
|
+ $result = $row->allowField(true)->save($params);
|
|
|
118
|
+ Db::commit();
|
|
|
119
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
120
|
+ Db::rollback();
|
|
|
121
|
+ $this->error($e->getMessage());
|
|
|
122
|
+ }
|
|
|
123
|
+ if (false === $result) {
|
|
|
124
|
+ $this->error(__('No rows were updated'));
|
|
|
125
|
+ }
|
|
|
126
|
+ $this->success();
|
86
|
}
|
127
|
}
|
87
|
|
128
|
|
88
|
/**
|
129
|
/**
|