private function getInstance() { if (self::$instance === false) { self::$instance = Model::load('system.audit_trail'); self::$dataModel = Model::load('system.audit_trail_data'); } return self::$instance; }
/** * Logs an activity. * @param string $activity * @param string $data */ public static function log($activity, $data = null) { $db = Db::get(); $data = Db::escape(json_encode($data)); if (ENABLE_AUDIT_TRAILS === true && class_exists("SystemAuditTrailModel", false)) { SystemAuditTrailModel::log(array('item_id' => 0, 'item_type' => 'system_activity', 'description' => $activity, 'type' => SystemAuditTrailModel::AUDIT_TYPE_SYSTEM)); } }
public static function logDelete($model, $field, $value) { if (ENABLE_AUDIT_TRAILS === true && $model->disableAuditTrails === false) { if ($value === null) { $data = reset($model->get(array('conditions' => $field))); } else { $data = reset($model->getWithField2($field, $value)); } SystemAuditTrailModel::log(array('item_id' => $data[$model->getKeyField()], 'item_type' => $model->package, 'description' => 'Deleted item', 'type' => SystemAuditTrailModel::AUDIT_TYPE_DELETED_DATA, 'data' => json_encode($data))); } }
public function delete($key_field, $key_value = null) { $this->datastore->beginTransaction(); $resolve = $this->queryResolve; $explicitRelations = $this->queryExplicitRelations; $this->queryResolve = false; $this->queryExplicitRelations = true; if ($key_value === null) { $data = reset($this->get(array('conditions' => $key_field))); } else { $data = reset($this->getWithField2($key_field, $key_value)); } if ($data === false) { //trigger_error("Trying to delete an item which does not exist from [{$this->package}] ", E_USER_NOTICE); } else { if (ENABLE_AUDIT_TRAILS === true && $this->disableAuditTrails === false) { SystemAuditTrailModel::log(array('item_id' => $data[$this->getKeyField()], 'item_type' => $this->package, 'description' => 'Deleted item', 'type' => SystemAuditTrailModel::AUDIT_TYPE_DELETED_DATA, 'data' => json_encode($data))); } } $this->queryResolve = $resolve; $this->queryExplicitRelations = $explicitRelations; $this->preDeleteHook($key_field, $key_value); $this->deleteImplementation($key_field, $key_value); $this->postDeleteHook(); $this->queryResolve = false; $this->queryExplicitRelations = true; $this->datastore->endTransaction(); }
/** * Logs an activity. * @param string $activity * @param string $data */ public static function log($activity) { if (ENABLE_AUDIT_TRAILS === true && class_exists("SystemAuditTrailModel", false)) { SystemAuditTrailModel::log(array('item_id' => 0, 'item_type' => 'system_activity', 'description' => $activity, 'type' => SystemAuditTrailModel::AUDIT_TYPE_SYSTEM)); } }
public function delete($key_field, $key_value = null) { $this->datastore->beginTransaction(); $resolve = $this->queryResolve; $explicitRelations = $this->queryExplicitRelations; $this->queryResolve = false; $this->queryExplicitRelations = true; SystemAuditTrailModel::logDelete($this, $key_field, $key_value); $this->queryResolve = $resolve; $this->queryExplicitRelations = $explicitRelations; $this->preDeleteHook($key_field, $key_value); $this->deleteImplementation($key_field, $key_value); $this->postDeleteHook(); $this->queryResolve = false; $this->queryExplicitRelations = true; $this->datastore->endTransaction(); }
$link .= "/" . $top_menu_items[$i + 1]; $i++; } $item = str_replace("_", " ", $item); $item = ucwords($item); $top_menu .= "<a href='" . Application::getLink($link) . "'><span>{$item}</span></a>"; } Application::$templateEngine->assign('top_menu', $top_menu); } } } // Log the route into the audit trail if it is enabled if ($_SESSION['logged_in'] == true && $_GET['q'] != 'system/api/table' && ENABLE_AUDIT_TRAILS === true) { $data = json_encode(array('route' => $_GET['q'], 'request' => $_REQUEST, 'get' => $_GET, 'post' => $_POST)); if (class_exists("SystemAuditTrailModel", false) && ENABLE_ROUTING_TRAILS === true) { SystemAuditTrailModel::log(array('item_id' => '0', 'item_type' => 'routing_activity', 'description' => "Accessed [{$_GET['q']}]", 'type' => SystemAuditTrailModel::AUDIT_TYPE_ROUTING, 'data' => $data)); } } // Load the styleseets and the javascripts if ($GLOBALS['fapi_stylesheet'] === false) { Application::preAddStylesheet("css/fapi.css", Application::getWyfHome("fapi/")); } else { Application::preAddStylesheet($GLOBALS['fapi_stylesheet']); } Application::preAddStylesheet("kalendae/kalendae.css", Application::getWyfHome('assets/js/')); Application::preAddStylesheet("css/main.css"); Application::addStylesheet('css/rapi.css', Application::getWyfHome('rapi/')); Application::addJavaScript(Application::getLink(Application::getWyfHome("fapi/js/fapi.js"))); Application::addJavaScript(Application::getLink(Application::getWyfHome("assets/js/jquery.js"))); Application::addJavaScript(Application::getLink(Application::getWyfHome("assets/js/kalendae/kalendae.js"))); // Blast the HTML code to the browser!