From ba590165e885e0f44a3efccb652fbf33f9b1dac1 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sat, 16 Aug 2014 15:21:40 +0200
Subject: [PATCH] Add functions: contains_only, contains_none

---
 rules_shipping_base.php | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/rules_shipping_base.php b/rules_shipping_base.php
index e63a4bf..c67b044 100644
--- a/rules_shipping_base.php
+++ b/rules_shipping_base.php
@@ -923,19 +923,31 @@ class ShippingRule {
 		// Extract the array from the args, the $args varialbe will now only contain the elements to be checked:
 		$array = array_shift($args);
 		switch ($function) {
-			case "contains_any": 
+			case "contains_any": // return true if one of the $args is in the $array
 					foreach ($args as $a) { 
 						if (in_array($a, $array)) 
 							return true; 
 					}
 					return false;
 			
-			case "contains_all":
+			case "contains_all": // return false if one of the $args is NOT in the $array
 					foreach ($args as $a) { 
 						if (!in_array($a, $array)) 
 							return false; 
 					}
 					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: 
 				JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring), 'error');
 				return false;
-- 
GitLab