コード例 #1
0
ファイル: StatusClosed.php プロジェクト: emilymwang8/ibug
 public function change_status($status, $input_arr)
 {
     $new_reporter = APF::get_instance()->get_request()->get_username();
     $new_ticket = array('priority' => $this->ticket->priority, 'reporter' => $new_reporter, 'owner' => $this->ticket->owner, 'assigned_qa' => $this->ticket->assigned_qa, 'status' => 'opened', 'summary' => $this->ticket->summary, 'pmt_id' => $this->ticket->pmt_id, 'environment' => $this->ticket->environment, 'department' => $this->ticket->department, 'component' => $this->ticket->component, 'version' => $this->ticket->version, 'is_regression' => $this->ticket->is_regression, 'description' => $this->ticket->description, 'resolution' => '', 'reason' => '', 'reason_detail' => '');
     $new_ticket_id = Bll_TicketBiz::get_instance()->ticket_add($new_ticket);
     if ($input_arr['comments']) {
         $current_time = date("Y-m-d H:i:s");
         $log_id_comment = Bll_TicketLogBiz::get_instance()->comment_add($new_ticket_id, $input_arr['comments'], $new_reporter, $current_time);
     }
     $parent_ticket_id = $this->ticket->id;
     $relation = Bll_TicketRelationBiz::get_instance()->find_root_by_parent($parent_ticket_id);
     if ($relation) {
         $root_ticket_id = $relation->root_ticket_id;
     } else {
         $root_ticket_id = $parent_ticket_id;
     }
     $new_relation = array();
     $new_relation['ticket_id'] = $new_ticket_id;
     $new_relation['parent_ticket_id'] = $parent_ticket_id;
     $new_relation['root_ticket_id'] = $root_ticket_id;
     $success = Bll_TicketRelationBiz::get_instance()->relation_add($new_relation);
     //return $success;
     if ($success) {
         //reopen log add
         $current_time = date("Y-m-d H:i:s");
         $input_arr_log = array('ticket_id' => $new_ticket_id, 'created_by' => $new_reporter, 'field' => 'ticket', 'oldvalue' => 'null', 'newvalue' => $new_ticket['description'], 'created_at' => $current_time);
         $log_id = Bll_TicketLogBiz::get_instance()->log_add($input_arr_log);
         $location = Ticket_DetailController::build_uri() . "?ticket_id=" . $new_ticket_id;
         APF::get_instance()->get_response()->redirect($location);
     }
 }
コード例 #2
0
ファイル: AttachAdd.php プロジェクト: emilymwang8/ibug
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     if ($params) {
         $ticket_id = $params['ticket_id'];
         $file_hidden = $params['file_hidden'];
         foreach ($file_hidden as $file_id) {
             $file_info = Bll_AttachmentBiz::get_instance()->get_file_info_by_id($file_id);
             $local_filepath = $file_info->local_filepath;
             //var_dump($file_info);
             //$file_path = $tmp_file_obj->path.$tmp_file_obj->name;
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
             $file_type = finfo_file($finfo, $local_filepath);
             $post_params = array("file" => "@" . $local_filepath . ";type=" . $file_type);
             //print_r($post_params);die();
             $request_url = APF::get_instance()->get_config('file_upload_url');
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $request_url);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $ret = curl_exec($ch);
             $info = curl_getinfo($ch);
             //var_dump($info);echo '<br/>';var_dump($post_params);
             $ret_value = json_decode($ret);
             if (!$ret_value->error) {
                 $fetch_hash = $ret_value->saved_file[0]->hash;
             }
             //var_dump($fetch_hash);die();
             //更新数据库
             $res = Bll_AttachmentBiz::get_instance()->modify_file_info($file_id, $ticket_id, $fetch_hash);
         }
         $current_time = date("Y-m-d H:i:s");
         if ($ticket_id) {
             //mail add
             $id = Bll_MailBiz::get_instance()->mail_add($ticket_id, $current_time);
         }
         if ($ticket_id) {
             //new ticket log add
             $input_arr = array('ticket_id' => $ticket_id, 'created_by' => $req->get_username(), 'field' => 'attachment', 'oldvalue' => 'Add a attachment', 'newvalue' => 'Add a attachment', 'created_at' => $current_time);
             $log_id = Bll_TicketLogBiz::get_instance()->log_add($input_arr);
         }
         $location = Ticket_DetailController::build_uri() . '?ticket_id=' . $ticket_id;
         APF::get_instance()->get_response()->redirect($location);
     }
 }
