Code

Hide php errors
[gosa.git] / plugins / admin / applications / class_applicationGeneric.inc
index 4330a54e09bacfb89459e56a5c09215a966d2a23..351d6e458cb1234aa8183e055ddd26173d6a8903 100644 (file)
@@ -31,7 +31,9 @@ class application extends plugin
 
        /* Load icon */
        $ldap= $config->get_ldap_link();
-       $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon");
+       if ($dn != 'new'){
+               $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon");
+       }
        if ($this->iconData == ""){
                $this->set_picture("");
        }
@@ -41,12 +43,16 @@ class application extends plugin
        /* This is always an account */
        $this->is_account= TRUE;
 
-        if ($this->dn == "new"){
-               $ui= get_userinfo();
-               $this->base= dn2base($ui->dn);
+       if ($this->dn == "new"){
+               if(isset($_SESSION['appfilter']['depselect'])){
+                       $this->base=$_SESSION['appfilter']['depselect'];
+               }else{
+                       $ui= get_userinfo();
+                       $this->base= dn2base($ui->dn);
+               }
        } else {
-                $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
-        }
+               $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
+       }
   }
 
   function execute()
@@ -96,6 +102,7 @@ class application extends plugin
        return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
   }
 
+
   function remove_from_parent()
   {
        $ldap= $this->config->get_ldap_link();
@@ -112,6 +119,12 @@ class application extends plugin
                unset($og->member[$this->dn]);
                $og->save ();
        }
+       $ldap->search ("(&(objectClass=posixGroup)(gosaMemberApplication=".$this->cn."))", array("cn"));
+       while ($attrs= $ldap->fetch()){
+               $ag= new appgroup($this->config, $ldap->getDN());
+               $ag->removeApp($this->cn);
+               $ag->save ();
+       }
 
   }