本文整理汇总了PHP中RuleAction::getRegexResultById方法的典型用法代码示例。如果您正苦于以下问题:PHP RuleAction::getRegexResultById方法的具体用法?PHP RuleAction::getRegexResultById怎么用?PHP RuleAction::getRegexResultById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleAction
的用法示例。
在下文中一共展示了RuleAction::getRegexResultById方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeActions
function executeActions($output, $params)
{
PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-entityrules", "execute action\n");
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-entityrules", "value " . $action->fields["value"] . "\n");
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "regex_result":
//Assign entity using the regex's result
if ($action->fields["field"] == "_affect_entity_by_tag") {
PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-entityrules", "value " . $action->fields["value"] . "\n");
//Get the TAG from the regex's results
$res = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
if (!is_null($res)) {
//Get the entity associated with the TAG
$target_entity = Entity::getEntityIDByTag($res);
if ($target_entity != '') {
$output["entities_id"] = $target_entity;
} else {
$output['pass_rule'] = True;
}
}
}
break;
}
}
}
return $output;
}
示例2: executeActions
/**
* @see Rule::executeActions()
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "regex_result":
//Assign entity using the regex's result
if ($action->fields["field"] == "_affect_entity_by_tag") {
//Get the TAG from the regex's results
if (isset($this->regex_results[0])) {
$res = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
} else {
$res = $action->fields["value"];
}
if ($res != null) {
//Get the entity associated with the TAG
$target_entity = Entity::getEntityIDByTag($res);
if ($target_entity != '') {
$output["entities_id"] = $target_entity;
}
}
}
break;
}
}
}
return $output;
}
示例3: executeActions
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "regex_result":
//Regex result : assign value from the regex
$res = "";
if (isset($this->regex_results[0])) {
$res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
} else {
$res .= $action->fields["value"];
}
if ($res != '' && ($action->fields["field"] != 'user' && $action->fields["field"] != 'otherserial' && $action->fields["field"] != 'software' && $action->fields["field"] != 'softwareversion')) {
$res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res);
}
$output[$action->fields["field"]] = $res;
break;
default:
//plugins actions
$executeaction = clone $this;
$ouput = $executeaction->executePluginsActions($action, $output, $params);
break;
}
}
}
return $output;
}
示例4: executeActions
function executeActions($output, $params)
{
PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-locationrules", "execute action\n");
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-locationrules", "value " . $action->fields["value"] . "\n");
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "regex_result":
$res = '';
if (isset($this->regex_results[0])) {
$res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
} else {
$res .= $action->fields["value"];
}
if ($res != '') {
$entities_id = 0;
if (isset($_SESSION["plugin_fusioninventory_entity"]) && $_SESSION["plugin_fusioninventory_entity"] > 0) {
$entities_id = $_SESSION["plugin_fusioninventory_entity"];
}
$res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res, $entities_id);
}
$output[$action->fields["field"]] = $res;
break;
}
}
}
return $output;
}
示例5: executeActions
/**
* @param $output
* @param $params
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "send":
$ticket = new Ticket();
if ($ticket->getFromDB($output['id'])) {
NotificationEvent::raiseEvent('recall', $ticket);
}
break;
case "add_validation":
if (isset($output['_add_validation']) && !is_array($output['_add_validation'])) {
$output['_add_validation'] = array($output['_add_validation']);
}
switch ($action->fields['field']) {
case 'users_id_validate_requester_supervisor':
$output['_add_validation'][] = 'requester_supervisor';
break;
case 'users_id_validate_assign_supervisor':
$output['_add_validation'][] = 'assign_supervisor';
break;
case 'groups_id_validate':
$output['_add_validation']['group'][] = $action->fields["value"];
break;
case 'users_id_validate':
$output['_add_validation'][] = $action->fields["value"];
break;
case 'validation_percent':
$output[$action->fields["field"]] = $action->fields["value"];
break;
default:
$output['_add_validation'][] = $action->fields["value"];
break;
}
break;
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
// Special case of users_id_requester
if ($action->fields["field"] === '_users_id_requester') {
// Add groups of requester
if (!isset($output['_groups_id_of_requester'])) {
$output['_groups_id_of_requester'] = array();
}
foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
$output['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
break;
case "append":
$actions = $this->getActions();
$value = $action->fields["value"];
if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) {
$value = $actions[$action->fields["field"]]["appendtoarray"];
$value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"];
}
$output[$actions[$action->fields["field"]]["appendto"]][] = $value;
// Special case of users_id_requester
if ($action->fields["field"] === '_users_id_requester') {
// Add groups of requester
if (!isset($output['_groups_id_of_requester'])) {
$output['_groups_id_of_requester'] = array();
}
foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
$output['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
break;
case 'fromuser':
if ($action->fields['field'] == 'locations_id' && isset($output['users_locations'])) {
$output['locations_id'] = $output['users_locations'];
}
break;
case 'fromitem':
if ($action->fields['field'] == 'locations_id' && isset($output['items_locations'])) {
$output['locations_id'] = $output['items_locations'];
}
if ($action->fields['field'] == 'groups_id' && isset($output['items_groups'])) {
$output['groups_id'] = $output['items_groups'];
}
break;
case 'compute':
// Value could be not set (from test)
$urgency = isset($output['urgency']) ? $output['urgency'] : 3;
$impact = isset($output['impact']) ? $output['impact'] : 3;
// Apply priority_matrix from config
$output['priority'] = Ticket::computePriority($urgency, $impact);
break;
case "affectbyip":
case "affectbyfqdn":
case "affectbymac":
if (!isset($output["entities_id"])) {
$output["entities_id"] = $params["entities_id"];
}
if (isset($this->regex_results[0])) {
$regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
//.........这里部分代码省略.........
示例6: executeActions
/**
* Execute the actions as defined in the rule
*
* @see Rule::executeActions()
*
* @param $output the result of the actions
* @param $params the parameters
*
* @return the fields modified
**/
function executeActions($output, $params)
{
global $CFG_GLPI;
$entity = '';
$right = '';
$is_recursive = 0;
$continue = true;
$output_src = $output;
if (count($this->actions)) {
$entity = array();
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
switch ($action->fields["field"]) {
case "entities_id":
$entity[] = $action->fields["value"];
break;
case "profiles_id":
$right = $action->fields["value"];
break;
case "is_recursive":
$is_recursive = $action->fields["value"];
break;
case "is_active":
$output["is_active"] = $action->fields["value"];
break;
case "_ignore_user_import":
$continue = false;
$output_src["_stop_import"] = true;
break;
}
// switch (field)
break;
case "regex_result":
switch ($action->fields["field"]) {
case "_affect_entity_by_dn":
case "_affect_entity_by_tag":
case "_affect_entity_by_domain":
case "_affect_entity_by_completename":
foreach ($this->regex_results as $regex_result) {
$res = RuleAction::getRegexResultById($action->fields["value"], $regex_result);
if ($res != null) {
switch ($action->fields["field"]) {
case "_affect_entity_by_dn":
$entity_found = Entity::getEntityIDByDN(addslashes($res));
break;
case "_affect_entity_by_tag":
$entity_found = Entity::getEntityIDByTag(addslashes($res));
break;
case "_affect_entity_by_domain":
$entity_found = Entity::getEntityIDByDomain(addslashes($res));
break;
case "_affect_entity_by_completename":
$res = Toolbox::unclean_cross_side_scripting_deep($res);
$entity_found = Entity::getEntityIDByCompletename(addslashes($res));
break;
default:
$entity_found = -1;
break;
}
//If an entity was found
if ($entity_found > -1) {
$entity[] = $entity_found;
}
}
}
if (!count($entity)) {
//Not entity assigned : action processing must be stopped for this rule
$continue = false;
}
break;
}
// switch (field)
break;
}
// switch (action_type)
}
// foreach (action)
}
// count (actions)
if ($continue) {
//Nothing to be returned by the function :
//Store in session the entity and/or right
if (count($entity)) {
if ($right != '') {
foreach ($entity as $entID) {
$output["_ldap_rules"]["rules_entities_rights"][] = array($entID, $right, $is_recursive);
}
} else {
foreach ($entity as $entID) {
//.........这里部分代码省略.........
示例7: executeActions
/**
* @see Rule::executeActions()
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
switch ($action->fields["field"]) {
default:
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "_affect_entity_by_user_entity":
//3 cases :
//1 - rule contains a criteria like : Profil is XXXX
// -> in this case, profiles_id is stored in
// $this->criterias_results['PROFILES'] (one value possible)
//2- rule contains criteria "User has only one profile"
// -> in this case, profiles_id is stored in
// $this->criterias_results['PROFILES'] (one value possible) (same as 1)
//3 -> rule contains only one profile
$profile = 0;
//Case 2:
if (isset($this->criterias_results['ONE_PROFILE'])) {
$profile = $this->criterias_results['ONE_PROFILE'];
//Case 3
} else {
if (isset($this->criterias_results['UNIQUE_PROFILE'])) {
$profile = $this->criterias_results['UNIQUE_PROFILE'];
//Case 1
} else {
if (isset($this->criterias_results['PROFILES'])) {
$profile = $this->criterias_results['PROFILES'];
}
}
}
if ($profile) {
$entities = array();
if (isset($params['_users_id_requester'])) {
// Not set when testing
$entities = Profile_User::getEntitiesForProfileByUser($params['_users_id_requester'], $profile);
}
//Case 2 : check if there's only one profile for this user
if (isset($this->criterias_results['ONE_PROFILE']) && count($entities) == 1 || !isset($this->criterias_results['ONE_PROFILE'])) {
if (count($entities) == 1) {
//User has right on only one entity
$output['entities_id'] = array_pop($entities);
} else {
if (isset($this->criterias_results['UNIQUE_PROFILE'])) {
$output['entities_id'] = array_pop($entities);
} else {
//Rights on more than one entity : get the user's prefered entity
if (isset($params['_users_id_requester'])) {
// Not set when testing
$user = new User();
$user->getFromDB($params['_users_id_requester']);
$tmpid = $user->getField('entities_id');
// Retrieve all the entities (pref could be set on a child)
$entities = Profile_User::getEntitiesForProfileByUser($params['_users_id_requester'], $profile, true);
// If an entity is defined in user's preferences,
// and this entity allowed for this profile, use this one
// else do not set the rule as matched
if (in_array($tmpid, $entities)) {
$output['entities_id'] = $user->fields['entities_id'];
}
}
}
}
}
}
}
break;
case "regex_result":
foreach ($this->regex_results as $regex_result) {
$entity_found = -1;
$res = RuleAction::getRegexResultById($action->fields["value"], $regex_result);
if ($res != null) {
switch ($action->fields["field"]) {
case "_affect_entity_by_domain":
$entity_found = Entity::getEntityIDByDomain(addslashes($res));
break;
case "_affect_entity_by_tag":
$entity_found = Entity::getEntityIDByTag(addslashes($res));
break;
}
//If an entity was found
if ($entity_found > -1) {
$output['entities_id'] = $entity_found;
break;
}
}
}
// switch (field)
break;
}
}
}
return $output;
}
示例8: executeActions
/**
* Execute the actions as defined in the rule
*
* @param $output the fields to manipulate
* @param $params parameters
*
* @return the $output array modified
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "append":
$actions = $this->getActions();
$value = $action->fields["value"];
if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) {
$value = $actions[$action->fields["field"]]["appendtoarray"];
$value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"];
}
$output[$actions[$action->fields["field"]]["appendto"]][] = $value;
break;
case "regex_result":
case "append_regex_result":
//Regex result : assign value from the regex
//Append regex result : append result from a regex
if ($action->fields["action_type"] == "append_regex_result") {
$res = isset($params[$action->fields["field"]]) ? $params[$action->fields["field"]] : "";
} else {
$res = "";
}
if (isset($this->regex_results[0])) {
$res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
} else {
$res .= $action->fields["value"];
}
$output[$action->fields["field"]] = $res;
break;
default:
//plugins actions
$executeaction = clone $this;
$ouput = $executeaction->executePluginsActions($action, $output, $params);
break;
}
}
}
return $output;
}
示例9: executeActions
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "send":
$ticket = new Ticket();
if ($ticket->getFromDB($output['id'])) {
NotificationEvent::raiseEvent('recall', $ticket);
}
break;
case "add_validation":
$output['_add_validation'] = $action->fields["value"];
break;
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
break;
case 'compute':
// Value could be not set (from test)
$urgency = isset($output['urgency']) ? $output['urgency'] : 3;
$impact = isset($output['impact']) ? $output['impact'] : 3;
// Apply priority_matrix from config
$output['priority'] = Ticket::computePriority($urgency, $impact);
break;
case "affectbyip":
case "affectbyfqdn":
case "affectbymac":
if (!isset($output["entities_id"])) {
$output["entities_id"] = $params["entities_id"];
}
if (isset($this->regex_results[0])) {
$regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
} else {
$regexvalue = $action->fields["value"];
}
switch ($action->fields["action_type"]) {
case "affectbyip":
$result = NetworkPort::getUniqueObjectIDByIPAddressOrMac($regexvalue, "IP", $output["entities_id"]);
break;
case "affectbyfqdn":
$result = NetworkPort::getUniqueObjectIDByFQDN($regexvalue, $output["entities_id"]);
break;
case "affectbymac":
$result = NetworkPort::getUniqueObjectIDByIPAddressOrMac($regexvalue, "MAC", $output["entities_id"]);
break;
default:
$result = array();
}
if (!empty($result)) {
$output["itemtype"] = $result["itemtype"];
$output["items_id"] = $result["id"];
}
break;
}
}
}
return $output;
}
示例10: executeActions
/**
* Execute the actions as defined in the rule
* @param $output the result of the actions
* @param $params the parameters
* @return the fields modified
**/
function executeActions($output, $params)
{
global $CFG_GLPI;
$entity = '';
$right = '';
$is_recursive = 0;
$continue = true;
$output_src = $output;
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
switch ($action->fields["field"]) {
case "entities_id":
$entity = $action->fields["value"];
break;
case "profiles_id":
$right = $action->fields["value"];
break;
case "is_recursive":
$is_recursive = $action->fields["value"];
break;
case "is_active":
$output["is_active"] = $action->fields["value"];
break;
case "_ignore_user_import":
$continue = false;
$output_src["_stop_import"] = true;
break;
}
// switch (field)
break;
case "regex_result":
switch ($action->fields["field"]) {
case "_affect_entity_by_dn":
case "_affect_entity_by_tag":
case "_affect_entity_by_domain":
$match_entity = false;
$entity = array();
foreach ($this->regex_results as $regex_result) {
$res = RuleAction::getRegexResultById($action->fields["value"], $regex_result);
if ($res != null) {
switch ($action->fields["field"]) {
case "_affect_entity_by_dn":
$entity_found = EntityData::getEntityIDByDN($res);
break;
case "_affect_entity_by_tag":
$entity_found = EntityData::getEntityIDByTag($res);
break;
case "_affect_entity_by_domain":
$entity_found = EntityData::getEntityIDByDomain($res);
break;
default:
$entity_found = -1;
break;
}
//If an entity was found
if ($entity_found > -1) {
array_push($entity, array($entity_found, $is_recursive));
$match_entity = true;
}
}
}
if (!$match_entity) {
//Not entity assigned : action processing must be stopped for this rule
$continue = false;
}
break;
}
// switch (field)
break;
}
// switch (action_type)
}
// foreach (action)
}
// count (actions)
if ($continue) {
//Nothing to be returned by the function :
//Store in session the entity and/or right
if ($entity != '' && $right != '') {
$output["_ldap_rules"]["rules_entities_rights"][] = array($entity, $right, $is_recursive);
} else {
if ($entity != '') {
if (!is_array($entity)) {
$entities_array = array($entity, $is_recursive);
$output["_ldap_rules"]["rules_entities"][] = array($entities_array);
//If it comes from a regex with multiple results
} else {
$output["_ldap_rules"]["rules_entities"][] = $entity;
}
} else {
if ($right != '') {
$output["_ldap_rules"]["rules_rights"][] = $right;
//.........这里部分代码省略.........
示例11: executeActions
/**
* Execute the actions as defined in the rule
*
* @param $output the fields to manipulate
* @param $params parameters
*
* @return the $output array modified
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
break;
case "regex_result":
case "append_regex_result":
//Regex result : assign value from the regex
//Append regex result : append result from a regex
if ($action->fields["action_type"] == "append_regex_result") {
$res = isset($params[$action->fields["field"]]) ? $params[$action->fields["field"]] : "";
} else {
$res = "";
}
if (isset($this->regex_results[0])) {
$res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
} else {
$res .= $action->fields["value"];
}
$output[$action->fields["field"]] = $res;
break;
default:
//Each type can add his own actions
$output = $this->executeSpecificActions($output, $params);
break;
}
}
}
return $output;
}