select([]); $result = array(); $result[] = array ( 'id' => 'root', 'name' => '全部系统', 'children' => $data, ); return $result; } # 创建管理员 public function update($db, $data, $param = array()) { if (isset($data['mobile']) && $data['mobile']) { $system = Dever::db('system', 'manage')->find(array('key' => $param['system'])); $data['system_id'] = $system['id']; $data['info_id'] = $data['id']; $data['partition'] = $system['partition']; $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data)); $info = $db->find(array('mobile' => $data['mobile'])); if (!$info) { $password = '123456'; $insert['name'] = Str::hide($data['mobile']); $insert['mobile'] = $data['mobile']; $insert['role'] = 1; $insert += Dever::load('common', 'manage')->createPwd($password); $db->insert($insert); } } } # 创建账户 public function createUser($data, $state = true) { if (isset($data['mobile']) && $data['mobile'] && isset($data['password']) && $data['password']) { $info = Dever::db($data['table'])->find($data['id']); if ($info) { $system = Dever::db('system', 'manage')->find(array('key' => $data['system'])); $set['system_id'] = $system['id']; $set['info_id'] = 1; $set['partition'] = $system['partition']; $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($set)); $user = $db->find(array('mobile' => $data['mobile'])); if ($state && $user) { Dever::error('手机号' . $data['mobile'] . '已存在,请更换手机号'); } $module = Dever::db('system_module', 'manage')->find(array('key' => $data['module'], 'system' => 'group')); $insert['name'] = $info['name']; $insert['mobile'] = $data['mobile']; $insert['role'] = 2; $insert['module_data'] = $module['id'] . '-' . $info['id']; $insert += Dever::load('common', 'manage')->createPwd($data['password']); if (!$user) { $db->insert($insert); } else { $module_data = $insert['module_data']; unset($insert['module_data']); if (!strstr($user['module_data'], $module_data)) { $insert['module_data'] = $module_data . ',' . $user['module_data']; } $db->update($user['id'], $insert); } } } return $data; } }