Code

Fixed msgs for applications / departments / fai
[gosa.git] / plugins / admin / applications / class_applicationGeneric.inc
index 2b5e5a645a9053fe48a138493570d2c62e3eea51..ff957bbfd97bbc32e4757f663e660277deccd060 100644 (file)
@@ -56,8 +56,8 @@ class application extends plugin
     $this->is_account= TRUE;
 
     if ($this->dn == "new"){
-      if(isset($_SESSION['appfilter']['depselect'])){
-        $this->base=$_SESSION['appfilter']['depselect'];
+      if(isset($_SESSION['CurrentMainBase'])){
+        $this->base= $_SESSION['CurrentMainBase'];
       }else{
         $ui= get_userinfo();
         $this->base= dn2base($ui->dn);
@@ -135,6 +135,31 @@ class application extends plugin
       $smarty->assign("namemode", "readonly");
       $smarty->assign("selectmode", "disabled");
     }
+    
+    /* Base select dialog */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^chooseBase/",$name) && $once){
+        $once = false;
+        $this->dialog = new baseSelectDialog($this->config,$this);
+        $this->dialog->setCurrentBase($this->base);
+      }
+    }
+
+    /* Dialog handling */
+    if(is_object($this->dialog)){
+      /* Must be called before save_object */
+      $this->dialog->save_object();
+
+      if($this->dialog->isClosed()){
+        $this->dialog = false;
+      }elseif($this->dialog->isSelected()){
+        $this->base = $this->dialog->isSelected();
+        $this->dialog= false;
+      }else{
+        return($this->dialog->execute());
+      }
+    }
 
     /* Get random number for pictures */
     srand((double)microtime()*1000000);
@@ -145,6 +170,7 @@ class application extends plugin
       $smarty->assign($val, $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
+    $smarty->assign("baseACL", chkacl($this->acl,"base"));
 
     /* Checkboxes */
     foreach (array("G" => "exec_for_groupmembers", "O" => "overwrite_config",
@@ -170,6 +196,7 @@ class application extends plugin
   {
     $ldap= $this->config->get_ldap_link();
     $ldap->rmDir($this->dn);
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of applciation with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove");
@@ -181,12 +208,14 @@ class application extends plugin
       $og= new ogroup($this->config, $ldap->getDN());
       unset($og->member[$this->dn]);
       $og->save ();
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing application from objectgroup '%s' failed"), $og->dn));
     }
     $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 ();
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing application from group '%s' failed"), $ag->dn));
     }
 
   }
@@ -370,7 +399,7 @@ class application extends plugin
 
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
-    $ldap->cat($this->dn);
+    $ldap->cat($this->dn, array('dn'));
 
     $a= $ldap->fetch();
     if (count($a)){
@@ -385,7 +414,7 @@ class application extends plugin
       $ldap->add($this->attrs);
       $this->handle_post_events("add");
     }
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of application with dn '%s' failed."),$this->dn));
   }
 
   function set_picture($filename)