/** * This class manages the audit "rule" linked to a given audit category. * Each rule is based on an OQL expression that returns either the "good" objects * or the "bad" ones. The core audit engines computes the complement to the definition * set when needed to obtain either the valid objects, or the ones with an error * * @copyright Copyright (C) 2010-2024 Combodo SAS * @license http://opensource.org/licenses/AGPL-3.0 */ require_once(APPROOT.'/application/audit.category.class.inc.php'); class AuditRule extends cmdbAbstractObject { public static function Init() { $aParams = [ "category" => "application,grant_by_profile", "key_type" => "autoincrement", "name_attcode" => "name", "state_attcode" => "", "reconc_keys" => ['name'], "db_table" => "priv_auditrule", "db_key_field" => "id", "db_finalclass_field" => "", 'style' => new ormStyle(null, null, null, null, null, '../images/icons/icons8-audit.svg'), ]; MetaModel::Init_Params($aParams); MetaModel::Init_AddAttribute(new AttributeString("name", ["allowed_values" => null, "sql" => "name", "default_value" => "", "is_null_allowed" => false, "depends_on" => []])); MetaModel::Init_AddAttribute(new AttributeString("description", ["allowed_values" => null, "sql" => "description", "default_value" => "", "is_null_allowed" => true, "depends_on" => []])); MetaModel::Init_AddAttribute(new AttributeOQL("query", ["allowed_values" => null, "sql" => "query", "default_value" => "", "is_null_allowed" => false, "depends_on" => []])); MetaModel::Init_AddAttribute(new AttributeEnum("valid_flag", ["allowed_values" => new ValueSetEnum('true,false'), "sql" => "valid_flag", "default_value" => "true", "is_null_allowed" => false, "depends_on" => []])); MetaModel::Init_AddAttribute(new AttributeExternalKey("category_id", ["allowed_values" => null, "sql" => "category_id", "targetclass" => "AuditCategory", "is_null_allowed" => false, "on_target_delete" => DEL_MANUAL, "depends_on" => []])); MetaModel::Init_AddAttribute(new AttributeExternalField("category_name", ["allowed_values" => null, "extkey_attcode" => 'category_id', "target_attcode" => "name"])); MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", ["allowed_values" => null, "sql" => "contact_id", "targetclass" => "Contact", "is_null_allowed" => true, "on_target_delete" => DEL_MANUAL, "depends_on" => []])); MetaModel::Init_AddAttribute(new AttributeHTML("process", ["allowed_values" => null, "sql" => "process", "default_value" => "", "is_null_allowed" => true, "depends_on" => []])); // Display lists MetaModel::Init_SetZListItems('details', ['category_id', 'name', 'description', 'query', 'valid_flag', 'process', 'contact_id']); // Attributes to be displayed for the complete details MetaModel::Init_SetZListItems('list', ['category_id', 'description', 'query']); // Attributes to be displayed for a list // Search criteria MetaModel::Init_SetZListItems('standard_search', ['category_id', 'name', 'description', 'valid_flag', 'query']); // Criteria of the std search form MetaModel::Init_SetZListItems('default_search', ['name', 'description', 'category_id', 'contact_id', 'query']); // Criteria of the advanced search form } public static function GetShortcutActions($sFinalClass) { $aShortcutActions = parent::GetShortcutActions($sFinalClass); if (!in_array('UI:Menu:RunAudit', $aShortcutActions)) { $aShortcutActions[] = 'UI:Menu:RunAudit'; } return $aShortcutActions; } }