예제 #1
0
 public static function &get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #2
0
}
$logs = Bll_TicketLogBiz::get_instance()->get_ticket_ids_great_than_id($id, 500);
if (empty($logs)) {
    echo date('c ') . "No tickets to update\n";
    exit(0);
}
$ticket_ids = array();
foreach ($logs as $ticket_log) {
    $ticket_ids[] = $ticket_log->ticket_id;
}
$id = $ticket_log->id;
$dao = Model_Ticket::data_access();
$ticket_ids = array_unique($ticket_ids);
$tickets = $dao->find_by_pks($ticket_ids);
$tickets = Bll_TicketBiz::get_instance()->process_solr_field($tickets);
$_ticket_ccs = Bll_TicketCcBiz::get_instance()->get_ticket_cc_by_ticket_ids($ticket_ids);
$ticket_ccs = array();
if (!empty($_ticket_ccs)) {
    foreach ($_ticket_ccs as $_ticket_cc) {
        $ticket_ccs[$_ticket_cc->ticket_id][] = $_ticket_cc->cc_to;
    }
}
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;
예제 #3
0
파일: Detail.php 프로젝트: emilymwang8/ibug
 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';
 }
예제 #4
0
 public function ticket_add($input_arr)
 {
     $current_time = date("Y-m-d H:i:s");
     $ticket = new Model_Ticket();
     $ticket->created_at = $current_time;
     $ticket->updated_at = $current_time;
     $ticket->priority = $input_arr['priority'];
     $ticket->emergency = $input_arr['emergency'];
     $ticket->reporter = $input_arr['reporter'];
     $ticket->owner = $input_arr['owner'];
     $ticket->assigned_qa = $input_arr['assigned_qa'];
     $ticket->status = $input_arr['status'];
     $ticket->summary = $input_arr['summary'];
     $ticket->pmt_id = $input_arr['pmt_id'];
     $ticket->environment = $input_arr['environment'];
     $ticket->department = $input_arr['department'];
     $ticket->component = $input_arr['component'];
     $ticket->is_regression = isset($input_arr['is_regression']) ? $input_arr['is_regression'] : '0';
     $ticket->version = $input_arr['version'];
     $ticket->description = $input_arr['description'];
     $ticket->is_occasional = isset($input_arr['is_occasional']) ? $input_arr['is_occasional'] : '0';
     $ticket->person_liable = $input_arr['person_liable'];
     $ticket->resolution = '';
     $ticket->reason = '';
     $ticket->reason_detail = '';
     $ticket->save();
     $ticket_id = $ticket->id;
     //add cc
     $cc_arr_whole = explode(';', $input_arr['cc_user']);
     $cc_arr_user = Bll_UserBiz::get_instance()->process_cc_users($cc_arr_whole);
     if ($input_arr['component']) {
         $owner = Bll_DdComponentBiz::get_instance()->get_owner_by_id($input_arr['component']);
         if ($owner) {
             $owner_arr = explode(";", $owner);
             foreach ($owner_arr as $row) {
                 if ($row) {
                     $cc_arr_user[] = $row;
                 }
             }
         }
     }
     $custom_cc = APF::get_instance()->get_config('custom_cc');
     foreach ($custom_cc as $c) {
         if (count(array_intersect($c['environment'], array($ticket->environment, '0'))) > 0 && in_array($c['priority'], array($ticket->priority, '0')) && in_array($c['component'], array($ticket->component, '0')) && count(array_intersect($c['department'], array($ticket->department, '0'))) > 0) {
             foreach ($c['cc'] as $crow) {
                 $cc_arr_user[] = $crow;
             }
         }
     }
     $custom_p01cc = APF::get_instance()->get_config('custom_p01cc');
     if ($ticket->priority == 11 || $ticket->priority == 7 || $ticket->priority == 80) {
         if ($ticket->environment == 19) {
             foreach ($custom_p01cc as $c) {
                 $cc_arr_user[] = $c;
             }
         }
     }
     $cc_arr_user = array_unique($cc_arr_user);
     $add = Bll_TicketCcBiz::get_instance()->cc_user_add($ticket_id, $cc_arr_user);
     return $ticket_id;
 }
예제 #5
0
 $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
 $ccs_address = array();
 foreach ($mail_to_ccs as $key => $mail_to_cc) {
     if ($mail_to_cc) {
         if (Util_StringUtils::is_email($mail_to_cc)) {
             $ccs_address[$key] = $mail_to_cc;
         } else {
             $cc_tmp = Bll_UserBiz::get_instance()->get_mail_address_by_username($mail_to_cc);
             if ($cc_tmp) {
                 $ccs_address[$key] = $cc_tmp;
             }
         }
     }