summaryrefslogtreecommitdiff
path: root/lib/kolab_api_service.php
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-06-21 10:52:17 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-06-21 10:52:17 (GMT)
commit7f7fbccc120c2206d2ba6976d033a8a60d02297c (patch)
treec8553f4a0543cdd535a2b0ec8f4518b44b744cbb /lib/kolab_api_service.php
parentc1109dfdf8929e13084fe72fbc334a2d1481805a (diff)
downloadkolab-wap-7f7fbccc120c2206d2ba6976d033a8a60d02297c.tar.gz
On the off-chance the object_type_id for a resource is to be determined, use additional attributes as well (#853)
Diffstat (limited to 'lib/kolab_api_service.php')
-rw-r--r--lib/kolab_api_service.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index b984d54..cbe27ba 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -107,14 +107,16 @@ abstract class kolab_api_service
* Detects object type ID for specified objectClass attribute value
*
* @param string $object_name Name of the object (user, group, etc.)
- * @param array $object_class Value of objectClass attribute
+ * @param array $attributes Array of attributes and values
*
* @return int Object type identifier
*/
- protected function object_type_id($object_name, $object_class)
+ protected function object_type_id($object_name, $attributes)
{
if ($object_name == 'domain') return 1;
+ $object_class = $attributes['objectclass'];
+
if (empty($object_class)) {
return null;
}
@@ -151,6 +153,18 @@ abstract class kolab_api_service
$type_id = $idx;
$type_score = $elem_score;
}
+
+ // On the likely chance that the object is a resource (types of which likely have the same
+ // set of objectclass attribute values), consider the other attributes. (#853)
+ if ($object_name == 'resource') {
+ //console("From database", $elem);
+ //console("Element key is " . $elem['key'] . " and \$attributes['mail'] is " . $attributes['mail']);
+
+ if (strstr($attributes['mail'], "-" . $elem['key'] . "-")) {
+ $type_id = $idx;
+ $type_score = 10;
+ }
+ }
}
return $type_id;
@@ -303,7 +317,7 @@ abstract class kolab_api_service
$extra_attrs = array();
// add group type id to the result
- $attrs['type_id'] = $this->object_type_id($object_name, $attrs['objectclass']);
+ $attrs['type_id'] = $this->object_type_id($object_name, $attrs);
if (empty($attrs['type_id'])) {
if ($object_name == 'domain') {