public function setRoleFuncs($roleid, $functions) { try { $sqls = []; $paras = []; $sqls[] = "delete from we_role_function where roleid=?"; $paras[] = array($roleid); for ($i = 0; $i < count($functions); $i++) { $id = SysSeq::GetSeqNextValue($this->conn, "we_role_function", "id"); $sqls[] = "insert into we_role_function (id,roleid,functionid) values(?,?,?)"; $paras[] = array($id, $roleid, $functions[$i]); } if (!$this->conn->ExecSQLs($sqls, $paras)) { return false; } //获取企业,员工 $sqls = []; $paras = []; $sqls[] = "select eno from we_role where id=?"; $paras[] = array($roleid); $sqls[] = "select staff from we_staff_role where roleid=?"; $paras[] = array($roleid); $ds = $this->conn->Getdatas(array('info1', 'info2'), $sqls, $paras); $eno = $ds['info1']['rows'][0]["eno"]; $rows = $ds['info2']['rows']; $staffs = []; foreach ($rows as $row) { array_push($staffs, $row['staff']); } $staffRole = new StaffRole($this->conn, $this->conn_im, null); return $staffRole->setStaffRole($roleid, $staffs, $eno); } catch (\Exception $e) { return false; } }
public function setUserRoleAction($network_domain) { $request = $this->get("request"); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $re = array('s' => '1', 'm' => ''); $roleid = $request->get("roleid"); $staffs = $request->get("staffs"); $StaffRole = new StaffRole($da, $da_im); if (!$StaffRole->setStaffRole($roleid, empty($staffs) ? array() : explode(',', $staffs), $user->eno)) { $re = array('s' => '0', 'm' => '角色授权失败'); } else { } $response = new Response(json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }