/** * @since version 0.83 (before addRule) * * @param $input array of values **/ function executeAddRule($input) { $this->check($_POST["affectentity"], UPDATE); $collection = RuleCollection::getClassByType($_POST['sub_type']); $rule = $collection->getRuleClass($_POST['sub_type']); $ruleid = $rule->add($_POST); if ($ruleid) { //Add an action associated to the rule $ruleAction = new RuleAction(); //Action is : affect computer to this entity $ruleAction->addActionByAttributes("assign", $ruleid, "entities_id", $_POST["affectentity"]); switch ($_POST['sub_type']) { case 'RuleRight': if ($_POST["profiles_id"]) { $ruleAction->addActionByAttributes("assign", $ruleid, "profiles_id", $_POST["profiles_id"]); } $ruleAction->addActionByAttributes("assign", $ruleid, "is_recursive", $_POST["is_recursive"]); } } Event::log($ruleid, "rules", 4, "setup", sprintf(__('%s adds the item'), $_SESSION["glpiname"])); Html::back(); }
function addRule($input) { global $LANG; $this->check($_POST["affectentity"], 'w'); $collection = RuleCollection::getClassByType($_POST['sub_type']); $rule = $collection->getRuleClass($_POST['sub_type']); $ruleid = $rule->add($_POST); if ($ruleid) { //Add an action associated to the rule $ruleAction = new RuleAction(); //Action is : affect computer to this entity $ruleAction->addActionByAttributes("assign", $ruleid, "entities_id", $_POST["affectentity"]); switch ($_POST['sub_type']) { case 'RuleRight': if ($_POST["profiles_id"]) { $ruleAction->addActionByAttributes("assign", $ruleid, "profiles_id", $_POST["profiles_id"]); } $ruleAction->addActionByAttributes("assign", $ruleid, "is_recursive", $_POST["is_recursive"]); } } Event::log($ruleid, "rules", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][22]); glpi_header($_SERVER['HTTP_REFERER']); }