/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryManufacturer'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryMonitorType'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryComputerModel'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryOperatingSystemServicePack'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryPeripheralModel'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryPhoneType'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryNetworkEquipmentModel'); }
/** * @see CommonGLPI::getMenuContent() * * @since version 0.85 **/ static function getMenuContent() { global $CFG_GLPI; $menu = array(); if (Session::haveRight("rule_ldap", READ) || Session::haveRight("rule_ocs", READ) || Session::haveRight("entity_rule_ticket", READ) || Session::haveRight("rule_softwarecategories", READ) || Session::haveRight("rule_mailcollector", READ)) { $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber()); $menu['rule']['page'] = static::getSearchURL(false); foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) { $rulecollection = new $rulecollectionclass(); if ($rulecollection->canList()) { $ruleclassname = $rulecollection->getRuleClassName(); $menu['rule']['options'][$rulecollection->menu_option]['title'] = $rulecollection->getRuleClass()->getTitle(); $menu['rule']['options'][$rulecollection->menu_option]['page'] = Toolbox::getItemTypeSearchURL($ruleclassname, false); $menu['rule']['options'][$rulecollection->menu_option]['links']['search'] = Toolbox::getItemTypeSearchURL($ruleclassname, false); if ($rulecollection->canCreate()) { $menu['rule']['options'][$rulecollection->menu_option]['links']['add'] = Toolbox::getItemTypeFormURL($ruleclassname, false); } } } } if (Transfer::canView() && Session::isMultiEntitiesMode()) { $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber()); $menu['rule']['page'] = static::getSearchURL(false); $menu['rule']['options']['transfer']['title'] = __('Transfer'); $menu['rule']['options']['transfer']['page'] = "/front/transfer.php"; $menu['rule']['options']['transfer']['links']['search'] = "/front/transfer.php"; if (Session::haveRightsOr("transfer", array(CREATE, UPDATE))) { $menu['rule']['options']['transfer']['links']['summary'] = "/front/transfer.action.php"; $menu['rule']['options']['transfer']['links']['add'] = "/front/transfer.form.php"; } } if (Session::haveRight("rule_dictionnary_dropdown", READ) || Session::haveRight("rule_dictionnary_software", READ) || Session::haveRight("rule_dictionnary_printer", READ)) { $menu['dictionnary']['title'] = _n('Dictionary', 'Dictionaries', Session::getPluralNumber()); $menu['dictionnary']['shortcut'] = ''; $menu['dictionnary']['page'] = '/front/dictionnary.php'; $menu['dictionnary']['options']['manufacturers']['title'] = _n('Manufacturer', 'Manufacturers', Session::getPluralNumber()); $menu['dictionnary']['options']['manufacturers']['page'] = '/front/ruledictionnarymanufacturer.php'; $menu['dictionnary']['options']['manufacturers']['links']['search'] = '/front/ruledictionnarymanufacturer.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['manufacturers']['links']['add'] = '/front/ruledictionnarymanufacturer.form.php'; } $menu['dictionnary']['options']['software']['title'] = _n('Software', 'Software', Session::getPluralNumber()); $menu['dictionnary']['options']['software']['page'] = '/front/ruledictionnarysoftware.php'; $menu['dictionnary']['options']['software']['links']['search'] = '/front/ruledictionnarysoftware.php'; if (RuleDictionnarySoftware::canCreate()) { $menu['dictionnary']['options']['software']['links']['add'] = '/front/ruledictionnarysoftware.form.php'; } $menu['dictionnary']['options']['model.computer']['title'] = _n('Computer model', 'Computer models', Session::getPluralNumber()); $menu['dictionnary']['options']['model.computer']['page'] = '/front/ruledictionnarycomputermodel.php'; $menu['dictionnary']['options']['model.computer']['links']['search'] = '/front/ruledictionnarycomputermodel.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['model.computer']['links']['add'] = '/front/ruledictionnarycomputermodel.form.php'; } $menu['dictionnary']['options']['model.monitor']['title'] = _n('Monitor model', 'Monitor models', Session::getPluralNumber()); $menu['dictionnary']['options']['model.monitor']['page'] = '/front/ruledictionnarymonitormodel.php'; $menu['dictionnary']['options']['model.monitor']['links']['search'] = '/front/ruledictionnarymonitormodel.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['model.monitor']['links']['add'] = '/front/ruledictionnarymonitormodel.form.php'; } $menu['dictionnary']['options']['model.printer']['title'] = _n('Printer model', 'Printer models', Session::getPluralNumber()); $menu['dictionnary']['options']['model.printer']['page'] = '/front/ruledictionnaryprintermodel.php'; $menu['dictionnary']['options']['model.printer']['links']['search'] = '/front/ruledictionnaryprintermodel.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['model.printer']['links']['add'] = '/front/ruledictionnaryprintermodel.form.php'; } $menu['dictionnary']['options']['model.peripheral']['title'] = _n('Peripheral model', 'Peripheral models', Session::getPluralNumber()); $menu['dictionnary']['options']['model.peripheral']['page'] = '/front/ruledictionnaryperipheralmodel.php'; $menu['dictionnary']['options']['model.peripheral']['links']['search'] = '/front/ruledictionnaryperipheralmodel.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['model.peripheral']['links']['add'] = '/front/ruledictionnaryperipheralmodel.form.php'; } $menu['dictionnary']['options']['model.networking']['title'] = _n('Networking equipment model', 'Networking equipment models', Session::getPluralNumber()); $menu['dictionnary']['options']['model.networking']['page'] = '/front/ruledictionnarynetworkequipmentmodel.php'; $menu['dictionnary']['options']['model.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmentmodel.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['model.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmentmodel.form.php'; } $menu['dictionnary']['options']['model.phone']['title'] = _n('Phone model', 'Phone models', Session::getPluralNumber()); $menu['dictionnary']['options']['model.phone']['page'] = '/front/ruledictionnaryphonemodel.php'; $menu['dictionnary']['options']['model.phone']['links']['search'] = '/front/ruledictionnaryphonemodel.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['model.phone']['links']['add'] = '/front/ruledictionnaryphonemodel.form.php'; } $menu['dictionnary']['options']['type.computer']['title'] = _n('Computer type', 'Computer types', Session::getPluralNumber()); $menu['dictionnary']['options']['type.computer']['page'] = '/front/ruledictionnarycomputertype.php'; $menu['dictionnary']['options']['type.computer']['links']['search'] = '/front/ruledictionnarycomputertype.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['type.computer']['links']['add'] = '/front/ruledictionnarycomputertype.form.php'; } $menu['dictionnary']['options']['type.monitor']['title'] = _n('Monitor type', 'Monitors types', Session::getPluralNumber()); $menu['dictionnary']['options']['type.monitor']['page'] = '/front/ruledictionnarymonitortype.php'; $menu['dictionnary']['options']['type.monitor']['links']['search'] = '/front/ruledictionnarymonitortype.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['type.monitor']['links']['add'] = '/front/ruledictionnarymonitortype.form.php'; } $menu['dictionnary']['options']['type.printer']['title'] = _n('Printer type', 'Printer types', Session::getPluralNumber()); $menu['dictionnary']['options']['type.printer']['page'] = '/front/ruledictionnaryprintertype.php'; $menu['dictionnary']['options']['type.printer']['links']['search'] = '/front/ruledictionnaryprintertype.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['type.printer']['links']['add'] = '/front/ruledictionnaryprintertype.form.php'; } $menu['dictionnary']['options']['type.peripheral']['title'] = _n('Peripheral type', 'Peripheral types', Session::getPluralNumber()); $menu['dictionnary']['options']['type.peripheral']['page'] = '/front/ruledictionnaryperipheraltype.php'; $menu['dictionnary']['options']['type.peripheral']['links']['search'] = '/front/ruledictionnaryperipheraltype.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['type.peripheral']['links']['add'] = '/front/ruledictionnaryperipheraltype.form.php'; } $menu['dictionnary']['options']['type.networking']['title'] = _n('Networking equipment type', 'Networking equipment types', Session::getPluralNumber()); $menu['dictionnary']['options']['type.networking']['page'] = '/front/ruledictionnarynetworkequipmenttype.php'; $menu['dictionnary']['options']['type.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmenttype.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['type.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmenttype.form.php'; } $menu['dictionnary']['options']['type.phone']['title'] = _n('Phone type', 'Phone types', Session::getPluralNumber()); $menu['dictionnary']['options']['type.phone']['page'] = '/front/ruledictionnaryphonetype.php'; $menu['dictionnary']['options']['type.phone']['links']['search'] = '/front/ruledictionnaryphonetype.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['type.phone']['links']['add'] = '/front/ruledictionnaryphonetype.form.php'; } $menu['dictionnary']['options']['os']['title'] = __('Operating system'); $menu['dictionnary']['options']['os']['page'] = '/front/ruledictionnaryoperatingsystem.php'; $menu['dictionnary']['options']['os']['links']['search'] = '/front/ruledictionnaryoperatingsystem.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['os']['links']['add'] = '/front/ruledictionnaryoperatingsystem.form.php'; } $menu['dictionnary']['options']['os_sp']['title'] = __('Service pack'); $menu['dictionnary']['options']['os_sp']['page'] = '/front/ruledictionnaryoperatingsystemservicepack.php'; $menu['dictionnary']['options']['os_sp']['links']['search'] = '/front/ruledictionnaryoperatingsystemservicepack.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['os_sp']['links']['add'] = '/front/ruledictionnaryoperatingsystemservicepack.form.php'; } $menu['dictionnary']['options']['os_version']['title'] = __('Version of the operating system'); $menu['dictionnary']['options']['os_version']['page'] = '/front/ruledictionnaryoperatingsystemversion.php'; $menu['dictionnary']['options']['os_version']['links']['search'] = '/front/ruledictionnaryoperatingsystemversion.php'; if (RuleDictionnaryDropdown::canCreate()) { $menu['dictionnary']['options']['os_version']['links']['add'] = '/front/ruledictionnaryoperatingsystemversion.form.php'; } $menu['dictionnary']['options']['printer']['title'] = _n('Printer', 'Printers', Session::getPluralNumber()); $menu['dictionnary']['options']['printer']['page'] = '/front/ruledictionnaryprinter.php'; $menu['dictionnary']['options']['printer']['links']['search'] = '/front/ruledictionnaryprinter.php'; if (RuleDictionnaryPrinter::canCreate()) { $menu['dictionnary']['options']['printer']['links']['add'] = '/front/ruledictionnaryprinter.form.php'; } } if (count($menu)) { $menu['is_multi_entries'] = true; return $menu; } return false; }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryPhoneModel'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryOperatingSystemArchitecture'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryOperatingSystemVersion'); }
/** * Constructor **/ function __construct() { parent::__construct('RuleDictionnaryPrinterType'); }
/** * Import of Software (with Rule) * * From OcsServer class */ public function testSoftwareRule() { // Clean preload rules $tmp = SingletonRuleList::getInstance('RuleDictionnaryManufacturer'); $tmp->load = 0; $tmp = SingletonRuleList::getInstance('RuleDictionnarySoftware'); $tmp->load = 0; // Needed objetcs $rulem = new RuleDictionnaryDropdown('RuleDictionnaryManufacturer'); $rules = new RuleDictionnaryDropdown('RuleDictionnarySoftware'); $crit = new RuleCriteria(); $acte = new RuleAction(); // Rule for Manufacturer $idr[0] = $rulem->add(array('name' => 'test1', 'sub_type' => 'RuleDictionnaryManufacturer', 'match' => 'AND', 'is_active' => 1)); $this->assertGreaterThan(0, $idr[0], "Fail: can't create manufacturer rule"); $this->assertTrue($rulem->getFromDB($idr[0])); $this->assertEquals(1, $rulem->fields['ranking'], "Fail: ranking not set"); $idc[0] = $crit->add(array('rules_id' => $idr[0], 'criteria' => 'name', 'condition' => Rule::PATTERN_CONTAIN, 'pattern' => 'indepnet')); $this->assertGreaterThan(0, $idc[0], "Fail: can't create manufacturer rule criteria"); $ida[0] = $acte->add(array('rules_id' => $idr[0], 'action_type' => 'assign', 'field' => 'name', 'value' => $outm = 'Indepnet')); $this->assertGreaterThan(0, $ida[0], "Fail: can't create manufacturer rule action"); // Rule for Software $idr[1] = $rules->add(array('name' => 'test2', 'sub_type' => 'RuleDictionnarySoftware', 'match' => 'AND', 'is_active' => 1)); $this->assertGreaterThan(0, $idr[1], "Fail: can't create software rule"); $this->assertTrue($rules->getFromDB($idr[1])); $this->assertEquals(1, $rules->fields['ranking'], "Fail: ranking not set"); $idc[1] = $crit->add(array('rules_id' => $idr[1], 'criteria' => 'name', 'condition' => Rule::REGEX_MATCH, 'pattern' => '/^glpi (0\\.[0-9]+)/')); $this->assertGreaterThan(0, $idc[1], "Fail: can't create software rule criteria"); $ida[1] = $acte->add(array('rules_id' => $idr[1], 'action_type' => 'assign', 'field' => 'name', 'value' => $outs = 'GLPI')); $this->assertGreaterThan(0, $ida[1], "Fail: can't create software rule action"); $ida[2] = $acte->add(array('rules_id' => $idr[1], 'action_type' => 'regex_result', 'field' => 'version', 'value' => $outv = '#0')); $this->assertGreaterThan(0, $ida[2], "Fail: can't create software rule action"); // Apply Rule to manufacturer $manu = Dropdown::import('Manufacturer', 'the indepnet team'); $this->assertEquals('Indepnet', $manu, "Fail: manufacturer not altered"); // Apply Rule to software $rulecollection = new RuleDictionnarySoftwareCollection(); $res_rule = $rulecollection->processAllRules(array("name" => 'glpi 0.78', "manufacturer" => $manu, "old_version" => ''), array(), array()); $this->assertArrayHasKey('name', $res_rule, "Fail: name not altered"); $this->assertEquals('GLPI', $res_rule['name'], "Fail: name not correct"); $this->assertArrayHasKey('version', $res_rule, "Fail: name not altered"); $this->assertEquals('0.78', $res_rule['version'], "Fail: version not correct"); // Clean $this->assertTrue($rulem->delete(array('id' => $idr[0]))); $this->assertTrue($rules->delete(array('id' => $idr[1]))); }
/** * Constructor **/ function __construct() { parent::__construct('PluginFusioninventoryRuleDictionnaryComputerArch'); }