Ejemplo n.º 1
0
 public function handle_request_internal()
 {
     $isAllowIp = self::is_allow_call_api();
     if (!$isAllowIp) {
         $ret = Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
     }
     if (!isset($this->_params["toPhone"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PARAM_MISS);
     }
     if (!isset($this->_params["msg"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PARAM_MISS);
     }
     $mobile = (int) $this->_params["toPhone"];
     $msg = Util_StringUtils::truncate($this->_params["msg"], 18, '...');
     $ret = array('status' => 'ok', 'data' => 'success');
     if (1 == $this->_params["chatFlag"]) {
         if (!isset($this->_params["userMobile"])) {
             return Util_MobileAPI::error(Const_APIStatus::E_PARAM_MISS);
         }
         $downloadUrl = 'http://t.anjuke.com/swzZMCV';
         $msg = '"' . $msg . '",安居客用户' . substr($this->_params["userMobile"], 0, 3) . '****' . substr($this->_params["userMobile"], 7) . '找您,与TA聊天,请安装经纪人APP:' . $downloadUrl;
         //更新经纪人微聊表发送短信数目
         $chatInfo = Model_Mobile_BrokerChatInfo::getBrokerByPhone($mobile, array('brokerId', 'phone', 'sendMsgNum', 'isActived'));
         if ($chatInfo) {
             $brokerId = $chatInfo['brokerId'];
             if ($chatInfo['sendMsgNum'] < 10 && 0 == $chatInfo['isActived']) {
                 //更新经纪人微聊信息表的数据
                 $updateData['brokerId'] = $chatInfo['brokerId'];
                 $updateData['sendMsgNum'] = $chatInfo['sendMsgNum'] + 1;
                 $updateData['updateTime'] = time();
                 Model_Mobile_BrokerChatInfo::updateChatInfo($chatInfo['brokerId'], $updateData);
             } else {
                 return $ret;
             }
         } else {
             return Util_MobileAPI::error(Const_APIStatus::E_BROKER_CHAT_NOT_EXISIT);
         }
     }
     //发送短信
     $business_id = SMS_API::BROKER_APP_MSG_CODE;
     $sms_api = SMS_API::get_instance();
     $sms_api->send($mobile, $msg, $business_id, $brokerId);
     return $ret;
 }
Ejemplo n.º 2
0
 /**
  * @param string $content 要过滤的内容,字符串
  * @param string $replace 违禁词替换为*号
  * @return mixed|string
  */
 public function exec($content, $replace = '*')
 {
     $filter = false;
     $content = str_replace(array("\r", "\n"), "", $content);
     if (class_exists('ZMQContext')) {
         $data = Util_StringUtils::patternsMatcher('stringmatch/stringMatchService/search', array($content), 500, false, 'multi_string_filter_host');
     } else {
         $data['status'] = 100;
     }
     if ($data['status'] == 200) {
         $filter = true;
         foreach ($data['reply'] as $v) {
             $content = str_replace($v[0], str_repeat($replace, mb_strlen($v[0], 'UTF-8')), $content);
         }
     }
     if (!$filter) {
         $content = $this->replace($content, $replace);
     }
     return $content;
 }
Ejemplo n.º 3
0
 public function process_cc_users($cc_arr)
 {
     $whole_arr = array();
     $custom_arr = array();
     $user_arr = array();
     $cc_users = array();
     foreach ($cc_arr as $row) {
         if (Util_StringUtils::is_email($row)) {
             $custom_arr[] = $row;
         } else {
             $whole_arr[] = $row;
         }
     }
     if (!empty($whole_arr)) {
         $user_arr = $this->get_usernames_by_wholenames($whole_arr);
     }
     $cc_users = array_merge($user_arr, $custom_arr);
     return $cc_users;
 }
Ejemplo n.º 4
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';
 }
Ejemplo n.º 5
0
 $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;
             }
         }
     }
 }
 $cc_to = implode(',', $ccs_address);
 $smtp_server = APF::get_instance()->get_config('smtp_server');
 $smtp_port = APF::get_instance()->get_config('smtp_port');
 $smtp_user = APF::get_instance()->get_config('smtp_user');
 $smtp_pass = APF::get_instance()->get_config('smtp_pass');
 $smtp_usermail = APF::get_instance()->get_config('smtp_usermail');