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); }
function ExportSnpp(Model_ExportType $export_type) { $logger = DevblocksPlatform::getConsoleLog(); $db = DevblocksPlatform::getDatabaseService(); @($snpp_current_hour = 0); @($snpp_sent_today = 0); $memory_limit = ini_get('memory_limit'); if (substr($memory_limit, 0, -1) < 128) { @ini_set('memory_limit', '128M'); } @set_time_limit(0); // Unlimited (if possible) $logger->info("[SNPP Exporter] Overloaded memory_limit to: " . ini_get('memory_limit')); $logger->info("[SNPP Exporter] Overloaded max_execution_time to: " . ini_get('max_execution_time')); $timeout = ini_get('max_execution_time'); $runtime = microtime(true); $sql = sprintf("SELECT mr.id " . "FROM message_recipient mr " . "inner join customer_recipient cr on mr.recipient_id = cr.id " . "WHERE mr.send_status in (0,3,4) " . "AND cr.is_disabled = 0 " . "AND cr.export_type = %d " . "AND cr.type = 2 ", $export_type->id); $rs = $db->Execute($sql); // Loop though pending outbound emails. while ($row = mysql_fetch_assoc($rs)) { $id = $row['id']; $logger->info("[SNPP Exporter] Procing MR ID: " . $id); $message_recipient = DAO_MessageRecipient::get($id); $message = DAO_Message::get($message_recipient->message_id); $message_lines = explode('\\n', substr($message->message, 1, -1)); $recipient = DAO_CustomerRecipient::get($message_recipient->recipient_id); $message_str = substr(implode("", $message_lines), 0, 160); // FIXME - Need to add in filter for now everything is unfiltered. // sendSnpp($phone_number, $message, $snpp_server="ann100sms01.answernet.com", $port=444) $send_status = FegSnpp::sendSnpp($recipient->address, $message_str); $logger->info("[SNPP Exporter] Send Status: " . ($send_status ? "Successful" : "Failure")); // Give plugins a chance to run export $eventMgr = DevblocksPlatform::getEventService(); $eventMgr->trigger(new Model_DevblocksEvent('cron.send.snpp', array('recipient' => $recipient, 'message' => $message, 'message_lines' => $message_lines, 'message_recipient' => $message_recipient, 'send_status' => $send_status))); if ($send_status) { $snpp_current_hour++; $snpp_sent_today++; } $fields = array(DAO_MessageRecipient::SEND_STATUS => $send_status ? 2 : 1, DAO_MessageRecipient::CLOSED_DATE => $send_status ? time() : 0); DAO_MessageRecipient::update($id, $fields); } mysql_free_result($rs); if ($snpp_current_hour) { $current_fields = DAO_Stats::get(0); $fields = array(DAO_Stats::SNPP_CURRENT_HOUR => $current_fields->snpp_current_hour + $snpp_current_hour, DAO_Stats::SNPP_SENT_TODAY => $current_fields->snpp_sent_today + $snpp_sent_today); DAO_Stats::update(0, $fields); } return NULL; }
function showMessageRecipientFailurePeekAction() { @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0)); @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $tpl->assign('id', $id); $tpl->assign('view_id', $view_id); $message_recipient = DAO_MessageRecipient::get($id); $tpl->assign('message_recipient', $message_recipient); $message = DAO_Message::get($message_recipient->message_id); $tpl->assign('message', $message); $message_lines = explode("\n", substr($message->message, 1, -1)); $tpl->assign('message_lines', $message_lines); $tpl->display('file:' . $this->_TPL_PATH . 'stats/message_recipient/failed_recipient.tpl'); }
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; }