function saveMessageRecipientFailurePeekAction() { @($id = DevblocksPlatform::importGPC($_POST['id'], 'integer')); @($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string')); @($retry = DevblocksPlatform::importGPC($_POST['retry'], 'integer', 0)); $fields = array(DAO_MessageRecipient::SEND_STATUS => $retry); $status = DAO_MessageRecipient::update($id, $fields); if (!empty($view_id)) { $view = Feg_AbstractViewLoader::getView($view_id); $view->render(); } //DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup','workers'))); }
function setMessageRecipientStatusAction() { $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)); $objects = DAO_MessageRecipient::get($id); $fields = get_object_vars($objects); $fields[DAO_MessageRecipient::SEND_STATUS] = $status; $status = DAO_MessageRecipient::update($id, $fields); // Give plugins a chance to note a message is imported. $eventMgr = DevblocksPlatform::getEventService(); $eventMgr->trigger(new Model_DevblocksEvent('message.recipient.status', array('message_recipient_id' => $id, 'recipient_id' => $fields['recipient_id'], 'message_id' => $fields['message_id'], 'account_id' => $fields['account_id'], 'send_status' => $fields['send_status']))); $status_text = $translate->_('feg.message_recipient.status_' . $fields['send_status']); if ($status_text == "") { $status_text = $translate->_('feg.message_recipient.status_unknown'); } echo $status_text; }
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 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) { // [TODO] Used for bulk update // $change_fields[DAO_MessageRecipient::ID] = intval($v); // $change_fields[DAO_MessageRecipient::RECIPIENT_ID] = intval($v); // $change_fields[DAO_MessageRecipient::MESSAGE_ID] = intval($v); // $change_fields[DAO_MessageRecipient::ACCOUNT_ID] = intval($v); // $change_fields[DAO_MessageRecipient::SEND_STATUS] = intval($v); // $change_fields[DAO_MessageRecipient::FAX_ID] = intval($v); // $change_fields[DAO_MessageRecipient::UPDATED_DATE] = intval($v); // $change_fields[DAO_MessageRecipient::CLOSED_DATE] = intval($v); // [TODO] Implement actions case 'example': //$change_fields[DAO_MessageRecipient::EXAMPLE] = 'some value'; break; default: } } } $pg = 0; if (empty($ids)) { do { list($objects, $null) = DAO_MessageRecipient::search($this->params, 100, $pg++, SearchFields_MessageRecipient::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_MessageRecipient::update($batch_ids, $change_fields); // Custom Fields self::_doBulkSetCustomFields(FegCustomFieldSource_MessageRecipient::ID, $custom_fields, $batch_ids); unset($batch_ids); } unset($ids); }