Code

Simplified the way we handle tags. This *may* break tagging. Needs testing.
[gosa.git] / include / functions.inc
index e83805413ea93da35bb4f1171bef0653a685d113..70ab363acedfc872f34830b1a1dd11b2ae7d51fc 100644 (file)
@@ -2604,6 +2604,45 @@ function is_in_network($network, $netmask, $address)
 }
 
 
+/* Add a given objectClass to an attrs entry */
+function add_objectClass($classes, &$attrs)
+{
+       if (is_array($classes)){
+               $list= $classes;
+       } else {
+               $list= array($classes);
+       }
+
+       foreach ($list as $class){
+               $attrs['objectClass'][]= $class;
+       }
+}
+
+
+/* Removes a given objectClass from the attrs entry */
+function remove_objectClass($classes, &$attrs)
+{
+       if (isset($attrs['objectClass'])){
+               /* Array? */
+               if (is_array($classes)){
+                       $list= $classes;
+               } else {
+                       $list= array($classes);
+               }
+
+               $tmp= array();
+               foreach ($attrs['objectClass'] as $oc) {
+                       foreach ($list as $class){
+                               if ($oc != $class){
+                                       $tmp[]= $oc;
+                               }
+                       }
+               }
+               $attrs['objectClass']= $tmp;
+       }
+}
+
+
 /* Returns contents of the given POST variable and check magic quotes settings */
 function get_post($name)
 {