Selaa lähdekoodia

Fixed Trac#313: Provider contracts are filtered on the 'provider_id' - for filtering in the UI via the drop-down list of Organizations and for the security profiles ("Allowed Organizations"). The mapping for 'org_id', if any, is now taken into account by the security.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1120 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 vuotta sitten
vanhempi
commit
584f54a7a4

+ 8 - 0
addons/userrights/userrightsprofile.class.inc.php

@@ -649,6 +649,14 @@ exit;
 		{
 			$sAttCode = 'id';
 		}
+		elseif (is_callable("$sClass::MapContextParam"))
+		{
+			$sAttCode = eval("return $sClass::MapContextParam('org_id');"); // Returns null when there is no mapping for this parameter
+			if ($sAttCode == null)
+			{
+				return true;
+			}
+		}
 		elseif(MetaModel::IsValidAttCode($sClass, 'org_id'))
 		{
 			$sAttCode = 'org_id';

+ 17 - 0
modules/itop-service-mgmt-1.0.0/model.itop-service-mgmt.php

@@ -92,6 +92,23 @@ class ProviderContract extends Contract
 		MetaModel::Init_SetZListItems('standard_search', array('name', 'description', 'start_date', 'end_date', 'cost', 'cost_currency', 'cost_unit', 'billing_frequency', 'provider_id', 'sla', 'coverage'));
 		MetaModel::Init_SetZListItems('list', array('start_date', 'end_date', 'provider_id', 'sla', 'coverage'));
 	}
+
+	/**
+	 * Maps the given context parameter name to the appropriate filter/search code for this class
+	 * @param string $sContextParam Name of the context parameter, e.g. 'org_id'
+	 * @return string Filter code, e.g. 'customer_id'
+	 */
+	public static function MapContextParam($sContextParam)
+	{
+		if ($sContextParam == 'org_id')
+		{
+			return 'provider_id';
+		}
+		else
+		{
+			return $sContextParam;
+		}
+	}
 }
 class CustomerContract extends Contract
 {