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(); $ticket_id = $req->get_parameter('ticket_id'); $ticket = Bll_TicketBiz::get_instance()->get_detail($ticket_id); if (empty($ticket)) { $location = Home_IndexController::build_uri(); $res->redirect($location); } $updated_at = $ticket->updated_at; $diff = strtotime(date('Y-m-d H:i:s')) - strtotime($updated_at); if ($diff < 5) { return true; } else { return false; } }
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; } } } } } }
public function handle_request_internal() { $req = APF::get_instance()->get_request(); $res = APF::get_instance()->get_response(); $ticket_id = $req->get_parameter('ticket_id'); $error = $req->get_parameter('error'); $user_id = $req->get_user_id(); $user_role = Bll_RoleBiz::get_instance()->get_user_role($user_id); $ticket = Bll_TicketBiz::get_instance()->get_detail($ticket_id); if (empty($ticket)) { $location = Home_IndexController::build_uri(); $res->redirect($location); } //custom_detail $custom_detail = Bll_TicketColumnDetailBiz::get_instance()->get_ticket_custom($ticket_id); $custom_all = Bll_TicketColumnDetailBiz::get_instance()->get_all_custom($ticket_id); $ticket_before_md5 = md5(json_encode($ticket)); $ticket->reporter = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->reporter); $ticket->owner = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->owner); $ticket->assigned_qa = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket->assigned_qa); $ticket_log = Bll_TicketLogBiz::get_instance()->get_log($ticket_id); $ticket_cc_arr = Bll_TicketCcBiz::get_instance()->get_ticket_cc($ticket_id); $cc_tmp = array(); foreach ($ticket_cc_arr as $key => $ticket_cc) { if (Util_StringUtils::is_email($ticket_cc->cc_to)) { $cc_tmp[] = $ticket_cc->cc_to; } else { $cc_tmp[] = Bll_UserBiz::get_instance()->get_wholename_by_username($ticket_cc->cc_to); } } $ticket_cc_str = implode(";", $cc_tmp); $current_time = date("Y-m-d H:i:s"); $ticket_log_process = array(); foreach ($ticket_log as $key => $log) { if ($ticket_log[$key]->field == "component") { if (ctype_digit($ticket_log[$key]->oldvalue)) { $ticket_log[$key]->oldvalue = Bll_TicketBiz::get_instance()->get_component_name($ticket_log[$key]->oldvalue); } if (ctype_digit($ticket_log[$key]->newvalue)) { $ticket_log[$key]->newvalue = Bll_TicketBiz::get_instance()->get_component_name($ticket_log[$key]->newvalue); } } else { if ($ticket_log[$key]->field == "department") { if (ctype_digit($ticket_log[$key]->oldvalue)) { $ticket_log[$key]->oldvalue = Bll_TicketBiz::get_instance()->get_common_name($ticket_log[$key]->oldvalue); } if (ctype_digit($ticket_log[$key]->newvalue)) { $ticket_log[$key]->newvalue = Bll_TicketBiz::get_instance()->get_common_name($ticket_log[$key]->newvalue); } } else { if ($ticket_log[$key]->field == "ticket" && $ticket_log[$key]->oldvalue == "null") { $ticket_log[$key]->newvalue = "new"; } } } $ticket_log_process[$log->created_at][] = $log; } $log_time = array(); foreach ($ticket_log_process as $key => $log) { /* * within 24h show xxx hours ago * mt 24h lt 7days show xx days ago * mt 7days lt 30days show xx weeks ago * mt 30days show xx months ago * floor((strtotime($current_time)-strtotime($log->created_at))/86400) */ $second = floor(strtotime($current_time) - strtotime($key)); $minute = floor((strtotime($current_time) - strtotime($key)) / 60); $hour = floor((strtotime($current_time) - strtotime($key)) / 3600); $day = floor((strtotime($current_time) - strtotime($key)) / 86400); $week = floor((strtotime($current_time) - strtotime($key)) / 604800); $month = floor((strtotime($current_time) - strtotime($key)) / 2592000); if ($second < 60) { $log_time[$key] = $second . ' seconds ago '; } else { if ($minute < 60) { $log_time[$key] = $minute . ' minutes ago '; } else { if ($hour < 24) { $log_time[$key] = $hour . ' hours ago '; } else { if ($hour >= 24 && $hour < 168) { $log_time[$key] = $day . ' days ago '; } else { if ($hour >= 168 && $hour < 720) { $log_time[$key] = $week . ' weeks ago '; } else { if ($hour >= 720) { $log_time[$key] = $month . ' months ago '; } } } } } } } $parent = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($ticket_id); if ($parent) { $parent_id = $parent->parent_ticket_id; } else { $parent_id = "0"; } $son = Bll_TicketRelationBiz::get_instance()->find_son_bugs_of_parent($ticket_id); if (empty($son)) { $son_id = "0"; } else { $son_id = $son[0]->ticket_id; } $ticket_status = Ticket_Status::get_status($ticket); $actions = $ticket_status->get_available_actions($user_role, $ticket->environment); $resolutions = Bll_DdCommonBiz::get_instance()->get_resolutions(); //start..... $all_users = Bll_UserBiz::get_instance()->get_all_valid_users(); $tmp_all = array(); foreach ($all_users as $key => $value) { $tmp_all[$key] = $value->whole_name; } $all_users = json_encode($tmp_all); $dev_users = Bll_UserBiz::get_instance()->get_dev_users(); $tmp_dev = array(); foreach ($dev_users as $key => $value) { $tmp_dev[$key] = $value->whole_name; } $dev_users = json_encode($tmp_dev); $qa_users = Bll_UserBiz::get_instance()->get_qa_users(); $admin_users = Bll_UserBiz::get_instance()->get_admins(); $qa_admin_users = array_merge($qa_users, $admin_users); $tmp_qa = array(); foreach ($qa_admin_users as $key => $value) { $tmp_qa[$key] = $value->whole_name; } $qa_admin_users = json_encode($tmp_qa); //end..... $reasons = Bll_DdCommonBiz::get_instance()->get_reasons(); $files = Bll_AttachmentBiz::get_instance()->get_file_by_ticket_id($ticket_id); if ($files) { foreach ($files as $file) { $file_link = Bll_AttachmentBiz::get_instance()->get_file_link_by_hash($file->fetch_hash); $file->fetch_hash = $file_link; } } $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys(); $emergencies = Bll_DdCommonBiz::get_instance()->get_emergencies(); $environments = Bll_DdCommonBiz::get_instance()->get_environments(); $departments = Bll_DdCommonBiz::get_instance()->get_departments_new(); $department_id = Bll_DdCommonBiz::get_instance()->get_department_id_by_name($ticket->department); $rel_components = Bll_DdComponentBiz::get_instance()->get_components($department_id->id); $req->set_attribute('user_id', $user_id); $req->set_attribute('files', $files); $req->set_attribute('prioritys', $prioritys); $req->set_attribute('emergencies', $emergencies); $req->set_attribute('departments', $departments); $req->set_attribute('rel_components', $rel_components); $req->set_attribute('environments', $environments); $req->set_attribute('reasons', $reasons); $req->set_attribute('resolutions', $resolutions); $req->set_attribute('ticket', $ticket); $req->set_attribute('ticket_cc_str', $ticket_cc_str); $req->set_attribute('ticket_logs', $ticket_log_process); $req->set_attribute('log_time', $log_time); $req->set_attribute('actions', $actions); $req->set_attribute('all_users', $all_users); $req->set_attribute('dev_users', $dev_users); $req->set_attribute('qa_admin_users', $qa_admin_users); $req->set_attribute('ticket_before_md5', $ticket_before_md5); $req->set_attribute('parent_id', $parent_id); $req->set_attribute('son_id', $son_id); $req->set_attribute('custom_detail', $custom_detail); $req->set_attribute('custom_all', $custom_all); if ($error) { $req->set_attribute('error', $error); } return 'Ticket_Detail'; }