Skip to content
Snippets Groups Projects
Commit ba590165 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Add functions: contains_only, contains_none

parent 0a10823d
No related branches found
No related tags found
No related merge requests found
...@@ -923,19 +923,31 @@ class ShippingRule { ...@@ -923,19 +923,31 @@ class ShippingRule {
// Extract the array from the args, the $args varialbe will now only contain the elements to be checked: // Extract the array from the args, the $args varialbe will now only contain the elements to be checked:
$array = array_shift($args); $array = array_shift($args);
switch ($function) { switch ($function) {
case "contains_any": case "contains_any": // return true if one of the $args is in the $array
foreach ($args as $a) { foreach ($args as $a) {
if (in_array($a, $array)) if (in_array($a, $array))
return true; return true;
} }
return false; return false;
case "contains_all": case "contains_all": // return false if one of the $args is NOT in the $array
foreach ($args as $a) { foreach ($args as $a) {
if (!in_array($a, $array)) if (!in_array($a, $array))
return false; return false;
} }
return true; return true;
case "contains_only": // return false if one of the $array elements is NOT in $args
foreach ($array as $a) {
if (!in_array($a, $args))
return false;
}
return true;
case "contains_none": // return false if one of the $args IS in the $array
foreach ($args as $a) {
if (in_array($a, $array))
return false;
}
return true;
default: default:
JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring), 'error'); JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring), 'error');
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment