...
|
...
|
@@ -144,4 +144,60 @@ class User extends Backend |
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改
|
|
|
*/
|
|
|
public function multi($ids = NULL){
|
|
|
if (!$this->request->isPost()) {
|
|
|
$this->error(__("Invalid parameters"));
|
|
|
}
|
|
|
$ids = $ids ? $ids : $this->request->post("ids");
|
|
|
$ids = $ids ?: $this->request->post('ids');
|
|
|
if (empty($ids)) {
|
|
|
$this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
}
|
|
|
|
|
|
if (false === $this->request->has('params')) {
|
|
|
$this->error(__('No rows were updated'));
|
|
|
}
|
|
|
parse_str($this->request->post('params'), $values);
|
|
|
$values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields)));
|
|
|
if (empty($values)) {
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds)) {
|
|
|
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
|
|
}
|
|
|
$count = 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$list = $this->model->where($this->model->getPk(), 'in', $ids)->select();
|
|
|
foreach ($list as $item) {
|
|
|
if ($values['is_teach'] == 1) {
|
|
|
$values['teach_phone'] = $item['mobile'];
|
|
|
} else if ($values['is_teach'] == 0){
|
|
|
$values['teach_phone'] = null;
|
|
|
}
|
|
|
$count += $item->allowField(true)->isUpdate(true)->save($values);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if ($count) {
|
|
|
$this->success();
|
|
|
}
|
|
|
$this->error(__('No rows were updated'));
|
|
|
// $row = $this->model->get($ids);
|
|
|
// if ($row['is_teach'] == 1){
|
|
|
// $row['teach_phone'] = $row['mobile'];
|
|
|
// }else{
|
|
|
// $row['teach_phone'] = null;
|
|
|
// }
|
|
|
// $this->success();
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|