private function _parse_query() { if (!isset($_GET['query'])) { return; } if (isset($_GET['query_mode'])) { $this->_query_mode = $_GET['query_mode']; } $this->_query_string = trim($_GET['query']); //Convert asterisks to correct wildcard $this->_query_string_processed = str_replace('*', '%', $this->_query_string); $this->_query = explode(' ', $this->_query_string_processed); // Handle automatic wildcards $auto_wildcards = $this->_config->get('auto_wildcards'); if ($auto_wildcards && strpos($this->_query_string_processed, '%') === false) { switch ($auto_wildcards) { case 'both': $this->_wildcard_template = '%__TERM__%'; break; case 'start': $this->_wildcard_template = '%__TERM__'; break; case 'end': $this->_wildcard_template = '__TERM__%'; break; default: debug_add("Don't know how to handle auto_wildcards value '{$auto_wildcards}'", MIDCOM_LOG_WARN); break; } } }
/** * Iterate over all articles and create index record using the datamanager indexer * method. */ public function _on_reindex($topic, $config, &$indexer) { if (is_null($config->get('symlink_topic')) && !$config->get('disable_indexing')) { $qb = midcom::get('dbfactory')->new_query_builder('midcom_db_article'); $qb->add_constraint('topic', '=', $topic->id); $result = $qb->execute(); if ($result) { $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb')); $datamanager = new midcom_helper_datamanager2_datamanager($schemadb); if (!$datamanager) { debug_add('Warning, failed to create a datamanager instance with this schemapath:' . $config->get('schemadb'), MIDCOM_LOG_WARN); continue; } foreach ($result as $article) { if (!$datamanager->autoset_storage($article)) { debug_add("Warning, failed to initialize datamanager for Article {$article->id}. Skipping it.", MIDCOM_LOG_WARN); continue; } net_nehmer_blog_viewer::index($datamanager, $indexer, $topic); } } } elseif (is_null($config->get('symlink_topic')) && !$config->get('disable_search')) { debug_add("The topic {$topic->id} is is not to be indexed, skipping indexing."); } else { debug_add("The topic {$topic->id} is symlinked to another topic, skipping indexing."); } return true; }
/** * Sends a notice to a selected person * * @param string $component_action Key of the event in format component:event * @param string $recipient GUID of the receiving person * @param Array $message Notification message in array format */ public static function notify($component_action, $recipient, $message) { // Parse action to component and action $action_parts = explode(':', $component_action); if (count($action_parts) != 2) { return false; } $component = $action_parts[0]; $action = $action_parts[1]; // Find in which ways to notify the user $notification_type = self::_merge_notification_prefences($component, $action, $recipient); if ($notification_type == 'none') { // User doesn't wish to be notified return true; } // Add the action to the message $message['action'] = $component_action; // Figure out notification rendering handler // TODO: Support component-specific renderers via class_exists() or handler-like autoloading // For example: if (class_exists('org_openpsa_calendar_notifications')) $notifier = new org_openpsa_notifications_notifier($recipient); // Send the type requested by user debug_add("Notifying {$recipient} with type {$notification_type}"); $method = "send_{$notification_type}"; if (!method_exists($notifier, $method)) { return false; } $notifier->{$method}($message); return true; }
function _on_execute() { debug_push_class(__CLASS__, __FUNCTION__); if (!$_MIDCOM->auth->request_sudo('fi.kilonkipinat.accountregistration')) { $msg = "Could not get sudo, aborting operation, see error log for details"; $this->print_error($msg); debug_add($msg, MIDCOM_LOG_ERROR); debug_pop(); return; } $time_for_old = date('Y-m-d 00:00', time() - 3600 * 24); $qb_resetrequests = fi_kilonkipinat_accountregistration_resetrequest_dba::new_query_builder(); $qb_resetrequests->add_constraint('metadata.revised', '<', $time_for_old); $qb_resetrequests->add_constraint('status', '=', FI_KILONKIPINAT_ACCOUNTREGISTRATION_PASSWORDRESETREQUEST_STATUS_NEW); $results = $qb_resetrequests->execute(); foreach ($results as $result) { $result->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_PASSWORDRESETREQUEST_STATUS_INVALID; $result->update(); } $time_for_old = date('Y-m-d 00:00', time() - 3600 * 24 * 31); $qb_accounts = fi_kilonkipinat_accountregistration_accountrequest_dba::new_query_builder(); $qb_accounts->add_constraint('metadata.revised', '<', $time_for_old); $qb_accounts->add_constraint('status', '=', FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_NEW); $results2 = $qb_accounts->execute(); foreach ($results2 as $result) { $result->status = FI_KILONKIPINAT_ACCOUNTREGISTRATION_ACCOUNT_STATUS_INVALID; $result->update(); } $_MIDCOM->auth->drop_sudo(); debug_pop(); }
/** * Find hanging duplicate marks (that no longer point anywhere) and clear them */ public function _on_execute() { debug_add('_on_execute called'); if (!$this->_config->get('enable_duplicate_search')) { debug_add('Duplicate operations disabled, aborting', MIDCOM_LOG_INFO); return; } // Untill the FIXME below is handled we abort debug_add('Duplicate cleanup disabled since it needs code cleanup for 1.8 Midgfard, aborting', MIDCOM_LOG_ERROR); return; ignore_user_abort(); $qb = new midgard_query_builder('midgard_parameter'); $qb->add_constraint('domain', '=', 'org.openpsa.contacts.duplicates:possible_duplicate'); $qb->add_order('name', 'ASC'); $results = @$qb->execute(); foreach ($results as $param) { try { $obj = midcom::get('dbfactory')->get_object_by_guid($param->name); } catch (midcom_error $e) { debug_add("GUID {$param->name} points to nonexistent person, removing possible duplicate mark", MIDCOM_LOG_INFO); if (!$param->delete()) { debug_add("Failed to delete parameter {$param->guid}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); } } } debug_add('Done'); return; }
/** * Initialize the class, if necessary, create a callback instance, otherwise * validate that an option array is present. */ public function _on_initialize() { if (is_string($this->callback)) { $classname = $this->callback; // Try auto-load. $path = MIDCOM_ROOT . '/' . str_replace('_', '/', $classname) . '.php'; if (!file_exists($path)) { debug_add("Auto-loading of the class {$classname} from {$path} failed: File does not exist.", MIDCOM_LOG_ERROR); return false; } require_once $path; if (!class_exists($classname)) { debug_add("The class {$classname} was defined as option callback for the field {$this->name} but did not exist.", MIDCOM_LOG_ERROR); return false; } $this->_callback = new $classname($this->option_callback_arg); $this->_callback->set_type($this); return true; } elseif (is_object($this->callback)) { $this->_callback =& $this->callback; return true; } // todo check the headers and rows return false; }
public function send() { if (!preg_match('|^https?://|', $this->url)) { if ($this->url == '' || substr($this->url, 0, 1) != "/") { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); if ($prefix == '') { $prefix = midcom::get()->get_page_prefix(); } $this->url = "{$prefix}{$this->url}"; debug_add("This is a relative URL from the local site, prepending anchor prefix: {$this->url}"); } else { $this->url = midcom::get()->get_host_name() . $this->url; debug_add("This is an absolute URL from the local host, prepending host name: {$this->url}"); } $location = "Location: {$this->url}"; } else { // This is an external URL $location = "Location: {$this->url}"; } midcom::get('cache')->content->no_cache(); midcom::get()->finish(); debug_add("Relocating to {$location}"); midcom::get()->header($location, $this->code); _midcom_stop_request(); }
/** * Find all old send tokens and clear them. */ public function _on_execute() { //Disable limits, TODO: think if this could be done in smaller chunks to save memory. midcom::get()->disable_limits(); debug_add('_on_execute called'); $days = $this->_config->get('send_token_max_age'); if ($days == 0) { debug_add('send_token_max_age evaluates to zero, aborting'); return; } $th = time() - $days * 3600 * 24; $qb = org_openpsa_directmarketing_campaign_messagereceipt_dba::new_query_builder(); $qb->add_constraint('token', '<>', ''); $qb->add_constraint('timestamp', '<', $th); $qb->add_constraint('orgOpenpsaObtype', '=', org_openpsa_directmarketing_campaign_messagereceipt_dba::SENT); $ret = $qb->execute_unchecked(); if ($ret === false || !is_array($ret)) { //TODO: display some error ? return false; } if (empty($ret)) { debug_add('No results, returning early.'); return; } foreach ($ret as $receipt) { debug_add("clearing token '{$receipt->token}' from receipt #{$receipt->id}"); $receipt->token = ''; $stat = $receipt->update(); if (!$stat) { debug_add("FAILED to update receipt #{$receipt->id}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_WARN); } } debug_add('Done'); return; }
/** */ public function process_deliverable(org_openpsa_sales_salesproject_deliverable_dba $deliverable, $cycle_number = null) { $this->_deliverable = $deliverable; // Recalculate price to catch possible unit changes $client_class = midcom_baseclasses_components_configuration::get('org.openpsa.sales', 'config')->get('calculator'); $client = new $client_class(); $client->run($this->_deliverable); $this_cycle_amount = $client->get_price(); if ($this_cycle_amount == 0) { debug_add('Invoice sum 0, skipping invoice creation'); return 0; } $this->_invoice = $this->_probe_invoice($cycle_number); if (!$this->_invoice->update()) { throw new midcom_error("The invoice could not be saved. Last Midgard error was: " . midcom_connection::get_error_string()); } // TODO: Create invoicing task if assignee is defined $items = $client->get_invoice_items($this->_invoice); foreach ($items as $item) { $item->deliverable = $this->_deliverable->id; $item->skip_invoice_update = true; if ($item->id) { $stat = $item->update(); } else { $stat = $item->create(); } if (!$stat) { throw new midcom_error('Failed to save item to disk, ' . midcom_connection::get_error_string()); } } org_openpsa_invoices_invoice_item_dba::update_invoice($this->_invoice); org_openpsa_invoices_invoice_item_dba::update_deliverable($this->_deliverable); return $this_cycle_amount; }
/** * Loads all (not-archived) smart campaigns and schedules a separate background update for each */ public function _on_execute() { debug_add('_on_execute called'); $qb = org_openpsa_directmarketing_campaign_dba::new_query_builder(); $qb->add_constraint('archived', '=', 0); $qb->add_constraint('orgOpenpsaObtype', '=', org_openpsa_directmarketing_campaign_dba::TYPE_SMART); midcom::get('auth')->request_sudo('org.openpsa.directmarketing'); $ret = $qb->execute(); midcom::get('auth')->drop_sudo(); if ($ret === false || !is_array($ret)) { //TODO: display some error ? return false; } if (empty($ret)) { return; } $i = 1; foreach ($ret as $campaign) { $next_time = time() + $i++ * 60; debug_add("Scheduling member update for campaign #{$campaign->id} ({$campaign->title}) to happen on " . date('Y-m-d H:i:s', $next_time)); $stat = $campaign->schedule_update_smart_campaign_members($next_time); if (!$stat) { //TODO: Display some error ? } } debug_add('Done'); return; }
/** * Find all old temporary reports and clear them. */ public function _on_execute() { //Disable limits, TODO: think if this could be done in smaller chunks to save memory. midcom::get()->disable_limits(); debug_add('_on_execute called'); $days = $this->_config->get('temporary_report_max_age'); if ($days == 0) { debug_add('temporary_report_max_age evaluates to zero, aborting'); return; } $th = time() - $days * 3600 * 24; $qb = org_openpsa_reports_query_dba::new_query_builder(); $qb->add_constraint('metadata.created', '<', $th); $qb->add_constraint('orgOpenpsaObtype', '=', ORG_OPENPSA_OBTYPE_REPORT_TEMPORARY); $ret = $qb->execute_unchecked(); if ($ret === false || !is_array($ret)) { //TODO: display some error ? return false; } if (empty($ret)) { debug_add('No results, returning early.'); return; } foreach ($ret as $query) { debug_add("removing temporary query #{$query->id}"); $stat = $query->delete(); if (!$stat) { debug_add("FAILED to delete query #{$query->id}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_WARN); } } debug_add('Done'); return; }
/** * Loads all entries that need to be processed and processes them. */ public function _on_execute() { $qb = midcom_services_at_entry_dba::new_query_builder(); // (to be) start(ed) AND last touched over two days ago $qb->add_constraint('start', '<=', time() - 3600 * 24 * 2); $qb->begin_group('OR'); $qb->add_constraint('host', '=', midcom_connection::get('host')); $qb->add_constraint('host', '=', 0); $qb->end_group(); $qb->add_constraint('metadata.revised', '<=', date('Y-m-d H:i:s', time() - 3600 * 24 * 2)); $qb->add_constraint('status', '>=', midcom_services_at_entry_dba::RUNNING); midcom::get('auth')->request_sudo('midcom.services.at'); $qbret = $qb->execute(); if (empty($qbret)) { debug_add('Got empty resultset, exiting'); midcom::get('auth')->drop_sudo(); return; } foreach ($qbret as $entry) { debug_add("Deleting dangling entry #{$entry->id}\n", MIDCOM_LOG_INFO); debug_print_r("Entry #{$entry->id} dump: ", $entry); $entry->delete(); } midcom::get('auth')->drop_sudo(); }
/** * Function to unblock an account after too many failed to login attempts * * @param array $args Contains the guid, parameter & parameter names to get username&password */ function reopen_account($args, &$handler) { midcom::get('auth')->request_sudo($this->_component); try { $person = new midcom_db_person($args['guid']); } catch (midcom_error $e) { $msg = 'Person with guid #' . $args['guid'] . ' does not exist'; debug_add($msg, MIDCOM_LOG_ERROR); $handler->print_error($msg); midcom::get('auth')->drop_sudo(); return false; } $accounthelper = new org_openpsa_user_accounthelper($person); try { $accounthelper->reopen_account(); } catch (midcom_error $e) { midcom::get('auth')->drop_sudo(); $e->log(); $handler->print_error($e->getMessage()); midcom::get('auth')->drop_sudo(); return false; } midcom::get('auth')->drop_sudo(); return true; }
/** * Handle the moving of a group phase * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_move($handler_id, array $args, array &$data) { $data['group'] = new midcom_db_group($args[0]); // Get the prefix $data['prefix'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); if (isset($_POST['f_cancel'])) { return new midcom_response_relocate("__mfa/asgard_midcom.admin.user/group/edit/{$data['group']->guid}/"); } if (isset($_POST['f_submit'])) { echo "<pre>\n"; print_r($_POST); echo "</pre>\n"; $data['group']->owner = (int) $_POST['midcom_admin_user_move_group']; if ($data['group']->update()) { midcom::get('uimessages')->add($this->_l10n->get('midcom.admin.user'), midcom::get('i18n')->get_string('updated', 'midcom')); return new midcom_response_relocate("__mfa/asgard_midcom.admin.user/group/edit/{$data['group']->guid}/"); } else { debug_add('Failed to update the group, last midcom_connection::get_error_string was ' . midgard_connection::get_error_string(), MIDCOM_LOG_ERROR); debug_print_r('We operated on this object', $data['group'], MIDCOM_LOG_ERROR); throw new midcom_error('Failed to update the group, see error level log for details'); } } $data['view_title'] = sprintf($this->_l10n->get('move %s'), $data['group']->official); midcom::get('head')->set_pagetitle($data['view_title']); $this->_update_breadcrumb($handler_id); }
/** * Trash view * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. * @return boolean Indicating success. */ public function _handler_trash($handler_id, array $args, array &$data) { midcom::get('auth')->require_admin_user(); midcom::get('cache')->content->no_cache(); $data['view_title'] = $this->_l10n->get('trash'); midcom::get('head')->set_pagetitle($data['view_title']); $data['types'] = array(); foreach (midcom_connection::get_schema_types() as $type) { if (substr($type, 0, 2) == '__') { continue; } if (class_exists('midgard_reflector_object')) { // In Midgard2 we can have objects that don't // have metadata. These should not be shown // in trash. $ref = new midgard_reflector_object($type); if (!$ref->has_metadata_class($type)) { debug_add("{$type} has no metadata, skipping", MIDCOM_LOG_DEBUG); continue; } } $qb = new midgard_query_builder($type); $qb->include_deleted(); $qb->add_constraint('metadata.deleted', '=', true); $data['types'][$type] = $qb->count(); } // Set the breadcrumb data $this->add_breadcrumb('__mfa/asgard/', $this->_l10n->get('midgard.admin.asgard')); $this->add_breadcrumb('__mfa/asgard/trash/', $this->_l10n->get('trash')); }
/** * Fetches subscribed feeds and imports them */ public function _on_execute() { debug_add('_on_execute called'); if (!midcom::get('auth')->request_sudo('net.nemein.rss')) { $msg = "Could not get sudo, aborting operation, see error log for details"; $this->print_error($msg); debug_add($msg, MIDCOM_LOG_ERROR); return; } midcom::get()->disable_limits(); $qb = net_nemein_rss_feed_dba::new_query_builder(); // Process lang0 subscriptions first $qb->add_order('itemlang', 'ASC'); $feeds = $qb->execute(); foreach ($feeds as $feed) { try { $node = new midcom_db_topic($feed->node); } catch (midcom_error $e) { debug_add("Node #{$feed->node} does not exist, skipping feed #{$feed->id}", MIDCOM_LOG_ERROR); continue; } debug_add("Fetching {$feed->url}...", MIDCOM_LOG_INFO); $fetcher = new net_nemein_rss_fetch($feed); $items = $fetcher->import(); debug_add("Imported " . count($items) . " items, set feed refresh time to " . strftime('%x %X', $feed->latestfetch), MIDCOM_LOG_INFO); } midcom::get('auth')->drop_sudo(); debug_add('Done'); return; }
public function __get($field) { if (array_key_exists($field, $this->_services)) { return $this->_services[$field]; } $instance = null; switch ($field) { case '_i18n': $instance = midcom::get('i18n'); break; case '_l10n': $instance = midcom::get('i18n')->get_l10n($this->_component); break; case '_l10n_midcom': $instance = midcom::get('i18n')->get_l10n('midcom'); break; case '_config': $instance = midcom_baseclasses_components_configuration::get($this->_component, 'config'); break; default: debug_add('Component ' . $this->_component . ' tried to access nonexistant service "' . $field . '"', MIDCOM_LOG_ERROR); debug_print_function_stack('Called from here:'); return false; } $this->_services[$field] = $instance; return $this->_services[$field]; }
/** * Find all old temporary reports and clear them. */ public function _on_execute() { debug_add('_on_execute called'); midcom::get('auth')->request_sudo('net.nemein.tag'); $qb_tags = net_nemein_tag_tag_dba::new_query_builder(); $tags = $qb_tags->execute_unchecked(); if (!is_array($tags)) { // QB error midcom::get('auth')->drop_sudo(); return; } foreach ($tags as $tag) { debug_add("Processing tag #{$tag->id} ('{$tag->tag}')"); $qb_links = net_nemein_tag_link_dba::new_query_builder(); $qb_links->add_constraint('tag', '=', $tag->id); $count = $qb_links->count_unchecked(); if ($count === false) { // QB error, skip debug_add("There was QB level error, skip rest of the checks"); continue; } if ($count > 0) { // Tag has links, skip debug_add("Tag has links to it, do not clean"); continue; } debug_add("Cleaning dangling tag #{$tag->id} ('{$tag->tag}')", MIDCOM_LOG_INFO); if (!$tag->delete()) { debug_add("Could not delete dangling tag #{$tag->id} ('{$tag->tag}'), errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); } } debug_add('done'); midcom::get('auth')->drop_sudo(); return; }
/** * Fetches Fire Eagle information for users */ public function _on_execute() { debug_add('_on_execute called'); $fireeagle = org_routamc_positioning_importer::create('fireeagle'); $fireeagle->seek_fireeagle_users(); debug_add('Done'); return; }
/** * Fetches icbm information for users */ public function _on_execute() { debug_add('_on_execute called'); $html = org_routamc_positioning_importer::create('html'); $html->seek_icbm_users(); debug_add('Done'); return; }
/** * The initialization event handler post-processes the maxlength setting. * * @return boolean Indicating Success */ public function _on_initialize() { if (!array_key_exists('value', $this->_type) || is_array($this->_type->value) || is_object($this->_type->value)) { debug_add("Warning, the field {$this->name} does not have a value member or it is an array or object, you cannot use the text widget with it.", MIDCOM_LOG_WARN); return false; } return true; }
/** * Fetches Plazes information for users */ public function _on_execute() { debug_add('_on_execute called'); $plazes = org_routamc_positioning_importer::create('plazes'); $plazes->seek_plazes_users(); debug_add('Done'); return; }
/** * The initialization event handler verifies the used type. * * @return boolean Indicating Success */ public function _on_initialize() { if (!isset($this->_type->location) || !is_object($this->_type->location)) { debug_add("Warning, the field {$this->name} does not have a location object as member, you cannot use the simpleposition widget with it.", MIDCOM_LOG_WARN); return false; } return true; }
/** * The initialization event handler validates the base type. * * @return boolean Indicating Success */ public function _on_initialize() { if (!is_a($this->_type, 'midcom_helper_datamanager2_type_privilege')) { debug_add("Warning, the field {$this->name} is not of type privilege.", MIDCOM_LOG_WARN); return false; } return true; }
/** * The initialization event handler verifies the correct type. * * @return boolean Indicating Success */ public function _on_initialize() { if (!is_a($this->_type, 'midcom_helper_datamanager2_type_select')) { debug_add("Warning, the field {$this->name} is not a select type or subclass thereof, you cannot use the select widget with it.", MIDCOM_LOG_WARN); return false; } return true; }
/** * Check if all the fields contain required information upon update * * @return boolean Indicating success */ public function _on_updating() { if (!$this->topic || !$this->article) { debug_add('Failed to update the link, either topic or article was undefined', MIDCOM_LOG_WARN); midcom_connection::set_error(MGD_ERR_ERROR); return false; } return true; }
function get_parent_guid_uncached() { if ($this->productGroup != 0) { $parent = new org_openpsa_products_product_group_dba($this->productGroup); return $parent->guid; } else { debug_add("No parent defined for this product"); return null; } }
private function _import_group($groupdata) { // Convert fields from latin-1 to MidCOM charset (usually utf-8) foreach ($groupdata as $key => $value) { $groupdata[$key] = iconv('ISO-8859-1', midcom::get('i18n')->get_current_charset(), $value); } $group = null; $new = false; if (isset($groupdata['code'])) { $qb = org_openpsa_products_product_group_dba::new_query_builder(); $qb->add_constraint('code', '=', (string) $groupdata['code']); $groups = $qb->execute(); if (count($groups) > 0) { // Match found, use it $group = $groups[0]; $this->_request_data['import_status']['already_created']++; } } if (!$group) { // We didn't have group matching the code in DB. Create a new one. $group = new org_openpsa_products_product_group_dba(); if (!$group->create()) { debug_add("Failed to create group, reason " . midcom_connection::get_error_string()); $this->_request_data['import_status']['failed_create']++; return false; // This will skip to next } $new = true; $this->_request_data['import_status']['created_new']++; } if (isset($groupdata['org_openpsa_products_import_parent_group'])) { // Validate and set parent group $qb = org_openpsa_products_product_group_dba::new_query_builder(); $qb->add_constraint('code', '=', (string) $groupdata['org_openpsa_products_import_parent_group']); $parents = $qb->execute(); if (count($parents) == 0) { // Invalid parent, delete $group->delete(); $this->_request_data['import_status']['failed_create']++; return false; } $group->up = $parents[0]->id; $groupdata['up'] = $parents[0]->id; $group->update(); } if (!$this->_datamanager_process($groupdata, $group)) { if ($new) { $group->delete(); $this->_request_data['import_status']['failed_create']++; } return false; } $this->_groups_processed[$group->code] = $group; return $group; }
/** * Don't save log if previous log is in same place */ public function _on_creating() { $previous = $this->get_previous(); if ($previous && round($previous->longitude, 4) == round($this->longitude, 4) && round($previous->latitude, 4) == round($this->latitude, 4) && $previous->altitude == $this->altitude && date('Y-m-d', $previous->date) == date('Y-m-d', $this->date)) { // We don't need to save duplicate entries on same day debug_add("Not saving log, previous log \"{$previous->guid}\" on same day is in same place.", MIDCOM_LOG_WARN); midcom_connection::set_error(MGD_ERR_DUPLICATE); return false; } return true; }
public function __construct(array $params) { foreach ($this->_try_backends as $backend) { try { $this->_backend = org_openpsa_mail_backend::get($backend, $params); } catch (midcom_error $e) { debug_add('Failed to load backend ' . $backend . ', message:' . $e->getMessage()); } } throw new midcom_error('All backends failed to load'); }