示例#1
0
 function doSplitMessageAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     if (null == ($orig_message = DAO_Ticket::getMessage($id))) {
         return;
     }
     if (null == ($orig_headers = $orig_message->getHeaders())) {
         return;
     }
     if (null == ($orig_ticket = DAO_Ticket::getTicket($orig_message->ticket_id))) {
         return;
     }
     if (null == ($messages = DAO_Ticket::getMessagesByTicket($orig_message->ticket_id))) {
         return;
     }
     // Create a new ticket
     $new_ticket_mask = CerberusApplication::generateTicketMask();
     $new_ticket_id = DAO_Ticket::createTicket(array(DAO_Ticket::CREATED_DATE => $orig_message->created_date, DAO_Ticket::UPDATED_DATE => $orig_message->created_date, DAO_Ticket::CATEGORY_ID => $orig_ticket->category_id, DAO_Ticket::FIRST_MESSAGE_ID => $orig_message->id, DAO_Ticket::FIRST_WROTE_ID => $orig_message->address_id, DAO_Ticket::LAST_WROTE_ID => $orig_message->address_id, DAO_Ticket::LAST_ACTION_CODE => CerberusTicketActionCode::TICKET_OPENED, DAO_Ticket::IS_CLOSED => CerberusTicketStatus::OPEN, DAO_Ticket::IS_DELETED => 0, DAO_Ticket::MASK => $new_ticket_mask, DAO_Ticket::SUBJECT => isset($orig_headers['subject']) ? $orig_headers['subject'] : $orig_ticket->subject, DAO_Ticket::TEAM_ID => $orig_ticket->team_id));
     // [TODO] SLA?
     // Copy all the original tickets requesters
     $orig_requesters = DAO_Ticket::getRequestersByTicket($orig_ticket->id);
     foreach ($orig_requesters as $orig_req_id => $orig_req_addy) {
         DAO_Ticket::createRequester($orig_req_id, $new_ticket_id);
     }
     // Pull the message off the ticket (reparent)
     unset($messages[$orig_message->id]);
     DAO_Message::update($orig_message->id, array(DAO_Message::TICKET_ID => $new_ticket_id));
     //[mdf] [CHD-979] The ticket id is also in the message_header table, so update those too
     $message_headers = DAO_MessageHeader::getAll($orig_message->id);
     foreach ($message_headers as $hk => $hv) {
         DAO_MessageHeader::create($orig_message->id, $new_ticket_id, $hk, $hv);
     }
     // Reindex the original ticket (last wrote, etc.)
     $last_message = end($messages);
     /* @var CerberusMessage $last_message */
     DAO_Ticket::updateTicket($orig_ticket->id, array(DAO_Ticket::LAST_WROTE_ID => $last_message->address_id));
     // Remove requester if they don't still have messages on the original ticket
     reset($messages);
     $found = false;
     if (is_array($messages)) {
         foreach ($messages as $msgid => $msg) {
             if ($msg->address_id == $orig_message->address_id) {
                 $found = true;
                 break;
             }
         }
     }
     if (!$found) {
         DAO_Ticket::deleteRequester($orig_ticket->id, $orig_message->address_id);
     }
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('display', $new_ticket_mask)));
 }
示例#2
0
 function setCustomerAccountNumberAction()
 {
     $db = DevblocksPlatform::getDatabaseService();
     @($account_number = DevblocksPlatform::importGPC($_REQUEST['acc_num'], 'string', ''));
     @($m_id = DevblocksPlatform::importGPC($_REQUEST['m_id'], 'string', ''));
     // Now Confirm the account exists and is active
     $account = array_shift(DAO_CustomerAccount::getWhere(sprintf("%s = %d AND %s = '0' ", DAO_CustomerAccount::ACCOUNT_NUMBER, $account_number, DAO_CustomerAccount::IS_DISABLED)));
     if (!isset($account)) {
         return;
     }
     $message_obj = DAO_Message::get($m_id);
     if (!isset($message_obj)) {
         return;
     }
     $fields = get_object_vars($message_obj);
     $fields[DAO_Message::ACCOUNT_ID] = $account->id;
     $fields[DAO_Message::IMPORT_STATUS] = 0;
     // Requeue
     $m_status = DAO_Message::update($m_id, $fields);
     // Give plugins a chance to note a message is assigned
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('message.account.assign', array('account_id' => $account->id, 'message_id' => $m_id)));
     echo json_encode($fields);
 }
