Code

Reverted Last commits, I've accidentally replaced to much.
[gosa.git] / gosa-plugins / goto / admin / devices / class_deviceGeneric.inc
index 1ceff18aead292a53e171c80c9989a57b608808a..037963de6088bed57a04b39341881eeb0f984fd5 100644 (file)
@@ -14,6 +14,7 @@ class deviceGeneric extends plugin
   public $base          = "";  
   public $types;
   public $type;
+  public $baseSelector;
 
   public $attributes      = array("cn","description","devID","serial","vendor", "type");
   public $objectclasses   = array("top","gotoDevice");
@@ -59,14 +60,21 @@ class deviceGeneric extends plugin
     }
     $this->orig_base = $this->base;
     $this->orig_dn   = $this->dn;
+
+    /* 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);
   }
 
 
   public function execute()
   {
+    plugin::execute();
     $smarty = get_smarty();
-    $smarty->assign("base",$this->base);
-    $smarty->assign("bases",$this->get_allowed_bases());
+
+    $smarty->assign("base", $this->baseSelector->render());
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
     }
@@ -105,6 +113,11 @@ class deviceGeneric extends plugin
     if(empty($this->vendor) || !$this->is_2byteHex($this->vendor)){
       $message[]= msgPool::invalid(_("Vendor-ID"),"","","0x1234");
     }
+
+    // Check if a wrong base was supplied
+    if(!$this->baseSelector->checkLastBaseUpdate()){
+      $message[]= msgPool::check_base();
+    }
   
     /* Check if entry already exists */ 
     if($this->cn != $this->orig_cn || $this->dn == "new"){
@@ -131,13 +144,18 @@ class deviceGeneric extends plugin
   {
     if(isset($_POST['deviceGeneric_posted'])){
       plugin::save_object();
-  
-      if(isset($_POST['base'])){
-        $tmp = $this->get_allowed_bases();
-        if(isset($tmp[get_post("base")])){
-          $this->base = get_post("base");
+
+      /* Refresh base */
+      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;
         }
       }
+
     }
   }
 
@@ -256,6 +274,18 @@ class deviceGeneric extends plugin
           "plSection"     => array("administration"),
           "plCategory"    => array("devices" => array("description"  => _("Devices"),
                                                         "objectClass"  => "gotoHotplugDevice")),
+          "plProperties" =>
+          array(
+              array(
+                  "name"          => "deviceRDN",
+                  "type"          => "rdn",
+                  "default"       => "ou=devices,",
+                  "description"   => "The 'deviceRDN' statement defines the location where new devices will be created. The default is 'ou=devices,'.",
+                  "check"         => "gosaProperty::isRdn",
+                  "migrate"       => "",
+                  "group"         => "plugin",
+                  "mandatory"     => FALSE)),
+
           "plProvidedAcls"=> array(
             "cn"            => _("Name"),
             "base"          => _("Base"),