audit.rule.class.inc.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. require_once('../application/audit.category.class.inc.php');
  3. /**
  4. * This class manages the audit "rule" linked to a given audit category.
  5. * Each rule is based ona SibusQL expression that returns either the "good" objects
  6. * or the "bad" ones. The core audit engines computes the complement to the definition
  7. * set when needed to obtain either the valid objects, or the ones with an error
  8. */
  9. class AuditRule extends cmdbAbstractObject
  10. {
  11. public static function Init()
  12. {
  13. $aParams = array
  14. (
  15. "category" => "application",
  16. "name" => "AuditRule",
  17. "description" => "A rule to check for a given Audit category",
  18. "key_type" => "autoincrement",
  19. "key_label" => "",
  20. "name_attcode" => "name",
  21. "state_attcode" => "",
  22. "reconc_keys" => array('name'),
  23. "db_table" => "priv_auditrule",
  24. "db_key_field" => "id",
  25. "db_finalclass_field" => "",
  26. "display_template" => "../business/templates/default.html",
  27. );
  28. MetaModel::Init_Params($aParams);
  29. MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Rule Name", "description"=>"Short name for this rule", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  30. MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Audit Rule Description", "description"=>"Long description for this audit rule", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
  31. MetaModel::Init_AddAttribute(new AttributeText("query", array("label"=>"Query to Run", "description"=>"The SibusQL expression to run", "allowed_values"=>null, "sql"=>"query", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  32. MetaModel::Init_AddAttribute(new AttributeEnum("valid_flag", array("label"=>"Valid objects?", "description"=>"True if the rule returns the valid objects, false otherwise", "allowed_values"=>new ValueSetEnum('true,false'), "sql"=>"valid_flag", "default_value"=>"true", "is_null_allowed"=>false, "depends_on"=>array())));
  33. MetaModel::Init_AddAttribute(new AttributeExternalKey("category_id", array("label"=>"Category", "description"=>"The category for this rule", "allowed_values"=>null, "sql"=>"category_id", "targetclass"=>"AuditCategory", "is_null_allowed"=>false, "depends_on"=>array())));
  34. MetaModel::Init_AddAttribute(new AttributeExternalField("category_name", array("label"=>"Category", "description"=>"Name of the category for this rule", "allowed_values"=>null, "extkey_attcode"=> 'category_id', "target_attcode"=>"name")));
  35. MetaModel::Init_AddFilterFromAttribute("name");
  36. MetaModel::Init_AddFilterFromAttribute("description");
  37. MetaModel::Init_AddFilterFromAttribute("query");
  38. MetaModel::Init_AddFilterFromAttribute("valid_flag");
  39. MetaModel::Init_AddFilterFromAttribute("category_id");
  40. MetaModel::Init_AddFilterFromAttribute("category_name");
  41. // Display lists
  42. MetaModel::Init_SetZListItems('details', array('category_id', 'name', 'description', 'query', 'valid_flag')); // Attributes to be displayed for the complete details
  43. MetaModel::Init_SetZListItems('list', array('category_id', 'name', 'description', 'valid_flag')); // Attributes to be displayed for a list
  44. // Search criteria
  45. MetaModel::Init_SetZListItems('standard_search', array('category_id', 'name', 'description', 'valid_flag')); // Criteria of the std search form
  46. MetaModel::Init_SetZListItems('advanced_search', array('category_id', 'name', 'description', 'valid_flag', 'query')); // Criteria of the advanced search form
  47. }
  48. }
  49. ?>