Пример #1
0
 public static function &get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 public function change_status($status, $input_arr)
 {
     $current_time = date("Y-m-d H:i:s");
     if ($status != 'Verified') {
         $history_arr = array('ticket_id' => $this->ticket->id, 'status' => strtolower($status), 'created_at' => $current_time, 'created_by' => $this->user);
         $history_id = Bll_TicketStatusHistoryBiz::get_instance()->insert_status_history($history_arr);
     }
     if ($status == 'Opened') {
         $input_log_open = array('ticket_id' => $this->ticket->id, 'created_by' => $input_arr['owner'], 'field' => 'resolution', 'oldvalue' => $this->ticket->resolution, 'newvalue' => 'null', 'created_at' => $current_time, 'rlog' => $input_arr['rlog']);
         $log_id_open = Bll_TicketLogBiz::get_instance()->log_add($input_log_open);
         $reject_counter = Bll_TicketCounterBiz::get_instance()->insert_reject_counter($this->ticket->id);
         $this->ticket->status = 'opened';
         $this->ticket->resolution = '';
     } else {
         if ($status == 'Closed') {
             $this->ticket->status = 'closed';
             $this->ticket->closed_at = $current_time;
         } else {
             if ($status == 'Released') {
                 $this->ticket->status = 'released';
             }
         }
     }
     $this->ticket->updated_at = $current_time;
     $success = $this->ticket->save();
     return $this->ticket->status;
 }
Пример #4
0
 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);
     }
 }
Пример #5
0
 public function change_status($status, $input_arr)
 {
     $current_time = date("Y-m-d H:i:s");
     if ($status != 'Opened') {
         $history_arr = array('ticket_id' => $this->ticket->id, 'status' => strtolower($status), 'created_at' => $current_time, 'created_by' => $this->user);
         $history_id = Bll_TicketStatusHistoryBiz::get_instance()->insert_status_history($history_arr);
     }
     if ($status == 'Opened') {
         $this->ticket->owner = $input_arr['owner'];
     } else {
         if ($status == 'Accepted') {
             $this->ticket->owner = $input_arr['owner'];
             $this->ticket->status = 'accepted';
         } else {
             if ($status == 'Closed') {
                 $input_log_reason = array('ticket_id' => $this->ticket->id, 'created_by' => $input_arr['owner'], 'field' => 'reason', 'oldvalue' => $this->ticket->reason, 'newvalue' => $input_arr['reason'], 'created_at' => $current_time);
                 if ($input_log_reason['oldvalue'] != $input_log_reason['newvalue']) {
                     $log_id_reason = Bll_TicketLogBiz::get_instance()->log_add($input_log_reason);
                 }
                 $input_log_reason_detail = array('ticket_id' => $this->ticket->id, 'created_by' => $input_arr['owner'], 'field' => 'reason Description', 'oldvalue' => $this->ticket->reason_detail ? $this->ticket->reason_detail : 'null', 'newvalue' => $input_arr['reason_detail'], 'created_at' => $current_time);
                 if ($input_log_reason_detail['oldvalue'] != $input_log_reason_detail['newvalue']) {
                     $log_id_reason_detail = Bll_TicketLogBiz::get_instance()->log_add($input_log_reason_detail);
                 }
                 $this->ticket->resolution = $input_arr['resolution'];
                 $this->ticket->reason = $input_arr['reason'];
                 $this->ticket->reason_detail = $input_arr['reason_detail'];
                 $this->ticket->closed_at = $current_time;
                 $this->ticket->status = 'closed';
                 $input_log_close = array('ticket_id' => $this->ticket->id, 'created_by' => $input_arr['owner'], 'field' => 'resolution', 'oldvalue' => 'null', 'newvalue' => $this->ticket->resolution, 'created_at' => $current_time);
                 $log_id_close = Bll_TicketLogBiz::get_instance()->log_add($input_log_close);
             }
         }
     }
     $this->ticket->updated_at = $current_time;
     $success = $this->ticket->save();
     return $this->ticket->status;
 }
Пример #6
0
 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);
     }
 }