示例#3
0
 function importInQueueReProcessMessage($id)
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $logger->info("[Message] Reprocessing message ID: " . $id);
     $message = DAO_Message::get($id);
     $status = $this->_createMessageRecipient($message->account_id, $id, $message->message);
     $fields = get_object_vars($message);
     if ($status) {
         $logger->info("[Message Import] Status set to: Complete");
         $fields[DAO_Message::IMPORT_STATUS] = 2;
         // 0 = In Queus, 1 = Failure, 2 = Complete
     } else {
         $logger->info("[Message Import] Status set to: Failure");
         $fields[DAO_Message::IMPORT_STATUS] = 1;
         // 0 = In Queus, 1 = Failure, 2 = Complete
     }
     $mr_status = DAO_Message::update($id, $fields);
 }
示例#4
0
文件: message.php 项目: rmiddle/feg
 function doBulkUpdate($filter, $do, $ids = array())
 {
     @set_time_limit(0);
     $change_fields = array();
     $custom_fields = array();
     // Make sure we have actions
     if (empty($do)) {
         return;
     }
     // Make sure we have checked items if we want a checked list
     if (0 == strcasecmp($filter, "checks") && empty($ids)) {
         return;
     }
     if (is_array($do)) {
         foreach ($do as $k => $v) {
             switch ($k) {
                 //			$change_fields[DAO_Message::ID] = intval($v);
                 //			$change_fields[DAO_Message::ACCOUNT_ID] = intval($v);
                 //			$change_fields[DAO_Message::CREATED_DATE] = intval($v);
                 //			$change_fields[DAO_Message::UPDATED_DATE] = intval($v);
                 //			$change_fields[DAO_Message::MESSAGE] = intval($v);
                 //			$change_fields[DAO_Message::PARAMS_JSON] = intval($v);
                 //			$change_fields[DAO_Message::PARAMS] = intval($v);
                 // [TODO] Implement actions
                 case 'example':
                     //$change_fields[DAO_Message::EXAMPLE] = 'some value';
                     break;
                 default:
                     // Custom fields
                     if (substr($k, 0, 3) == "cf_") {
                         $custom_fields[substr($k, 3)] = $v;
                     }
             }
         }
     }
     $pg = 0;
     if (empty($ids)) {
         do {
             list($objects, $null) = DAO_Message::search($this->params, 100, $pg++, SearchFields_Message::ID, true, false);
             $ids = array_merge($ids, array_keys($objects));
         } while (!empty($objects));
     }
     $batch_total = count($ids);
     for ($x = 0; $x <= $batch_total; $x += 100) {
         $batch_ids = array_slice($ids, $x, 100);
         DAO_Message::update($batch_ids, $change_fields);
         // Custom Fields
         self::_doBulkSetCustomFields(FegCustomFieldSource_Message::ID, $custom_fields, $batch_ids);
         unset($batch_ids);
     }
     unset($ids);
 }
示例#5
0
文件: customer.php 项目: rmiddle/feg
 function setMessageStatusAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     @($status = DevblocksPlatform::importGPC($_REQUEST['status'], 'integer', 0));
     @($goto_recent = DevblocksPlatform::importGPC($_REQUEST['goto_recent'], 'integer', 0));
     $message_obj = DAO_Message::get($id);
     $fields = get_object_vars($message_obj);
     $fields[DAO_Message::IMPORT_STATUS] = $status;
     $mr_status = DAO_Message::update($id, $fields);
     // Give plugins a chance to note a message is imported.
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('message.status', array('message_id' => $id, 'account_id' => $message_obj->account_id, 'import_status' => $status)));
     $status_text = $translate->_('feg.message.import_status_' . $status);
     if ($status_text == "") {
         $status_text = $translate->_('feg.message_recipient.status_unknown');
     }
     echo $status_text;
 }