Code

Updated plugin creation && locking for all main.incs
[gosa.git] / gosa-plugins / goto / admin / devices / class_deviceManagement.inc
index 5cb193a085d0cdf8fbc562d734f8c33a7b6dd102..1acd7d6fa5e0b22a47124e9b4789c925a6411969 100644 (file)
@@ -6,6 +6,7 @@ class deviceManagement extends plugin
   /* Definitions */
   var $plHeadline     = "Hotplug devices";
   var $plDescription  = "Manage hotplug devices";
+  var $plIcon         = "plugins/goto/images/devices.png";
 
   /* Dialog attributes */
   var $ui                             = NULL;
@@ -18,13 +19,15 @@ class deviceManagement extends plugin
   var $dn ="";
   var $dns = array();
 
+  var $acl_module = array("devices");
+
   function deviceManagement(&$config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
     $this->ui = get_userinfo();  
 
     /* Check if copy & paste is activated */
-    if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){
+    if($this->config->get_cfg_value("copyPaste") == "true"){
       $this->CopyPasteHandler = new CopyPasteHandler($this->config);
     }
 
@@ -146,7 +149,7 @@ class deviceManagement extends plugin
     if (isset($_POST['edit_cancel']) && is_object($this->devicetabs)){
       $this->remove_lock();
       $this->devicetabs= NULL;
-      session::un_set('objectinfo');
+      set_object_info();
     }
 
 
@@ -176,7 +179,7 @@ class deviceManagement extends plugin
           }
           unset ($this->devicetabs);
           $this->devicetabs= NULL;
-          session::un_set('objectinfo');
+          set_object_info();
         }else{
 
           /* Reinitialize tab */
@@ -205,7 +208,7 @@ class deviceManagement extends plugin
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
       if (($user= get_lock($this->dn)) != ""){
-        return(gen_locked_message ($user, $this->dn));
+        return(gen_locked_message ($user, $this->dn,TRUE));
       }
 
       /* Lock the current entry, so everyone will get the
@@ -216,7 +219,7 @@ class deviceManagement extends plugin
       /* Register devicetabs to trigger edit dialog */
       $this->devicetabs= new devicetabs($this->config,$this->config->data['TABS']['DEVICETABS'], $this->dn,"devices");
       $this->devicetabs->set_acl_base($this->dn);
-      session::set('objectinfo',$this->dn);
+      set_object_info($this->dn);
     }
 
 
@@ -252,7 +255,7 @@ class deviceManagement extends plugin
 
           $dns_names = array();
           foreach($this->dns as $dn){
-            $dns_names[] =@LDAP::fix($dn);
+            $dns_names[] =LDAP::fix($dn);
           }
           add_lock ($this->dns, $this->ui->dn);
 
@@ -339,7 +342,7 @@ class deviceManagement extends plugin
         /* Lock the current entry, so nobody will edit it during deletion */
         add_lock ($this->dn, $this->ui->dn);
         $smarty= get_smarty();
-        $smarty->assign("intro", msgPool::deleteInfo(@LDAP::fix($this->dn),_("device")));
+        $smarty->assign("intro", msgPool::deleteInfo(LDAP::fix($this->dn),_("device")));
         $smarty->assign("multiple", false);
         return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
       } else {
@@ -392,7 +395,7 @@ class deviceManagement extends plugin
     /* Delete device canceled? */
     if (isset($_POST['delete_cancel'])){
       $this->remove_lock();
-      session::un_set('objectinfo');
+      set_object_info();
     }
 
     /* Show tab dialog if object is present */
@@ -400,7 +403,12 @@ class deviceManagement extends plugin
       $display= $this->devicetabs->execute();
 
       /* Don't show buttons if tab dialog requests this */
-      if (!$this->devicetabs->by_object[$this->devicetabs->current]->dialog){
+
+      if(($this->devicetabs instanceOf tabs || $this->devicetabs instanceOf plugin) && $this->devicetabs->read_only == TRUE){
+        $display.= "<p style=\"text-align:right\">
+          <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
+          </p>";
+      }elseif (!$this->devicetabs->by_object[$this->devicetabs->current]->dialog){
         $display.= "<p style=\"text-align:right\">\n";
         $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
         $display.= "&nbsp;\n";
@@ -421,7 +429,7 @@ class deviceManagement extends plugin
 
         /* Check if there is a snapshot dialog open */
     $base = $this->DivListDevices->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
@@ -446,7 +454,7 @@ class deviceManagement extends plugin
   /* Return departments, that will be included within snapshot detection */
   function get_used_snapshot_bases()
   {
-    return(array(get_ou('deviceou').$this->DivListDevices->selectedBase));
+    return(array(get_ou('deviceRDN').$this->DivListDevices->selectedBase));
   }
 
   function copyPasteHandling_from_queue($s_action,$s_entry)
@@ -532,11 +540,11 @@ class deviceManagement extends plugin
     if($SubSearch){
       $Flags    |= GL_SUBSEARCH;
     }else{
-      $base = get_ou('deviceou').$base;
+      $base = get_ou('deviceRDN').$base;
     }
 
     /* Get results and create index */
-    $res= get_sub_list($Filter,"devices",get_ou('deviceou'), $base, array("cn","gotoHotplugDevice","description","dn","objectClass"), $Flags);
+    $res= get_sub_list($Filter,"devices",get_ou('deviceRDN'), $base, array("cn","gotoHotplugDevice","description","dn","objectClass"), $Flags);
     $tmp2 = array();
     foreach ($res as $val){
       if (!isset($val['description']) && isset($val['gotoHotplugDevice'][0])) {