Пример #7
0
foreach ($tickets as $ticket_id => $ticket) {
    if (empty($ticket)) {
        try {
            $solr->deleteById($ticket_id);
            echo date('c ') . " Delete ok {$ticket_id}\n";
        } catch (Exception $e) {
            echo date('c ') . " Delete failed {$ticket_id}\n";
        }
        continue;
    }
    $reopento = 0;
    $relation = Bll_TicketRelationBiz::get_instance()->find_son_bugs_of_parent($ticket->id);
    if ($relation) {
        $reopento = 1;
    }
    $reject = Bll_TicketLogBiz::get_instance()->get_log($ticket->id);
    $ifreject = 0;
    if ($reject) {
        foreach ($reject as $value) {
            if ($value->rlog === 'Ticket_ActionReject') {
                $ifreject = 1;
            }
        }
    }
    $ticket = Ibug_GlobalFunc::objToArray($ticket);
    #var_dump($ticket['component'],$ticket['department']);
    $_ticket = array("id" => $ticket["id"], "created_at" => intval(strtotime($ticket["created_at"])), "updated_at" => intval(strtotime($ticket["updated_at"])), "closed_at" => intval(strtotime($ticket["closed_at"])), "priority" => $ticket["priority"], "reporter" => $ticket["reporter"], "owner" => $ticket["owner"], "assigned_qa" => $ticket["assigned_qa"], "status" => $ticket["status"], "summary" => $ticket["summary"], "pmt_id" => $ticket["pmt_id"], "environment" => $ticket["environment"], "department" => $ticket["department"], "component" => $ticket["component"], "resolution" => $ticket["resolution"], "is_regression" => intval($ticket["is_regression"]), "is_occasional" => intval($ticket["is_occasional"]), "person_liable" => $ticket["person_liable"], "reason" => $ticket["reason"], "version" => $ticket["version"], "reason_detail" => $ticket["reason_detail"], "description" => $ticket["description"], 'cc' => empty($ticket_ccs[$ticket['id']]) ? null : $ticket_ccs[$ticket['id']], 'reject' => $ifreject, 'reopen' => $reopento);
    try {
        $solr->addDocument($_ticket);
        echo date('c ') . " AddDocument ok {$ticket['id']}\n";
    } catch (Exception $e) {
Пример #8
0
 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';
 }
Пример #9
0
 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';
 }
Пример #10
0
apf_require_class('Bll_TicketLogBiz');
apf_require_class('Bll_MailBiz');
apf_require_class('Bll_TicketBiz');
apf_require_class('Bll_TicketCcBiz');
apf_require_class('Bll_UserBiz');
apf_require_class('SMTP');
apf_require_class('Template');
apf_require_class('Util_StringUtils');
$mails = Bll_MailBiz::get_instance()->mail_read();
if ($mails) {
    foreach ($mails as $key => $mail) {
        $ticket_id = $mail->ticket_id;
        $ticket_detail = Bll_TicketBiz::get_instance()->get_detail($ticket_id);
        $time = $mail->created_at;
        $log_arr = Bll_TicketLogBiz::get_instance()->get_log_by_id_time($ticket_id, $time);
        //it is an obj for msg
        $mail_to_reporter = Bll_TicketBiz::get_instance()->get_reporter_for_mail($ticket_id);
        $reporter_address = Bll_UserBiz::get_instance()->get_mail_address_by_username($mail_to_reporter);
        $mail_to_owner = Bll_TicketBiz::get_instance()->get_owner_for_mail($ticket_id);
        $tmp = explode(';', $mail_to_owner);
        $mail_to_owner = $tmp[0];
        $owner_address = Bll_UserBiz::get_instance()->get_mail_address_by_username($mail_to_owner);
        $mail_to_qa = Bll_TicketBiz::get_instance()->get_assign_qa_for_mail($ticket_id);
        $tmp = explode(';', $mail_to_qa);
        $mail_to_qa = $tmp[0];
        $qa_address = Bll_UserBiz::get_instance()->get_mail_address_by_username($mail_to_qa);
        $mail_to_cc_str = Bll_TicketCcBiz::get_instance()->get_cc_for_mail($ticket_id);
        //string such as bai;jian;
        $mail_to_ccs = explode(';', $mail_to_cc_str);
        //cc users array