Code

Fixed Ogroup Copy & Paste for workstation startup
[gosa.git] / plugins / generic / references / class_reference.inc
index 43d945dbeb41c00b70c0929018b7f1cb0f87561b..4b17529dbbbf318a30ffc91b5e3ebb99f40418d4 100644 (file)
@@ -106,6 +106,9 @@ class reference extends plugin
                        }
                        foreach ($attrs[$memberattr] as $uid){
                                $content= $this->getCacheObject($uid);
+                               if ($content == NULL){
+                                       continue;
+                               }
                                $addon.= '<tr style="background-color:'.$cycle[$id&1].';"><td title="'.$attrs['cn'][0].'">&nbsp;&nbsp;&nbsp;'.$content['name'].'</td><td>'.$content['description'].'</td><td>'.$content['type'].'</td> </tr>';
                        }
                }
@@ -138,15 +141,19 @@ class reference extends plugin
                } else {
                        $ldap->search("(uid=$dn)", array("cn", "objectClass", "description"));
                }
-               $attrs= $ldap->fetch();
-               if (isset($attrs['description'])){
-                       $description= $attrs['description'][0];
+               if ($ldap->count()){
+                       $attrs= $ldap->fetch();
+                       if (isset($attrs['description'])){
+                               $description= $attrs['description'][0];
+                       } else {
+                               $description= "-";
+                       }
+                       $this->objectCache[$dn]= array( 'name' => $attrs['cn'][0],
+                                       'description' => "$description",
+                                       'type' => $this->createContentString($attrs['objectClass']));
                } else {
-                       $description= "-";
+                       return NULL;
                }
-               $this->objectCache[$dn]= array( 'name' => $attrs['cn'][0],
-                                               'description' => "$description",
-                                               'type' => $this->createContentString($attrs['objectClass']));
        }
        return ($this->objectCache[$dn]);
   }
@@ -154,11 +161,13 @@ class reference extends plugin
   function createContentString($classes)
   {
        $result= "";
-       foreach ($classes as $class){
-               if (isset($this->obtypes[$class])){
-                       $result.= "<a><img alt=\"\" border=0 src='images/".$this->obtypes[$class]['image']."'>&nbsp;".$this->obtypes[$class]['text']."</a> ";
+       if(!is_null($classes)) {
+               foreach ($classes as $class){
+                       if (isset($this->obtypes[$class])){
+                               $result.= "<a><img alt=\"\" border=0 src='images/".$this->obtypes[$class]['image']."'>&nbsp;".$this->obtypes[$class]['text']."</a> ";
+                       }
                }
-       }       
+       }
        return (preg_replace('/ $/', '', $result));
   }