Code

Added storage RDN properties.
[gosa.git] / gosa-plugins / goto / admin / applications / class_applicationGeneric.inc
index b6caa4d92e41ee5becc1d495299430004d078fb3..bf11b1f7aba247fc43dd11fe70a9124912a42532 100644 (file)
@@ -28,6 +28,8 @@ class application extends plugin
   var $objectclasses= array("top", "gosaApplication");
   var $FAIstate ="";
 
+  var $baseSelector;
+
   function application (&$config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
@@ -57,12 +59,18 @@ class application extends plugin
         $this->base= dn2base($ui->dn);
       }
     } else {
-      $this->base= preg_replace ("/^[^,]+,".get_ou('applicationRDN')."/", "", $this->dn);
+      $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou('applicationRDN'), '/')."/i", "", $this->dn);
     }
 
     $this->orig_cn = $this->cn;
     $this->orig_base = $this->base;
     $this->gosaApplicationFlags = preg_replace("/[^GDLMO]/","",$this->gosaApplicationFlags);
+
+    /* Instanciate base selector */
+    $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
+    $this->baseSelector->setSubmitButton(false);
+    $this->baseSelector->setHeight(300);
+    $this->baseSelector->update(true);
   }
 
 
@@ -115,6 +123,9 @@ class application extends plugin
 
     $smarty= get_smarty();
 
+    /* Assign base ACL */
+    $smarty->assign("base", $this->baseSelector->render());
+
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translation){
       $smarty->assign($name."ACL",$this->getacl($name, preg_match("/freeze/i",$this->FAIstate)));
@@ -167,36 +178,6 @@ class application extends plugin
       $smarty->assign("selectmode", "disabled");
     }
     
-    /* Base select dialog */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once && !preg_match("/freeze/i",$this->FAIstate)){
-        $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
-        $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()){
-        /* Just allow selection valid bases */ 
-        $tmp = $this->get_allowed_bases();
-        if(isset($tmp[$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);
     $smarty->assign("rand", rand(0, 10000));
@@ -227,10 +208,8 @@ class application extends plugin
 
   function remove_from_parent()
   {
-    restore_error_handler();
-
     /* Parse release out of object dn */
-    $release = preg_replace("/".get_ou("applicationRDN").preg_quote($this->base, '/')."$/","",$this->dn);
+    $release = preg_replace("/".preg_quote(get_ou("applicationRDN").$this->base, '/')."$/i","",$this->dn);
     $release = preg_replace("/^cn=[^,]+,/","",$release);
 
     /* Get a list of all groups 
@@ -304,6 +283,20 @@ class application extends plugin
       plugin::save_object();
       $this->base = $base_tmp;
 
+      /* Refresh base */
+      if(!$this->is_release()){
+        if ($this->acl_is_moveable($this->base)){
+          if (!$this->baseSelector->update()) {
+            msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
+          }
+          if ($this->base != $this->baseSelector->getBase()) {
+            $this->base= $this->baseSelector->getBase();
+            $this->is_modified= TRUE;
+          }
+        }
+      }
+
+
       /* Save attributes */
       parent::save_object();
 
@@ -390,15 +383,6 @@ class application extends plugin
         /* Activate new picture */
         $this->set_picture($_FILES['picture_file']['tmp_name']);
       }        
-
-      if(!$this->is_release()){
-        $tmp = $this->get_allowed_bases();
-        if(isset($_POST['base'])){
-          if(isset($tmp[$_POST['base']])){
-            $this->base= $_POST['base'];
-          }
-        }
-      }
     }
   }
 
@@ -413,6 +397,11 @@ class application extends plugin
       $message[]=msgPool::invalid(_("Execute path"),"","","/some/path");
     }
 
