/** * Used by usort to RE-sort log query results, because we lose the ordering * because we're possibly combining the results from two queries * @param EE_Change_Log $logA * @param EE_Change_Log $logB * @return int */ protected function _sort_logs_again($logA, $logB) { $timeA = $logA->get_raw('LOG_time'); $timeB = $logB->get_raw('LOG_time'); if ($timeA == $timeB) { return 0; } $comparison = $timeA < $timeB ? -1 : 1; if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { return $comparison * -1; } else { return $comparison; } }
/** * Adds a gateway log for the specified object, given its ID and type * @param string $message * @param mixed $related_obj_id * @param string $related_obj_type * @throws EE_Error * @return EE_Change_Log */ public function gateway_log($message, $related_obj_id, $related_obj_type) { if (!EE_Registry::instance()->is_model_name($related_obj_type)) { throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"), $related_obj_type)); } $log = EE_Change_Log::new_instance(array('LOG_type' => EEM_Change_Log::type_gateway, 'LOG_message' => $message, 'OBJ_ID' => $related_obj_id, 'OBJ_type' => $related_obj_type)); $log->save(); return $log; }
/** * column_TXN_ID * @param \EE_Change_Log $item * @return string */ public function column_TXN_ID(EE_Change_Log $item) { if ($item->object() instanceof EE_Payment) { if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->object()->TXN_ID())) { $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $item->object()->TXN_ID()), TXN_ADMIN_URL); return '<a href="' . $view_txn_lnk_url . '" title="' . sprintf(esc_attr__('click to view transaction #%s', 'event_espresso'), $item->object()->TXN_ID()) . '">' . sprintf(__('view txn %s', 'event_espresso'), $item->object()->TXN_ID()) . '</a>'; } } else { return __("Unable to find transaction", 'event_espresso'); } }
/** * @group github-102 * @group 8589 */ public function test_get__serialized_data__twice() { $log_message = serialize(array('key1' => 'value1', 'key2' => 'value2')); $log = EE_Change_Log::new_instance(); $log->set('LOG_message', $log_message); $log->save(); //verify that when we get its LOG_message its still serialized $this->assertTrue(is_array($log->get('LOG_message'))); $this->assertEquals(unserialize($log_message), $log->get('LOG_message')); //now when we get it from the DB, and get its LOG_message, its still serialized $log_id = $log->ID(); EEM_Change_Log::reset(); unset($log); $log_from_db = EEM_Change_Log::instance()->get_one_by_ID($log_id); $this->assertTrue(is_array($log_from_db->get('LOG_message'))); $this->assertEquals(unserialize($log_message), $log_from_db->get('LOG_message')); }