public static function &get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $params = $req->get_parameters(); $id = $params['pid'] ? $params['pid'] : 0; if (isset($params['edit_submit'])) { $person_id = $params['person_id']; $input_arr = array('english_name' => $params['english_name'], 'chinese_name' => $params['chinese_name'], 'whole_name' => $params['whole_name'], 'email' => $params['email'], 'is_disabled' => $params['disable']); $ret = Bll_UserBiz::get_instance()->modify_user($person_id, $input_arr); $role_id = $params['role']; if (in_array($role_id, array('1', '2', '3', '4'))) { $ret = Bll_UserRoleBiz::get_instance()->change_role_by_userid($person_id, $role_id); } $url = Admin_PersonViewController::build_uri(); $res->redirect($url); } else { if ($id != 0) { $person = Bll_UserBiz::get_instance()->get_userinfo_by_user_id($id); $role = Bll_UserRoleBiz::get_instance()->get_role_by_user($id); } $req->set_attribute('person', $person); $req->set_attribute('role', $role); return 'Admin_PersonEdit'; } }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); //echo 'x';die(); $params = $req->get_parameters(); if ($params['changerole_user_id'] && $params['new_role']) { //echo 'x';die(); $changerole_user_id = $params['changerole_user_id']; $new_role = $params['new_role']; //echo 'cao';die(); $suc = Bll_UserRoleBiz::get_instance()->change_role($changerole_user_id, $new_role); if ($suc) { $req->set_attribute('suc', 'change succeed!'); } else { $req->set_attribute('suc', 'change failed!'); } } //$dev=Bll_UserBiz::get_instance()->get_dev_users();var_dump($dev);die(); $admins = Bll_UserBiz::get_instance()->get_admins(); //var_dump($admins);die(); $qas = Bll_UserBiz::get_instance()->get_qa_users(); //var_dump($qas);die(); $devs = Bll_UserBiz::get_instance()->get_dev_users(); //var_dump($dev);die(); $qa_dev = array_merge($qas, $devs); $req->set_attribute('admins', $admins); $req->set_attribute('qa_dev', $qa_dev); return 'Home_Root'; }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $oauth_config = APF::get_instance()->get_config('oauth', 'ldap'); $client_id = $oauth_config['client_id']; $client_secret = $oauth_config['client_secret']; $oauth_url = $oauth_config['oauth_url']; $user = $this->login_with_oauth($client_id, $client_secret, $oauth_url); if ($user) { $user = json_decode($user, true); $username = $user['username']; $token = $user['access_token']; $user_info = Bll_UserBiz::get_instance()->get_userinfo_by_username($username); //get userinfo from ibug if ($user_info) { $user_info = Util_ArrayUtils::obj_to_arr($user_info); $location = Home_IndexController::build_uri(); $this->login_success($user_info[0]['user_id'], $user_info[0]['user_name'], $location); } else { $ldap_info = $this->get_info_from_oauth($token, $oauth_url); $ldap_info = json_decode($ldap_info, true); $new_user = array('user_name' => $username, 'chinese_name' => $ldap_info['chinese_name'], 'english_name' => $ldap_info['english_name'], 'email' => $ldap_info['email']); $new_user_id = Bll_UserBiz::get_instance()->insert_newuser($new_user); $user_role_id = Bll_UserRoleBiz::get_instance()->default_role($new_user_id, 'dev'); $location = Home_IndexController::build_uri(); $this->login_success($new_user_id, $new_user['user_name'], $location); } } }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $params = $req->get_parameters(); $persons = Bll_UserBiz::get_instance()->get_all_users(); $user_roles = Bll_UserRoleBiz::get_instance()->get_all_user_role(); $roles = array(); foreach ($user_roles as $row) { $roles[$row->user_id] = $row; } $req->set_attribute('persons', $persons); $req->set_attribute('roles', $roles); return 'Admin_PersonView'; }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $params = $req->get_parameters(); $login_page = 'Login'; //cookie start for 自动跳转! $cookiename = APF::get_instance()->get_config('AuthCookieName'); $cookie = @$req->get_cookie($cookiename); if ($cookie) { $id_name_array = $this->is_auth($cookie); if ($id_name_array) { $uid = $id_name_array[0]; $uname = $id_name_array[1]; $url = Home_IndexController::build_uri(); $this->login_success($uid, $uname, $url); } } //cookie end if (!$params) { return $login_page; } if (empty($params['username']) || empty($params['password'])) { $req->set_attribute('err_msg', '请输入用户名和密码!'); return $login_page; } else { $username = strtolower($params['username']); $password = $params['password']; $ldap_auth = Bll_LdapBiz::get_instance()->auth($username, $password); //ldap_auth return true or false if (!$ldap_auth) { //root login: if ($username == 'root') { $root_id = Bll_UserBiz::get_instance()->root_auth($password); if ($root_id) { $location = Home_IndexController::build_uri(); $this->login_success($root_id, 'root', $location); } else { $req->set_attribute('err_msg', 'root密码错误!'); return $login_page; } } $req->set_attribute('err_msg', '域验证失败,请检查域账户名和密码是否正确,域账户名不包含@anjuke.com<br/>或者请检查域密码是否过期<a href="https://192.168.1.98/iisadmpwd/">密码重置</a>'); return $login_page; } else { $user_info = Bll_UserBiz::get_instance()->get_userinfo_by_username($username); //get userinfo from ibug if ($user_info) { $user_info = Util_ArrayUtils::obj_to_arr($user_info); $location = Home_IndexController::build_uri(); $this->login_success($user_info[0]['user_id'], $user_info[0]['user_name'], $location); } else { $ldap_info = Bll_LdapBiz::get_instance()->get_userinfo_from_ldap($username, $password); if (!$ldap_info) { $req->set_attribute('err_msg', '域账户信息获取失败,请联系系统开发iBug(pidgin:柏健)'); return $login_page; } else { $new_user = array('user_name' => $username, 'chinese_name' => $ldap_info->chinese_name, 'english_name' => $ldap_info->english_name, 'email' => $ldap_info->email); $new_user_id = Bll_UserBiz::get_instance()->insert_newuser($new_user); if ($new_user_id) { $user_role_id = Bll_UserRoleBiz::get_instance()->default_role($new_user_id, 'dev'); if ($user_role_id) { $location = Home_IndexController::build_uri(); $this->login_success($new_user_id, $new_user['user_name'], $location); } else { $req->set_attribute('err_msg', '账户权限初始化失败,请联系系统开发iBug(pidgin:柏健)'); return $login_page; } } else { //insert new failed! $req->set_attribute('err_msg', '账户初始化失败,请联系系统开发iBug(pidgin:柏健)'); return $login_page; } } } } } }