+    // Check if a wrong base was supplied
+    if(!$this->baseSelector->checkLastBaseUpdate()){
+      $message[]= msgPool::check_base();;
+    }
+
     /* Permissions for that base? */
     if ($this->base != ""){
       $new_dn= "cn=".$this->cn.",".get_ou('applicationRDN').$this->base;
@@ -441,9 +430,6 @@ class application extends plugin
     /* Check for existing application */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current["BASE"]);
-
-    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
-
     if($this->is_release()){
       $base = $this->parent->parent->app_release;
     }else{
@@ -522,11 +508,9 @@ class application extends plugin
     if(isset($this->parent->parent)){
       return($this->parent->parent->IsReleaseManagementActivated());
     }else{
+
       /* Check if we should enable the release selection */
-      $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
-      if(!empty($tmp)){
-        return(true);
-      }
+      return($this->config->pluginEnabled("faiManagement"));
     }
     return(FALSE);
   }
@@ -554,8 +538,8 @@ class application extends plugin
   {
     $vars = array("cn");
 
-    $str ="<h2>"._("Application settings")."</h2>
-      <table>
+    $str ="<h3>"._("Application settings")."</h3>
+      <table summary=\""._("Application settings")."\">
       <tr>
       <td>".
       _("Application name"). 
@@ -593,30 +577,42 @@ class application extends plugin
       #FIXME FAIscript seams to ununsed within this class... */
   static function plInfo()
   {
-    return (array(
-          "plShortName"   => _("Generic"),
-          "plDescription" => _("Application generic"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 0,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("application" => array("description"  => _("Application"),
-                                                          "objectClass"  => "gosaApplication")),
+      return (array(
+                  "plShortName"   => _("Generic"),
+                  "plDescription" => _("Application generic"),
+                  "plSelfModify"  => FALSE,
+                  "plDepends"     => array(),
+                  "plPriority"    => 0,
+                  "plSection"     => array("administration"),
+                  "plCategory"    => array("application" => array("description"  => _("Application"),
+                          "objectClass"  => "gosaApplication")),
+                  "plProperties" =>
+                  array(
+                      array(
+                          "name"          => "applicationRDN",
+                          "type"          => "rdn",
+                          "default"       => "ou=apps,",
+                          "description"   => "The 'applicationRDN' statement defines the location where new applications will be created. The default is 'ou=apps,'.",
+                          "check"         => "gosaProperty::isRdn",
+                          "migrate"       => "",
+                          "group"         => "plugin",
+                          "mandatory"     => FALSE)),
+
           "plProvidedAcls"=> array(
-            "cn"                => _("Name"),
-            "base"              => _("Base"),
-            "description"       => _("Description"),
-            "gosaApplicationExecute"  => _("Execute"),
-            "gosaApplicationName"     => _("Name"),
-            "gosaApplicationIcon"     => _("Icon"),
-            "gotoLogonScript"         => _("Script content"),
-
-            "execForGroupmembers" => _("Only executable for members"),              // G
-            "placeOnDesktop"      => _("Place icon on members desktop"),            // D
-            "placeOnKicker"       => _("Place entry in members launch bar"),        // L
-            "placeInStartmenu"    => _("Place entry in members startmenu"),         // M
-            "overwriteConfig"      => _("Replace user configuration on startup"))  // O
-            ));
+                  "cn"                => _("Name"),
+                  "base"              => _("Base"),
+                  "description"       => _("Description"),
+                  "gosaApplicationExecute"  => _("Execute"),
+                  "gosaApplicationName"     => _("Name"),
+                  "gosaApplicationIcon"     => _("Icon"),
+                  "gotoLogonScript"         => _("Script content"),
+
+                  "execForGroupmembers" => _("Only executable for members"),              // G
+                  "placeOnDesktop"      => _("Place icon on members desktop"),            // D
+                  "placeOnKicker"       => _("Place entry in members launch bar"),        // L
+                  "placeInStartmenu"    => _("Place entry in members startmenu"),         // M
+                  "overwriteConfig"      => _("Replace user configuration on startup"))  // O
+              ));
   }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: