Code

<h2> => </h3>
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_SelectDeviceType.inc
index c17b8ef5f1f2e5777aa5e6ccb8a43c001416ed4c..9e1c10975b0b2860c8b348cd9bb23f898e3279d8 100644 (file)
@@ -2,11 +2,6 @@
 
 class SelectDeviceType extends plugin
 {
-  /* CLI vars */
-  var $cli_summary= "Manage server basic objects";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* attribute list for save action */
   var $ignore_account= TRUE;
   var $attributes= array("ObjectGroup","SystemType");
@@ -15,23 +10,35 @@ class SelectDeviceType extends plugin
   var $ObjectGroups   = array();
   var $SystemTypes       = array();
 
-  var $ObjectGroup    = "";
-  var $SystemType        = "";
+  var $ObjectGroup    = "none";
+  var $SystemType        = "gotoWorkstation";
+
+  var $dn;
 
   function SelectDeviceType  (&$config, $dn= NULL)
   {
-    plugin::plugin ($config, $dn);
+    if(!is_array($dn)){
+      $this->dns = array($dn);
+    }else{
+      $this->dns = $dn;
+    }
+    plugin::plugin ($config, NULL);
 
     /* Get object groups */
     $ldap = $this->config->get_ldap_link();
     $ldap->cd ($this->config->current['BASE']);
     $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
-    $this->ObjectGroups['none']=_("none");
+    $tmp= array();
     while($attrs = $ldap->fetch()){
-      $this->ObjectGroups[$attrs['dn']]= $attrs['cn'][0];
+      $tmp[$attrs['dn']]= $attrs['cn'][0];
     }
+    asort($tmp, SORT_LOCALE_STRING);
+    $this->ObjectGroups= $tmp;
 
-    $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server"));
+    $this->SystemTypes =array("gotoWorkstation"=>_("Workstation"), "gotoTerminal"=>_("Terminal"), "goServer"=>_("Server"));
+    if(class_available("opsi")){
+      $this->SystemTypes["FAKE_OC_OpsiHost"]= _("Windows workstation");
+    }
   }
 
   function execute()
@@ -39,19 +46,28 @@ class SelectDeviceType extends plugin
     /* Call parent execute */
     plugin::execute();
 
+
+    /* Get object groups */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("gosaGroupObjects","cn"));
+    $tmp= array("W" => array(),"T" => array(), "S" => array(),"O" => array());
+    while($attrs = $ldap->fetch()){
+      $tmp[preg_replace("/[\[\] ]/","",$attrs['gosaGroupObjects'][0])][$attrs['dn']] = $attrs['cn'][0];
+    }
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
 
-    $smarty->assign("ObjectGroups"    ,$this->ObjectGroups);
-    $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups));
+    $map = array("gotoWorkstation" => "W","gotoTerminal" => "T","goServer" => "S", "FAKE_OC_OpsiHost" => "O");
+    $smarty->assign("dns_cnt" , count($this->dns));
+    $smarty->assign("ogroups", $tmp[$map[$this->SystemType]]);
     $smarty->assign("SystemTypes"     ,$this->SystemTypes);
     $smarty->assign("SystemTypeKeys"  ,array_flip($this->SystemTypes)); 
-
     $smarty->assign("ObjectGroup",$this->ObjectGroup);
     $smarty->assign("SystemType",$this->SystemType);
-
-    $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE));
+    $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE,dirname(__FILE__)));
     return($display);
   }