function render() { $active_worker = FegApplication::getActiveWorker(); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->tpl_path); $response = DevblocksPlatform::getHttpResponse(); $stack = $response->path; array_shift($stack); // reports @($reportId = array_shift($stack)); $report = null; // We're given a specific report to display if (!empty($reportId)) { if (null != ($reportMft = DevblocksPlatform::getExtension($reportId))) { // Make sure we have a report group if (null == ($report_group_mft_id = $reportMft->params['report_group'])) { return; } // Make sure the report group exists if (null == ($report_group_mft = DevblocksPlatform::getExtension($report_group_mft_id))) { return; } // Check our permissions on the parent report group before rendering the report if (isset($report_group_mft->params['acl']) && !$active_worker->hasPriv($report_group_mft->params['acl'])) { return; } // Render if (null != ($report = $reportMft->createInstance()) && $report instanceof Extension_Report) { /* @var $report Extension_Report */ $report->render(); return; } } } // If we don't have a selected report yet if (empty($report)) { // Organize into report groups $report_groups = array(); $reportGroupMfts = DevblocksPlatform::getExtensions('feg.report.group', false); // [TODO] Alphabetize groups and nested reports // Load report groups if (!empty($reportGroupMfts)) { foreach ($reportGroupMfts as $reportGroupMft) { $report_groups[$reportGroupMft->id] = array('manifest' => $reportGroupMft, 'reports' => array()); } } $reportMfts = DevblocksPlatform::getExtensions('feg.report', false); // Load reports and file them under groups according to manifest if (!empty($reportMfts)) { foreach ($reportMfts as $reportMft) { $report_group = $reportMft->params['report_group']; if (isset($report_group)) { $report_groups[$report_group]['reports'][] = $reportMft; } } } $tpl->assign('report_groups', $report_groups); } $tpl->display('file:' . $this->tpl_path . '/reports/index.tpl'); }
function render() { $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $active_worker = FegApplication::getActiveWorker(); $visit = FegApplication::getVisit(); $response = DevblocksPlatform::getHttpResponse(); $translate = DevblocksPlatform::getTranslationService(); $url = DevblocksPlatform::getUrlService(); $stack = $response->path; @array_shift($stack); // customer @($customer_id = array_shift($stack)); @($customer = DAO_CustomerAccount::get($customer_id)); if (empty($customer)) { echo "<H1>" . $translate->_('customer.display.invalid_customer') . "</H1>"; return; } $tpl->assign('customer_id', $customer_id); // Tabs $tab_manifests = DevblocksPlatform::getExtensions('feg.customer.tab', false); $tpl->assign('tab_manifests', $tab_manifests); @($tab_selected = array_shift($stack)); if (empty($tab_selected)) { $tab_selected = 'property'; } $tpl->assign('tab_selected', $tab_selected); switch ($tab_selected) { case 'property': @($tab_parm = array_shift($stack)); break; } // ====== Who's Online $whos_online = DAO_Worker::getAllOnline(); if (!empty($whos_online)) { $tpl->assign('whos_online', $whos_online); $tpl->assign('whos_online_count', count($whos_online)); } $tpl->display('file:' . $this->_TPL_PATH . 'customer/index.tpl'); }
function saveLicensesAction() { $translate = DevblocksPlatform::getTranslationService(); $settings = DevblocksPlatform::getPluginSettingsService(); $worker = FegApplication::getActiveWorker(); if (!$worker || !$worker->is_superuser) { echo $translate->_('common.access_denied'); return; } @($name = DevblocksPlatform::importGPC($_POST['company_name'], 'string', '')); @($serial = DevblocksPlatform::importGPC($_POST['company_serial'], 'string', '')); @($email = DevblocksPlatform::importGPC($_POST['email'], 'string', '')); @($do_delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0)); if (!empty($do_delete)) { $settings->set('feg.core', FegSettings::LICENSE, ''); DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings'))); return; } if (empty($name) || empty($serial) || empty($email)) { DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings', 'empty'))); return; } if (null == ($valid = FegLicense::validate($name, $serial, $email)) || 5 != count($valid)) { DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings', 'invalid'))); return; } /* * [IMPORTANT -- Yes, this is simply a line in the sand.] * You're welcome to modify the code to meet your needs, but please respect * our licensing. Buy a legitimate copy to help support the project! * http://feg.answernet.com/ */ $license = $valid; $settings->set('feg.core', FegSettings::LICENSE, serialize($license)); DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings'))); }
public function writeResponse(DevblocksHttpResponse $response) { $path = $response->path; // [JAS]: Ajax? // [TODO] Explore outputting whitespace here for Safari // if(empty($path)) // return; $tpl = DevblocksPlatform::getTemplateService(); $session = DevblocksPlatform::getSessionService(); $settings = DevblocksPlatform::getPluginSettingsService(); $translate = DevblocksPlatform::getTranslationService(); $active_worker = FegApplication::getActiveWorker(); $visit = $session->getVisit(); $page_manifests = $this->_getAllowedPages(); $controller = array_shift($path); // Default page [TODO] This is supposed to come from framework.config.php if (empty($controller)) { $controller = 'preferences'; } // [JAS]: Require us to always be logged in for Feg pages if (empty($visit) && 0 != strcasecmp($controller, 'login')) { $query = array(); if (!empty($response->path)) { $query = array('url' => urlencode(implode('/', $response->path))); } DevblocksPlatform::redirect(new DevblocksHttpRequest(array('login'), $query)); } $page_id = $this->_getPageIdByUri($controller); @($page = DevblocksPlatform::getExtension($page_id, true)); /* @var $page FegPageExtension */ if (empty($page)) { header("Status: 404"); return; // [TODO] 404 } // [JAS]: Listeners (Step-by-step guided tour, etc.) $listenerManifests = DevblocksPlatform::getExtensions('devblocks.listener.http'); foreach ($listenerManifests as $listenerManifest) { /* @var $listenerManifest DevblocksExtensionManifest */ $inst = $listenerManifest->createInstance(); /* @var $inst DevblocksHttpRequestListenerExtension */ $inst->run($response, $tpl); } $tpl->assign('active_worker', $active_worker); $tour_enabled = false; if (!empty($visit) && !is_null($active_worker)) { $tour_enabled = intval(DAO_WorkerPref::get($active_worker->id, 'assist_mode', 1)); $keyboard_shortcuts = intval(DAO_WorkerPref::get($active_worker->id, 'keyboard_shortcuts', 1)); $tpl->assign('pref_keyboard_shortcuts', $keyboard_shortcuts); // $active_worker_memberships = $active_worker->getMemberships(); // $tpl->assign('active_worker_memberships', $active_worker_memberships); $unread_notifications = DAO_WorkerEvent::getUnreadCountByWorker($active_worker->id); $tpl->assign('active_worker_notify_count', $unread_notifications); DAO_Worker::logActivity($active_worker->id, $page->getActivity()); } $tpl->assign('tour_enabled', $tour_enabled); // [JAS]: Variables provided to all page templates $tpl->assign('settings', $settings); $tpl->assign('session', $_SESSION); $tpl->assign('translate', $translate); $tpl->assign('visit', $visit); $tpl->assign('license', FegLicense::getInstance()); $tpl->assign('page_manifests', $page_manifests); $tpl->assign('page', $page); $tpl->assign('response_uri', implode('/', $response->path)); $core_tpl = APP_PATH . '/features/feg.core/templates/'; $tpl->assign('core_tpl', $core_tpl); // Prebody Renderers $preBodyRenderers = DevblocksPlatform::getExtensions('feg.renderer.prebody', true); if (!empty($preBodyRenderers)) { $tpl->assign('prebody_renderers', $preBodyRenderers); } // Postbody Renderers $postBodyRenderers = DevblocksPlatform::getExtensions('feg.renderer.postbody', true); if (!empty($postBodyRenderers)) { $tpl->assign('postbody_renderers', $postBodyRenderers); } // Timings $tpl->assign('render_time', microtime(true) - DevblocksPlatform::getStartTime()); if (function_exists('memory_get_usage') && function_exists('memory_get_peak_usage')) { $tpl->assign('render_memory', memory_get_usage() - DevblocksPlatform::getStartMemory()); $tpl->assign('render_peak_memory', memory_get_peak_usage() - DevblocksPlatform::getStartPeakMemory()); } $tpl->display($core_tpl . 'border.tpl'); // $cache = DevblocksPlatform::getCacheService(); // $cache->printStatistics(); }
/** * Enter description here... * * @param string $class Feg_AbstractView * @param string $view_label ID * @return Feg_AbstractView instance */ static function getView($view_label, Feg_AbstractViewModel $defaults = null) { $active_worker = FegApplication::getActiveWorker(); if (is_null(self::$views)) { self::_init(); } if (self::exists($view_label)) { $model = self::$views[$view_label]; return self::unserializeAbstractView($model); } else { // See if the worker has their own saved prefs @($prefs = unserialize(DAO_WorkerPref::get($active_worker->id, 'view' . $view_label))); // Sanitize if (!empty($prefs) && $prefs instanceof Feg_AbstractViewModel && !empty($prefs->class_name)) { if (!class_exists($prefs->class_name)) { DAO_WorkerPref::delete($active_worker->id, 'view' . $view_label); } $prefs = null; } // If no worker prefsd, check if we're passed defaults if (!$prefs instanceof Feg_AbstractViewModel && !empty($defaults)) { $prefs = $defaults; } // Create a default view if it doesn't exist if ($prefs instanceof Feg_AbstractViewModel) { if (!empty($prefs->class_name) && class_exists($prefs->class_name)) { $view = new $prefs->class_name(); $view->id = $view_label; if (!empty($prefs->view_columns)) { $view->view_columns = $prefs->view_columns; } if (!empty($prefs->renderLimit)) { $view->renderLimit = $prefs->renderLimit; } if (null !== $prefs->renderSortBy) { $view->renderSortBy = $prefs->renderSortBy; } if (null !== $prefs->renderSortAsc) { $view->renderSortAsc = $prefs->renderSortAsc; } self::setView($view_label, $view); return $view; } } } return null; }
static function shouldLoadExtension(DevblocksExtensionManifest $extension_manifest) { // Always allow core if ("feg.core" == $extension_manifest->plugin_id) { return true; } // [TODO] This should limit to just things we can run with no session // Community Tools, Cron/Update. They are still limited by their own // isVisible() otherwise. if (null == ($active_worker = FegApplication::getActiveWorker())) { return true; } // [TODO] ACL //return $active_worker->hasPriv('plugin.'.$extension_manifest->plugin_id); return true; }
function createNewCustomerAction() { $active_worker = FegApplication::getActiveWorker(); @($account_number = DevblocksPlatform::importGPC($_REQUEST['account_name'], 'string', '')); @($message_id = DevblocksPlatform::importGPC($_REQUEST['message_id'], 'integer', 0)); if (!$active_worker->hasPriv('core.access.customer.create')) { return; } if (empty($account_number)) { $fields = array(DAO_CustomerAccount::IMPORT_SOURCE => 0, DAO_CustomerAccount::ACCOUNT_NAME => "", DAO_CustomerAccount::ACCOUNT_NUMBER => "", DAO_CustomerAccount::IS_DISABLED => 1); } else { $fields = array(DAO_CustomerAccount::IMPORT_SOURCE => 0, DAO_CustomerAccount::ACCOUNT_NAME => "Customer # " . $account_number, DAO_CustomerAccount::ACCOUNT_NUMBER => $account_number, DAO_CustomerAccount::IS_DISABLED => 1); } // Create a new Customer Recipients $account_id = DAO_CustomerAccount::create($fields); if ($message_id > 0) { ImportCron::importAccountReProcessMessage($message_id, $account_id); } // DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('customer', $customer_id,'property'))); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('customer', $account_id, 'property'))); }
function showAccountFormatFailurePeekAction() { $active_worker = FegApplication::getActiveWorker(); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0)); @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); $tpl->assign('id', $id); $tpl->assign('view_id', $view_id); $message = DAO_Message::get($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/failed_format.tpl'); }
function signoutAction() { $session = DevblocksPlatform::getSessionService(); $visit = $session->getVisit(); if (null != ($worker = FegApplication::getActiveWorker())) { DAO_Worker::logActivity($worker->id, new Model_Activity(null)); } $session->clear(); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login'))); }
function doStopTourAction() { // $request = DevblocksPlatform::getHttpRequest(); $worker = FegApplication::getActiveWorker(); DAO_WorkerPref::set($worker->id, 'assist_mode', 0); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('preferences'))); // DevblocksPlatform::redirect(new DevblocksHttpResponse($request->path, $request->query)); }
function saveAddLanguagePanelAction() { $active_worker = FegApplication::getActiveWorker(); // Make sure we're an active worker if (empty($active_worker) || empty($active_worker->id)) { return; } $codes = DAO_Translation::getDefinedLangCodes(); @($add_lang_code = DevblocksPlatform::importGPC($_REQUEST['add_lang_code'], 'string', '')); @($copy_lang_code = DevblocksPlatform::importGPC($_REQUEST['copy_lang_code'], 'string', '')); @($del_lang_ids = DevblocksPlatform::importGPC($_REQUEST['del_lang_ids'], 'array', array())); if (!empty($del_lang_ids)) { if (is_array($del_lang_ids)) { foreach ($del_lang_ids as $lang_id) { DAO_Translation::deleteByLangCodes($lang_id); } } } // Don't add blanks or the same language twice. if (!empty($add_lang_code) && !isset($codes[$add_lang_code])) { // English reference strings (to know our scope) $english_strings = DAO_Translation::getMapByLang('en_US'); $copy_strings = array(); // If we have a desired source language for defaults, load it. if (!empty($copy_lang_code)) { if (0 == strcasecmp('en_US', $copy_lang_code)) { $copy_strings = $english_strings; } else { $copy_strings = DAO_Translation::getMapByLang($copy_lang_code); } } // Loop through English strings for new language if (is_array($english_strings)) { foreach ($english_strings as $string_id => $src_en) { /* @var $src_en Model_Translation */ $override = ''; // If we have a valid source, copy its override or its default (in that order) @($copy_string = $copy_strings[$string_id]); if (is_a($copy_string, 'Model_Translation')) { $override = !empty($copy_string->string_override) ? $copy_string->string_override : $copy_string->string_default; } // Insert the new string as an override. Only official translations are defaults $fields = array(DAO_Translation::STRING_ID => $string_id, DAO_Translation::LANG_CODE => $add_lang_code, DAO_Translation::STRING_DEFAULT => '', DAO_Translation::STRING_OVERRIDE => $override); DAO_Translation::create($fields); } } } // If we added a new language then change the view to display it if (!empty($add_lang_code)) { $defaults = new Feg_AbstractViewModel(); $defaults->class_name = 'Feg_TranslationView'; $defaults->id = Feg_TranslationView::DEFAULT_ID; // Clear the existing view $view = Feg_AbstractViewLoader::getView(Feg_TranslationView::DEFAULT_ID, $defaults); $view->doResetCriteria(); // Set search to untranslated strings that aren't English $view->renderSortBy = SearchFields_Translation::STRING_ID; $view->renderSortAsc = true; $view->params = array(SearchFields_Translation::LANG_CODE => new DevblocksSearchCriteria(SearchFields_Translation::LANG_CODE, DevblocksSearchCriteria::OPER_EQ, $add_lang_code)); /* * If we didn't copy from another language, only show empty strings * which makes it easier to translate in the GUI. */ if (empty($copy_lang_code)) { $view->params[SearchFields_Translation::STRING_OVERRIDE] = new DevblocksSearchCriteria(SearchFields_Translation::STRING_OVERRIDE, DevblocksSearchCriteria::OPER_EQ, ''); } Feg_AbstractViewLoader::setView($view->id, $view); } self::_clearCache(); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('setup', 'translations'))); }
<?php require getcwd() . '/framework.config.php'; require DEVBLOCKS_PATH . 'Devblocks.class.php'; require APP_PATH . '/api/Application.class.php'; header("Content-type: text/html; charset=" . LANG_CHARSET_CODE); $request = DevblocksPlatform::readRequest(); DevblocksPlatform::init(); DevblocksPlatform::setExtensionDelegate('UM_DevblocksExtensionDelegate'); $session = DevblocksPlatform::getSessionService(); $settings = DevblocksPlatform::getPluginSettingsService(); $worker = FegApplication::getActiveWorker(); // Localization DevblocksPlatform::setLocale(isset($_SESSION['locale']) && !empty($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US'); if (isset($_SESSION['timezone'])) { @date_default_timezone_set($_SESSION['timezone']); } $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('translate', DevblocksPlatform::getTranslationService()); $tpl->assign('session', $_SESSION); $tpl->assign('visit', $session->getVisit()); $tpl->assign('active_worker', $worker); $tpl->assign('settings', $settings); $tpl->assign('core_tpl', APP_PATH . '/features/feg.core/templates/'); if (!empty($worker)) { // $active_worker_memberships = $worker->getMemberships(); // $tpl->assign('active_worker_memberships', $active_worker_memberships); // $keyboard_shortcuts = intval(DAO_WorkerPref::get($worker->id,'keyboard_shortcuts', 1)); // $tpl->assign('pref_keyboard_shortcuts', $keyboard_shortcuts); } FegApplication::processRequest($request, true);
/** * @param Model_DevblocksEvent $event */ function handleEvent(Model_DevblocksEvent $event) { $translate = DevblocksPlatform::getTranslationService(); switch ($event->id) { case 'cron.maint': DAO_MessageAuditLog::maint(); break; case 'cron.import': // Is a worker around to invoke this change? 0 = automatic /* @$worker_id = (null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id)) ? $active_worker->id : 0; $fields = array( DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => 0, DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => 0, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cron.import', DAO_MessageAuditLog::CHANGE_VALUE => 'Cron Importer Ran', ); $log_id = DAO_MessageAuditLog::create($fields); */ break; case 'cron.reprocessing.accounts': @($account_id = $event->params['account_id']); @($message_id = $event->params['message_id']); @($import_source = $event->params['import_source']); if ($account_id == 0) { break; } // Is a worker around to invoke this change? 0 = automatic @($worker_id = null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id) ? $active_worker->id : 0); $fields = array(DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => $account_id, DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => $message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cf.message.status', DAO_MessageAuditLog::CHANGE_VALUE => sprintf("Message ID %d assocated to Account ID %d", $message_id, $account_id)); $log_id = DAO_MessageAuditLog::create($fields); break; case 'cron.export': // Is a worker around to invoke this change? 0 = automatic /* @$worker_id = (null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id)) ? $active_worker->id : 0; $fields = array( DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => 0, DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => 0, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cron.export', DAO_MessageAuditLog::CHANGE_VALUE => 'Cron Exporter Ran', ); $log_id = DAO_MessageAuditLog::create($fields); */ break; case 'cron.send.email': @($recipient = $event->params['recipient']); @($message = $event->params['message']); @($message_recipient = $event->params['message_recipient']); @($message_text = $event->params['message_text']); @($send_status = $event->params['send_status']); $fields = array(DAO_MessageAuditLog::WORKER_ID => 0, DAO_MessageAuditLog::ACCOUNT_ID => $message_recipient->account_id, DAO_MessageAuditLog::RECIPIENT_ID => $message_recipient->recipient_id, DAO_MessageAuditLog::MESSAGE_ID => $message_recipient->message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => $message_recipient->id, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cs.message.email.send', DAO_MessageAuditLog::CHANGE_VALUE => $send_status ? "Successful Sent" : "Failed to Send"); $log_id = DAO_MessageAuditLog::create($fields); break; case 'cron.queue.fax': @($recipient = $event->params['recipient']); @($message = $event->params['message']); @($message_recipient = $event->params['message_recipient']); @($message_text = $event->params['message_text']); @($queue_status = $event->params['queue_status']); @($fax_id = $event->params['fax_id']); $fields = array(DAO_MessageAuditLog::WORKER_ID => 0, DAO_MessageAuditLog::ACCOUNT_ID => $message_recipient->account_id, DAO_MessageAuditLog::RECIPIENT_ID => $message_recipient->recipient_id, DAO_MessageAuditLog::MESSAGE_ID => $message_recipient->message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => $message_recipient->id, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cs.message.fax.queue', DAO_MessageAuditLog::CHANGE_VALUE => $queue_status ? "Fax successful queue with ID: " . $fax_id : "Failed to Queue"); $log_id = DAO_MessageAuditLog::create($fields); break; case 'cron.send.snpp': @($recipient = $event->params['recipient']); @($message = $event->params['message']); @($message_recipient = $event->params['message_recipient']); @($message_text = $event->params['message_text']); @($send_status = $event->params['send_status']); $fields = array(DAO_MessageAuditLog::WORKER_ID => 0, DAO_MessageAuditLog::ACCOUNT_ID => $message_recipient->account_id, DAO_MessageAuditLog::RECIPIENT_ID => $message_recipient->recipient_id, DAO_MessageAuditLog::MESSAGE_ID => $message_recipient->message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => $message_recipient->id, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cs.message.snpp.send', DAO_MessageAuditLog::CHANGE_VALUE => $send_status ? "Successful Sent" : "Failed to Send"); $log_id = DAO_MessageAuditLog::create($fields); break; case 'dao.customer.account.update': @($objects = $event->params['objects']); foreach ($objects as $object_id => $object) { $model = $object['model']; $changes = $object['changes']; // Filter out any changes we could care less about //unset($changes[DAO_CustomerAccount::IS_DISABLED]); // Is a worker around to invoke this change? 0 = automatic @($worker_id = null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id) ? $active_worker->id : 0); if (!empty($changes)) { foreach ($changes as $key => $change) { $value = $change['to']; if (is_array($value)) { $value = implode("\r\n", $value); } $fields = array(DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => $model['id'], DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => 0, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => "auditlog.ca." . $key, DAO_MessageAuditLog::CHANGE_VALUE => substr($value, 0, 128)); $log_id = DAO_MessageAuditLog::create($fields); } } } break; case 'dao.customer.recipient.update': @($objects = $event->params['objects']); foreach ($objects as $object_id => $object) { $model = $object['model']; $changes = $object['changes']; // Filter out any changes we could care less about //unset($changes[DAO_CustomerAccount::IS_DISABLED]); // Is a worker around to invoke this change? 0 = automatic @($worker_id = null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id) ? $active_worker->id : 0); if (!empty($changes)) { foreach ($changes as $key => $change) { $value = $change['to']; if (is_array($value)) { $value = implode("\r\n", $value); } if ($key == 'cr.type') { $value = $translate->_('auditlog.cr.type_' . $value); if ($value == "") { $value = $translate->_('auditlog.cr.type_unknown'); } } $fields = array(DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => $model['account_id'], DAO_MessageAuditLog::RECIPIENT_ID => $model['id'], DAO_MessageAuditLog::MESSAGE_ID => 0, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => "auditlog.cr." . $key, DAO_MessageAuditLog::CHANGE_VALUE => substr($value, 0, 128)); $log_id = DAO_MessageAuditLog::create($fields); } } } break; case 'message.account.assign': @($account_id = $event->params['account_id']); @($message_id = $event->params['message_id']); // Is a worker around to invoke this change? 0 = automatic @($worker_id = null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id) ? $active_worker->id : 0); $account = DAO_CustomerAccount::get($account_id); $assign_text = "Message id: " . $message_id . " assigned to account: " . $account->account_number; $fields = array(DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => $account_id, DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => $message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cf.message.assign', DAO_MessageAuditLog::CHANGE_VALUE => $assign_text); $log_id = DAO_MessageAuditLog::create($fields); break; case 'message.create': @($account_id = $event->params['account_id']); @($message_id = $event->params['message_id']); @($message_text = $event->params['message_text']); $fields = array(DAO_MessageAuditLog::WORKER_ID => 0, DAO_MessageAuditLog::ACCOUNT_ID => $account_id, DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => $message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cf.message.created', DAO_MessageAuditLog::CHANGE_VALUE => sprintf("Message created for account %d", $account_id)); $log_id = DAO_MessageAuditLog::create($fields); break; case 'message.recipient.create': @($account_id = $event->params['account_id']); @($recipient_id = $event->params['recipient_id']); @($message_id = $event->params['message_id']); @($message_recipient_id = $event->params['message_recipient_id']); @($message_text = $event->params['message_text']); $cr_id = array_shift(DAO_CustomerRecipient::getWhere(sprintf("%s = %d", DAO_CustomerRecipient::ID, $recipient_id))); switch ($cr_id->type) { case 0: // Email @($send_type = "Email"); break; case 1: // Fax @($send_type = "Fax"); break; case 2: // SNPP @($send_type = "Page"); break; default: @($send_type = "Unknown"); break; } @($change_value = sprintf("%s Scheduled for %s <'%s'>", $send_type, $cr_id->address_to, $cr_id->address)); $fields = array(DAO_MessageAuditLog::WORKER_ID => 0, DAO_MessageAuditLog::ACCOUNT_ID => $account_id, DAO_MessageAuditLog::RECIPIENT_ID => $recipient_id, DAO_MessageAuditLog::MESSAGE_ID => $message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => $message_recipient_id, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cf.message.recipient.created', DAO_MessageAuditLog::CHANGE_VALUE => $change_value); $log_id = DAO_MessageAuditLog::create($fields); break; case 'message.recipient.status': @($message_recipient_id = $event->params['message_recipient_id']); @($account_id = $event->params['account_id']); @($recipient_id = $event->params['recipient_id']); @($message_id = $event->params['message_id']); @($send_status = $event->params['send_status']); // Is a worker around to invoke this change? 0 = automatic @($worker_id = null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id) ? $active_worker->id : 0); $status_text = $translate->_('feg.message_recipient.status_' . $send_status); if ($status_text == "") { $status_text = $translate->_('feg.core.send_status.unknown'); } $fields = array(DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => $account_id, DAO_MessageAuditLog::RECIPIENT_ID => $recipient_id, DAO_MessageAuditLog::MESSAGE_ID => $message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => $message_recipient_id, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cf.message.recipient.status', DAO_MessageAuditLog::CHANGE_VALUE => $status_text); $log_id = DAO_MessageAuditLog::create($fields); break; case 'message.status': @($account_id = $event->params['account_id']); @($message_id = $event->params['message_id']); @($import_status = $event->params['import_status']); // Is a worker around to invoke this change? 0 = automatic @($worker_id = null != ($active_worker = FegApplication::getActiveWorker()) && !empty($active_worker->id) ? $active_worker->id : 0); $status_text = $translate->_('feg.message.import_status_' . $import_status); if ($status_text == "") { $status_text = $translate->_('feg.core.send_status.unknown'); } $fields = array(DAO_MessageAuditLog::WORKER_ID => $worker_id, DAO_MessageAuditLog::ACCOUNT_ID => $account_id, DAO_MessageAuditLog::RECIPIENT_ID => 0, DAO_MessageAuditLog::MESSAGE_ID => $message_id, DAO_MessageAuditLog::MESSAGE_RECIPIENT_ID => 0, DAO_MessageAuditLog::CHANGE_DATE => time(), DAO_MessageAuditLog::CHANGE_FIELD => 'auditlog.cf.message.status', DAO_MessageAuditLog::CHANGE_VALUE => $status_text); $log_id = DAO_MessageAuditLog::create($fields); break; } }
function doNotificationsMarkReadAction() { $worker = FegApplication::getActiveWorker(); @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); @($row_ids = DevblocksPlatform::importGPC($_REQUEST['row_id'], 'array', array())); if (is_array($row_ids) && !empty($row_ids)) { DAO_WorkerEvent::updateWhere(array(DAO_WorkerEvent::IS_READ => 1), sprintf("%s = %d AND %s IN (%s)", DAO_WorkerEvent::WORKER_ID, $worker->id, DAO_WorkerEvent::ID, implode(',', $row_ids))); DAO_WorkerEvent::clearCountCache($worker->id); } $myEventsView = Feg_AbstractViewLoader::getView($view_id); $myEventsView->render(); }