コード例 #3
0
ファイル: AttachDelete.php プロジェクト: emilymwang8/ibug
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     if ($params) {
         $attach_id = $params['id'];
         $ticket_id = $params['ticket'];
         if ($attach_id) {
             $del = Bll_AttachmentBiz::get_instance()->delete_file_by_id($attach_id);
         }
         $current_time = date("Y-m-d H:i:s");
         if ($ticket_id) {
             //mail add
             $id = Bll_MailBiz::get_instance()->mail_add($ticket_id, $current_time);
         }
         if ($ticket_id) {
             //new ticket log add
             $input_arr = array('ticket_id' => $ticket_id, 'created_by' => $req->get_username(), 'field' => 'attachment', 'oldvalue' => 'Delete a attachment', 'newvalue' => 'Delete a attachment', 'created_at' => $current_time);
             $log_id = Bll_TicketLogBiz::get_instance()->log_add($input_arr);
         }
         $location = Ticket_DetailController::build_uri() . '?ticket_id=' . $ticket_id;
         APF::get_instance()->get_response()->redirect($location);
     }
 }
コード例 #4
0
ファイル: Add.php プロジェクト: emilymwang8/ibug
 public function handle_request_internal()
 {
     $req = APF::get_instance()->get_request();
     $params = $req->get_parameters();
     //var_dump($params);die();
     //var_dump($params['description']);die();
     if ($params && $params['summary'] && $params['editor1'] && $params['owner'] && $params['reporter']) {
         $input_arr = array('summary' => $params['summary'], 'reporter' => $params['reporter'], 'description' => Ticket_AttachAddController::convert_imageurl($params['editor1']), 'priority' => $params['priority'], 'emergency' => $params['emergency'], 'environment' => $params['environment'], 'department' => $params['department'], 'component' => $params['component'], 'owner' => $params['owner'], 'cc_user' => $params['cc_user'], 'assigned_qa' => $params['assigned_qa'], 'pmt_id' => $params['pmt_id'], 'version' => $params['version'], 'is_regression' => $params['is_regression'], 'status' => 'opened', 'version' => $params['version'], 'is_occasional' => $params['is_occasional'], 'person_liable' => $params['person_liable']);
         if (in_array($input_arr['department'], array('47', '48'))) {
             $input_arr['pmt_id'] = 0;
         }
         $input_arr['owner'] = strpos($input_arr['owner'], ";") ? substr($input_arr['owner'], 0, strpos($input_arr['owner'], ";")) : $input_arr['owner'];
         $input_arr['owner'] = Bll_UserBiz::get_instance()->get_username_by_wholename($input_arr['owner']);
         $input_arr['assigned_qa'] = strpos($input_arr['assigned_qa'], ";") ? substr($input_arr['assigned_qa'], 0, strpos($input_arr['assigned_qa'], ";")) : $input_arr['assigned_qa'];
         $input_arr['assigned_qa'] = Bll_UserBiz::get_instance()->get_username_by_wholename($input_arr['assigned_qa']);
         //$input_arr['person_liable'] = strpos($input_arr['person_liable'],";")?substr($input_arr['person_liable'], 0, strpos($input_arr['person_liable'],";")):$input_arr['person_liable'];
         //$input_arr['person_liable'] = Bll_UserBiz::get_instance()->get_username_by_wholename($input_arr['person_liable']);
         $ticket_id = Bll_TicketBiz::get_instance()->ticket_add($input_arr);
         //request icase api
         if (isset($params['case_id'])) {
             $cycle = 3;
             $url = "http://icase.corp.anjuke.com/api/save/case2bug?";
             $p = array();
             $p['bug_id'] = $ticket_id;
             $p['case_id'] = $params['case_id'];
             $url = $url . "bug_id=" . $p['bug_id'] . "&case_id=" . $p['case_id'] . "&key=nmzszxsl";
             $culr = curl_init();
             curl_setopt($culr, CURLOPT_URL, $url);
             curl_setopt($culr, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($culr, CURLOPT_FOLLOWLOCATION, 1);
             $data = curl_exec($culr);
             $data = json_decode($data, true);
             while ($cycle > 0) {
                 if ($data['status'] == "ok") {
                     break;
                 }
                 $data = curl_exec($culr);
                 $cycle--;
             }
             curl_close($culr);
         }
         //request imonitor api
         if (isset($params['task_fail_id']) && $params['task_fail_id'] != "") {
             $cycle = 3;
             $url = "10.10.9.53:8888/api/ibug/";
             $p = array();
             $p['bug_id'] = $ticket_id;
             $p['task_fail_id'] = $params['task_fail_id'];
             $culr = curl_init();
             curl_setopt($culr, CURLOPT_URL, $url);
             curl_setopt($culr, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($culr, CURLOPT_HEADER, 0);
             curl_setopt($culr, CURLOPT_POST, 1);
             curl_setopt($culr, CURLOPT_POSTFIELDS, $p);
             $data = curl_exec($culr);
             while ($cycle > 0) {
                 if ($data == "ok") {
                     break;
                 }
                 $data = curl_exec($culr);
                 $cycle--;
             }
             curl_close($culr);
         }
         //custom column
         $custom_columns = Bll_TicketCustomColumnBiz::get_instance()->get_custom_columns();
         foreach ($custom_columns as $column) {
             if (!empty($params[$column->column_name])) {
                 $custom_arr[$column->column_name] = $params[$column->column_name];
             }
         }
         if (!empty($custom_arr)) {
             $res = Bll_TicketColumnDetailBiz::get_instance()->ticket_custom_add($ticket_id, $custom_arr);
         }
         //save files using curl
         $file_hidden = $params['file_hidden'];
         if (!empty($file_hidden)) {
             foreach ($file_hidden as $file_id) {
                 $file_info = Bll_AttachmentBiz::get_instance()->get_file_info_by_id($file_id);
                 $local_filepath = $file_info->local_filepath;
                 $finfo = finfo_open(FILEINFO_MIME_TYPE);
                 $file_type = finfo_file($finfo, $local_filepath);
                 $post_params = array("file" => "@" . $local_filepath . ";type=" . $file_type);
                 $request_url = APF::get_instance()->get_config('file_upload_url');
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $request_url);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $ret = curl_exec($ch);
                 $info = curl_getinfo($ch);
                 $ret_value = json_decode($ret);
                 if (!$ret_value->error) {
                     $fetch_hash = $ret_value->saved_file[0]->hash;
                 }
                 //更新数据库
                 $res = Bll_AttachmentBiz::get_instance()->modify_file_info($file_id, $ticket_id, $fetch_hash);
             }
         }
         $current_time = date("Y-m-d H:i:s");
         if ($ticket_id) {
             //mail add
             $id = Bll_MailBiz::get_instance()->mail_add($ticket_id, $current_time);
         }
         if ($ticket_id) {
             //new ticket log add
             $input_arr = array('ticket_id' => $ticket_id, 'created_by' => $req->get_username(), 'field' => 'ticket', 'oldvalue' => 'null', 'newvalue' => $input_arr['description'], 'created_at' => $current_time);
             $log_id = Bll_TicketLogBiz::get_instance()->log_add($input_arr);
         }
         $location = Ticket_DetailController::build_uri() . '?ticket_id=' . $ticket_id;
         APF::get_instance()->get_response()->redirect($location);
     } else {
         if ($params['post'] == 'posted') {
             $req->set_attribute('error', '请检查,summary,description,owner为必填项!');
         }
     }
     $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);
     $prioritys = Bll_DdCommonBiz::get_instance()->get_prioritys();
     $emergencies = Bll_DdCommonBiz::get_instance()->get_emergencies();
     $reasons = Bll_DdCommonBiz::get_instance()->get_reasons();
     $environments = Bll_DdCommonBiz::get_instance()->get_environments();
     $departments = Bll_DdCommonBiz::get_instance()->get_departments_new();
     $custom_columns = Bll_TicketCustomColumnBiz::get_instance()->get_custom_columns();
     $req->set_attribute('prioritys', $prioritys);
     $req->set_attribute('emergencies', $emergencies);
     $req->set_attribute('reasons', $reasons);
     $req->set_attribute('environments', $environments);
     $req->set_attribute('departments', $departments);
     $req->set_attribute('reporter', $req->get_username());
     $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('custom_columns', $custom_columns);
     $req->set_attribute('paramas', $params);
     return 'Ticket_Add';
 }