Code

Added admin stuff
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 13:11:16 +0000 (13:11 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 13:11:16 +0000 (13:11 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8447 594d385d-05f5-0310-b6e9-bd551577e9d8

56 files changed:
gosa-plugins/goto/admin/applications/class_applicationGeneric.inc [new file with mode: 0644]
gosa-plugins/goto/admin/applications/class_applicationManagement.inc [new file with mode: 0644]
gosa-plugins/goto/admin/applications/class_applicationParameters.inc [new file with mode: 0644]
gosa-plugins/goto/admin/applications/class_divListApplication.inc [new file with mode: 0644]
gosa-plugins/goto/admin/applications/generic.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/applications/main.inc [new file with mode: 0644]
gosa-plugins/goto/admin/applications/parameters.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/applications/release_select.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/applications/remove.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/applications/tabs_application.inc [new file with mode: 0644]
gosa-plugins/goto/admin/devices/class_deviceGeneric.inc [new file with mode: 0644]
gosa-plugins/goto/admin/devices/class_deviceManagement.inc [new file with mode: 0644]
gosa-plugins/goto/admin/devices/class_divListDevices.inc [new file with mode: 0644]
gosa-plugins/goto/admin/devices/deviceGeneric.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/devices/main.inc [new file with mode: 0644]
gosa-plugins/goto/admin/devices/paste_deviceGeneric.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/devices/remove.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/devices/tabs_devices.inc [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/generic.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/main.inc [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/paste_generic.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/release_select.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/remove.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/SelectDeviceType.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/chooser.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_SelectDeviceType.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_selectUserToPrinterDialog.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_terminalInfo.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_terminalService.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_workstationService.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/gencd.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/gencd_frame.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/info.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/printer.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/scanner-list [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/selectUserToPrinterDialog.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/tabs_printers.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/tabs_terminal.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/tabs_workstation.inc [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/terminal.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/terminalService.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/terminalStartup.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/workstation.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/workstationService.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/systems/goto/workstationStartup.tpl [new file with mode: 0644]

diff --git a/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc b/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc
new file mode 100644 (file)
index 0000000..247acf9
--- /dev/null
@@ -0,0 +1,572 @@
+<?php
+class application extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Handling of GOsa's application object";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* application attributes */
+  var $cn= "";
+  var $description= "";
+  var $base= "";
+  var $gosaApplicationExecute= "";
+  var $gosaApplicationName= "";
+  var $gosaApplicationFlags= "";
+  var $gosaApplicationIcon= "";
+  var $gotoLogonScript ="";
+  var $iconData;
+  var $view_logged = FALSE;
+
+  /* Headpage attributes */
+  var $last_sorting= "invalid";
+  var $applications= array();
+
+  /* attribute list for save action */
+  var $attributes= array("cn", "description", "gosaApplicationExecute", "gosaApplicationName","gosaApplicationIcon",
+      "gosaApplicationFlags","gotoLogonScript");
+  var $objectclasses= array("top", "gosaApplication");
+
+  var $isReleaseApplikation = false;
+
+  function application (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin ($config, $dn, $parent);
+
+    $appfilter = session::get('appfilter')    ;
+
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)) {
+      if(!preg_match("/^".get_ou('applicationou')."/",$appfilter['release'])){
+        $this->isReleaseApplikation = true;  
+      }
+    }
+
+    /* Load icon */
+    $ldap= $config->get_ldap_link();
+    if ($dn != 'new'){
+      $this->iconData= $ldap->get_attribute($dn, "gosaApplicationIcon");
+      $this->saved_attributes['gosaApplicationIcon'] = $this->iconData;
+    }
+    if ($this->iconData == ""){
+      $this->set_picture("");
+    }
+    session::set('binary',$this->iconData);
+    session::set('binarytype',"image/jpeg");
+    $this->gosaApplicationIcon= $this->iconData;
+
+    /* This is always an account */
+    $this->is_account= TRUE;
+
+    if ($this->dn == "new"){
+      if(session::is_set('CurrentMainBase')){
+        $this->base = session::get('CurrentMainBase');
+      }else{
+        $ui= get_userinfo();
+        $this->base= dn2base($ui->dn);
+      }
+    } else {
+
+      if($this->isReleaseApplikation){
+        $this->base = preg_replace("/^.*,".get_ou('applicationou')."/","",$this->dn);
+      }else{
+        $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
+      }
+    }
+  }
+
+
+  function generateTemplate()
+  {
+    $str= "# This code is part of GOsa (https://gosa.gonicus.de)\n#\n";
+
+    $values = array();
+    $names     = array();
+    if($this->parent->by_object['applicationParameters']->is_account){
+      $names = $this->parent->by_object['applicationParameters']->option_name;
+      $values = $this->parent->by_object['applicationParameters']->option_value;
+    }
+
+    if (count($names)){
+      $str .="# This plugin handles these environment variables:\n";
+    } else {
+      $str .="# This plugin handles no environment variables.\n";
+    }
+
+    foreach($names as $index => $name){
+
+      // Fix length
+      for($i = strlen($name) ; $i < 30 ; $i++){
+        $name= $name." ";
+      }
+      if((isset($values[$index]))&&(!empty($values[$index]))){
+        $str.= "# ".$name."\t(e.g. '".$values[$index]."')\n";
+      }else{
+        $str.= "# ".$name."\t("._("no example").")\n";
+      }
+    }
+    $str .= "#\n".
+      "# Don't remove the following tag, it is used for header update.\n".
+      "### END HEADER ###";
+
+    return($str);
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    /* Log view */
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","application/".get_class($this),$this->dn);
+    }
+
+    $smarty= get_smarty();
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+    /* Do we represent a valid group? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+        _("This 'dn' is no application.")."</b>";
+      return ($display);
+    }
+
+    /* Download requested */
+    foreach($_POST as $name => $value){
+      if(preg_match("/^downloadScript/",$name)){
+        session::set('binary',$this->gotoLogonScript);
+        session::set('binarytype',"octet-stream");
+        session::set('binaryfile',$this->cn.".gosaApplication");
+        header("location: getbin.php ");
+        exit();
+      }
+    }
+
+    /* Reassign picture data, sometimes its corrupt cause we started a download of application scripts */
+    session::set('binary',$this->iconData);
+    session::set('binarytype',"image/jpeg");
+    
+    $smarty->assign("rand", rand(0, 10000));
+    $head = $this->generateTemplate();
+    $this->gotoLogonScript= $this->generateTemplate().preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript);
+
+    if((isset($_POST['upLoad']))&&(isset($_FILES['ScriptFile']))){
+      $str = file_get_contents($_FILES['ScriptFile']['tmp_name']);
+      $this->gotoLogonScript = $str;
+    }
+
+    /* Fill templating stuff */
+    $smarty->assign("cn", $this->cn);
+    $smarty->assign("bases", $this->get_allowed_bases());
+    if ($this->dn == "new"){
+      $smarty->assign("selectmode", "");
+      $smarty->assign("namemode", "");
+    } else {
+      $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->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));
+
+    /* Variables */
+    foreach(array("description", "gosaApplicationExecute", "gosaApplicationName","cn") as $val){
+      $smarty->assign($val, $this->$val);
+    }
+
+    /* Checkboxes */
+    foreach (array("G" => "exec_for_groupmembers", "O" => "overwrite_config",
+          "L" => "place_on_kicker",
+          "D" => "place_on_desktop", "M" => "place_in_startmenu") as $key => $val){
+      if (preg_match("/$key/", $this->gosaApplicationFlags)){
+        $smarty->assign("$val", "checked");
+      } else {
+        $smarty->assign("$val", "");
+      }
+    }
+
+    $smarty->assign("isReleaseApplikation" , $this->isReleaseApplikation);
+    $smarty->assign("gotoLogonScript",htmlentities($this->gotoLogonScript, ENT_COMPAT, 'UTF-8'));
+    $smarty->assign("base_select", $this->base);
+    /* Show main page */
+    return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
+  }
+
+
+  function remove_from_parent()
+  {
+    $ldap= $this->config->get_ldap_link();
+    $ldap->rmDir($this->dn);
+    new log("remove","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of application with dn '%s' failed."),$this->dn));
+
+    /* Optionally execute a command after we're done */
+    $this->handle_post_events("remove");
+
+    /* Delete references to object groups */
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
+    while ($ldap->fetch()){
+      $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));
+    }
+
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    if (isset($_POST['cn'])){
+
+      /* Create a base backup and reset the
+         base directly after calling plugin::save_object();
+         Base will be set seperatly a few lines below */
+      $base_tmp = $this->base;
+      plugin::save_object();
+      $this->base = $base_tmp;
+
+      /* Save attributes */
+      parent::save_object();
+
+      /* Save application flags */
+      $flag= "";
+      if (isset($_POST['exec_for_groupmembers']) && $_POST['exec_for_groupmembers'] == 1){
+        $flag.= "G";
+      }
+      if (isset($_POST['place_on_desktop']) && $_POST['place_on_desktop'] == 1){
+        $flag.= "D";
+      }
+      if (isset($_POST['place_on_kicker']) && $_POST['place_on_kicker'] == 1){
+        $flag.= "L";
+      }
+      if (isset($_POST['place_in_startmenu']) && $_POST['place_in_startmenu'] == 1){
+        $flag.= "M";
+      }
+      if (isset($_POST['overwrite_config']) && $_POST['overwrite_config'] == 1){
+        $flag.= "O";
+      }
+      if ($this->acl_is_writeable("gosaApplicationFlags")){
+        $this->gosaApplicationFlags= "[$flag]";
+      }
+
+      /* Remove current picture */
+      if(isset($_POST['remove_picture'])){
+        $this->set_picture("");
+      }
+
+      /* Check for picture upload */
+      if (isset($_FILES['picture_file']['name']) && $_FILES['picture_file']['name'] != ""){
+
+        if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
+          print_red (_("The specified picture has not been uploaded correctly."));
+        }
+
+        if (!function_exists("imagick_blob2image")){
+          /* Get temporary file name for conversation */
+          $fname = tempnam ("/tmp", "GOsa");
+
+          /* Open file and write out photoData */
+          $fp = fopen ($fname, "w");
+          fwrite ($fp, $_FILES['picture_file']['tmp_name']);
+          fclose ($fp);
+
+          /* Build conversation query. Filename is generated automatically, so
+             we do not need any special security checks. Exec command and save
+             output. For PHP safe mode, you'll need a configuration which respects
+             image magick as executable... */
+          $query= "convert -size 48x48 $fname -resize 48x48 +profile \"*\" -";
+          @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $query, "Execute");
+
+          /* Read data written by convert */
+          $output= "";
+          $sh= popen($query, 'r');
+          while (!feof($sh)){
+            $output.= fread($sh, 4096);
+          }
+          pclose($sh);
+
+          unlink($fname);      
+        } else {
+
+          /* Load the new uploaded Photo */
+          if(!$handle  =  imagick_ReadImage($_FILES['picture_file']['tmp_name'])){
+            print_red(_("Can't access uploaded image."));
+          }
+
+          /* Resizing image to 147x200 and blur */
+          if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){
+            print_red(_("Uploaded image could not be resized, possilby the image magick extension is missing."));
+          }
+
+          /* Converting image to JPEG */
+          if(!imagick_convert($handle,"PNG")) {
+            print_red(_("Could not convert image to png, possilby the image magick extension is missing."));
+          }
+
+          if(!imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
+            print_red(sprintf(_("Could not save uploaded image to %s."),$_FILES['picture_file']['tmp_name']));
+          }
+
+          imagick_free($handle);
+        }
+
+        /* Activate new picture */
+        $this->set_picture($_FILES['picture_file']['tmp_name']);
+      }        
+
+      if(!$this->isReleaseApplikation){
+        $tmp = $this->get_allowed_bases();
+        if(isset($_POST['base'])){
+          if(isset($tmp[$_POST['base']])){
+            $this->base= $_POST['base'];
+          }
+        }
+      }
+    }
+  }
+
+
+  /* Check values */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    if(!preg_match("#^/#",$this->gosaApplicationExecute)){
+      $message[]=(_("Specified execute path must start with '/'."));
+    }
+
+    /* Permissions for that base? */
+    if ($this->base != ""){
+      $new_dn= "cn=".$this->cn.",".get_ou('applicationou').$this->base;
+    } else {
+      $new_dn= $this->dn;
+    }
+
+
+    if($this->dn == "new"){
+      $this->set_acl_base($this->base);
+    }
+
+    /* All required fields are set? */
+    if ($this->cn == ""){
+      $message[]= _("Required field 'Name' is not filled.");
+    }
+
+    if(preg_match("/[^a-z0-9]/",$this->cn))    {
+      $message[]=_("Invalid character in application name. Only a-z 0-9 are allowed.");
+    }
+
+    if ($this->gosaApplicationExecute == ""){
+      $message[]= _("Required field 'Execute' is not filled.");
+    }
+
+    /* 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'));
+    $appfilter = session::get('appfilter');
+    if((!empty($tmp)) && (isset($appfilter['release']))){
+      $baseDn = str_replace($this->config->current['BASE'],$this->base,$appfilter['release']);
+      $baseDn = preg_replace("/".get_ou('applicationou').".*/",get_ou('applicationou').$this->base,$appfilter['release']);
+      $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))",$baseDn,array("cn"));
+      if($ldap->count()){
+        $attrs = $ldap->fetch();
+        if($this->dn != $attrs['dn']) {
+          $message[]= _("There's already an application with this 'Name'.");
+        }
+      }
+    }else{
+      $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))",get_ou('applicationou').$this->base,array("cn"));
+      if ($ldap->count()){
+        $attrs = $ldap->fetch();
+        if($this->dn != $attrs['dn']) {
+          $message[]= _("There's already an application with this 'Name'.");
+        }
+      }
+    }
+    return $message;
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Get application script without header part, to check if we must save the script itself */
+    $script = preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript);
+
+    plugin::save();
+    $this->attrs["gosaApplicationIcon"]= $this->gosaApplicationIcon;
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cat($this->dn, array('dn'));
+
+    $a= $ldap->fetch();
+    if (count($a)){
+
+      /* Remove gotoLogonScript if it is empty */
+      if(empty($script))    {
+        $this->attrs['gotoLogonScript'] = array();
+      }
+
+      $ldap->cd($this->dn);
+      $this->cleanup();
+      $ldap->modify ($this->attrs); 
+      $this->handle_post_events("modify");
+      new log("modify","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    } else {
+      
+      /* Remove gotoLogonScript if it is empty */
+      if(empty($script))    {
+        unset($this->attrs['gotoLogonScript']);
+      }
+
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+      new log("create","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      $this->handle_post_events("add");
+    }
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of application with dn '%s' failed."),$this->dn));
+  }
+
+  function set_picture($filename)
+  {
+    if (!is_file($filename)){
+      $filename= "./images/default_icon.png";
+      $this->gosaApplicationIcon= "*removed*";
+    }
+
+    if (file_exists($filename)){
+      $fd = fopen ($filename, "rb");
+      $this->iconData= fread ($fd, filesize ($filename));
+      session::set('binary',$this->iconData);
+      session::set('binarytype',"image/jpeg");
+      $this->gosaApplicationIcon= $this->iconData;
+
+      fclose ($fd);
+    }
+  }
+
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+
+    $str ="<h2>"._("Application settings")."</h2>
+      <table>
+      <tr>
+      <td>".
+      _("Application name"). 
+      "</td>  
+      <td>
+      <input id='gosaApplicationName' name='cn' size='35' maxlength='60' 
+      value='".$this->cn."' 
+      title='"._("Application name to be displayed (i.e. below icons)")."'>                     
+      </td>
+      </tr>
+      </table>";
+    $ret = array();
+    $ret['status'] = "";
+    $ret['string'] = $str;
+    return($ret);
+  }
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    $source_o = new application($this->config,$source['dn']);
+    $this->gosaApplicationIcon = $source_o->gosaApplicationIcon;     
+  }
+
+
+  /* Return plugin informations for acl handling
+      #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")),
+          "plProvidedAcls"=> array(
+            "cn"                => _("Name"),
+            "base"              => _("Base"),
+            "description"       => _("Description"),
+            "gosaApplicationExecute"  => _("Execute"),
+            "gosaApplicationName"     => _("Name"),
+            "gosaApplicationIcon"     => _("Icon"),
+            "gosaApplicationFlags"    => _("Flag"),
+            "gotoLogonScript"         => _("Script content"),
+
+            "exec_for_groupmembers" => _("Only executable for members"),              // G
+            "place_on_desktop"      => _("Place icon on members desktop"),            // D
+            "place_on_kicker"       => _("Place entry in members launch bar"),        // L
+            "place_in_startmenu"    => _("Place entry in members startmenu"),         // M
+            "overwrite_config"      => _("Replace user configuration on startup"))  // O
+            ));
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/applications/class_applicationManagement.inc b/gosa-plugins/goto/admin/applications/class_applicationManagement.inc
new file mode 100644 (file)
index 0000000..c781032
--- /dev/null
@@ -0,0 +1,647 @@
+<?php
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2003  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class applicationManagement extends plugin
+{
+  /* Definitions */
+  var $plHeadline     = "Applications";
+  var $plDescription  = "This does something";
+
+  /* Dialog attributes */
+  var $apptabs                  = NULL;
+  var $ui                       = NULL;
+  var $CopyPasteHandler         = NULL;
+  var $DivListApplication       = NULL;
+  var $applications             = array();
+  var $enableReleaseManagement  = false;
+  var $start_pasting_copied_objects = FALSE;
+
+  function IsReleaseManagementActivated()
+  {
+    /* Check if we should enable the release selection */
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)){
+      return(true);
+    }
+    return(false);
+  }
+
+  function applicationManagement (&$config, &$ui)
+  {
+    /* Save configuration for internal use */
+    $this->config   = &$config;
+    $this->ui       = &$ui;
+
+    /* Check if copy & paste is activated */
+    if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
+    }
+
+    /* Creat dialog object */
+    $this->DivListApplication = new divListApplication($this->config,$this);
+
+    if($this->IsReleaseManagementActivated()){
+    /* Check if we should enable the release selection */
+      $this->enableReleaseManagement = true;
+
+      /* Hide SubSearch checkbox */
+      $this->DivListApplication->DisableCheckBox("SubSearch");
+    }
+  }
+
+  function getReleases($base)
+  {
+    $ldap                   = $this->config->get_ldap_link();
+    $dn                     = get_ou('applicationou').$base;
+    $ret                    = array();
+    $ret [get_ou('applicationou').$base] = "/";
+
+    $ldap->cd($dn);
+    $ldap->search("objectClass=organizationalUnit",array("ou"));
+
+    while($attrs = $ldap->fetch()){
+      $str = str_replace($dn,"",$attrs['dn']);
+      $tmp = array_reverse( split("ou=",$str));
+      $str = "";
+      foreach($tmp as $val){
+        $val = trim(preg_replace("/,/","",$val));
+        if(empty($val)) break;
+        $str .= "/".$val;
+      } 
+      if(!empty($str)){
+        $ret[$attrs['dn']]= preg_replace("/^\//","",$str);
+      }
+    }
+    asort($ret);
+    return($ret);
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+
+    /**************** 
+      Variable init 
+     ****************/
+
+    /* These vars will be stored if you try to open a locked app, 
+        to be able to perform your last requests after showing a warning message */
+    session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^appl_edit_/","/^appl_del_/","/^item_selected/","/^remove_multiple_applications/"));
+
+    $smarty       = get_smarty();             // Smarty instance
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+    
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/appl_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/appl_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/appl_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/appl_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/^copy_.*/",$key)){
+        $s_action="copy";
+        $s_entry  = preg_replace("/^copy_/i","",$key);
+      }elseif(preg_match("/^cut_.*/",$key)){
+        $s_action="cut";
+        $s_entry  = preg_replace("/^cut_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/^appl_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/^remove_multiple_applications/",$key)){
+        $s_action="del_multiple";
+      }elseif(preg_match("/^editPaste.*/i",$key)){
+        $s_action="editPaste";
+      }elseif(preg_match("/^multiple_copy_groups/",$key)){
+        $s_action = "copy_multiple";
+      }elseif(preg_match("/^multiple_cut_groups/",$key)){
+        $s_action = "cut_multiple";
+      }
+    }
+
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+
+    /* handle C&P from layers menu */
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
+      $s_action = "copy_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
+      $s_action = "cut_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
+      $s_action = "editPaste";
+    }
+
+    /* Create options */
+    if(isset($_POST['menu_action']) && $_POST['menu_action'] == "appl_new"){
+      $s_action = "new";
+    }
+
+    /* handle remove from layers menu */
+    if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
+      $s_action = "del_multiple";
+    }
+
+    /**************** 
+      Copy & Paste handling  
+     ****************/
+
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+
+    /**************** 
+      Create a new app 
+     ****************/
+
+    /* New application? */
+    if ($s_action=="new"){
+
+      /* By default we set 'dn' to 'new', all relevant plugins will
+         react on this. */
+      $this->dn= "new";
+
+      /* Create new usertab object */
+      $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application");
+      $this->apptabs->set_acl_base($this->DivListApplication->selectedBase);
+    }
+
+
+    /**************** 
+      Edit entry canceled 
+     ****************/
+
+    /* Cancel dialogs */
+    if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
+      del_lock ($this->apptabs->dn);
+      unset ($this->apptabs);
+      $this->apptabs= NULL;
+      session::un_set('objectinfo');
+    }
+
+
+    /**************** 
+      Edit entry finished 
+     ****************/
+
+    /* Finish apps edit is triggered by the tabulator dialog, so
+       the user wants to save edited data. Check and save at this
+       point. */
+    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->apptabs->config))){
+
+      /* Check tabs, will feed message array */
+      $this->apptabs->last= $this->apptabs->current;
+      $this->apptabs->save_object();
+      $message= $this->apptabs->check();
+
+      /* Save, or display error message? */
+      if (count($message) == 0){
+
+        /* Save data data to ldap */
+        $this->apptabs->set_release($this->DivListApplication->selectedRelease);
+        $this->apptabs->save();
+
+        if (!isset($_POST['edit_apply'])){
+          /* Application has been saved successfully, remove lock from
+             LDAP. */
+          if ($this->dn != "new"){
+            del_lock ($this->dn);
+          }
+          unset ($this->apptabs);
+          $this->apptabs= NULL;
+          session::un_set('objectinfo');
+        }
+      } else {
+        /* Ok. There seem to be errors regarding to the tab data,
+           show message and continue as usual. */
+        show_errors($message);
+      }
+    }
+
+
+    /**************** 
+      Edit entry  
+     ****************/
+
+    /* User wants to edit data? */
+    if (($s_action=="edit") && (!isset($this->apptabs->config))){
+
+      /* Get 'dn' from posted 'applist', must be unique */
+      $this->dn= $this->applications[$s_entry]['dn'];
+
+      /* 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));
+      }
+
+      /* Lock the current entry, so everyone will get the
+         above dialog */
+      add_lock ($this->dn, $this->ui->dn);
+
+      /* Register apptabs to trigger edit dialog */
+      $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application");
+      $this->apptabs->set_acl_base($this->dn);
+      session::set('objectinfo',$this->dn);
+    }
+
+
+
+    /********************
+      Delete MULTIPLE entries requested, display confirm dialog
+     ********************/
+
+    if ($s_action=="del_multiple"){
+      $ids = $this->list_get_selected_items();
+
+      if(count($ids)){
+
+        foreach($ids as $id){
+          $dn = $this->applications[$id]['dn'];
+          if (($user= get_lock($dn)) != ""){
+            return(gen_locked_message ($user, $dn));
+          }
+          $this->dns[$id] = $dn;
+        }
+
+        $dns_names = "<br><pre>";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="</pre>";
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        if (count($this->dns) == 1){
+          $smarty->assign("intro",     sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
+        } else {
+          $smarty->assign("intro",     sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
+        }
+        $smarty->assign("multiple", true);
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries confirmed
+     ********************/
+
+    /* Confirmation for deletion has been passed. Users should be deleted. */
+    if (isset($_POST['delete_multiple_application_confirm'])){
+
+      /* Remove user by user and check acls before removeing them */
+      foreach($this->dns as $key => $dn){
+
+        $ui = get_userinfo();
+        $acl = $ui->get_permissions($dn ,"application/application");
+        if (preg_match('/d/', $acl)){
+
+          /* Delete request is permitted, perform LDAP action */
+          $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,"application");
+          $this->apptabs->set_acl_base($dn);
+          $this->apptabs->delete ();
+          unset ($this->apptabs);
+          $this->apptabs= NULL;
+
+        } else {
+          /* Normally this shouldn't be reached, send some extra
+             logs to notify the administrator */
+          print_red (_("You are not allowed to delete this application!"));
+          new log("security","application/".get_class($this),$dn,array(),"Tried to trick deletion.");
+        }
+        /* Remove lock file after successfull deletion */
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries Canceled
+     ********************/
+
+    /* Remove lock */
+    if(isset($_POST['delete_multiple_application_cancel'])){
+      foreach($this->dns as $key => $dn){
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+    /**************** 
+      Delete app 
+     ****************/
+
+    /* Remove user was requested */
+    if ($s_action == "del"){
+
+      /* Get 'dn' from posted 'uid' */
+      $this->dn= $this->applications[$s_entry]['dn'];
+
+      /* Load permissions for selected 'dn' and check if
+         we're allowed to remove this 'dn' */
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($this->dn ,"application/application");
+
+      if(preg_match("/d/",$acl)){
+        /* 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));
+        }
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        add_lock ($this->dn, $this->ui->dn);
+        $smarty= get_smarty();
+        $smarty->assign("intro", sprintf(_("You're about to delete the application '%s'."), @LDAP::fix($this->dn)));
+        $smarty->assign("multiple", false);
+        return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
+      } else {
+
+        /* Obviously the user isn't allowed to delete. Show message and
+           clean session. */
+        print_red (_("You are not allowed to delete this application!"));
+      }
+    }
+
+
+    /**************** 
+      Delete app confirmed 
+     ****************/
+
+    /* Confirmation for deletion has been passed. Group should be deleted. */
+    if (isset($_POST['delete_app_confirm'])){
+
+      /* Some nice guy may send this as POST, so we've to check
+         for the permissions again. */
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($this->dn ,"application/application");
+
+      if(preg_match("/d/",$acl)){
+
+        /* Delete request is permitted, perform LDAP action */
+        $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $this->dn,"application");
+        $this->apptabs->set_acl_base($this->dn);
+        $this->apptabs->delete ();
+        unset ($this->apptabs);
+        $this->apptabs= NULL;
+
+      } else {
+
+        /* Normally this shouldn't be reached, send some extra
+           logs to notify the administrator */
+        print_red (_("You are not allowed to delete this application!"));
+        new log("security","application/".get_class($this),$dn,array(),"Tried to trick deletion.");
+      }
+
+      /* Remove lock file after successfull deletion */
+      del_lock ($this->dn);
+    }
+
+
+    /**************** 
+      Delete app canceled 
+     ****************/
+
+    /* Delete application canceled? */
+    if (isset($_POST['delete_cancel'])){
+      del_lock ($this->dn);
+      session::un_set('objectinfo');
+    }
+
+    /* Show tab dialog if object is present */
+    if (($this->apptabs) && (isset($this->apptabs->config))){
+      $display= $this->apptabs->execute();
+
+      /* Don't show buttons if tab dialog requests this */
+      if (!$this->apptabs->by_object[$this->apptabs->current]->dialog){
+        $display.= "<p style=\"text-align:right\">\n";
+        $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+        $display.= "&nbsp;\n";
+        if ($this->dn != "new"){
+          $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+          $display.= "&nbsp;\n";
+        }
+        $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+        $display.= "</p>";
+      }
+      return ($display);
+    }
+
+
+    /****************
+      Dialog display
+     ****************/
+
+    /* Check if there is a snapshot dialog open */
+    $base = $this->DivListApplication->selectedBase;
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases($base))){
+      return($str);
+    }
+
+    /* Display dialog with system list */
+    $this->DivListApplication->parent = $this;
+    $this->DivListApplication->execute();
+    $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1);
+    $this->reload();
+    $this->DivListApplication->setEntries($this->applications);
+    return($this->DivListApplication->Draw());
+  }
+
+
+  /* Return departments, that will be included within snapshot detection */
+  function get_used_snapshot_bases(){
+    if($this->DivListApplication->selectedRelease == "main"){
+      return(array($this->DivListApplication->selectedBase));
+    }else{
+      return(array($this->DivListApplication->selectedRelease));
+    }
+  }
+
+
+  function reload()
+  {
+    $this->applications= array();
+
+    /* Set base for all searches */
+    $base       = $this->DivListApplication->selectedBase;
+    $release    = $this->DivListApplication->selectedRelease;
+    $Regex      = $this->DivListApplication->Regex;
+    $SubSearch  = $this->DivListApplication->SubSearch; 
+    $Flags      =  GL_NONE | GL_SIZELIMIT;
+    $Filter     = "(&(cn=".$Regex.")(objectClass=gosaApplication))";
+    $tmp        = array();
+    $Releases   = $this->getReleases($base);
+
+    if(!$this->enableReleaseManagement){
+      $use_base = get_ou('applicationou').$base;
+    }else{
+      if(isset($Releases[$release])){
+        $use_base  = $release;
+      }else{
+        $use_base  = get_ou('applicationou').$base;
+      }
+    }
+
+    if($SubSearch){
+      $Flags    |= GL_SUBSEARCH;  
+    }
+   
+    $res= get_sub_list($Filter, "application",get_ou('applicationou'), $use_base, array("cn","description","dn","objectClass"), $Flags);
+    $tmp2 = array();
+    foreach ($res as $val){
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val;
+      $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn'];
+    }
+
+    natcasesort($tmp2);
+    $this->applications=array();
+    foreach($tmp2 as $val){
+      $this->applications[]=$tmp[$val];
+    }
+    reset ($this->applications);
+  }
+
+  function remove_from_parent()
+  {
+    /* Optionally execute a command after we're done */
+    $this->postremove();
+  }
+
+
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+    /* Check if Copy & Paste is disabled */
+    if(!is_object($this->CopyPasteHandler)){
+      return("");
+    }
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $dn = $this->applications[$s_entry]['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"apptabs","APPSTABS","application");
+    }
+
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->applications[$id]['dn'];
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","apptabs","APPSTABS","application");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","apptabs","APPSTABS","application");
+        }
+      }
+    }
+
+    /* Start pasting entries */
+    if($s_action == "editPaste"){
+      $this->start_pasting_copied_objects = TRUE;
+    }
+
+
+    /* Return C&P dialog */
+    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
+
+      /* Load entry from queue and set base */
+      $this->CopyPasteHandler->load_entry_from_queue();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListApplication->selectedBase);
+
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      /* Return dialog data */
+      if(!empty($data)){
+        return($data);
+      }
+    }
+
+    /* Automatically disable status for pasting */
+    if(!$this->CopyPasteHandler->entries_queued()){
+      $this->start_pasting_copied_objects = FALSE;
+    }
+    return("");
+  }
+
+
+  function list_get_selected_items()
+  {
+    $ids = array();
+    foreach($_POST as $name => $value){
+      if(preg_match("/^item_selected_[0-9]*$/",$name)){
+        $id   = preg_replace("/^item_selected_/","",$name);
+        $ids[$id] = $id;
+      }
+    }
+    return($ids);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Optionally execute a command after we're done */
+    $this->postcreate();
+  }
+
+  function remove_lock()
+  {
+    if (isset($this->apptabs->dn)){
+      del_lock ($this->apptabs->dn);
+    }
+  }
+
+  function save_object() {
+    $this->DivListApplication->save_object();
+  }
+
+  function check() {}
+  function adapt_from_template($dn) {}
+  function password_change_needed() {}
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/applications/class_applicationParameters.inc b/gosa-plugins/goto/admin/applications/class_applicationParameters.inc
new file mode 100644 (file)
index 0000000..9f11eb6
--- /dev/null
@@ -0,0 +1,248 @@
+<?php
+class applicationParameters extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage application class parameters";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Parameters  */
+  var $option_name= array();
+  var $option_value= array();
+
+  /* attribute list for save action */
+  var $attributes= array("gosaApplicationParameter");
+  var $objectclasses= array();
+
+  var $CopyPasteVars = array("option_name","option_value");
+
+  function applicationParameters (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin ($config, $dn, $parent);
+
+    $this->gosaApplicationParameter = array();
+
+    if (isset($this->attrs['gosaApplicationParameter'])){
+      $this->is_account= TRUE;
+      for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){
+        $option= preg_replace('/^[^:]+:/', '',
+            $this->attrs['gosaApplicationParameter'][$i]);
+        $name= preg_replace('/:.*$/', '',
+            $this->attrs['gosaApplicationParameter'][$i]);
+        $this->option_name[$i]= $name;
+        $this->option_value[$i]= $option;
+      }
+    } else {
+      $this->is_account= FALSE;
+    }
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    /* Do we need to flip is_account state? */
+    if (isset($_POST['modify_state'])){
+      $this->is_account= !$this->is_account;
+    }
+
+    /* Show tab dialog headers */
+    $display= "";
+    if ($this->parent !== NULL){
+      if ($this->is_account){
+        $display= $this->show_disable_header(_("Remove options"),
+            _("This application has options. You can disable them by clicking below."));
+      } else {
+        $display= $this->show_enable_header(_("Create options"),
+            _("This application has options disabled. You can enable them by clicking below."));
+        $this->parent->by_object['application']->generateTemplate();
+        return ($display);
+      }
+    }
+
+    /* Add option to list */
+    if (isset($_POST['add_option'])){
+      $i= count($this->option_name);
+      $this->option_name[$i]= "";
+      $this->option_value[$i]= "";
+    }
+
+    /* Remove value from list */
+    for ($i= 0; $i<count($this->option_name); $i++){
+      if (isset($_POST["remove$i"])){
+        $k= 0;
+        $on= array();
+        $ov= array();
+        for ($j= 0; $j<count($this->option_name); $j++){
+          if ($j != $i){
+            $on[$k]= $this->option_name[$j];
+            $ov[$k]= $this->option_value[$j];
+            $k++;
+          }
+        }
+        $this->option_name= $on;
+        $this->option_value= $ov;
+        break;
+      }
+    }
+
+    /* Generate list of attributes */
+    if (count($this->option_name) == 0){
+      $this->option_name[]= "";
+      $this->option_value[]= "";
+    }
+
+
+    $acl = $this->getacl("gosaApplicationParameter")   ;
+    $table= "<table summary=\"\"><tr><td>"._("Variable")."</td><td>"._("Default value")."</td><td></td></tr>";
+    if (count ($this->option_name)){
+
+      for ($i= 0; $i < count($this->option_name); $i++){
+        $name = $this->option_name[$i];
+        $value= $this->option_value[$i];
+
+        $tag = "";
+        if(!preg_match("/w/",$acl)){
+          $tag = " disabled ";
+        }
+
+        if(!preg_match("/r/",$acl)){
+          $name = "";
+          $value= "";
+        }
+
+        $table.="<tr>".
+          " <td>".
+          "  <input name=\"option$i\" size=25 maxlength=50 value=\"".$name."\" ".$tag.">".
+          " </td>".
+          " <td>".
+          "  <input name=\"value$i\" size=60 maxlength=250 value=\"".$value."\" ".$tag.">".
+          "  <br>".
+          " </td>".
+          " <td>".
+          "  <input type=\"submit\" name=\"remove$i\" value=\""._("Remove")."\" ".$tag.">".
+          " </td>".
+          "</tr>";
+      }
+    }
+    $table.= "</table>";
+    $table.="<input type=\"submit\" name=\"add_option\" value=\""._("Add option")."\">";
+
+    /* Show main page */
+    $smarty= get_smarty();
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    $smarty->assign("table", $table);
+    $display.= $smarty->fetch(get_template_path('parameters.tpl', TRUE));
+    $this->parent->by_object['application']->generateTemplate();
+    return ($display);
+  }
+
+  function remove_from_parent()
+  {
+    $ldap= $this->config->get_ldap_link();
+
+    /* Zero attributes */
+    $this->attrs= array();
+    $this->attrs['gosaApplicationParameter']= array();
+
+    $ldap->cd($this->dn);
+    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
+        $this->attributes, "Save");
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of application parameters with dn '%s' failed."),$this->dn));
+
+    /* Optionally execute a command after we're done */
+    $this->handle_post_events('remove');
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    if (isset($_POST['option0'])){
+      for ($i= 0; $i<count($this->option_name); $i++){
+        $this->option_name[$i]= $_POST["option$i"];
+        $this->option_value[$i]= "";
+        if ($_POST["value$i"] != ""){
+          $this->option_value[$i]= $_POST["value$i"];
+        }
+      }
+    }
+  }
+
+
+  /* Check values */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    /* Check for valid option names */
+    for ($i= 0; $i<count($this->option_name); $i++){
+      if (!preg_match ("/^[a-z0-9_]+$/i", $this->option_name[$i])){
+        $message[]= sprintf(_("Value '%s' specified as option name is not valid."), 
+            $this->option_name[$i]);
+      }
+    }
+
+    return $message;
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Generate values */
+    $this->attrs= array();
+    if (count($this->option_name) == 0){
+      $this->attrs['gosaApplicationParameter']= array();
+    } else {
+      for ($i= 0; $i<count($this->option_name); $i++){
+        $this->attrs['gosaApplicationParameter'][]= $this->option_name[$i].
+          ":".$this->option_value[$i];
+      }
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
+        $this->attributes, "Save");
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of application parameters with dn '%s' failed."),$this->dn));
+
+    /* Optionally execute a command after we're done */
+    $this->handle_post_events('modify');
+  }
+
+  /* Return plugin informations for acl handling
+#FIXME FAIscript seams to ununsed within this class... */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Parameter"),
+          "plDescription" => _("Parameter configuration"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("application"),
+
+          "plProvidedAcls"=> array(
+            "gosaApplicationParameter"      => _("Application parameter settings"))  
+          ));
+  }
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/applications/class_divListApplication.inc b/gosa-plugins/goto/admin/applications/class_divListApplication.inc
new file mode 100644 (file)
index 0000000..f70d5c6
--- /dev/null
@@ -0,0 +1,323 @@
+<?php
+
+class divListApplication extends MultiSelectWindow
+{
+  /* Current base */
+  var $selectedBase       = "";
+  var $selectedRelease    = "main";
+  var $AvailableReleases  = array();
+  var $departments        = array();
+  var $parent               ;
+  var $ui                   ;
+
+  /* Regex */
+  var $Regex           = "*";
+
+  /* Subsearch checkbox */
+  var $SubSearch;
+
+  var $SaveAdditionalVars = array("selectedRelease");
+
+  function divListApplication (&$config,&$parent)
+  {
+    MultiSelectWindow::MultiSelectWindow($config,"Application", "application");
+   
+    $this->selectedRelease = get_ou('applicationou').session::get('CurrentMainBase');
+    $this->parent       = &$parent;
+    $this->ui           = get_userinfo();
+
+    /* Set list strings */
+    $this->SetTitle(_("List of Applications"));
+    $this->SetSummary(_("This table displays all applications in the selected tree."));
+
+    /* Result page will look like a headpage */
+    $this->SetHeadpageMode();
+    $this->SetInformation(_("This menu allows you to add, edit and remove selected applications. You may want to use the range selector on top of the application listbox, when working with a large number of applications."));
+
+    $this->EnableAplhabet(true);
+  
+    /* Disable buttonsm */
+    $this->EnableCloseButton(false);
+    $this->EnableSaveButton (false);
+
+    /* set Page header */
+    $action_col_size = 80;
+    if($this->parent->snapshotEnabled()){
+      $action_col_size += 38;
+    }
+
+
+    /* Toggle all selected / deselected */
+    $chk = "<input type='checkbox' id='select_all' name='select_all'
+               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
+    /* set Page header */
+    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
+    $this->AddHeader(array("string" => "&nbsp;",                "attach" => "style='text-align:center;width:20px;'"));
+    $this->AddHeader(array("string" => _("Application name")." / "._("Department"), "attach" => "style=''"));
+    $this->AddHeader(array("string" => _("Actions"),            "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
+
+    /* Add SubSearch checkbox */
+    $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
+
+    /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
+    $this->AddRegex   ("Regex",     _("Display users matching"),"*" , true);
+  }
+
+  function AddUserBoxToFilter($position){
+    $str = "";
+    if(($position  == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
+      $smarty = get_smarty();
+      $smarty->assign("selectedRelease",$this->selectedRelease);
+      $smarty->assign("branchimage","images/branch.png");
+      $smarty->assign("releases",$this->AvailableReleases);
+      $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
+    }
+    return($str);
+  }
+
+  function GenHeader()
+  {
+    /* Prepare departments,
+       which are shown in the listbox on top of the listbox
+    */
+    $options= "";
+
+    /* Get all departments within this subtree */
+    $base = $this->config->current['BASE'];
+
+    /* Add base */
+    $tmp = array();
+    $tmp[] = array("dn"=>$this->config->current['BASE']);
+    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+    $deps = array();
+    foreach($tmp as $tm){
+      $deps[$tm['dn']] = $tm['dn'];
+    }
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments("application");
+    $ids = $this->config->idepartments;
+    $first = "";
+    $found = FALSE;
+    foreach($ids as $dep => $name){
+      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+        /* Keep first base dn in mind, we could need this
+         *  info if no valid base was found
+         */
+        if(empty($first)) {
+          $first = $dep['dn'];
+        }
+
+        $value = $ids[$dep];
+        if ($this->selectedBase == $dep){
+          $found = TRUE;
+          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep."'>$value</option>";
+        }
+      }
+    }
+
+    /* The currently used base is not visible with your acl setup.
+     * Set base to first useable base.
+     */
+    if(!$found){
+      $this->selectedBase = $first;
+    }
+
+    /* Get acls */
+    $ui       = get_userinfo();
+    $acl      = $ui->get_permissions("cn=dummy,".$this->selectedBase,"application/application");
+    $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"application");
+
+    /* Add default header */
+    $listhead = MultiSelectWindow::get_default_header();
+
+    /* And the rest, a base selection box */
+    $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+      " <input class='center' type='image' src='images/list_submit.png' align='middle' 
+        title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
+
+    /* Create Layers menu */
+    $s  = ".|"._("Actions")."|\n";
+    $s .= "..|<img src='images/list_new.png' alt='' border='0' class='center'>".
+      "&nbsp;"._("Create")."|\n";
+
+    /* Append create options */
+    if(preg_match("/c/",$acl)) {
+      $s.= "...|<input class='center' type='image' src='images/list_new_app' alt=''>".
+        "&nbsp;"._("Application")."|appl_new|\n";
+    }
+
+    /* Multiple options */
+    $s.= "..|---|\n";
+    $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>".
+      "&nbsp;"._("Remove")."|"."remove_multiple|\n";
+
+    /* Add multiple copy & cut icons */
+    if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $s.= "..|---|\n";
+      $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Copy")."|"."multiple_copy_systems|\n";
+      $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Cut")."|"."multiple_cut_systems|\n";
+
+      if($this->parent->CopyPasteHandler->entries_queued()){
+        $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
+        $s.="..|".$img."&nbsp;"._("Paste")."|editPaste|\n";
+      }else{
+        $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
+        $s.="..|".$img."&nbsp;"._("Paste")."\n";
+      }
+    }
+
+    /* Add snapshot icons */
+    if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $s .= "..|---|\n";
+      $s .= $this->get_snapshot_header(TRUE);
+    }
+
+    $this->SetDropDownHeaderMenu($s);
+    $this->SetListHeader($listhead);
+
+    $this->SetListHeader($listhead);
+  }
+
+  /* so some basic settings */
+  function execute()
+  {
+    $this->ClearElementsList();
+    $this->GenHeader();
+    $this->AvailableReleases = $this->parent->getReleases($this->selectedBase);
+  }
+
+  function setEntries($list)
+  {
+    /********************
+      Variable init
+     ********************/
+  
+    /* Create links */
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
+    $applimg  = "<img class='center' src='images/select_application.png' alt='A'  title='"._("Application")."'>";
+    $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+
+    /* set Page header */
+    $action_col_size = 80;
+    if($this->parent->snapshotEnabled()){
+      $action_col_size += 38;
+    }
+
+    /********************
+      Attach objects
+     ********************/
+    
+    $ui = get_userinfo();
+    foreach($list as $key => $val){
+
+      $acl = $ui->get_permissions($val['dn'],"application/application");
+      $acl_all= $ui->has_complete_category_acls($val['dn'],"application");
+
+      /* Create action icons */
+      $actions= "";
+
+      /* Add Copy & Paste icon */
+      if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+        /* Only add cut icon, if we are allowed to move this user */
+        if(preg_match("/m/",$acl)){
+          $actions.= "<input class='center' type='image'
+            src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+
+          $actions.= "<input class='center' type='image'
+            src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+        }
+      }
+
+      /* Add edit icon */
+      $actions.= "<input class='center' type='image'
+        src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
+
+
+      if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $actions.= $this->GetSnapShotActions($val['dn']);
+      }
+
+      /* If we are allowed to remove the application account, display remove icon */
+      if(preg_match("/d/",$acl)){
+        $actions.= "<input class='center' type='image'
+          src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
+      }else{
+        $actions.= "<img src='images/empty.png' alt='&nbsp;'>";
+      }
+
+      $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
+
+      if(!isset($val['description'][0])){
+        $desc = "";
+      }else{
+        $desc = " - [ ".$val['description'][0]." ]";
+      }
+
+      /* Cutted objects should be displayed in light grey */
+      $display = $val['cn'][0].$desc;
+      if($this->parent->CopyPasteHandler){
+        foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
+          if($queue_data['dn'] == $val['dn']) {
+            $display = "<font color='#999999'>".$display."</font>";
+            break;
+          }
+        }
+      }
+
+      /* Create each field */
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+                      "attach" => "style='width:20px;'");
+      $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
+      $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
+      $this->AddElement(array($field0,$field1,$field2,$field3));
+    }
+
+    /* Create summary string for list footer */
+    $num_deps=0;
+    if(!$this->SubSearch){
+      $num_deps = count($this->Added_Departments);
+    }
+    $num_apps = count($list);
+
+    $num_app_str = _("Number of listed applications");
+    $num_dep_str = _("Number of listed departments");
+  
+    $str = "<img class='center' src='images/select_application.png' 
+              title='".$num_app_str."' alt='".$num_app_str."'>&nbsp;".$num_apps."&nbsp;&nbsp;&nbsp;&nbsp;";
+    $str.= "<img class='center' src='images/folder.png' 
+              title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
+
+    $this->set_List_Bottom_Info($str);
+  }
+
+  function Save()
+  {
+    MultiSelectWindow::Save();  
+  }
+
+  function save_object()
+  {
+    /* Save automatic created POSTs like regex, checkboxes */
+    MultiSelectWindow::save_object(); 
+    $appfilter = session::get('appfilter');
+    $appfilter['release']  = $this->selectedRelease;
+    session::set('appfilter',$appfilter);
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/applications/generic.tpl b/gosa-plugins/goto/admin/applications/generic.tpl
new file mode 100644 (file)
index 0000000..b50ed7e
--- /dev/null
@@ -0,0 +1,152 @@
+<table summary="" style="width:100%;">
+ <tr>
+  <td style="width:50%;">
+
+   <table summary="">
+     <tr>
+      <td><LABEL for="cn">{t}Application name{/t}{$must}</LABEL></td>
+      <td>
+{render acl=$cnACL}
+       <input id="cn" name="cn" size=25 maxlength=60 value="{$cn}" title="{t}Application name{/t}">
+{/render}
+      </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gosaApplicationName">{t}Display name{/t}</LABEL></td>
+     <td>
+{render acl=$gosaApplicationNameACL}
+        <input id="gosaApplicationName" name="gosaApplicationName" size=35 maxlength=60 
+         value="{$gosaApplicationName}" title="{t}Application name to be displayed (i.e. below icons){/t}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gosaApplicationExecute">{t}Execute{/t}{$must}</LABEL></td>
+     <td>
+{render acl=$gosaApplicationExecuteACL}
+        <input id="gosaApplicationExecute" name="gosaApplicationExecute" size=35 maxlength=120 
+         value="{$gosaApplicationExecute}" title="{t}Path and/or binary name of application{/t}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="description">{t}Description{/t}</LABEL></td>
+     <td>
+{render acl=$descriptionACL}
+      <input id="description" name="description" size=35 maxlength=80 value="{$description}">
+{/render}
+     </td>
+    </tr>
+    <tr><td colspan=2><div style="height:15px;"></div></td></tr>
+    <tr>
+      <td><LABEL for="base">{t}Base{/t}{$must}</LABEL></td>
+      <td>
+{render acl=$baseACL}
+       <select size="1" id="base" name="base" title="{t}Choose subtree to place application in{/t}" 
+        {if $isReleaseApplikation} disabled {/if}>
+        {html_options options=$bases selected=$base_select}
+       </select>
+{/render}
+{if !$isReleaseApplikation}
+{render acl=$baseACL disable_picture='images/folder_gray.png'}
+      <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+{/render}
+{/if}
+      </td>
+     </tr>
+   </table>
+  </td>
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  <td style="vertical-align:top;">
+   <table summary="">
+    <tr>
+    <td>
+    <LABEL for="picture_file">{t}Icon{/t}</LABEL>
+    <br>
+    <img alt="" src="getbin.php?rand={$rand}" border=1 style="width:48px; height:48; background-color:white; vertical-align:bottom;">
+    </td>
+    <td style="vertical-align:top">
+    &nbsp;<br>
+
+    <input type="hidden" name="MAX_FILE_SIZE" value="100000">
+{render acl=$gosaApplicationIconACL}
+    <input name="picture_file" type="file" size="20" maxlength="255" accept="image/*.png" id="picture_file">
+{/render}
+{render acl=$gosaApplicationIconACL}
+<input type="submit" name="update" value="{t}Update{/t}" title="{t}Reload picture from LDAP{/t}">
+{/render}
+{render acl=$gosaApplicationIconACL}
+<input type="submit" name="remove_picture" value="{t}Remove picture{/t}" title="{t}Remove picture from LDAP{/t}">
+{/render}
+    </td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+
+<p class="plugbottom" style="height:4px; margin-bottom:0px;">&nbsp;</p>
+
+<h2><img src="images/lamp.png" alt="{t}Options{/t}" align="middle">&nbsp;{t}Options{/t}</h2>
+<table summary="" style="width:100%;">
+  <tr>
+    <td style="width:50%;border-right:1px solid #B0B0B0; vertical-align:top">
+{render acl=$gosaApplicationFlagsACL}
+      <input type=checkbox name="exec_for_groupmembers" value="1" {$exec_for_groupmembers}>
+{/render}
+       {t}Only executable for members{/t}
+      <br>
+{render acl=$gosaApplicationFlagsACL}
+      <input type=checkbox name="overwrite_config" value="1" {$overwrite_config}>
+{/render}
+       {t}Replace user configuration on startup{/t}
+    </td>
+    <td>
+{render acl=$gosaApplicationFlagsACL}
+      <input type=checkbox name="place_on_desktop" value="1" {$place_on_desktop}>
+{/render}
+      {t}Place icon on members desktop{/t}
+      <br>
+{render acl=$gosaApplicationFlagsACL}
+      <input type=checkbox name="place_in_startmenu" value="1" {$place_in_startmenu}>
+{/render}
+      {t}Place entry in members startmenu{/t}
+      <br>
+{render acl=$gosaApplicationFlagsACL}
+      <input type=checkbox name="place_on_kicker" value="1" {$place_on_kicker}>
+{/render}
+      {t}Place entry in members launch bar{/t}
+    </td>
+  </tr>
+</table>
+
+<p class="plugbottom" style="height:4px; margin-bottom:0px;">&nbsp;</p>
+
+<table width="99%" summary="">
+       <tr>
+               <td>
+                       <h2><img src="images/fai_script.png" alt="{t}Script{/t}" align="middle">&nbsp;{t}Script{/t}</h2>
+{render acl=$gotoLogonScriptACL}
+                       <textarea name="gotoLogonScript" style='width:99%;height:220px;'>{$gotoLogonScript}</textarea>
+{/render}
+{render acl=$gotoLogonScriptACL}
+                       <input type="file" name="ScriptFile" value="{t}Import{/t}">
+{/render}
+{render acl=$gotoLogonScriptACL}
+                       <input type="submit" name="upLoad" value="{t}Upload{/t}">
+{/render}
+                       <input type='image' name='downloadScript'  src='images/save.png' title='{t}Download{/t}' class='center'>
+               </td>
+       </tr>
+</table>
+
+<div style="height:20px;"></div>
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('cn');
+  -->
+</script>
diff --git a/gosa-plugins/goto/admin/applications/main.inc b/gosa-plugins/goto/admin/applications/main.inc
new file mode 100644 (file)
index 0000000..7b74838
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/*
+  This code is part of GOsa (https://gosa.gonicus.de)
+  Copyright (C) 2003  Cajus Pollmeier
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+if ($remove_lock){
+        if(session::is_set('applicationManagement')){
+                $applicationManagement = session::get('applicationManagement');
+                $applicationManagement->remove_lock();
+                del_lock ($ui->dn);
+                session::un_set ('applicationManagement');
+        }
+} else {
+       /* Create applicationManagement object on demand */
+       if (!session::is_set('applicationManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+               session::set('applicationManagement',new applicationManagement ($config, $ui));
+       }
+       $applicationManagement = session::get('applicationManagement');
+       $applicationManagement->save_object();
+       $output= $applicationManagement->execute();
+
+       /* Page header*/
+       if (session::is_set('objectinfo')){
+               $display= print_header(get_template_path('images/application.png'), _("Application management"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".@LDAP::fix(session::get('objectinfo')));
+       } else {
+               $display= print_header(get_template_path('images/application.png'), _("Application management"));
+       }
+
+       /* Reset requested? */
+       if (isset($_GET['reset']) && $_GET['reset'] == 1){
+               del_lock ($ui->dn);
+               session::un_set ('applicationManagement');
+       }
+
+       /* Show and save dialog */
+       $display.= $output;
+       session::set('applicationManagement',$applicationManagement);
+}
+
+?>
diff --git a/gosa-plugins/goto/admin/applications/parameters.tpl b/gosa-plugins/goto/admin/applications/parameters.tpl
new file mode 100644 (file)
index 0000000..57c2219
--- /dev/null
@@ -0,0 +1,2 @@
+{$table}
+<div style="height:20px"></div>
diff --git a/gosa-plugins/goto/admin/applications/release_select.tpl b/gosa-plugins/goto/admin/applications/release_select.tpl
new file mode 100644 (file)
index 0000000..d58738f
--- /dev/null
@@ -0,0 +1,16 @@
+<br> 
+<div class="contentboxh" style="border-bottom:1px solid #B0B0B0;">
+ <p class="contentboxh"><img src="{$branchimage}" align="right" alt="[F]">{t}Branches{/t}</p>
+</div>
+<div class="contentboxb">
+ <table summary="" style="width:100%;">
+  <tr>
+   <td>
+    {t}Current release{/t}&nbsp;
+    <select name="selectedRelease" onChange="document.mainform.submit();">
+     {html_options options=$releases selected=$selectedRelease}
+    </select>
+   </td>
+  </tr>
+ </table>
+</div>
diff --git a/gosa-plugins/goto/admin/applications/remove.tpl b/gosa-plugins/goto/admin/applications/remove.tpl
new file mode 100644 (file)
index 0000000..8598ed8
--- /dev/null
@@ -0,0 +1,23 @@
+<div style="font-size:18px;">
+  <img alt="" src="images/button_cancel.png" align=top>&nbsp;{t}Warning{/t}
+</div>
+<p>
+ {$intro}
+ {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+</p>
+<p>
+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+       {if $multiple}
+               <input type=submit name="delete_multiple_application_confirm" value="{t}Delete{/t}">
+               &nbsp;
+               <input type=submit name="delete_multiple_application_cancel" value="{t}Cancel{/t}">
+       {else}
+               <input type=submit name="delete_app_confirm" value="{t}Delete{/t}">
+               &nbsp;
+               <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+       {/if}
+</p>
+
diff --git a/gosa-plugins/goto/admin/applications/tabs_application.inc b/gosa-plugins/goto/admin/applications/tabs_application.inc
new file mode 100644 (file)
index 0000000..5b6e829
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+class apptabs extends tabs
+{
+  var $Release= "";
+
+  function apptabs($config, $data, $dn,$category)
+  {
+    tabs::tabs($config, $data, $dn,$category);
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function set_release($newRelease)
+  {
+    $this->Release= preg_replace('/,'.get_ou('applicationou').'.*$/', '', $newRelease);
+    if ($this->Release != ""){
+      $this->Release= ",".$this->Release;
+    }
+  }
+
+  function save($ignore_account= FALSE)
+  {
+    $baseobject= $this->by_object['application'];
+
+    /* Check for new 'dn', in order to propagate the
+       'dn' to all plugins */
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+    $appfilter = session::get('appfilter');
+    if((!empty($tmp)) && (isset($appfilter['release']))){
+      if(!$baseobject->isReleaseApplikation){
+        $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base;
+      }else{
+        $new_dn ="cn=".$baseobject->cn.",".$appfilter['release'];
+      }
+    }else{
+      $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base;
+    }
+
+    /* Move group? */
+    if ($this->dn != $new_dn){
+
+      /* Write entry on new 'dn' */
+      if ($this->dn != "new"){
+        $baseobject->move($this->dn, $new_dn);
+        $this->by_object['application']= $baseobject;
+      }
+
+      /* Happen to use the new one */
+      $this->dn= $new_dn;
+    }
+
+    tabs::save();
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc b/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc
new file mode 100644 (file)
index 0000000..bc870eb
--- /dev/null
@@ -0,0 +1,256 @@
+<?php
+
+class deviceGeneric extends plugin
+{
+  public $dn            = "";
+  public $cn            = "";
+  public $orig_cn       = "";
+  public $description   = "";
+  public $vendor        = "";
+  public $dev_id        = "";
+  public $serial        = "";
+  public $base          = "";  
+  public $types;
+  public $type;
+
+  public $posts           = array("description","dev_id","serial","vendor", "type");
+  public $attributes      = array("cn");
+  public $objectclasses   = array("top","gotoDevice");
+
+  public $CopyPasteVars   = array("orig_cn","description","vendor","dev_id","serial","base");
+
+  public function deviceGeneric(&$config,$dn = NULL)
+  {
+    plugin::plugin($config,$dn);
+
+    $this->is_account = TRUE;
+
+    $this->types= array("camera" => _("Digital camera"),
+                        "harddisk" => _("Harddisk"),
+                        "stick" => _("USB stick"),
+                        "cd" => _("CD/DVD drive"),);
+    asort($this->types);
+
+    /* Set class values */
+    if(isset($this->attrs['gotoHotplugDevice'][0])){
+      $tmp = preg_split("/\|/",$this->attrs['gotoHotplugDevice'][0]);
+      $this->cn         = $this->attrs['cn'][0];
+      $this->description= $tmp[0];
+      $this->dev_id     = $tmp[1];
+      $this->serial     = $tmp[2];
+      $this->vendor     = $tmp[3];
+      if (isset($tmp[4])){
+        $this->type= $tmp[4];
+      }
+    }     
+
+    $this->orig_cn = $this->cn;
+
+    /* Set Base */
+    if ($this->dn == "new"){
+      if(session::is_set('CurrentMainBase')){
+        $this->base = session::get('CurrentMainBase');
+      }else{
+        $ui= get_userinfo();
+        $this->base= dn2base($ui->dn);
+      }
+    } else {
+      $this->base =preg_replace ("/^[^,]+,".get_ou('deviceou')."/","",$this->dn);
+    }
+  }
+
+
+  public function execute()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("base",$this->base);
+    $smarty->assign("bases",$this->get_allowed_bases());
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }
+    foreach($this->posts as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }
+
+    $smarty->assign("type",$this->type);
+    $smarty->assign ("types", $this->types);
+
+    return($smarty->fetch(get_template_path("deviceGeneric.tpl",TRUE,dirname(__FILE__))));
+  }
+
+  
+  public function check()
+  {
+    $message = plugin::check();
+
+    if(empty($this->cn)||(preg_match("/[^a-z0-9]/i",$this->cn))){
+      $message[]=_("Please specify a valid name. Only 0-9 a-Z is allowed.");
+    }
+    if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->description)){
+      $message[]=_("Invalid character in description. Please specify a valid description.");
+    }
+
+    /* Skip serial check if vendor and product id are given */
+    if(preg_match("/^\s+$/i",$this->dev_id)){
+      $message[]=_("Please specify a valid iSerial.");
+    }
+    if(empty($this->serial) || !$this->is_2byteHex($this->serial)){
+      $message[]=_("Please specify a valid vendor ID. (2 byte hex like '0xFFFF')");
+    }
+    if(empty($this->vendor) || !$this->is_2byteHex($this->vendor)){
+      $message[]=_("Please specify a valid product ID. (2 byte hex like '0xFFFF')");
+    }
+   
+    /* Check if entry already exists */ 
+    if($this->cn != $this->orig_cn){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->search("(&(objectClass=gotoDevice)(cn=".$this->cn."*))",array("cn"));
+      if($ldap->count()){
+        $message[]=_("An Entry with this name already exists.");
+      }
+    }
+
+    return($message);
+  }
+
+
+  public function save_object()
+  {
+    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");
+        }
+      }
+    
+      foreach($this->posts as $post){
+        if(isset($_POST[$post])){
+          $this->$post = get_post($post);
+        }
+      }
+    }
+  }
+
+  
+  public function remove_from_parent()
+  {
+    plugin::remove_from_parent();
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+
+    $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDeviceDN=".$this->dn."))",array("cn","gotoHotplugDeviceDN"));
+    $skip = FALSE;
+    $str ="";
+    $cnt = 3;
+    while($cnt && $attrs = $ldap->fetch()){
+      $skip =TRUE;
+      $str .= $attrs['cn'][0].", ";
+      $cnt --;
+    }
+    if($skip){
+      $str  = preg_replace("/, $/","",$str);
+      if($cnt == 0){
+        $str .= "...";
+      }
+      print_red(sprintf(_("Can't remove the device '%s' it is still in use be this user(s) : %s"),$this->cn,$str));
+    }else{
+      $ldap->rmdir_recursive($this->dn);
+    }
+  }
+
+
+  public function save()
+  {
+    plugin::save();
+
+    $this->attrs['gotoHotplugDevice'] = "";
+    foreach($this->posts as $post){
+      $this->attrs['gotoHotplugDevice'] .= $this->$post."|"; 
+    }
+    $this->attrs['gotoHotplugDevice'] = preg_replace("/\|$/","",$this->attrs['gotoHotplugDevice']);
+
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->cat($this->dn);
+    if($ldap->count()){
+      $ldap->cd($this->dn);
+      $ldap->modify($this->attrs);
+    }else{
+      $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$this->dn));
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+    }
+    show_ldap_error($ldap->get_error(),_("Device could not be saved."));
+  }
+
+
+  /* check if given str in like this 0xffff*/
+  function is_2byteHex($str)
+  {
+    return !strlen($str) || preg_match("/^(0x|x|)[a-f0-9][a-f0-9][a-f0-9][a-f0-9]/i",$str);
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    $source_o = new deviceGeneric($this->config,$source['dn']);
+    foreach($this->CopyPasteVars as $post){
+      $this->$post = $source_o->$post;
+    }
+  }
+
+
+  /* Return a dialog with all fields that must be changed,
+     if we want to copy this entry */
+  function getCopyDialog()
+  {
+    $str = "";
+    $smarty = get_smarty();
+    $smarty->assign("cn",         $this->cn);
+    $str = $smarty->fetch(get_template_path("paste_deviceGeneric.tpl",TRUE,dirname(__FILE__)));
+
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  /* Save all */
+  function saveCopyDialog()
+  {
+    $attrs = array("cn");
+    foreach($attrs as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr = $_POST[$attr];
+      }
+    }
+  }
+
+
+
+  /* Return plugin informations for acl handling  */
+  public static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Generic"),
+          "plDescription" => _("Device generic"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("devices" => array("description"  => _("Devices"),
+                                                        "objectClass"  => "gotoHotplugDevice")),
+          "plProvidedAcls"=> array(
+            "cn"                          => _("Name"))
+          ));
+
+  }
+       
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/devices/class_deviceManagement.inc b/gosa-plugins/goto/admin/devices/class_deviceManagement.inc
new file mode 100644 (file)
index 0000000..77c5825
--- /dev/null
@@ -0,0 +1,557 @@
+<?php
+
+class deviceManagement extends plugin
+{
+
+  /* Definitions */
+  var $plHeadline     = "Devices";
+  var $plDescription  = "Manage devices";
+
+  /* Dialog attributes */
+  var $ui                             = NULL;
+  var $DivListDevices               = NULL;
+  var $enableReleaseManagement        = false;
+  var $devicetabs                       = NULL;
+  var $snapDialog                     = NULL;
+  var $CopyPasteHandler               = NULL;
+  var $start_pasting_copied_objects;
+  var $dn ="";
+
+  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")){
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
+    }
+
+    /* Creat dialog object */
+    $this->DivListDevices = new divListDevices($this->config,$this);
+  }
+
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    /****************
+      Variable init
+     ****************/
+
+    /* These vars will be stored if you try to open a locked device,
+        to be able to perform your last requests after showing a warning message */
+    session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^device_edit_/",
+                                          "/^device_del_/","/^item_selected/","/^remove_multiple_devices/"));
+
+    $smarty       = get_smarty();             // Smarty instance
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+
+      if(preg_match("/device_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/device_".$s_action."_/i","",$key);
+      }elseif(preg_match("/device_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/device_".$s_action."_/i","",$key);
+      }elseif(preg_match("/^copy_.*/",$key)){
+        $s_action="copy";
+        $s_entry  = preg_replace("/^copy_/i","",$key);
+      }elseif(preg_match("/^cut_.*/",$key)){
+        $s_action="cut";
+        $s_entry  = preg_replace("/^cut_/i","",$key);
+      }elseif(preg_match("/^device_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/^remove_multiple_devices/",$key)){
+        $s_action="del_multiple";
+      }elseif(preg_match("/^editPaste.*/i",$key)){
+        $s_action="editPaste";
+      }elseif(preg_match("/^multiple_copy_devices/",$key)){
+        $s_action = "copy_multiple";
+     }elseif(preg_match("/^multiple_cut_devices/",$key)){
+        $s_action = "cut_multiple";
+      }
+    }
+
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+
+    /* handle C&P from layers menu */
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
+      $s_action = "copy_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
+      $s_action = "cut_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
+      $s_action = "editPaste";
+    }
+
+    /* Create options */
+    if(isset($_POST['menu_action']) && $_POST['menu_action'] == "device_new"){
+      $s_action = "new";
+    }
+
+    /* handle remove from layers menu */
+    if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
+      $s_action = "del_multiple";
+    }
+
+    /****************
+      Copy & Paste handling
+     ****************/
+
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+
+    /****************
+      Create a new device type
+     ****************/
+
+    /* New device type? */
+    $ui = get_userinfo();
+    $acl = $ui->get_permissions($this->DivListDevices->selectedBase,"devices/deviceGeneric");
+    if (($s_action=="new") && preg_match("/c/",$acl)){
+
+      /* By default we set 'dn' to 'new', all relevant plugins will
+         react on this. */
+      $this->dn= "new";
+
+      /* Create new usertab object */
+      $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $this->dn,"devices");
+      $this->devicetabs->set_acl_base($this->DivListDevices->selectedBase);
+    }
+
+
+    /****************
+      Edit entry canceled
+     ****************/
+
+    /* Cancel dialogs */
+    if (isset($_POST['edit_cancel']) && is_object($this->devicetabs)){
+      del_lock ($this->devicetabs->dn);
+      unset ($this->devicetabs);
+      $this->devicetabs= NULL;
+      session::un_set('objectinfo');
+    }
+
+
+    /****************
+      Edit entry finished
+     ****************/
+
+    /* Finish device edit is triggered by the tabulator dialog, so
+       the user wants to save edited data. Check and save at this point. */
+    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->devicetabs->config))){
+
+      /* Check tabs, will feed message array */
+      $this->devicetabs->save_object();
+      $message= $this->devicetabs->check();
+
+      /* Save, or display error message? */
+      if (count($message) == 0){
+
+        /* Save data data to ldap */
+#        $this->devicetabs->set_release($this->DivListDevices->selectedRelease);
+        $this->devicetabs->save();
+
+        if (!isset($_POST['edit_apply'])){
+          /* device type has been saved successfully, remove lock from LDAP. */
+          if ($this->dn != "new"){
+            del_lock ($this->dn);
+          }
+          unset ($this->devicetabs);
+          $this->devicetabs= NULL;
+          session::un_set('objectinfo');
+        }
+      } else {
+       /* Ok. There seem to be errors regarding to the tab data,
+           show message and continue as usual. */
+        show_errors($message);
+      }
+    }
+
+
+    /****************
+      Edit entry
+     ****************/
+
+    /* User wants to edit data? */
+    if (($s_action=="edit") && (!isset($this->devicetabs->config))){
+
+      /* Get 'dn' from posted 'devicelist', must be unique */
+      $this->dn= $this->devices[$s_entry]['dn'];
+
+      /* 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));
+      }
+
+      /* Lock the current entry, so everyone will get the
+         above dialog */
+      add_lock ($this->dn, $this->ui->dn);
+
+
+      /* 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);
+    }
+
+
+    /********************
+      Delete MULTIPLE entries requested, display confirm dialog
+     ********************/
+    if ($s_action=="del_multiple"){
+      $ids = $this->list_get_selected_items();
+
+      if(count($ids)){
+
+        foreach($ids as $id){
+          $dn = $this->devices[$id]['dn'];
+          if (($user= get_lock($dn)) != ""){
+            return(gen_locked_message ($user, $dn));
+          }
+          $this->dns[$id] = $dn;
+        }
+
+        $dns_names = "<br><pre>";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="</pre>";
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        if (count($this->dns) == 1){
+          $smarty->assign("intro",     sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
+        } else {
+          $smarty->assign("intro",     sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
+        }
+        $smarty->assign("multiple", true);
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries confirmed
+     ********************/
+
+    /* Confirmation for deletion has been passed. Users should be deleted. */
+    if (isset($_POST['delete_multiple_device_confirm'])){
+
+      $ui = get_userinfo();
+
+      /* Remove user by user and check acls before removeing them */
+      foreach($this->dns as $key => $dn){
+
+        $acl = $ui->get_permissions($dn,"devices/deviceGeneric");
+        if(preg_match("/d/",$acl)){
+
+          /* Delete request is permitted, perform LDAP action */
+          $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $dn,"devices");
+          $this->devicetabs->set_acl_base($dn);
+          $this->devicetabs->delete ();
+          unset ($this->devicetabs);
+          $this->devicetabs= NULL;
+
+        } else {
+          /* Normally this shouldn't be reached, send some extra
+             logs to notify the administrator */
+          print_red (_("You are not allowed to delete this device type!"));
+          new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion.");
+        }
+        /* Remove lock file after successfull deletion */
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries Canceled
+     ********************/
+
+    /* Remove lock */
+    if(isset($_POST['delete_multiple_device_cancel'])){
+      foreach($this->dns as $key => $dn){
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
+    /****************
+      Delete device type
+     ****************/
+
+    /* Remove user was requested */
+    if ($s_action == "del"){
+
+      /* Get 'dn' from posted 'uid' */
+      $this->dn= $this->devices[$s_entry]['dn'];
+
+      /* Load permissions for selected 'dn' and check if
+         we're allowed to remove this 'dn' */
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($this->dn,"devices/deviceGeneric");
+      if (preg_match("/d/",$acl)){
+
+        /* 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));
+        }
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        add_lock ($this->dn, $this->ui->dn);
+        $smarty= get_smarty();
+        $smarty->assign("intro", sprintf(_("You're about to delete the device '%s'."), @LDAP::fix($this->dn)));
+        $smarty->assign("multiple", false);
+        return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
+      } else {
+
+        /* Obviously the user isn't allowed to delete. Show message and
+           clean session. */
+       print_red (_("You are not allowed to delete this device!"));
+      }
+    }
+
+
+    /****************
+      Delete device confirmed
+     ****************/
+
+    /* Confirmation for deletion has been passed. Group should be deleted. */
+    if (isset($_POST['delete_device_confirm'])){
+
+      /* Some nice guy may send this as POST, so we've to check
+         for the permissions again. */
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($this->dn,"devices/deviceGeneric");
+      if(preg_match("/d/",$acl)){
+
+        /* Delete request is permitted, perform LDAP action */
+        $this->devicetabs= new devicetabs($this->config, $this->config->data['TABS']['DEVICETABS'], $this->dn,"devices");
+        $this->devicetabs->set_acl_base($this->dn);
+        $this->devicetabs->delete ();
+        unset ($this->devicetabs);
+        $this->devicetabs= NULL;
+
+      } else {
+
+        /* Normally this shouldn't be reached, send some extra
+           logs to notify the administrator */
+        print_red (_("You are not allowed to delete this device!"));
+        new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion.");
+      }
+
+      /* Remove lock file after successfull deletion */
+      del_lock ($this->dn);
+    }
+
+
+    /****************
+      Delete device canceled
+     ****************/
+
+    /* Delete device canceled? */
+    if (isset($_POST['delete_cancel'])){
+      del_lock ($this->dn);
+      session::un_set('objectinfo');
+  }
+
+    /* Show tab dialog if object is present */
+    if (($this->devicetabs) && (isset($this->devicetabs->config))){
+      $display= $this->devicetabs->execute();
+
+      /* Don't show buttons if tab dialog requests this */
+      if (!$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=\""._("Ok")."\">\n";
+        $display.= "&nbsp;\n";
+        if ($this->dn != "new"){
+          $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+          $display.= "&nbsp;\n";
+        }
+        $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+        $display.= "</p>";
+      }
+      return ($display);
+    }
+
+
+    /****************
+      Dialog display
+     ****************/
+
+        /* Check if there is a snapshot dialog open */
+    $base = $this->DivListDevices->selectedBase;
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+      return($str);
+    }
+
+    /* Display dialog with system list */
+    $this->DivListDevices->parent = $this;
+    $this->DivListDevices->execute();
+    $this->DivListDevices->AddDepartments($this->DivListDevices->selectedBase,3,1);
+    $this->reload();
+    $this->DivListDevices->setEntries($this->devices);
+    return($this->DivListDevices->Draw());
+
+  }
+
+  function save_object() {
+    $this->DivListDevices->save_object();
+  }
+
+
+  /* Return departments, that will be included within snapshot detection */
+  function get_used_snapshot_bases()
+  {
+    return(array(get_ou('deviceou').$this->DivListDevices->selectedBase));
+  }
+
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+    /* Check if Copy & Paste is disabled */
+    if(!is_object($this->CopyPasteHandler)){
+      return("");
+    }
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $dn = $this->devices[$s_entry]['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"devicetabs","DEVICETABS","devices");
+    }
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->devices[$id]['dn'];
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","devicetabs","DEVICETABS","devices");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","devicetabs","DEVICETABS","devices");
+        }
+      }
+    }
+
+    /* Start pasting entries */
+    if($s_action == "editPaste"){
+      $this->start_pasting_copied_objects = TRUE;
+    }
+
+    /* Return C&P dialog */
+    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
+
+      /* Load entry from queue and set base */
+      $this->CopyPasteHandler->load_entry_from_queue();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListDevices->selectedBase);
+
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      /* Return dialog data */
+      if(!empty($data)){
+        return($data);
+      }
+    }
+
+    /* Automatically disable status for pasting */
+    if(!$this->CopyPasteHandler->entries_queued()){
+      $this->start_pasting_copied_objects = FALSE;
+    }
+    return("");
+  }
+
+
+
+  function reload()
+  {
+    /* Set base for all searches */
+    $base       = $this->DivListDevices->selectedBase;
+    $Regex      = $this->DivListDevices->Regex;
+    $SubSearch  = $this->DivListDevices->SubSearch;
+    $Flags      =  GL_NONE | GL_SIZELIMIT;
+    $Filter     = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoDevice))";
+    $tmp        = array();
+
+    /* In case of subsearch, add the subsearch flag */
+    if($SubSearch){
+      $Flags    |= GL_SUBSEARCH;
+    }else{
+      $base = get_ou('deviceou').$base;
+    }
+
+    /* Get results and create index */
+    $res= get_sub_list($Filter,"devices",get_ou('deviceou'), $base, array("cn","description","dn","objectClass"), $Flags);
+    $tmp2 = array();
+    foreach ($res as $val){
+      $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn'];
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val;
+    }
+
+    /* sort entries */
+    natcasesort($tmp2);
+    $this->devices=array();
+    foreach($tmp2 as $val){
+      $this->devices[]=$tmp[$val];
+    }
+    reset ($this->devices);
+  }
+
+
+  function remove_lock()
+  {
+    if (isset($this->devicetabs->dn)){
+      del_lock ($this->devicetabs->dn);
+    }
+  }
+
+  function list_get_selected_items()
+  {
+    $ids = array();
+    foreach($_POST as $name => $value){
+      if(preg_match("/^item_selected_[0-9]*$/",$name)){
+        $id   = preg_replace("/^item_selected_/","",$name);
+        $ids[$id] = $id;
+      }
+    }
+    return($ids);
+  }
+
+
+  function remove_from_parent()
+  {
+    /* This cannot be removed... */
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/devices/class_divListDevices.inc b/gosa-plugins/goto/admin/devices/class_divListDevices.inc
new file mode 100644 (file)
index 0000000..e9d5f85
--- /dev/null
@@ -0,0 +1,303 @@
+<?php
+
+class divListDevices extends MultiSelectWindow
+{
+  /* Current base */
+  var $selectedBase       = "";
+  var $departments        = array();
+  var $parent               ;
+  var $ui                   ;
+
+  /* Regex */
+  var $Regex              = "*";
+
+  /* Subsearch checkbox */
+  var $SubSearch;
+
+  function divListDevices (&$config, &$parent)
+  {
+    /* Create divlist and setup */
+    MultiSelectWindow::MultiSelectWindow($config, "Devices", "devices");
+    /* initialize required attributes */ 
+    $this->parent           = &$parent;
+    $this->ui               = get_userinfo();
+
+    /* set Page header */
+    $action_col_size = 80;
+    if($this->parent->snapshotEnabled()){
+      $action_col_size += 38;
+    }
+
+    /* Set list strings */
+    $this->SetTitle       (_("List of defined devices"));
+    $this->SetSummary     (_("List of defined devices"));
+    $this->SetInformation (_("This menu allows you to add, edit and remove selected devices. You may want to use the range selector on top of the device listbox, when working with a large number of devices."));
+
+    /* Result page will look like a headpage */
+    $this->SetHeadpageMode();
+    $this->EnableAplhabet(true);
+  
+    /* Disable buttonsm */
+    $this->EnableCloseButton(false);
+    $this->EnableSaveButton (false);
+
+    /* Toggle all selected / deselected */
+    $chk = "<input type='checkbox' id='select_all' name='select_all'
+               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
+    /* set Page header */
+    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
+    $this->AddHeader(array("string" => "&nbsp;",                "attach" => "style='text-align:center;width:20px;'"));
+    $this->AddHeader(array("string" => _("Device name")." / "._("Department"), "attach" => "style=''"));
+    $this->AddHeader(array("string" => _("Actions"),            "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
+
+    /* Add SubSearch checkbox */
+    $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
+
+    /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
+    $this->AddRegex   ("Regex",     _("Display devices matching"),"*" , true);
+  }
+
+
+  /* Create list header, with create / copy & paste etc*/
+  function GenHeader()
+  {
+    /* Prepare departments,
+       which are shown in the listbox on top of the listbox
+     */
+    $options= "";
+
+    /* Get all departments within this subtree */
+    $ui= get_userinfo();
+    $first = "";
+    $found = FALSE;
+    $base = $this->config->current['BASE'];
+
+    /* Add base */
+    $tmp = array();
+    $tmp[] = array("dn"=>$this->config->current['BASE']);
+    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+    $deps = array();
+    foreach($tmp as $tm){
+      $deps[$tm['dn']] = $tm['dn'];
+    }
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments($this->module);
+    $ids = $this->config->idepartments;
+    $first = "";
+    $found = FALSE;
+    foreach($ids as $dep => $name){
+      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+        /* Keep first base dn in mind, we could need this
+         *  info if no valid base was found
+         */
+        if(empty($first)) {
+          $first = $dep['dn'];
+        }
+
+        $value = $ids[$dep];
+        if ($this->selectedBase == $dep){
+          $found = TRUE;
+          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep."'>$value</option>";
+        }
+      }
+    }
+
+    /* The currently used base is not visible with your acl setup.
+     * Set base to first useable base.
+     */
+    if(!$found){
+      $this->selectedBase = $first;
+    }
+
+    /* Get acls */
+    $ui       = get_userinfo();
+    $acl      = $ui->get_permissions("cn=dummy,".get_ou('deviceou').$this->selectedBase,"devices/deviceGeneric");
+    $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"devices") ;
+
+
+    /* If this is true we add an additional seperator. Just look a few lines below */  
+    $listhead = MultiSelectWindow::get_default_header();
+
+    /* And at least add a department selection box */
+    $listhead .=  _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+      " <input class='center' type='image' src='images/list_submit.png' align='middle' 
+        title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
+
+    /* Create Layers menu */
+    $s  = ".|"._("Actions")."|\n";
+    $s .= "..|<img src='images/list_new.png' alt='' border='0' class='center'>".
+      "&nbsp;"._("Create")."|\n";
+
+    /* Append create options */
+    if(preg_match("/c/",$acl)) {
+      $s.= "...|<input class='center' type='image' src='images/list_new_device.png' alt=''>".
+        "&nbsp;"._("Device")."|device_new|\n";
+    }
+
+    /* Multiple options */
+    $s.= "..|---|\n";
+    $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>".
+      "&nbsp;"._("Remove")."|"."remove_multiple|\n";
+
+    /* Add multiple copy & cut icons */
+    if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $s.= "..|---|\n";
+      $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Copy")."|"."multiple_copy_systems|\n";
+      $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Cut")."|"."multiple_cut_systems|\n";
+
+      if($this->parent->CopyPasteHandler->entries_queued()){
+        $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
+        $s.="..|".$img."&nbsp;"._("Paste")."|editPaste|\n";
+      }else{
+        $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
+        $s.="..|".$img."&nbsp;"._("Paste")."\n";
+      }
+    }
+
+    /* Add snapshot icons */
+    if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $s .= "..|---|\n";
+      $s .= $this->get_snapshot_header(TRUE);
+    }
+
+    $this->SetDropDownHeaderMenu($s);
+                                                                       
+    $this->SetListHeader($listhead);
+  }
+
+
+  /* Some basic settings */
+  function execute()
+  {
+    $this->ClearElementsList();
+    $this->GenHeader();
+  }
+
+
+  function setEntries($list)
+  {
+    /********************
+      Variable init
+     ********************/
+
+    /* Create links */
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
+    $deviceimg  = "<img class='center' src='images/select_device.png' alt='A'  title='"._("Device")."'>";
+    $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+
+    /* set Page header */
+    $action_col_size = 80;
+    if($this->parent->snapshotEnabled()){
+      $action_col_size += 38;
+    }
+
+    /********************
+      Attach objects
+     ********************/
+
+    foreach($list as $key => $val){
+
+      $ui       = get_userinfo();
+      $acl      = $ui->get_permissions($val['dn'],"devices/deviceGeneric");
+      $acl_all  = $ui->has_complete_category_acls($val['dn'],"devices") ;
+
+      /* Create action icons */
+      $actions = "";
+      if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $actions .= $this->GetSnapShotActions($val['dn']);
+      }
+
+      /* Get copy Paste icons */
+      if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $actions.= "<input class='center' type='image'
+          src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+        $actions.= "<input class='center' type='image'
+          src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+      }
+
+      $actions.= "<input class='center' type='image'
+        src='images/edit.png' alt='"._("edit")."' name='device_edit_%KEY%' title='"._("Edit this entry")."'>";
+
+      /* Add delete button */
+      if(preg_match("/d/",$acl)){
+        $actions.= "<input class='center' type='image'
+          src='images/edittrash.png' alt='"._("delete")."' name='device_del_%KEY%' title='"._("Delete this entry")."'>";
+      }else{
+        $actions.= "<img src='images/empty.png' alt='&nbsp;' class='center'>";
+      }
+
+      $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
+
+      if(!isset($val['description'][0])){
+        $desc = "";
+      }else{
+        $desc = " - [ ".$val['description'][0]." ]";
+      }
+
+      /* Cutted objects should be displayed in light grey */
+      $display = $val['cn'][0].$desc;
+      if($this->parent->CopyPasteHandler){
+        foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
+          if($queue_data['dn'] == $val['dn']) {
+            $display = "<font color='#999999'>".$display."</font>";
+            break;
+          }
+        }
+      }
+
+
+      /* Create each field */
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+                      "attach" => "style='width:20px;'");
+      $field1 = array("string" => sprintf($deviceimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
+      $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
+      $this->AddElement(array($field0,$field1,$field2,$field3));
+    }
+
+
+    /* Create summary string for list footer */
+    $num_deps=0;
+    if(!$this->SubSearch){
+      $num_deps = count($this->Added_Departments);
+    }
+    $num_objs = count($list);
+
+    $num_obj_str = _("Number of listed devices");
+    $num_dep_str = _("Number of listed departments");
+
+    $str = "<img class='center' src='images/select_devices.png'
+              title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
+    $str.= "<img class='center' src='images/folder.png'
+              title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
+
+    $this->set_List_Bottom_Info($str);
+  }
+
+  function Save()
+  {
+    MultiSelectWindow::Save();  
+  }
+
+  function save_object()
+  {
+    /* Save automatic created POSTs like regex, checkboxes */
+    MultiSelectWindow::save_object(); 
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/devices/deviceGeneric.tpl b/gosa-plugins/goto/admin/devices/deviceGeneric.tpl
new file mode 100644 (file)
index 0000000..863851e
--- /dev/null
@@ -0,0 +1,75 @@
+
+<h2>{t}Devices{/t}</h2>
+
+<table width="100%" summary="">
+ <tr>
+  <td width="50%" style="vertical-align:top">
+    <table style="border-right:1px solid #B0B0B0;width:100%">
+        <tr>
+            <td><LABEL for="base">{t}Base{/t}</LABEL>
+            </td>
+            <td>
+                               <select name="base">
+                                       {html_options options=$bases selected=$base}
+                               </select>
+            </td>
+        </tr>
+        <tr>
+            <td><LABEL for="cn">{t}Device name{/t}</LABEL>{$must}
+            </td>
+            <td>
+                <input type="text" size=40 value="{$cn}" name="cn" id="cn">
+            </td>
+        </tr>
+        <tr>
+            <td><LABEL for="description">{t}Description{/t}</LABEL>
+            </td>
+            <td>
+                <input type="text" size=40 value="{$description}" name="description" id="description">
+            </td>
+        </tr>
+        <tr>
+            <td><LABEL for="description">{t}Device type{/t}</LABEL>
+            </td>
+            <td>
+               <select id="type" size="1" name="type" title="{t}Choose the device type{/t}">
+                       {html_options options=$types selected=$type}
+               </select>
+            </td>
+        </tr>
+    </table>
+   </td>
+   <td style="vertical-align:top">
+    <table summary="">
+        <tr>
+            <td><LABEL for="dev_id">{t}Serial number{/t}&nbsp;{t}(iSerial){/t}</LABEL>{$must}
+            </td>
+            <td>
+                <input type="text" value="{$dev_id}" name="dev_id" id="dev_id">
+            </td>
+            <td colspan="2">&nbsp;</td>
+        </tr>
+        <tr>
+            <td><LABEL for="vendor">{t}Vendor-ID{/t}&nbsp;{t}(idVendor){/t}</LABEL>{$must}
+            </td>
+            <td>
+                <input type="text" value="{$vendor}" name="vendor" id="vendor">
+            </td>
+        </tr>
+        <tr>
+          <td><LABEL for="produkt">{t}Product-ID{/t}&nbsp;{t}(idProduct){/t}</LABEL>{$must}
+            </td>
+            <td>
+                <input type="text" value="{$serial}" name="serial" id="serial">
+            </td>
+        </tr>
+    </table>
+</table>
+<input type='hidden' value="1" name="deviceGeneric_posted">
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+    focus_field('name');
+  -->
+</script>
+
+
diff --git a/gosa-plugins/goto/admin/devices/main.inc b/gosa-plugins/goto/admin/devices/main.inc
new file mode 100644 (file)
index 0000000..45209ca
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2003  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+if ($remove_lock){
+               if(session::is_set('DeviceManagement')){
+                               $DeviceManagement = session::get('DeviceManagement');
+                               $DeviceManagement->remove_lock();
+                               del_lock ($ui->dn);
+                               session::un_set ('DeviceManagement');
+               }
+} else {
+
+               /* Create DeviceManagement object on demand */
+               if (!session::is_set('DeviceManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+                       session::set('DeviceManagement',new deviceManagement ($config));
+               }
+
+               /* Get object */
+               $DeviceManagement = session::get('DeviceManagement');
+               $DeviceManagement->save_object();
+               $output= $DeviceManagement->execute();
+
+               /* Page header*/
+               if (session::is_set('objectinfo')){
+                               $display= print_header(get_template_path('images/devices.png'), _("Device management"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".@LDAP::fix(session::get('objectinfo')));
+               } else {
+                               $display= print_header(get_template_path('images/devices.png'), _("Device management"));
+               }
+
+               /* Reset requested? */
+               if (isset($_GET['reset']) && $_GET['reset'] == 1){
+                               del_lock ($ui->dn);
+                               session::un_set ('DeviceManagement');
+               }
+
+               /* Show and save dialog */
+               $display.= $output;
+               session::set('DeviceManagement',$DeviceManagement);
+}
+?>
diff --git a/gosa-plugins/goto/admin/devices/paste_deviceGeneric.tpl b/gosa-plugins/goto/admin/devices/paste_deviceGeneric.tpl
new file mode 100644 (file)
index 0000000..44d6882
--- /dev/null
@@ -0,0 +1,25 @@
+
+<h2>{t}Devices{/t}</h2>
+
+<table width="100%" summary="">
+ <tr>
+  <td width="50%" style="vertical-align:top">
+    <table style="border-right:1px solid #B0B0B0;width:100%">
+        <tr>
+            <td><LABEL for="cn">{t}Device name{/t}</LABEL>{$must}
+            </td>
+            <td>
+                <input type="text" size=40 value="{$cn}" name="cn" id="cn">
+            </td>
+        </tr>
+    </table>
+   </td>
+</table>
+<input type='hidden' value="1" name="deviceGeneric_posted">
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+    focus_field('name');
+  -->
+</script>
+
+
diff --git a/gosa-plugins/goto/admin/devices/remove.tpl b/gosa-plugins/goto/admin/devices/remove.tpl
new file mode 100644 (file)
index 0000000..643056c
--- /dev/null
@@ -0,0 +1,23 @@
+<div style="font-size:18px;">
+  <img alt="" src="images/button_cancel.png" align=top>&nbsp;{t}Warning{/t}
+</div>
+<p>
+ {$intro}
+ {t}This may be used by several users/groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+</p>
+<p>
+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+       {if $multiple}
+               <input type=submit name="delete_multiple_device_confirm" value="{t}Delete{/t}">
+               &nbsp;
+               <input type=submit name="delete_multiple_device_cancel" value="{t}Cancel{/t}">
+       {else}
+               <input type=submit name="delete_device_confirm" value="{t}Delete{/t}">
+               &nbsp;
+               <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+       {/if}
+</p>
+
diff --git a/gosa-plugins/goto/admin/devices/tabs_devices.inc b/gosa-plugins/goto/admin/devices/tabs_devices.inc
new file mode 100644 (file)
index 0000000..0feddfc
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+class devicetabs extends tabs
+{
+  var $Release= "";
+
+  function devicetabs($config, $data, $dn,$category)
+  {
+    tabs::tabs($config, $data, $dn,$category);
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function save($ignore_account= FALSE)
+  {
+    $baseobject= $this->by_object['deviceGeneric'];
+    $new_dn= "cn=".$baseobject->cn.",".get_ou('deviceou').$baseobject->base;
+
+    /* Move group? */
+    if ($this->dn != $new_dn){
+
+      /* Write entry on new 'dn' */
+      if ($this->dn != "new"){
+        $baseobject->move($this->dn, $new_dn);
+        $this->by_object['deviceGeneric']= $baseobject;
+      }
+
+      /* Happen to use the new one */
+      $this->dn= $new_dn;
+    }
+
+    tabs::save();
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc
new file mode 100644 (file)
index 0000000..da73758
--- /dev/null
@@ -0,0 +1,345 @@
+<?php
+
+class divListMimeTypes extends MultiSelectWindow
+{
+  /* Current base */
+  var $selectedBase       = "";
+  var $selectedRelease    = "main";
+  var $AvailableReleases  = array();
+  var $departments        = array();
+  var $parent               ;
+  var $ui                   ;
+
+  /* Regex */
+  var $Regex              = "*";
+
+  /* Subsearch checkbox */
+  var $SubSearch;
+
+  /* These vars should be saved too */
+  var $SaveAdditionalVars = array("selectedRelease");
+
+
+  function divListMimeTypes (&$config, &$parent)
+  {
+    /* Create divlist and setup */
+    MultiSelectWindow::MultiSelectWindow($config, "Mimetypes", "mimetypes");
+  
+    /* initialize required attributes */ 
+    $this->selectedRelease  = get_ou('mimetypeou').session::get('CurrentMainBase');
+    $this->parent           = &$parent;
+    $this->ui               = get_userinfo();
+    $this->AvailableReleases= $this->parent->getReleases($this->selectedBase);
+
+    /* Set list strings */
+    $this->SetTitle       (_("List of defined mime types"));
+    $this->SetSummary     (_("List of defined mime types"));
+    $this->SetInformation (_("This menu allows you to add, edit and remove selected mime types. You may want to use the range selector on top of the mime type listbox, when working with a large number of mime types."));
+
+    /* Result page will look like a headpage */
+    $this->SetHeadpageMode();
+    $this->EnableAplhabet(true);
+  
+    /* Disable buttonsm */
+    $this->EnableCloseButton(false);
+    $this->EnableSaveButton (false);
+
+    /* set Page header */
+    $action_col_size = 80;
+    if($this->parent->snapshotEnabled()){
+      $action_col_size += 38;
+    }
+
+    /* Toggle all selected / deselected */
+    $chk = "<input type='checkbox' id='select_all' name='select_all'
+               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
+    /* set Page header */
+    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
+    $this->AddHeader(array("string" => "&nbsp;",                "attach" => "style='text-align:center;width:20px;'"));
+    $this->AddHeader(array("string" => _("Mime type name")." / "._("Department"), "attach" => "style=''"));
+    $this->AddHeader(array("string" => _("Actions"),            "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
+
+    /* Add SubSearch checkbox */
+    $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
+
+    /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
+    $this->AddRegex   ("Regex",     _("Display mime types matching"),"*" , true);
+  }
+
+
+  /* This function allows us to add a user defined filter part at position $position*/
+  function AddUserBoxToFilter($position)
+  {
+    $str = "";
+    if(($position  == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
+      $smarty = get_smarty();
+      $smarty->assign("selectedRelease",$this->selectedRelease);
+      $smarty->assign("branchimage","images/branch.png");
+      $smarty->assign("releases",$this->AvailableReleases);
+      $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE,dirname(__FILE__)));
+    }
+    return($str);
+  }
+
+
+  /* Create list header, with create / copy & paste etc*/
+  function GenHeader()
+  {
+    /* Prepare departments,
+       which are shown in the listbox on top of the listbox
+     */
+    $options= "";
+
+    /* Get all departments within this subtree */
+    $ui= get_userinfo();
+    $first = "";
+    $found = FALSE;
+    $base = $this->config->current['BASE'];
+
+    /* Add base */
+    $tmp = array();
+    $tmp[] = array("dn"=>$this->config->current['BASE']);
+    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+    $deps = array();
+    foreach($tmp as $tm){
+      $deps[$tm['dn']] = $tm['dn'];
+    }
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments($this->module);
+    $ids = $this->config->idepartments;
+    $first = "";
+    $found = FALSE;
+    foreach($ids as $dep => $name){
+      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+        /* Keep first base dn in mind, we could need this
+         *  info if no valid base was found
+         */
+        if(empty($first)) {
+          $first = $dep['dn'];
+        }
+
+        $value = $ids[$dep];
+        if ($this->selectedBase == $dep){
+          $found = TRUE;
+          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep."'>$value</option>";
+        }
+      }
+    }
+
+    /* The currently used base is not visible with your acl setup.
+     * Set base to first useable base.
+     */
+    if(!$found){
+      $this->selectedBase = $first;
+    }
+
+    /* Get acls */
+    $ui       = get_userinfo();
+    $acl      = $ui->get_permissions("cn=dummy,".get_ou('mimetypeou').$this->selectedBase,"mimetypes/mimetype");
+    $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"mimetypes") ;
+
+
+    /* If this is true we add an additional seperator. Just look a few lines below */  
+    $add_sep = false;
+    /* Get copy & paste icon */
+    $Copy_Paste ="";
+    if(preg_match("/(c.*w|w.*c)/",$acl_all) &&  $this->parent->CopyPasteHandler){
+      $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
+      $add_sep = true;
+    }
+
+    /* Add default header */
+    $listhead = MultiSelectWindow::get_default_header();
+
+    /* And at least add a department selection box */
+    $listhead .=  _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+      " <input class='center' type='image' src='images/list_submit.png' align='middle' 
+        title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
+
+    /* Create Layers menu */
+    $s  = ".|"._("Actions")."|\n";
+    $s .= "..|<img src='images/list_new.png' alt='' border='0' class='center'>".
+      "&nbsp;"._("Create")."|\n";
+
+    /* Append create options */
+    if(preg_match("/c/",$acl)) {
+      $s.= "...|<input class='center' type='image' src='images/list_new_mime.png' alt=''>".
+        "&nbsp;"._("Mime type")."|mime_new|\n";
+    }
+
+    /* Multiple options */
+    $s.= "..|---|\n";
+    $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>".
+      "&nbsp;"._("Remove")."|"."remove_multiple|\n";
+
+    /* Add multiple copy & cut icons */
+    if(is_object($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $s.= "..|---|\n";
+      $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Copy")."|"."multiple_copy_systems|\n";
+      $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Cut")."|"."multiple_cut_systems|\n";
+
+      if($this->parent->CopyPasteHandler->entries_queued()){
+        $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
+        $s.="..|".$img."&nbsp;"._("Paste")."|editPaste|\n";
+      }else{
+        $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
+        $s.="..|".$img."&nbsp;"._("Paste")."\n";
+      }
+    }
+
+    /* Add snapshot icons */
+    if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+      $s .= "..|---|\n";
+      $s .= $this->get_snapshot_header(TRUE);
+    }
+
+    $this->SetDropDownHeaderMenu($s);
+    $this->SetListHeader($listhead);
+  }
+
+
+  /* Some basic settings */
+  function execute()
+  {
+    $this->ClearElementsList();
+    $this->GenHeader();
+  }
+
+
+  function setEntries($list)
+  {
+    /********************
+      Variable init
+     ********************/
+
+    /* Create links */
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
+    $mimeimg  = "<img class='center' src='images/select_mimetype.png' alt='A'  title='"._("Mime type")."'>";
+    $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
+
+    /* set Page header */
+    $action_col_size = 80;
+    if($this->parent->snapshotEnabled()){
+      $action_col_size += 38;
+    }
+
+    /********************
+      Attach objects
+     ********************/
+
+    foreach($list as $key => $val){
+
+      $ui       = get_userinfo();
+      $acl      = $ui->get_permissions($val['dn'],"mimetypes/mimetype");
+      $acl_all  = $ui->has_complete_category_acls($val['dn'],"mimetypes") ;
+
+      /* Create action icons */
+      $actions = "";
+      if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $actions .= $this->GetSnapShotActions($val['dn']);
+      }
+
+      /* Get copy Paste icons */
+      if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
+        $actions.= "<input class='center' type='image'
+          src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+        $actions.= "<input class='center' type='image'
+          src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+      }
+
+      $actions.= "<input class='center' type='image'
+        src='images/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
+
+      /* Add delete button */
+      if(preg_match("/d/",$acl)){
+        $actions.= "<input class='center' type='image'
+          src='images/edittrash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
+      }else{
+        $actions.= "<img src='images/empty.png' alt='&nbsp;' class='center'>";
+      }
+
+      $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
+
+      if(!isset($val['description'][0])){
+        $desc = "";
+      }else{
+        $desc = " - [ ".$val['description'][0]." ]";
+      }
+
+      /* Cutted objects should be displayed in light grey */
+      $display = $val['cn'][0].$desc;
+      if($this->parent->CopyPasteHandler){
+        foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
+          if($queue_data['dn'] == $val['dn']) {
+            $display = "<font color='#999999'>".$display."</font>";
+            break;
+          }
+        }
+      }
+
+
+      /* Create each field */
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+                      "attach" => "style='width:20px;'");
+      $field1 = array("string" => sprintf($mimeimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
+      $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
+      $this->AddElement(array($field0,$field1,$field2,$field3));
+    }
+
+
+    /* Create summary string for list footer */
+    $num_deps=0;
+    if(!$this->SubSearch){
+      $num_deps = count($this->Added_Departments);
+    }
+    $num_objs = count($list);
+
+    $num_obj_str = _("Number of listed mimetypes");
+    $num_dep_str = _("Number of listed departments");
+
+    $str = "<img class='center' src='images/select_mimetype.png'
+              title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
+    $str.= "<img class='center' src='images/folder.png'
+              title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
+
+    $this->set_List_Bottom_Info($str);
+  }
+
+  function Save()
+  {
+    MultiSelectWindow::Save();  
+  }
+
+  function save_object()
+  {
+    /* Save automatic created POSTs like regex, checkboxes */
+    MultiSelectWindow::save_object(); 
+
+    /* check if returned selectedRelease is a valid release.
+        If it isn't set to a valid release */
+    $this->AvailableReleases = $this->parent->getReleases($this->selectedBase);
+    if(!isset($this->AvailableReleases[$this->selectedRelease])){
+      $this->selectedRelease =key($this->AvailableReleases);
+    }
+    $mimefilter = session::get('mimefilter');
+    $mimefilter['release']  = $this->selectedRelease;
+    session::set('mimefilter',$mimefilter);
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc
new file mode 100644 (file)
index 0000000..03867eb
--- /dev/null
@@ -0,0 +1,758 @@
+<?php
+class mimetype extends plugin
+{
+       /* CLI vars */
+       var $cli_summary                  = "This tab allows you to modify, add or remove mime types in the selected department.";
+       var $cli_description    = "Management dialog to handle mime types";
+       var $ignore_account     = true; // This is always a valid account
+       var $cli_parameters             = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+       var $objectclasses              = array("top","gotoMimeType");
+       var $attributes                   = array("cn","gotoMimeApplication","gotoMimeLeftClickAction","gotoMimeIcon",
+                                                                       "description","gotoMimeFilePattern","gotoMimeEmbeddedApplication",
+                                                                       "gotoMimeGroup");       
+
+       /* Class vars */
+       var $ui;
+       var $cn                                                                               = "";                                     
+       var $gotoMimeLeftClickAction                        = "I";
+       var $gotoMimeLeftClickAction_I              = true;
+       var $gotoMimeLeftClickAction_E              = false;
+       var $gotoMimeLeftClickAction_Q              = false;
+       var $gotoMimeIcon                                                         = "*removed*";
+       var $description                                                          = "";
+       var $gotoMimeFilePattern                                      = array();
+       var $gotoMimeApplication                                      = array();
+       var $gotoMimeEmbeddedApplication            = array();
+       var $gotoMimeGroup                                                      = "";
+       var $iconData                                                               = NULL;     
+       var $base                                                                             = "";
+  var $ApplicationList                  = array();  
+
+
+  /* To prevent errors when using the 'apply' button, we use this variables 
+      to manage array attributes */
+       var $use_gotoMimeIcon                                           = NULL;
+       var $use_gotoMimeFilePattern                        = array();
+       var $use_gotoMimeApplication                        = array();
+       var $use_gotoMimeEmbeddedApplication    = array();
+
+  /* divLists */
+  var $DivPatterns                                                       = NULL;
+  var $DivApps                                                             = NULL;
+  var $DivEApps                                                                    = NULL;
+
+  /* Mime type release mode */
+  var $isReleaseMimeType                                             = false;
+
+  /* These vars will be copied too, if you use copy&paste mode */
+  var $CopyPasteVars        = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData",
+                                    "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon");
+
+  var $view_logged  = FALSE;
+
+  /* Select options */
+  var $MimeGroups                            = array("application","audio","chemical","image","inode","message","model",
+                                      "multipart","text","video","x-conference","x-world");
+
+  /* Orig_Dn is used to verify if this object is new or only edited */         
+  var $orig_dn                 = "";
+
+  function mimetype(&$config,$dn= NULL)
+  {
+    plugin::plugin ($config, $dn);
+
+    /* Save original dn */
+    $this->orig_dn = $dn;      
+
+    /* get gotoMimeLeftClickActions I/E/Q */
+    if(isset($this->gotoMimeLeftClickAction)){
+      $str = $this->gotoMimeLeftClickAction;
+      for($i = 0 ; $i < strlen($str) ; $i ++ ){
+        $varna = "gotoMimeLeftClickAction_". $str[$i];
+        if(isset($this->$varna)){
+          $this->$varna = true;
+        }
+      }
+    }
+
+    /* Create list of defined applications in GOsa */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaApplication)(cn=*))",array('cn'));
+    $this->ApplicationList = array();
+    while($attrs = $ldap->fetch()){
+      $this->ApplicationList[$attrs['cn'][0]] = $attrs['cn'][0];
+    }
+
+    /* If both radio buttons arn't set, set option I */
+    if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){
+      $this->gotoMimeLeftClickAction_I = true;
+    }
+
+    /* Get list of array attributes */
+    foreach(array("gotoMimeFilePattern") as $attr){
+      $this->$attr = array();
+      if(isset($this->attrs[$attr])){
+        $tmp = array();
+        for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
+          $str = $this->attrs[$attr][$i];
+          $tmp[] = $str;
+        }
+        $use_attr = "use_".$attr;
+        $this->$use_attr = $tmp;
+      }
+    }
+
+    /* Get list of array attributes with priority tag ( Test|32 )*/
+    foreach(array("gotoMimeApplication","gotoMimeEmbeddedApplication") as $attr){
+      $this->$attr = array();
+      if(isset($this->attrs[$attr])){
+        $tmp = array();
+        for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
+          $str = $this->attrs[$attr][$i];
+          $tmp2= split("\|",$str);
+
+          if(count($tmp2) == 2){
+            $name = $tmp2[0];
+            $prio = $tmp2[1];
+            $tmp[$prio] = $name;
+          }
+        }
+        ksort($tmp);
+        $use_attr = "use_".$attr;
+        $this->$use_attr = $tmp;
+      }
+    }
+
+    /* Check if release Management is enabled */
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)) {
+      $this->isReleaseMimeType= true;
+    }
+
+    /* Set base */     
+    if ($this->dn == "new"){
+      if(session::is_set('CurrentMainBase')){
+        $this->base= session::get('CurrentMainBase');
+      }else{
+        $ui= get_userinfo();
+        $this->base= dn2base($ui->dn);
+      }
+    } else {
+      $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
+    }
+
+    /* Get icon data */
+    if(isset($this->attrs['gotoMimeIcon'])){
+      $ldap = $this->config->get_ldap_link();
+      $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon");
+      $this->saved_attributes['gotoMimeIcon'] = $this->iconData;
+    }
+    if ($this->iconData == ""){
+      $this->set_new_picture("");
+    }
+    session::set('binary',$this->iconData);
+    session::set('binarytype',"image/jpeg");
+  }
+
+
+  function execute()
+  {
+    $smarty = get_smarty();
+
+    if(!$this->view_logged){
+      $this->view_logged =TRUE;
+      new log("view","mimetypes/".get_class($this),$this->dn);
+    }
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    /* 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->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()){
+
+        /* A new base was selected, check if it is a valid one */
+        $tmp = $this->get_allowed_bases();
+        if(isset($tmp[$this->dialog->isSelected()])){
+          $this->base = $this->dialog->isSelected();
+        }
+
+        $this->dialog= false;
+      }else{
+        return($this->dialog->execute());
+      }
+    }
+
+    /* Check Posts */
+    $posts = array(    
+        "/^Pattern_SortUp_/"   => array("Action" => "Pattern_SortUp",  "Func" => "ArrayUp",    "Attr" => "use_gotoMimeFilePattern"),
+        "/^Pattern_SortDown_/"         => array("Action" => "Pattern_SortDown","Func" => "ArrayDown",  "Attr" => "use_gotoMimeFilePattern"),
+        "/^Pattern_Remove_/"   => array("Action" => "Pattern_Remove",  "Func" => "ArrayRemove","Attr" => "use_gotoMimeFilePattern"),
+        "/^Apps_SortUp_/"              => array("Action" => "Apps_SortUp",             "Func" => "ArrayUp",    "Attr" => "use_gotoMimeApplication"),
+        "/^Apps_SortDown_/"    => array("Action" => "Apps_SortDown",   "Func" => "ArrayDown",  "Attr" => "use_gotoMimeApplication"),
+        "/^Apps_Remove_/"              => array("Action" => "Apps_Remove",             "Func" => "ArrayRemove","Attr" => "use_gotoMimeApplication"),
+        "/^EApps_SortUp_/"             => array("Action" => "EApps_SortUp",    "Func" => "ArrayUp",    "Attr" => "use_gotoMimeEmbeddedApplication"),
+        "/^EApps_SortDown_/"   => array("Action" => "EApps_SortDown",  "Func" => "ArrayDown",  "Attr" => "use_gotoMimeEmbeddedApplication"),
+        "/^EApps_Remove_/"             => array("Action" => "EApps_Remove",    "Func" => "ArrayRemove","Attr" => "use_gotoMimeEmbeddedApplication"));          
+    $once = true;
+
+    /* Walk through posts and try to find some commands for us. */
+    foreach($_POST as $name => $value){
+
+      /* Walk through possible commands */
+      foreach($posts as $regex => $action){
+
+        /* Check if there is a command posted */
+        if(preg_match($regex,$name) && $once){
+          $once = false;
+
+          /* Get action vars */
+          $func                = $action['Func'];              // Get function name 
+          $attr                = $action['Attr'];              // Get attribute name
+
+          /* Get entry id */
+          $s_entry     = preg_replace($regex,"",$name);
+          $s_entry     = preg_replace("/_[xy]$/","",$s_entry); 
+
+          /* Execute a command with the given attribute and entry 
+             e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
+          if($this->acl_is_writeable($attr)){
+            $this->$attr= $this->$func($s_entry,$this->$attr,true);                                     
+          }
+        }
+      }
+    }
+
+    /* Set a new icon was requested */
+    if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
+      $this->set_new_picture($_FILES['picture_file']['tmp_name']);             
+    }
+
+    /* Add gotoMimeFilePattern */
+    if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
+      if($this->acl_is_writeable("gotoMimeFilePattern")){
+        $str = $_POST['NewFilePattern'];
+        if(!empty($str)){
+          $this->use_gotoMimeFilePattern[] = $str;
+        }
+      }
+    }  
+
+    /* Add gotoMimeFilePattern */
+    if(isset($_POST['AddNewApplication']) && 
+            (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){
+      if($this->acl_is_writeable("gotoMimeApplication")){
+        $str = "";
+        if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){
+          $str = get_post("NewApplicationSelect");
+        }
+        if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){
+          $str = get_post("NewApplication");
+        }
+        if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){
+          $this->use_gotoMimeApplication[] = $str;
+        }
+      }
+    }  
+
+    /* Add embedded application 
+     *  - From input or from select box 
+     */
+    if(isset($_POST['AddNewEmbeddedApplication']) && 
+            (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){
+      if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
+        $str = "";
+        if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){
+          $str = get_post('NewEmbeddedApplicationSelect');
+        }
+        if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){
+          $str = get_post('NewEmbeddedApplication');
+        }
+        if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){
+          $this->use_gotoMimeEmbeddedApplication[] = $str;
+        }
+      }
+    }  
+
+    /* Create divlists */
+    $DivPatterns       = new divSelectBox("gotoMimePatterns");
+    $DivApps           = new divSelectBox("gotoMimeApplications");
+    $DivEApps          = new divSelectBox("gotoMimeEmbeddedApplications");
+    $DivPatterns       -> SetHeight(100);
+    $DivApps           -> SetHeight(100);
+    $DivEApps          -> SetHeight(100);
+
+
+    if($this->acl_is_writeable("gotoMimeFilePattern")){
+      $Pattern_Actions= " <input type='image' src='images/sort_up.png'         class='center'  name='Pattern_SortUp_%s' >&nbsp;
+      <input type='image' src='images/sort_down.png'   class='center'  name='Pattern_SortDown_%s'>&nbsp;
+      <input type='image' src='images/edittrash.png'   class='center'  name='Pattern_Remove_%s'>";
+    }else{
+      $Pattern_Actions= "";    
+    }
+
+    if($this->acl_is_writeable("gotoMimeApplication")){
+      $Apps_Actions    = " <input type='image' src='images/sort_up.png'        class='center'  name='Apps_SortUp_%s' >&nbsp;
+      <input type='image' src='images/sort_down.png'   class='center'  name='Apps_SortDown_%s'>&nbsp;
+      <input type='image' src='images/edittrash.png'   class='center'  name='Apps_Remove_%s'>";
+    }else{
+      $Apps_Actions= "";       
+    }
+
+    if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
+      $EApps_Actions   = " <input type='image' src='images/sort_up.png'        class='center'  name='EApps_SortUp_%s' >&nbsp;
+      <input type='image' src='images/sort_down.png'   class='center'  name='EApps_SortDown_%s'>&nbsp;
+      <input type='image' src='images/edittrash.png'   class='center'  name='EApps_Remove_%s'>";
+    }else{
+      $EApps_Actions= "";      
+    }
+
+    /* Before adding some entries check acls */
+    if($this->acl_is_readable("gotoMimeFilePattern")){
+      foreach($this->use_gotoMimeFilePattern as $key => $pattern){
+        $field1 = array("string" => $pattern);
+        $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'");
+        $fields = array($field1,$field2);
+        $DivPatterns -> AddEntry($fields);
+      }                        
+    }
+
+    if($this->acl_is_readable("gotoMimeApplication")){
+      foreach($this->use_gotoMimeApplication as $key => $pattern){
+        $field1 = array("string" => $pattern);
+        $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
+        $fields = array($field1,$field2);
+        $DivApps -> AddEntry($fields);
+      }                        
+    }                  
+    if($this->acl_is_readable("gotoMimeEmbeddedApplication")){
+      foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){
+        $field1 = array("string" => $pattern);
+        $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
+        $fields = array($field1,$field2);
+        $DivEApps -> AddEntry($fields);
+      }
+    }                  
+    $smarty->assign("bases",                                           $this->get_allowed_bases());            
+    $smarty->assign("base_select",                                     $this->base);           
+    $smarty->assign("isReleaseMimeType",                       $this->isReleaseMimeType);
+    $smarty->assign("gotoMimeFilePatterns",                    $DivPatterns->DrawList());
+    $smarty->assign("gotoMimeApplications",                    $DivApps->DrawList());
+    $smarty->assign("gotoMimeEmbeddedApplications",    $DivEApps->DrawList());
+
+    $smarty->assign("ApplicationList",$this->ApplicationList);
+  
+    /* Assign class vars to smarty */
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }  
+
+    /* Assign additional vars that are not included in attributes*/
+    foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }  
+
+    /* Assign select box options */
+    $smarty->assign("gotoMimeGroups",$this->MimeGroups);
+    $smarty->assign("gotoMimeIcon"     ,$this->get_picture());
+    return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
+  }
+
+
+  function save_object()
+  {
+    if(isset($_POST['MimeGeneric'])){
+
+      /* Create a base backup and reset the
+         base directly after calling plugin::save_object();
+         Base will be set seperatly a few lines below */
+      $base_tmp = $this->base;
+      plugin::save_object();
+      $this->base = $base_tmp;
+  
+      /* Only save base if we are not in release mode */
+      if(!$this->isReleaseMimeType){
+
+        /* Set new base if allowed */
+        $tmp = $this->get_allowed_bases();
+        if(isset($_POST['base'])){
+          if(isset($tmp[$_POST['base']])){
+            $this->base= $_POST['base'];
+          }
+        }
+
+      }
+
+      /* Save radio buttons */
+      if($this->acl_is_writeable("gotoMimeLeftClickAction")){
+        if(isset($_POST['gotoMimeLeftClickAction_IE'])){
+          $chr = $_POST['gotoMimeLeftClickAction_IE'];
+          if($chr == "E"){
+            $this->gotoMimeLeftClickAction_E = true;
+            $this->gotoMimeLeftClickAction_I = false;
+          }else{
+            $this->gotoMimeLeftClickAction_E = false;
+            $this->gotoMimeLeftClickAction_I = true;
+          }
+        }
+        if(isset($_POST['gotoMimeLeftClickAction_Q'])){
+          $this->gotoMimeLeftClickAction_Q = true;
+        }else{
+          $this->gotoMimeLeftClickAction_Q = false;
+        }
+      }
+    }
+  }
+
+
+  /* save current changes */
+  function save()
+  {
+    /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */   
+    $arr = array ("E","I","Q");
+    $str = "";
+    foreach ($arr as $Chr){
+      $var = "gotoMimeLeftClickAction_".$Chr;
+      if($this->$var){
+        $str .= $Chr;
+      }
+    }
+    $this->gotoMimeLeftClickAction = $str;
+
+    /* Create array entries with priority tag ( Test|3 )*/
+    foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){
+      $i                               = 0;
+      $use_attr                = "use_".$attr;
+      $tmp                     = array();
+      $this->$attr     = array();
+      foreach($this->$use_attr as $entry){
+        $tmp[] = $entry."|".$i ++;
+      }
+      $this->$attr = $tmp;
+    }
+
+    /* Create array entries */
+    foreach(array("gotoMimeFilePattern") as $attr){
+      $i                               = 0;
+      $use_attr                = "use_".$attr;
+      $tmp                     = array();
+      $this->$attr     = array();
+      foreach($this->$use_attr as $entry){
+        $tmp[] = $entry;
+      }
+      $this->$attr = $tmp;
+    }
+
+    /* Remove Icon if requested  */
+    if($this->use_gotoMimeIcon != "*removed*"){
+      $this->gotoMimeIcon = $this->iconData;
+    }else{
+      $this->gotoMimeIcon = "";
+    }
+
+    plugin::save();
+
+    /* If this is a newly created object, skip storing those 
+       attributes that contain an empty array */
+    if($this->orig_dn == "new"){
+      foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){
+        if(!count($this->$attr)){
+          unset($this->attrs[$attr]);
+        }
+      }
+    }
+
+    $ldap = $this->config->get_ldap_link();
+    $ldap-> cd ( $this->config->current['BASE']);
+    $ldap->cat($this->dn);
+    if($ldap->count()){
+      $ldap->cd($this->dn);
+      $this->cleanup();
+      $ldap->modify($this->attrs);
+      new log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+      new log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of mime type/generic with dn '%s' failed."),$this->dn));
+  }
+
+
+  /* Remove current mime type */
+  function remove_from_parent()
+  {
+    plugin::remove_from_parent();
+    $ldap = $this->config->get_ldap_link();
+    $ldap->rmDir($this->dn);
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn));
+    new log("remove","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    /* Optionally execute a command after we're done */
+    $this->handle_post_events("remove");
+
+    /* Delete references to object groups */
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
+    while ($ldap->fetch()){
+      $og= new ogroup($this->config, $ldap->getDN());
+      unset($og->member[$this->dn]);
+      $og->save ();
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn));
+    }
+  }
+
+
+  /* Check given values */
+  function check()
+  {
+    $message = plugin::check();
+    if(empty($this->cn)){
+      $message[] = _("Please specify a valid name for this mime type.");
+    }
+    if(!count($this->use_gotoMimeFilePattern)){
+      $message[] = _("Please specify at least one file pattern.") ;
+    }
+
+    /* Check if there is already a mime type with this cn */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current["BASE"]);
+
+    $mimefilter = session::get('mimefilter');
+  
+    if($this->isReleaseMimeType && (isset($mimefilter['release']))){
+      $baseDn = str_replace($this->config->current['BASE'],$this->base,$mimefilter['release']);
+      $baseDn = preg_replace("/".get_ou('mimetypeou').".*/",get_ou('mimetypeou').$this->base,$mimefilter['release']);
+      $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn"));
+      if($ldap->count()){
+        $attrs = $ldap->fetch();
+        if($this->dn != $attrs['dn']) {
+          $message[]= _("There's already a mime type with this 'Name'.");
+        }
+      }
+    }else{
+      $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",get_ou('mimetypeou').$this->base,array("cn"));
+      if ($ldap->count()){
+        $attrs = $ldap->fetch();
+        if($this->dn != $attrs['dn']) {
+          $message[]= _("There's already an mime with this 'Name'.");
+        }
+      }
+    }
+
+    return($message);
+  }
+
+  /** Helper functions **/
+
+  /* Set a new picture */      
+  function set_new_picture($filename)
+  {
+    if (empty($filename)){
+      $filename= "./images/default_icon.png";
+      $this->use_gotoMimeIcon= "*removed*";
+    }else{
+      $this->use_gotoMimeIcon= $filename;
+    }
+
+    if (file_exists($filename)){
+      $fd = fopen ($filename, "rb");
+      $this->iconData= fread ($fd, filesize ($filename));
+      session::set('binary',$this->iconData);
+      session::set('binarytype',"image/jpeg");
+      fclose ($fd);
+    }
+  }
+
+  /* Get picture link */
+  function get_picture()
+  {
+    session::set('binary',$this->iconData);
+    session::set('binarytype',"image/jpeg");
+    return("getbin.php");
+  }
+
+  /* Transports the given Arraykey one position up*/
+  function ArrayUp($atr,$attrs)
+  {
+    $ret = $attrs;
+    $pos = $this->getpos($atr,$attrs) ;
+    $cn = count($attrs);
+    if(!(($pos == -1)||($pos == 1))){
+      $before = array_slice($attrs,0,($pos-2));
+      $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
+      $unten  = array_slice($attrs,$pos);
+      $ret = array();
+      $ret = $this->combineArrays($before,$mitte,$unten);
+    }
+    return($ret);
+  }
+
+
+  /* Transports the given Arraykey one position down*/
+  function ArrayDown($atr,$attrs)
+  {
+    $ret = $attrs;
+    $pos = $this->getpos($atr,$attrs) ;
+    $cn = count($attrs);
+    if(!(($pos == -1)||($pos == $cn))){
+      $before = array_slice($attrs,0,($pos-1));
+      $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
+      $unten  = array_slice($attrs,($pos+1));
+      $ret = array();
+      $ret = $this->combineArrays($before,$mitte,$unten);
+    }
+    return($ret);
+  }
+
+
+  /* return the position of the element in the array */
+  function getpos($atr,$attrs)
+  {
+    $i = 0;
+    foreach($attrs as $attr => $name)    {
+      $i++;
+      if($attr == $atr){
+        return($i);
+      }
+    }
+    return(-1);
+  }
+
+
+  /* Remove this element from array */
+  function ArrayRemove($key,$array,$reorder = false)   
+  {
+    if(isset($array[$key])){
+      unset($array[$key]);
+      if($reorder){
+        $tmp = array();
+        foreach($array as $entry){
+          $tmp[] = $entry;
+        }
+        $array = $tmp;
+      }
+    }  
+    return($array);
+  }
+
+
+  /* Combine new array */
+  function combineArrays($ar0,$ar1,$ar2)
+  {
+    $ret = array();
+    if(is_array($ar0))
+      foreach($ar0 as $ar => $a){
+        $ret[]=$a;
+      }
+    if(is_array($ar1))
+      foreach($ar1 as $ar => $a){
+        $ret[]=$a;
+      }
+    if(is_array($ar2))
+      foreach($ar2 as $ar => $a){
+        $ret[]=$a;
+      }
+    return($ret);
+  }
+
+
+  /* Return a dialog with all fields that must be changed, 
+     if we want to copy this entry */
+  function getCopyDialog()
+  {
+    $str = "";
+
+    $smarty = get_smarty();
+    $smarty->assign("cn",              $this->cn);
+    $smarty->assign("description",  $this->description);
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
+
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  /* Save all */
+  function saveCopyDialog()
+  {
+    $attrs = array("cn","description");
+    foreach($attrs as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr = $_POST[$attr];
+      }
+    }
+  }
+
+  /* Return plugin informations for acl handling  */ 
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Generic"),
+          "plDescription" => _("Mime type generic"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("mimetypes" => array("description"  => _("Mime types"),
+                                                        "objectClass"  => "gotoMimeType")),
+          "plProvidedAcls"=> array(
+            "cn"                          => _("Name"),
+            "gotoMimeGroup"               => _("Mime group"),
+            "description"                 => _("Description"),
+            "base"                        => _("Base"),
+            "gotoMimeApplication"         => _("Application"),
+            "gotoMimeLeftClickAction"     => _("Left click action"),
+            "gotoMimeIcon"                => _("Icon"),
+            "gotoMimeFilePattern"         => _("File patterns"),
+            "gotoMimeEmbeddedApplication" => _("Embedded applications"))
+          ));
+
+  }
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+
+    $source_o = new mimetype($this->config,$source['dn'],$this->parent);
+
+    foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){
+      $use_attr     = "use_".$name;
+      if(isset($this->$use_attr)){
+        $this->$use_attr= $source_o->$use_attr;
+      }
+      $this->$name = $source_o->$name;
+    } 
+    foreach($this->attributes as $name){
+      $this->$name = $source_o->$name;
+    }
+
+    if($this->iconData){
+      $this->use_gotoMimeIcon ="Not emtpy, causes icon to be written.";
+    }
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
new file mode 100644 (file)
index 0000000..7af6280
--- /dev/null
@@ -0,0 +1,666 @@
+<?php
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2003  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class mimetypeManagement extends plugin
+{
+  /* Definitions */
+  var $plHeadline     = "Mime types";
+  var $plDescription  = "Manage mime types";
+
+  /* Dialog attributes */
+  var $ui                             = NULL;
+  var $DivListMimeTypes               = NULL;
+  var $enableReleaseManagement        = false;
+  var $mimetabs                       = NULL;
+  var $snapDialog                     = NULL;
+  var $CopyPasteHandler               = NULL;
+  var $start_pasting_copied_objects = FALSE;
+
+
+  function mimetypeManagement (&$config, &$ui)
+  {
+    /* Save configuration for internal use */
+    $this->config   = &$config;
+    $this->ui       = &$ui;
+
+    /* Check if copy & paste is activated */
+    if($this->config->boolValueIsTrue("MAIN","ENABLECOPYPASTE")){
+      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
+    }
+
+    /* Creat dialog object */
+    $this->DivListMimeTypes = new divListMimeTypes($this->config,$this);
+
+    if($this->IsReleaseManagementActivated()){
+
+      /* Check if we should enable the release selection */
+      $this->enableReleaseManagement = true;
+
+      /* Hide SubSearch checkbox */
+      $this->DivListMimeTypes->DisableCheckBox("SubSearch");
+    }
+
+  }
+
+
+  /* Get all releases */
+  function getReleases($base)
+  {
+    $ldap                   = $this->config->get_ldap_link();
+    $dn                     = get_ou('mimetypeou').$base;
+    $ret                    = array();
+    $ret [get_ou('mimetypeou').$base] = "/";    
+
+    $ldap->cd($dn);
+    $ldap->search("objectClass=organizationalUnit",array("ou"));
+
+    while($attrs = $ldap->fetch()){
+      $str = str_replace($dn,"",$attrs['dn']);
+      $tmp = array_reverse( split("ou=",$str));
+      $str = "";
+      foreach($tmp as $val){
+        $val = trim(preg_replace("/,/","",$val));
+        if(empty($val)) break;
+        $str .= "/".$val;
+      } 
+      if(!empty($str)){
+        $ret[$attrs['dn']]= preg_replace("/^\//","",$str);
+      }
+    }
+    asort($ret);
+    return($ret);
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+
+    /**************** 
+      Variable init 
+     ****************/
+
+    /* These vars will be stored if you try to open a locked mime, 
+        to be able to perform your last requests after showing a warning message */
+    session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/","/^item_selected/","/^remove_multiple_mimetypes/"));
+
+    $smarty       = get_smarty();             // Smarty instance
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+    
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/mime_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/mime_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/mime_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/mime_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/^copy_.*/",$key)){
+        $s_action="copy";
+        $s_entry  = preg_replace("/^copy_/i","",$key);
+      }elseif(preg_match("/^cut_.*/",$key)){
+        $s_action="cut";
+        $s_entry  = preg_replace("/^cut_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/^mime_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/^remove_multiple_mimetypes/",$key)){
+        $s_action="del_multiple";
+      }elseif(preg_match("/^editPaste.*/i",$key)){
+        $s_action="editPaste";
+      }elseif(preg_match("/^multiple_copy_mimetypes/",$key)){
+        $s_action = "copy_multiple";
+      }elseif(preg_match("/^multiple_cut_mimetypes/",$key)){
+        $s_action = "cut_multiple";
+      }
+    }
+
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+
+    /* handle C&P from layers menu */
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
+      $s_action = "copy_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
+      $s_action = "cut_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
+      $s_action = "editPaste";
+    }
+
+    /* Create options */
+    if(isset($_POST['menu_action']) && $_POST['menu_action'] == "mime_new"){
+      $s_action = "new";
+    }
+
+    /* handle remove from layers menu */
+    if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
+      $s_action = "del_multiple";
+    }
+
+    /**************** 
+      Copy & Paste handling  
+     ****************/
+
+    /* Display the copy & paste dialog, if it is currently open */
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+
+
+    /**************** 
+      Create a new mime type 
+     ****************/
+
+    /* New mime type? */
+    $ui = get_userinfo();
+    $acl = $ui->get_permissions($this->DivListMimeTypes->selectedBase,"mimetypes/mimetype");
+    if (($s_action=="new") && preg_match("/c/",$acl)){
+
+      /* By default we set 'dn' to 'new', all relevant plugins will
+         react on this. */
+      $this->dn= "new";
+
+      /* Create new usertab object */
+      $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
+      $this->mimetabs->set_acl_base($this->DivListMimeTypes->selectedBase);
+    }   
+
+
+    /**************** 
+      Edit entry canceled 
+     ****************/
+
+    /* Cancel dialogs */
+    if (isset($_POST['edit_cancel'])){
+      del_lock ($this->mimetabs->dn);
+      unset ($this->mimetabs);
+      $this->mimetabs= NULL;
+      session::un_set('objectinfo');
+    }
+
+
+    /**************** 
+      Edit entry finished 
+     ****************/
+
+    /* Finish mime edit is triggered by the tabulator dialog, so
+       the user wants to save edited data. Check and save at this point. */
+    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply']) ) && (isset($this->mimetabs->config))){
+
+      /* Check tabs, will feed message array */
+      $this->mimetabs->save_object();
+      $message= $this->mimetabs->check();
+
+      /* Save, or display error message? */
+      if (count($message) == 0){
+
+        /* Save data data to ldap */
+        $this->mimetabs->set_release($this->DivListMimeTypes->selectedRelease);
+        $this->mimetabs->save();
+
+        if (!isset($_POST['edit_apply'])){
+          /* Mime type has been saved successfully, remove lock from LDAP. */
+          if ($this->dn != "new"){
+            del_lock ($this->dn);
+          }
+          unset ($this->mimetabs);
+          $this->mimetabs= NULL;
+          session::un_set('objectinfo');
+        }
+      } else {
+        /* Ok. There seem to be errors regarding to the tab data,
+           show message and continue as usual. */
+        show_errors($message);
+      }
+    }
+
+
+    /**************** 
+      Edit entry  
+     ****************/
+
+    /* User wants to edit data? */
+    if (($s_action=="edit") && (!isset($this->mimetabs->config))){
+
+      /* Get 'dn' from posted 'mimelist', must be unique */
+      $this->dn= $this->mimetypes[$s_entry]['dn'];
+
+      /* 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));
+      }
+
+      /* Lock the current entry, so everyone will get the
+         above dialog */
+      add_lock ($this->dn, $this->ui->dn);
+
+
+      /* Register mimetabs to trigger edit dialog */
+      $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
+      $this->mimetabs->set_acl_base($this->dn);
+      session::set('objectinfo',$this->dn);
+    }
+
+
+    /********************
+      Delete MULTIPLE entries requested, display confirm dialog
+     ********************/
+
+    if ($s_action=="del_multiple"){
+      $ids = $this->list_get_selected_items();
+
+      $this->dns = array();
+      if(count($ids)){
+
+        foreach($ids as $id){
+          $dn = $this->mimetypes[$id]['dn'];
+          if (($user= get_lock($dn)) != ""){
+            return(gen_locked_message ($user, $dn));
+          }
+          $this->dns[$id] = $dn;
+        }
+
+        $dns_names = "<br><pre>";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="</pre>";
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        if (count($this->dns) == 1){
+          $smarty->assign("intro",     sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
+        } else {
+          $smarty->assign("intro",     sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
+        }
+        $smarty->assign("multiple", true);
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      }
+    }
+
+
+
+
+    /********************
+      Delete MULTIPLE entries confirmed
+     ********************/
+
+    /* Confirmation for deletion has been passed. Users should be deleted. */
+    if (isset($_POST['delete_multiple_mimetype_confirm'])){
+
+      $ui = get_userinfo();
+
+      /* Remove user by user and check acls before removeing them */
+      foreach($this->dns as $key => $dn){
+
+        $acl = $ui->get_permissions($dn,"mimetypes/mimetype");
+        if(preg_match("/d/",$acl)){
+
+          /* Delete request is permitted, perform LDAP action */
+          $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn,"mimetypes");
+          $this->mimetabs->set_acl_base($dn);
+          $this->mimetabs->delete ();
+          unset ($this->mimetabs);
+          $this->mimetabs= NULL;
+
+        } else {
+          /* Normally this shouldn't be reached, send some extra
+             logs to notify the administrator */
+          print_red (_("You are not allowed to delete this mime type!"));
+          new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion.");
+        }
+        /* Remove lock file after successfull deletion */
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries Canceled
+     ********************/
+
+    /* Remove lock */
+    if(isset($_POST['delete_multiple_mimetype_cancel'])){
+      foreach($this->dns as $key => $dn){
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
+    /**************** 
+      Delete mime type 
+     ****************/
+
+    /* Remove user was requested */
+    if ($s_action == "del"){
+
+      /* Get 'dn' from posted 'uid' */
+      $this->dn= $this->mimetypes[$s_entry]['dn'];
+
+      /* Load permissions for selected 'dn' and check if
+         we're allowed to remove this 'dn' */
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($this->dn,"mimetypes/mimetype");
+      if (preg_match("/d/",$acl)){
+
+        /* 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));
+        }
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        add_lock ($this->dn, $this->ui->dn);
+        $smarty= get_smarty();
+        $smarty->assign("intro", sprintf(_("You're about to delete the mime type '%s'."), @LDAP::fix($this->dn)));
+        $smarty->assign("multiple", false);
+        return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
+      } else {
+
+        /* Obviously the user isn't allowed to delete. Show message and
+           clean session. */
+        print_red (_("You are not allowed to delete this mime type!"));
+      }
+    }
+
+
+    /**************** 
+      Delete mime confirmed 
+     ****************/
+
+    /* Confirmation for deletion has been passed. Group should be deleted. */
+    if (isset($_POST['delete_mime_confirm'])){
+
+      /* Some nice guy may send this as POST, so we've to check
+         for the permissions again. */
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($this->dn,"mimetypes/mimetype");
+      if(preg_match("/d/",$acl)){
+
+        /* Delete request is permitted, perform LDAP action */
+        $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
+        $this->mimetabs->set_acl_base($this->dn);
+        $this->mimetabs->delete ();
+        unset ($this->mimetabs);
+        $this->mimetabs= NULL;
+
+      } else {
+
+        /* Normally this shouldn't be reached, send some extra
+           logs to notify the administrator */
+        print_red (_("You are not allowed to delete this mime type!"));
+        new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion.");
+      }
+
+      /* Remove lock file after successfull deletion */
+      del_lock ($this->dn);
+    }
+
+
+    /**************** 
+      Delete mime canceled 
+     ****************/
+
+    /* Delete mime type canceled? */
+    if (isset($_POST['delete_cancel'])){
+      del_lock ($this->dn);
+      session::un_set('objectinfo');
+    }
+
+    /* Show tab dialog if object is present */
+    if (($this->mimetabs) && (isset($this->mimetabs->config))){
+      $display= $this->mimetabs->execute();
+
+      /* Don't show buttons if tab dialog requests this */
+      if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){
+        $display.= "<p style=\"text-align:right\">\n";
+        $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+        $display.= "&nbsp;\n";
+        if ($this->dn != "new"){
+          $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+          $display.= "&nbsp;\n";
+        }
+        $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+        $display.= "</p>";
+      }
+      return ($display);
+    }
+
+
+    /****************
+      Dialog display
+     ****************/
+
+        /* Check if there is a snapshot dialog open */
+    $base = $this->DivListMimeTypes->selectedBase;
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+      return($str);
+    }
+
+    /* Display dialog with system list */
+    $this->DivListMimeTypes->parent = $this;
+    $this->DivListMimeTypes->execute();
+    $this->DivListMimeTypes->AddDepartments($this->DivListMimeTypes->selectedBase,3,1);
+    $this->reload();
+    $this->DivListMimeTypes->setEntries($this->mimetypes);
+    return($this->DivListMimeTypes->Draw());
+  }
+
+    
+  /* Return departments, that will be included within snapshot detection */
+  function get_used_snapshot_bases()
+  {
+    return(array($this->DivListMimeTypes->selectedRelease));
+  }
+
+
+
+  function reload()
+  {
+    $this->mimetypes= array();
+
+    /* Set base for all searches */
+    $base       = $this->DivListMimeTypes->selectedBase;
+    $release    = $this->DivListMimeTypes->selectedRelease;
+    $Regex      = $this->DivListMimeTypes->Regex;
+    $SubSearch  = $this->DivListMimeTypes->SubSearch; 
+    $Flags      =  GL_NONE | GL_SIZELIMIT;
+    $Filter     = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoMimeType))";
+    $tmp        = array();
+    $Releases   = $this->getReleases($base);
+
+
+    /* If release management is enabled, use release as base. */
+    if(!$this->enableReleaseManagement){
+      $use_base = $base;
+    }else{
+      if(isset($Releases[$release])){
+        $use_base  = $release;
+      }else{
+        $use_base  = $base;
+      }
+    }
+
+    /* In case of subsearch, add the subsearch flag */
+    if($SubSearch){
+      $Flags    |= GL_SUBSEARCH;  
+    }else{
+      if(!$this->enableReleaseManagement){
+        $use_base = get_ou('mimetypeou').$use_base;
+      }
+    }
+  
+    /* Get results and create index */ 
+    $res= get_sub_list($Filter, "mimetypes",get_ou('mimetypeou'), $use_base, array("cn","description","dn","objectClass"), $Flags);
+    $tmp2 = array();
+    foreach ($res as $val){
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val;
+      $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn'];
+    }
+
+    /* sort entries */
+    natcasesort($tmp2);
+    $this->mimetypes=array();
+    foreach($tmp2 as $val){
+      $this->mimetypes[]=$tmp[$val];
+    }
+    reset ($this->mimetypes);
+  }
+
+  function remove_from_parent()
+  {
+    /* Optionally execute a command after we're done */
+    $this->postremove();
+  }
+
+
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+    /* Check if Copy & Paste is disabled */
+    if(!is_object($this->CopyPasteHandler)){
+      return("");
+    }
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $this->start_pasting_copied_objects = FALSE;
+      $dn = $this->mimetypes[$s_entry]['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"mimetabs","MIMETABS","mimetypes");
+    }
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $this->start_pasting_copied_objects = FALSE;
+  
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->mimetypes[$id]['dn'];
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","mimetabs","MIMETABS","mimetypes");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","mimetabs","MIMETABS","mimetypes");
+        }
+      }
+    }
+
+    /* Start pasting entries */
+    if($s_action == "editPaste"){
+      $this->start_pasting_copied_objects = TRUE;
+    }
+
+    /* Return C&P dialog */
+    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
+
+      /* Load entry from queue and set base */
+      $this->CopyPasteHandler->load_entry_from_queue();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListMimeTypes->selectedBase);
+
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      /* Return dialog data */
+      if(!empty($data)){
+        return($data);
+      }
+    }
+
+    /* Automatically disable status for pasting */
+    #if(!$this->CopyPasteHandler->entries_queued()){
+    #  $this->start_pasting_copied_objects = FALSE;
+    #}
+    return("");
+  }
+
+
+  /* Check if the release management is activated. */
+  function IsReleaseManagementActivated()
+  {
+    /* Check if we should enable the release selection */
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)){
+      return(true);
+    }
+    return(false);
+  }
+
+
+  function list_get_selected_items()
+  {
+    $ids = array();
+    foreach($_POST as $name => $value){
+      if(preg_match("/^item_selected_[0-9]*$/",$name)){
+        $id   = preg_replace("/^item_selected_/","",$name);
+        $ids[$id] = $id;
+      }
+    }
+    return($ids);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Optionally execute a command after we're done */
+    $this->postcreate();
+  }
+
+  function remove_lock()
+  {
+    if (isset($this->mimetabs->dn)){
+      del_lock ($this->mimetabs->dn);
+    }
+  }
+
+  function save_object() {
+    $this->DivListMimeTypes->save_object();
+  }
+
+  function check() {}
+  function adapt_from_template($dn) {}
+  function password_change_needed() {}
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/mimetypes/generic.tpl b/gosa-plugins/goto/admin/mimetypes/generic.tpl
new file mode 100644 (file)
index 0000000..1cb6d75
--- /dev/null
@@ -0,0 +1,199 @@
+<table style="width:100%">
+       <tr>
+               <td colspan="2">
+                       <h2><img src='images/list_mime.png' class='center' alt='[M]'>&nbsp;{t}Generic{/t}</h2>
+               </td>
+       </tr>
+       <tr>
+               <td style='width:50%; vertical-align:top;' >
+                       <table>
+                               <tr>
+                                       <td>
+                                               {t}Mime type{/t}{$must}
+                                       </td>
+                                       <td>
+{render acl=$gotoMimeGroupACL}
+                                               <input type="text" name='cn' value="{$cn}" title='{t}Please enter a name for the mime type here{/t}'>
+{/render}
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               {t}Mime group{/t}
+                                       </td>
+                                       <td>
+{render acl=$gotoMimeGroupACL}
+                                               <select name='gotoMimeGroup' title='{t}Categorize this mime type{/t}'>
+                                                       {html_options output=$gotoMimeGroups values=$gotoMimeGroups selected=$gotoMimeGroup}
+                                               </select>
+{/render}
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               {t}Description{/t}
+                                       </td>
+                                       <td>
+{render acl=$descriptionACL}
+                                               <input type="text" name='description' value="{$description}" title='{t}Please specify a description{/t}'>
+{/render}
+                                       </td>
+                               </tr>
+{if !$isReleaseMimeType} 
+                               <tr>
+                                       <td><LABEL for="base">{t}Base{/t}{$must}</LABEL></td>
+                                       <td>
+       {render acl=$baseACL}
+               <select size="1" id="base" name="base" title="{t}Choose subtree to place application in{/t}">
+                       {html_options options=$bases selected=$base_select}
+               </select>
+       {/render}
+       {if !$isReleaseMimeType}
+               {render acl=$baseACL disable_picture='images/folder_gray.png'}
+                       <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+               {/render}
+       {/if}
+                                       </td>
+                                </tr>
+
+{/if}
+                       </table>
+                       
+               </td>
+               <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+                       <table summary="">
+                               <tr>
+                                       <td>
+                                               <LABEL for="picture_file">{t}Icon{/t}</LABEL><br>
+                                               <img src="{$gotoMimeIcon}" border=1 alt='{t}Mime icon{/t}' 
+                                                       style="width:48px; height:48; background-color:white; vertical-align:bottom;">
+                                       </td>
+                                       <td style="vertical-align:top">
+                                               &nbsp;<br>
+                                               <input type="hidden" name="MAX_FILE_SIZE" value="100000">
+{render acl=$gotoMimeIconACL}
+                                               <input name="picture_file" type="file" size="20" maxlength="255" 
+                                                       accept="image/*.png" id="picture_file">
+{/render}
+{render acl=$gotoMimeIconACL}
+                                               <input type="submit" name="update_icon" value="{t}Update{/t}" 
+                                                       title="{t}Update mime type icon{/t}">
+{/render}
+                                       </td>
+                               </tr>
+                       </table>
+               </td>
+       </tr>
+       <tr>
+               <td colspan="2">
+                       <p class='seperator'>&nbsp;</p>
+               </td>
+       </tr>
+       <tr>
+               <td colspan="2">
+                       <h2><img src='images/mime_leftclick.png' class='center' alt='{t}Left click{/t}'>&nbsp;{t}Left click{/t}</h2>
+               </td>
+       </tr>
+       <tr>
+               <td style='width:50%; vertical-align:top;' >
+                       {t}File patterns{/t}{$must}
+{render acl=$gotoMimeFilePatternACL}   
+                       {$gotoMimeFilePatterns} 
+{/render}
+
+{render acl=$gotoMimeFilePatternACL}   
+                       <input type='text'       name='NewFilePattern'    value='' title='{t}Please specify a new file pattern{/t}'>
+{/render}
+{render acl=$gotoMimeFilePatternACL}   
+                       <input type='submit' name='AddNewFilePattern' value='{t}Add{/t}' title='{t}Add a new file pattern{/t}'>
+{/render}
+               </td>
+               <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+                       {t}Applications{/t}
+{render acl=$gotoMimeApplicationACL}   
+                       {$gotoMimeApplications}         
+{/render}
+
+{render acl=$gotoMimeApplicationACL}   
+                       <select name="NewApplicationSelect">
+                               <option value="">-</option>
+                               {html_options options=$ApplicationList}
+                       </select>
+{/render}
+{render acl=$gotoMimeApplicationACL}   
+                       <input type='text'       name='NewApplication'    value='' title='{t}Enter an application name here{/t}'>
+{/render}
+{render acl=$gotoMimeApplicationACL}   
+                       <input type='submit' name='AddNewApplication' value='{t}Add{/t}' title='{t}Add application{/t}'>
+{/render}
+               </td>
+       </tr>
+       <tr>    
+               <td colspan="2">
+                       <p class='seperator'>&nbsp;</p>
+               </td>
+       </tr>
+       <tr>    
+               <td colspan="2">
+                       <h2><img src='images/mime_embedding.png' class='center' alt='{t}Embedding{/t}'>&nbsp;{t}Embedding{/t}</h2>
+               </td>
+       </tr>
+       <tr>
+               <td style='width:50%; vertical-align:top;' >
+                               
+                       <table>
+                               <tr>
+                                       <td style='vertical-align:top; '>
+{render acl=$gotoMimeLeftClickActionACL}
+                                               <input type='radio' name='gotoMimeLeftClickAction_IE' value='I' 
+                                                       {if $gotoMimeLeftClickAction_I} checked {/if}>
+{/render}
+                                               {t}Show file in embedded viewer{/t}
+                                               <br>
+
+{render acl=$gotoMimeLeftClickActionACL}
+                                               <input type='radio' name='gotoMimeLeftClickAction_IE' value='E' 
+                                                       {if $gotoMimeLeftClickAction_E} checked {/if}>
+{/render}
+                                               {t}Show file in external viewer{/t}
+                                               <br>
+
+{render acl=$gotoMimeLeftClickActionACL}
+                                               <input type='checkbox' name='gotoMimeLeftClickAction_Q' value='1' 
+                                                       {if $gotoMimeLeftClickAction_Q} checked {/if}>
+{/render}
+                                               {t}Ask whether to save to local disk{/t}
+                                       </td>
+                               </tr>
+                       </table>
+                       
+               </td>
+               <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+                       {t}Applications{/t}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+                       {$gotoMimeEmbeddedApplications}         
+{/render}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+                       <select name="NewEmbeddedApplicationSelect">
+                               <option value="">-</option>
+                               {html_options options=$ApplicationList}
+                       </select>
+{/render}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+                       <input type='text'       name='NewEmbeddedApplication'    value='' 
+                               title='{t}Enter an application name here{/t}'>
+{/render}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+                       <input type='submit' name='AddNewEmbeddedApplication' value='{t}Add{/t}' 
+                               title='{t}Add application{/t}'>
+{/render}
+               </td>
+       </tr>
+</table>
+<input type="hidden" name="MimeGeneric" value="1">
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('cn');
+  -->
+</script>
diff --git a/gosa-plugins/goto/admin/mimetypes/main.inc b/gosa-plugins/goto/admin/mimetypes/main.inc
new file mode 100644 (file)
index 0000000..de92142
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2003  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+if ($remove_lock){
+               if(session::is_set('MimeTypeManagement')){
+                               $MimeTypeManagement = session::get('MimeTypeManagement');
+                               $MimeTypeManagement->remove_lock();
+                               del_lock ($ui->dn);
+                               session::un_set ('MimeTypeManagement');
+               }
+} else {
+
+               /* Create MimeTypeManagement object on demand */
+               if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+                       session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui));
+               }
+
+               /* Get object */
+               $MimeTypeManagement = session::get('MimeTypeManagement');
+               $MimeTypeManagement->save_object();
+               $output= $MimeTypeManagement->execute();
+
+               /* Page header*/
+               if (session::is_set('objectinfo')){
+                               $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".@LDAP::fix(session::get('objectinfo')));
+               } else {
+                               $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"));
+               }
+
+               /* Reset requested? */
+               if (isset($_GET['reset']) && $_GET['reset'] == 1){
+                               del_lock ($ui->dn);
+                               session::un_set ('MimeTypeManagement');
+               }
+
+               /* Show and save dialog */
+               $display.= $output;
+               session::set('MimeTypeManagement',$MimeTypeManagement);
+}
+?>
diff --git a/gosa-plugins/goto/admin/mimetypes/paste_generic.tpl b/gosa-plugins/goto/admin/mimetypes/paste_generic.tpl
new file mode 100644 (file)
index 0000000..34b5e07
--- /dev/null
@@ -0,0 +1,31 @@
+<table style="width:100%">
+       <tr>
+               <td colspan="2">
+                       <h2><img src='images/head.png' class='center'>&nbsp;{t}Generic{/t}</h2>
+               </td>
+       </tr>
+       <tr>
+               <td style='width:50%; vertical-align:top;' >
+                               
+                       <table>
+                               <tr>
+                                       <td>
+                                               {t}Mime type{/t}
+                                       </td>
+                                       <td>
+                                               <input type="text" name='cn' value="{$cn}" title='{t}Please enter a name for the mime type here{/t}'>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               {t}Description{/t}
+                                       </td>
+                                       <td>
+                                               <input type="text" name='description' value="{$description}" title='{t}Please specify a description for this mime type here{/t}'>
+                                       </td>
+                               </tr>
+                       </table>
+                       
+               </td>
+       </tr>
+</table>
diff --git a/gosa-plugins/goto/admin/mimetypes/release_select.tpl b/gosa-plugins/goto/admin/mimetypes/release_select.tpl
new file mode 100644 (file)
index 0000000..d58738f
--- /dev/null
@@ -0,0 +1,16 @@
+<br> 
+<div class="contentboxh" style="border-bottom:1px solid #B0B0B0;">
+ <p class="contentboxh"><img src="{$branchimage}" align="right" alt="[F]">{t}Branches{/t}</p>
+</div>
+<div class="contentboxb">
+ <table summary="" style="width:100%;">
+  <tr>
+   <td>
+    {t}Current release{/t}&nbsp;
+    <select name="selectedRelease" onChange="document.mainform.submit();">
+     {html_options options=$releases selected=$selectedRelease}
+    </select>
+   </td>
+  </tr>
+ </table>
+</div>
diff --git a/gosa-plugins/goto/admin/mimetypes/remove.tpl b/gosa-plugins/goto/admin/mimetypes/remove.tpl
new file mode 100644 (file)
index 0000000..30c4233
--- /dev/null
@@ -0,0 +1,23 @@
+<div style="font-size:18px;">
+  <img alt="" src="images/button_cancel.png" align=top>&nbsp;{t}Warning{/t}
+</div>
+<p>
+ {$intro}
+ {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+</p>
+<p>
+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+       {if $multiple}
+               <input type=submit name="delete_multiple_mimetype_confirm" value="{t}Delete{/t}">
+               &nbsp;
+               <input type=submit name="delete_multiple_mimetype_cancel" value="{t}Cancel{/t}">
+       {else}
+               <input type=submit name="delete_mime_confirm" value="{t}Delete{/t}">
+               &nbsp;
+               <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+       {/if}
+</p>
+
diff --git a/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc
new file mode 100644 (file)
index 0000000..38570fd
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+class mimetabs extends tabs
+{
+  var $Release= "";
+
+  function mimetabs($config, $data, $dn,$category)
+  {
+    tabs::tabs($config, $data, $dn,$category);
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function set_release($newRelease)
+  {
+    $this->Release= preg_replace('/,'.get_ou('mimetypeou').'.*$/', '', $newRelease);
+    if ($this->Release != ""){
+      $this->Release= ",".$this->Release;
+    }
+  }
+
+  function save($ignore_account= FALSE)
+  {
+    $baseobject= $this->by_object['mimetype'];
+
+    /* Check for new 'dn', in order to propagate the
+       'dn' to all plugins */
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+
+    $mimefilter = session::get('mimefilter');
+
+    if((!empty($tmp)) && (isset($mimefilter['release']))){
+      if(!$baseobject->isReleaseMimeType){
+        $new_dn= "cn=".$baseobject->cn.",".get_ou('mimetypeou').$baseobject->base;
+      }else{
+        $new_dn ="cn=".$baseobject->cn.",".$mimefilter['release'];
+      }
+    }else{
+      $new_dn= "cn=".$baseobject->cn.",".get_ou('mimetypeou').$baseobject->base;
+    }
+
+    /* Move group? */
+    if ($this->dn != $new_dn){
+
+      /* Write entry on new 'dn' */
+      if ($this->dn != "new"){
+        $baseobject->move($this->dn, $new_dn);
+        $this->by_object['mimetype']= $baseobject;
+      }
+
+      /* Happen to use the new one */
+      $this->dn= $new_dn;
+    }
+
+    tabs::save();
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl b/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl
new file mode 100644 (file)
index 0000000..8e4bf44
--- /dev/null
@@ -0,0 +1,31 @@
+<h2><img class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Integrating unknown devices{/t}</h2>
+<p>
+ {t}The current device has been detected by the ARP monitor used by GOsa. You can integrate this device into your running DHCP/DNS infrastructure by submitting this form. The device entry will disapear from the list of the systems and move to the DNS/DHCP configuration.{/t}
+</p>
+<table summary="" style="width:100%">
+<tr>
+ <td style>
+  <LABEL for="cn">
+   {t}DNS name{/t}{$must}
+  </LABEL>
+ </td>
+ <td style='width:35%;border-right:1px solid #aaa'>
+  <input name="cn" id="cn" size=18 maxlength=60 value="{$cn}">
+ </td>
+ <td style='width:15%'>
+  <LABEL for="description">
+   {t}Description{/t}
+  </LABEL>
+ </td>
+ <td style='width:35%'>
+  <input name="description" id="description" size=18 maxlength=60 value="{$description}">
+ </td>
+</tr>
+</table>
+<br>
+<p class="seperator"></p>
+{$netconfig}
+
+<input type='hidden' name='ArpNewDevice_posted' value='1'>
+
+<p class="seperator"></p>
diff --git a/gosa-plugins/goto/admin/systems/goto/SelectDeviceType.tpl b/gosa-plugins/goto/admin/systems/goto/SelectDeviceType.tpl
new file mode 100644 (file)
index 0000000..d25acbf
--- /dev/null
@@ -0,0 +1,46 @@
+<br>
+<p class="seperator">
+{t}This is a new system which currently has no system type defined. Please choose a system type for this entry and press the 'continue' button. If this system should be added to a group of system settings, specify the preferred object group below.{/t}
+<br>
+<br>
+</p>
+<p class="seperator">
+<br>
+<b>{t}Please select a system type and an optional bundle of predefined settings to be inherited.{/t}</b>
+<br>
+<br>
+</p>
+<br>
+<table summary="" style='width:100%'>
+ <tr>
+  <td style='width:49%'>
+   <table summary="">
+    <tr>
+     <td> 
+      {t}System type{/t}&nbsp;
+         <select name="SystemType" title="{t}Choose a system type{/t}" style="width:120px;">
+       {html_options values=$SystemTypeKeys output=$SystemTypes selected=$SystemType}
+      </select>
+     </td>
+    </tr>
+   </table>
+  </td>
+  <td>
+   <table summary="">
+    <tr>
+     <td> 
+      {t}Choose an object group as template{/t}&nbsp;
+         <select name="ObjectGroup" title="{t}Choose an object group{/t}" style="width:120px;">
+       {html_options values=$ObjectGroupKeys output=$ObjectGroups selected=$ObjectGroup}
+      </select>
+     </td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+<p class="seperator">&nbsp;</p>
+<div style="align: right;" align="right"><p>
+       <input type="submit" name="SystemTypeChoosen" value="{t}Continue{/t}">
+       <input type="submit" name="SystemTypeAborted" value="{t}Cancel{/t}">
+</p></div>
diff --git a/gosa-plugins/goto/admin/systems/goto/chooser.tpl b/gosa-plugins/goto/admin/systems/goto/chooser.tpl
new file mode 100644 (file)
index 0000000..3e8bf95
--- /dev/null
@@ -0,0 +1,21 @@
+<h1>{t}Choose the kind of system component you want to create{/t}</h1>
+
+<p>
+ {t}Linux terminals and workstations are autocreated on bootup. For this reason you're only be able to create templates for a specific tree. Servers are normally automatically added too, but in some special cases you may need to create a faked server entry to provide GOsa with some informations. Other network components may be used for Nagios setups to create component dependencies.{/t}
+</p>
+
+<input type="radio" name="system" value="terminal" checked>{t}Linux thin client template{/t}<br>
+<input type="radio" name="system" value="workstation">{t}Linux workstation template{/t}<br>
+<input type="radio" name="system" value="server">{t}Linux Server{/t}<br>
+<!--<input type="radio" name="system" value="machineaccount">{t}Windows workstation{/t}<br>-->
+<input type="radio" name="system" value="printer">{t}Network printer{/t}<br>
+<input type="radio" name="system" value="phone">{t}Phone{/t}<br>
+<input type="radio" name="system" value="component">{t}Other network component{/t}<br>
+
+<p class="plugbottom">
+ <input type=submit name="create_system" value="{t}Create{/t}">
+ &nbsp;
+ <input type=submit name="cancel" value="{t}Cancel{/t}">
+</p>
+
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc b/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc
new file mode 100644 (file)
index 0000000..7900990
--- /dev/null
@@ -0,0 +1,74 @@
+<?php 
+class ArpNewDevice extends plugin
+{
+  var $cn= "";
+  var $description = "";
+  var $netConfigDNS = NULL;
+  var $attributes= array("cn","description");
+  var $objectclasses = array("gotoHard");
+  var $ignore_account = TRUE;
+
+  function ArpNewDevice ($config, $dn= NULL, $parent= NULL)
+  {
+    plugin :: plugin($config,$dn);
+    $this->cn ="";
+    $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
+    $this->acl = "#all#";
+    $this->netConfigDNS->acl = $this->acl;
+    $this->netConfigDNS->force_dns();
+  }
+
+  function execute()
+  {
+    $smarty = get_smarty();
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,$this->$attr);
+    }
+    $this->netConfigDNS->cn= $this->cn;
+    $smarty->assign("netconfig", $this->netConfigDNS->execute());
+
+    /* Display sub dialog from network settings */
+    $this->netConfigDNS->acl = $this->acl;
+    if($this->netConfigDNS->dialog){
+      $this->dialog = TRUE;
+      return($this->netConfigDNS->execute());
+    }else{
+      $this->dialog = FALSE;
+    }
+
+    return($smarty->fetch (get_template_path('ArpNewDevice.tpl', TRUE)));
+  }
+
+  function check()
+  {
+    $message= plugin::check();
+    $message= array_merge($message, $this->netConfigDNS->check());
+    if(empty($this->cn)){
+      $message[] = _("Please specify a valid dns name.");
+    }
+    return($message);
+  }
+
+  function save_object()
+  {
+    if(isset($_POST['ArpNewDevice_posted'])){
+      plugin::save_object();
+      $this->netConfigDNS->save_object();
+    }
+  }
+
+  function save()
+  {
+    $this->netConfigDNS->acl = $this->acl;
+    plugin::save();
+    $this->netConfigDNS->cn = $this->cn;    
+    $this->netConfigDNS->save($this->dn);
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->rmdir_recursive($this->dn);
+    show_ldap_error($ldap->get_error(),_("Could not remove arp-alert device after writing dns and dhcp configuration."));
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_SelectDeviceType.inc b/gosa-plugins/goto/admin/systems/goto/class_SelectDeviceType.inc
new file mode 100644 (file)
index 0000000..c17b8ef
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+
+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");
+  var $objectclasses= array("whatever");
+
+  var $ObjectGroups   = array();
+  var $SystemTypes       = array();
+
+  var $ObjectGroup    = "";
+  var $SystemType        = "";
+
+  function SelectDeviceType  (&$config, $dn= NULL)
+  {
+    plugin::plugin ($config, $dn);
+
+    /* 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");
+    while($attrs = $ldap->fetch()){
+      $this->ObjectGroups[$attrs['dn']]= $attrs['cn'][0];
+    }
+
+    $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server"));
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    /* Fill templating stuff */
+    $smarty= get_smarty();
+    $display= "";
+
+    $smarty->assign("ObjectGroups"    ,$this->ObjectGroups);
+    $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups));
+    $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));
+    return($display);
+  }
+
+  /* Save data to object */
+  function save_object()
+  {
+    plugin::save_object();
+    foreach($this->attributes as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr = $_POST[$attr];
+      }
+    }
+  }
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    return ($message);
+  }
+
+  /* Save to LDAP */
+  function save()
+  {
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
new file mode 100644 (file)
index 0000000..9eec1ac
--- /dev/null
@@ -0,0 +1,1046 @@
+<?php
+
+class printgeneric extends plugin
+{
+  /* CLI vars */
+  var $cli_summary      = "Manage terminal base objects";
+  var $cli_description  = "Some longer text\nfor help";
+  var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Generic terminal attributes */
+  var $interfaces     = array();
+  var $ignore_account = FALSE;
+
+  /* Needed values and lists */
+  var $base             = "";
+  var $cn               = "";
+  var $l                = "";
+  var $description      = "";
+  var $labeledURI       = "";
+  var $gotoPrinterPPD   = "";
+  var $initial_PPD      = "";
+  var $orig_dn          = "";
+
+  var $UserMember       ="";
+  var $UserMembers      =array();
+  var $UserMemberKeys   =array();
+
+  var $AdminMember      ="";
+  var $AdminMembers     =array();
+  var $AdminMemberKeys  =array();
+
+  var $PPDdialogToSave  = NULL;
+  var $BelongsTo        = "unknown"; //  Specifies if this is a standalone printer, or belongs to a terminal / WS
+
+  var $member           =array();
+  var $strings          = "";
+  var $netConfigDNS;
+  var $baseSelection    = false;
+  var $macAddress       = "";
+
+  var $gotoUserAdminPrinter;
+  var $gotoGroupAdminPrinter ;
+  var $gotoGroupPrinter;
+  var $gotoUserPrinter ;
+
+  /* attribute list for save action */
+  var $attributes     = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress", 
+                              "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter");
+  var $objectclasses  = array("top", "gotoPrinter");
+  var $view_logged    = FALSE;
+  var $parent;
+
+  function printgeneric (&$config, $dn,$parent_init,$parent)
+  {
+    $this->config = &$config;
+    $this->dn = $dn; 
+    /* If parent was posted(the tabs object) we can detect the printer type. */
+    if($parent){
+      $this->parent = $parent;
+      $this->getTypeOfPrinter();
+    }else{
+      $this->BelongsTo = "unknown";
+      return;
+    }
+
+    /* Update dn, to ensure storing as printer instead of WS / terminal */
+    if(preg_match("/Terminal/i",$this->BelongsTo) || preg_match("/TerminalTemplate/i",$this->BelongsTo)){
+      $this->dn= preg_replace("/".normalizePreg(get_ou('terminalou'))."/",get_ou('printerou'),$this->dn);
+    }
+
+    if(preg_match("/Workstation/i",$this->BelongsTo) || preg_match("/WorkstationTemplate/i",$this->BelongsTo)){
+      $this->dn= preg_replace("/".normalizePreg(get_ou('workstationou'))."/",get_ou('printerou'),$this->dn);
+    }
+
+    $this->orig_dn = $this->dn;
+
+    /* Get printer settings, possibly dn has changed */
+    plugin::plugin ($config, $this->dn);
+
+    /* Get is_account initially_was_account status */
+    $this->getTypeOfPrinter(true);
+
+    /* set orig dn to new if object is new */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cat($this->dn, array('dn'));
+    if(!$ldap->count()){
+      $this->orig_dn = "new";
+    }
+    
+    /* create dns object */
+    $this->netConfigDNS = new termDNS($this->config, $this,$this->objectclasses);
+
+    /* Set base */
+    if ($this->dn == "new"){
+      $ui= get_userinfo();
+      $this->base= dn2base($ui->dn);
+      $this->cn= "";
+    } else {
+    
+      /* Set base and check if the extracted base exists */
+      if(preg_match("/".normalizePreg(get_ou('incomingou'))."/",$this->dn)){
+        $this->base= preg_replace("/".normalizePreg(get_ou('incomingou'))."/","",dn2base($this->dn));
+      }else{
+        $this->base= preg_replace("/".normalizePreg(get_ou('printerou'))."/","",dn2base($this->dn));
+      }
+
+      if(!isset($this->config->idepartments[$this->base])){
+        print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),session::get('CurrentMainBase'));
+        $this->base  = session::get('CurrentMainBase');
+      }
+    }
+
+    /* Extract selected ppd */
+    if(isset($this->gotoPrinterPPD)){
+      $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
+    }
+
+    $this->initial_PPD = $this->gotoPrinterPPD;
+
+    /* Prepare different member types */ 
+    foreach(array("AddUser"       =>"gotoUserPrinter",
+          "AddGroup"      =>"gotoGroupPrinter",
+          "AddAdminUser"  =>"gotoUserAdminPrinter",
+          "AddAdminGroup" =>"gotoGroupAdminPrinter") as $type => $attr){
+
+      /* $this->members contains all members */
+      $this->member[$type]=array();
+
+      if (isset($this->attrs[$attr]['count'])) {
+        unset($this->attrs[$attr]['count']);
+      }
+
+      if(isset($this->attrs[$attr])){
+        foreach($this->attrs[$attr] as $mem){
+          if(preg_match("/Group/",$type)){
+            $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description"));
+            if($ldap->count()){
+              $entry = $ldap->fetch();
+              $this->member[$type][$entry['cn'][0]]=$entry;
+            }
+          }else{
+            $ldap->search("(&(objectClass=person)(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid"));
+            if($ldap->count()){
+              $entry = $ldap->fetch();
+              $this->member[$type][$entry['uid'][0]]=$entry;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  function set_acl_base($base)
+  {
+    plugin::set_acl_base($base);
+    if(is_object($this->netConfigDNS)){
+      $this->netConfigDNS->set_acl_base($base);
+    }
+  }
+
+  function set_acl_category($cat)
+  {
+    plugin::set_acl_category($cat);
+    if(is_object($this->netConfigDNS)){
+      $this->netConfigDNS->set_acl_category($cat);
+    }
+  }
+
+  /* Detect type of printer.
+   * Printer can be stand alone, belong to a workstation or belong to a terminal. 
+   * We can detect the type printer type when comparing the tabs objects
+   */
+  function getTypeOfPrinter($UpdateAccountStatus = false)
+  {
+    /* Disable account as default
+     */  
+    $this->is_account = $this->initially_was_account = false;
+
+    /* Detect type of printer via parent tabs.
+     */
+
+    $class = get_class($this->parent);
+    if(isset($this->parent->by_object['workgeneric'])){
+
+      /* Exclude templates 
+       */
+      $this->cn = $this->parent->by_object['workgeneric']->cn;
+      if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+        $this->BelongsTo = "WorkstationTemplate";
+      }else{
+        $this->BelongsTo = "Workstation";
+      }
+    }elseif(isset($this->parent->by_object['termgeneric'])){
+
+      /* Exclude templates 
+       */
+      $this->cn = $this->parent->by_object['termgeneric']->cn;
+      if($this->parent->by_object['termgeneric']->cn == "default"){
+        $this->BelongsTo = "TerminalTemplate";  
+      }else{
+        $this->BelongsTo = "Terminal";
+      }
+    }elseif(isset($this->parent->by_name['printgeneric'])){
+      $this->BelongsTo  = "Printer";
+    }
+
+    if($UpdateAccountStatus){
+
+      /* Set is_account / was account 
+       */
+      if($this->dn == "new"){
+        $this->initially_was_account = false;
+      }
+
+      /* If is printer it must be a true account.
+       */
+      if(preg_match("/printer/i",$this->BelongsTo)){
+        $this->is_account = true;
+      }
+
+      /* Update dn, to ensure storing as printer instead of WS / terminal
+       */
+      if(preg_match("/terminal/i",$this->BelongsTo)){
+        $this->dn= preg_replace("/".normalizePreg(get_ou('terminalou'))."/",get_ou('printerou'),$this->dn);
+      }
+
+      if(preg_match("/workstation/i",$this->BelongsTo)){
+        $this->dn= preg_replace("/".normalizePreg(get_ou('workstationou'))."/",get_ou('printerou'),$this->dn);
+      }
+
+      /* Detect if this is a valid printer account;
+       */
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cat($this->dn, array('objectClass'));
+
+      if($ldap->count()){
+        $attrs = $ldap->fetch();
+        if(in_array("gotoPrinter",$attrs['objectClass'])){
+          $this->initially_was_account = true;
+          $this->is_account             = true;
+        }else{
+          $this->is_account = false;
+        }
+      }
+    }
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","printer/".get_class($this),$this->dn);
+    }
+
+
+    /* If type of printer couldn't be detected (because of missing parent object in construction) 
+     * hide this tab.
+     */
+    if(preg_match("/unknown/i",$this->BelongsTo)){
+      $display= $this->show_enable_header(_("Add printer extension"),
+          _("Could not initialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
+      return($display);
+    }
+
+    /* Templates can't have printer extensions 
+     */
+    if(preg_match("/WorkstationTemplate/i",$this->BelongsTo)){
+      $display= $this->show_enable_header(_("Add printer extension"),
+          _("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
+      return($display);
+    }
+    if(preg_match("/TerminalTemplate/i",$this->BelongsTo)){
+      $display= $this->show_enable_header(_("Add printer extension"),
+          _("This is a terminal template, printer tab is disabled."),TRUE,TRUE);
+      return($display);
+    }
+
+    /* Get cn from base object */
+    if(preg_match("/^Workstation$/i",$this->BelongsTo)){
+      $this->cn = $this->parent->by_object['workgeneric']->cn;
+    }
+    if(preg_match("/^Terminal$/i",$this->BelongsTo)){
+      $this->cn = $this->parent->by_object['termgeneric']->cn;
+    }
+
+    $smarty= get_smarty();
+
+    /* Assign acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL", $this->getacl($name));
+    }
+
+    $display="";
+
+    /* Tell smarty if this is a standalone object or a terminal / WS depending printer */
+    if(preg_match("/^Printer$/i",$this->BelongsTo)){    
+      $smarty->assign("StandAlone",true);
+    }else{
+      $smarty->assign("StandAlone",false);
+    }
+
+    /* Do we need to flip is_account state? */
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }
+
+    /* Do we represent a valid printer? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+        _("This 'dn' has no printer features.")."</b>";
+      return($display);
+    }
+
+    /* If this is a WS / Terminal depending printer, display account state button */
+    if(!preg_match("/^Printer$/i",$this->BelongsTo)){
+      if((empty($this->cn)) && ($this->dn != "new")){
+        $display= $this->show_enable_header(_("Add printer extension"),
+            _("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
+        $this->is_account= false;
+        return $display;
+      }
+
+      if (($this->is_account)){
+        if(preg_match("/^Workstation$/i",$this->BelongsTo)){
+          $display= $this->show_disable_header(_("Remove printer extension"),
+              _("This workstation has printer extension enabled.You can disable it by clicking below."));
+        }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){
+          $display= $this->show_disable_header(_("Remove printer extension"),
+              _("This terminal has printer extension enabled. You can disable it by clicking below."));
+        }
+      }else{
+        if(preg_match("/^Workstation$/i",$this->BelongsTo)){
+          $display= $this->show_disable_header(_("Add printer extension"),
+              _("This workstation has printer extension disabled. You can enable it by clicking below."));
+        }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){
+          $display= $this->show_enable_header(_("Add printer extension"),
+              _("This terminal has printer extension disabled. You can enable it by clicking below."));
+        }  
+        return ($display);
+      }
+    }
+
+    /* Base select dialog */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){
+        $once = false;
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
+        $this->dialog->setCurrentBase($this->base);
+        $this->baseSelection = true;
+      }
+    }
+
+    /* Dialog handling for base select dialog
+     * Check if base was selected, dialog aborted etc */
+    if(is_object($this->dialog)){
+
+      $this->dialog->save_object();
+      if($this->baseSelection){
+        if($this->dialog->isClosed()){
+          $this->dialog = false;
+          $this->baseSelection = false;
+        }elseif($this->dialog->isSelected()){
+
+          /* A new base was selected, check if it is a valid one */
+          $tmp = $this->get_allowed_bases();
+          if(isset($tmp[$this->dialog->isSelected()])){
+            $this->base = $this->dialog->isSelected();
+          }
+
+          $this->dialog= false;
+          $this->baseSelection = false;
+        }else{
+          return($this->dialog->execute());
+        }
+      }
+    }
+
+    /* Fill templating stuff */
+    $smarty->assign("bases", $this->get_allowed_bases());
+    $smarty->assign("base_select", $this->base);
+
+    /* Assign attributes */
+    foreach ($this->attributes as $attr){
+      $smarty->assign("$attr", $this->$attr);
+    }
+
+    if(isset($_POST['AddUser'])){
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser");
+    }
+    if(isset($_POST['AddGroup'])){
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddGroup");
+    }
+    if(isset($_POST['AddAdminUser'])){
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminUser");
+    }
+    if(isset($_POST['AddAdminGroup'])){
+      $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddAdminGroup");
+    }
+
+    /* Display ppd configure/select dialog      */
+    if(isset($_POST['EditDriver'])){
+      if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){
+        $this->dialog = $this->PPDdialogToSave;
+      }else{
+        $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+        $this->dialog->cn= $this->cn;
+      }
+    }
+
+    /* remove ppd */
+    if(isset($_POST['RemoveDriver'])){
+      $this->gotoPrinterPPD = array();
+      $this->PPDdialogToSave = NULL;
+    }
+
+    /* Close ppd dialog */
+    if(isset($_POST['ClosePPD'])){
+      unset($this->dialog);
+      $this->dialog=FALSE;
+    }
+
+    /* Save selected ppd */
+    if(isset($_POST['SavePPD'])){
+      $this->dialog->save_object();
+      if(count($this->dialog->check())){
+        foreach($this->dialog->check() as $msg){
+          print_red($msg);
+        }
+      }else{
+        $this->gotoPrinterPPD = array();
+        $this->gotoPrinterPPD = $this->dialog->save();
+        $this->PPDdialogToSave = $this->dialog;
+        unset($this->dialog);
+        $this->dialog=FALSE;
+      }
+    }
+
+     /* Member management, delete user / group / admin ..*/
+    if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
+      foreach($_POST['UserMember'] as $mem){
+        $this->DelMember('AddUser',$mem);
+      }
+    }
+
+    if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
+      foreach($_POST['UserMember'] as $mem){
+        $this->DelMember('AddGroup',$mem);
+      }
+    }
+
+    if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
+      foreach($_POST['AdminMember'] as $mem){
+        $this->DelMember('AddAdminUser',$mem);
+      }
+    }
+
+    if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
+      foreach($_POST['AdminMember'] as $mem){
+        $this->DelMember('AddAdminGroup',$mem);
+      }
+    }
+
+    /* Abort user / group adding dialog */
+    if(isset($_POST['PrinterCancel'])){
+      unset($this->dialog);
+      $this->dialog= FALSE;
+    }
+
+    /* Save selected users / groups */
+    if(isset($_POST['PrinterSave'])){
+      $this->dialog->save_object();
+      if(count($this->dialog->check())){
+        foreach($this->dialog->check() as $msg){
+          print_red($msg);
+        }
+      }else{
+        $data= $new = $this->dialog->save();
+        unset($data['type']);
+        foreach($data as $mem){
+          $this->AddMember($new['type'], $mem['dn']);
+        }
+        unset($this->dialog);
+        $this->dialog=FALSE;
+      }
+    }
+
+    /* Display dialog, if there is currently one open*/
+    if(is_object($this->dialog)){
+      $this->dialog->save_object();
+      $display = $this->dialog->execute();
+      return $display;
+    }
+
+    /* Parse selected ppd file */
+    $config = session::get('config');
+    if((isset($config->data['MAIN']['PPD_PATH']))&&(is_dir($config->data['MAIN']['PPD_PATH']))){
+
+      $path = $config->data['MAIN']['PPD_PATH'];
+      if(!preg_match("/\/$/",$path)){
+        $path = $path."/";
+      }
+
+      $ppdManager= new ppdManager($path);
+      if(!empty($this->gotoPrinterPPD)){
+        if((!file_exists($path.$this->gotoPrinterPPD))){
+          $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD)."</b>");
+        }else{
+          $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
+        }
+      }else{
+        $smarty->assign("driverInfo", _("Not defined"));
+      }
+    }else{
+      $smarty->assign("driverInfo",_("Can't get ppd informations."));
+    }
+
+    /* Create user & admin user list */
+    $list=$this->generateList();
+    $userlist   = array_merge($list['AddUser'],$list['AddGroup']);
+    $adminlist  = array_merge($list['AddAdminUser'],$list['AddAdminGroup']);
+
+    asort($userlist);
+    asort($adminlist);
+
+    if(!preg_match("/Printer/i",$this->BelongsTo)){
+      if(preg_match("/Terminal/i",$this->BelongsTo)){
+        $smarty->assign("desc"    ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
+      }else{
+        $smarty->assign("desc"    ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
+      }
+      $smarty->assign("cnACL"    , $this->getacl("cn",true));
+    }else{
+      $smarty->assign("desc"    ,"");
+    }
+    $smarty->assign("UserMember"    ,$this->UserMember);
+    $smarty->assign("UserMembers"   ,$userlist);
+    $smarty->assign("UserMemberKeys",array_flip($userlist));
+
+    $smarty->assign("AdminMember"    ,$this->AdminMember);
+    $smarty->assign("AdminMembers"   ,$adminlist);
+    $smarty->assign("AdminMemberKeys",array_flip($adminlist));
+    if(preg_match("/Printer/i",$this->BelongsTo)){
+
+      /* Show main page */
+      $str = $this->netConfigDNS->execute();
+      if(is_object($this->netConfigDNS->dialog)){
+        return($str);
+      }
+      $smarty->assign("netconfig", $str);
+    } else {
+      $smarty->assign("netconfig", "");
+    }
+
+    return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE)));
+  }
+
+  function remove_from_parent()
+  {
+    /* Only remove if there was initially an account */
+    if($this->initially_was_account){
+
+      /* Update dn, to ensure storing as printer instead of WS / terminal
+       */
+      if(preg_match("/terminal/i",$this->BelongsTo)){
+        $this->dn= preg_replace("/".normalizePreg(get_ou('terminalou')).",/",get_ou('printerou'),$this->dn);
+      }
+
+      if(preg_match("/workstation/i",$this->BelongsTo)){
+        $this->dn= preg_replace("/".normalizePreg(get_ou('workstationou'))."/",get_ou('printerou'),$this->dn);
+      }
+
+      /* Check if this dn points to a printer, to avoid deleting something else */
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cat($this->dn, array('dn',"objectClass"));
+      if(!$ldap->count()){
+        print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
+        return;
+      }
+
+      /* Check if obejct is a printer */
+      $CheckPrinter = $ldap->fetch();
+      if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){
+        print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
+        return;
+      }
+
+      /* Remove account & dns extension */ 
+      $this->netConfigDNS->remove_from_parent();
+      $ldap->rmdir($this->dn);
+
+      new log("remove","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+  
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing of system print/generic with dn '%s' failed."),$this->dn));
+      $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+
+      /* Delete references to object groups */
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
+      while ($ldap->fetch()){
+        $og= new ogroup($this->config, $ldap->getDN());
+        unset($og->member[$this->dn]);
+        $og->save ();
+      }
+
+      /* Remove previously selected ppd file.*/
+      if(!empty($this->initial_PPD)){
+        $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+        $tmp->removeModifiedPPD();
+      }
+    }
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    /* Create a base backup and reset the
+       base directly after calling plugin::save_object();
+       Base will be set seperatly a few lines below */
+    $base_tmp = $this->base;
+    plugin::save_object();
+    $this->base = $base_tmp;
+
+    if(is_object($this->netConfigDNS)){
+      $this->netConfigDNS->save_object();
+    }
+    
+    /* Set new base if allowed */
+    $tmp = $this->get_allowed_bases();
+    if(isset($_POST['base'])){
+      if(isset($tmp[$_POST['base']])){
+        $this->base= $_POST['base'];
+      }
+    }
+  }
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+    if (preg_match("/printer/i",$this->BelongsTo)){
+      $message= array_merge($message, $this->netConfigDNS->check());
+    }
+
+    /* Don't display check messages if this is a template object */
+    if(isset($this->parent->by_object['workgeneric'])){
+      if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+        return $message;
+      }
+    }elseif(isset($this->parent->by_object['termgeneric'])){
+      if($this->parent->by_object['termgeneric']->cn == "default"){
+        return $message;
+      }
+    }
+
+    $dn= "cn=".$this->cn.get_ou('printerou').",".$this->base;
+
+    /* must: cn */
+    if(($this->BelongsTo == "Printer") && (empty($this->cn))){
+      $message[]= _("The required field 'Printer name' is not set.");
+    }
+
+    /* must: cn */
+    if(($this->BelongsTo == "Printer") && !tests::is_dns_name($this->cn)){
+      $message[]= _("Invalid character in printer name.");
+    }
+
+    /* must: labeledURI */
+    if(empty($this->labeledURI)){
+      $message[]= "The required field 'Printer URL' is not set.";
+    }
+    
+    /* Check if there is already an entry with this cn*/
+    if (($this->orig_dn != $dn)&&( preg_match("/printer/i",$this->BelongsTo))){
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd ($this->base);
+      $ldap->ls("(cn=".$this->cn.")",get_ou('printerou').$this->base, array("cn"));
+      if ($ldap->count() != 0){
+        while ($attrs= $ldap->fetch()){
+          if(preg_match("/cn=dhcp,/",$attrs['dn'])){
+            continue;
+          }
+          if ($attrs['dn'] != $this->orig_dn){
+            $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
+            break;
+          }
+        }
+      }
+    }
+
+    return ($message);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Update dn, to ensure storing as printer instead of WS / terminal
+     */
+    if(preg_match("/terminal/i",$this->BelongsTo)){
+      $this->dn= preg_replace("/".normalizePreg(get_ou('terminalou')).",/",get_ou('printerou'),$this->dn);
+    }
+
+    if(preg_match("/workstation/i",$this->BelongsTo)){
+      $this->dn= preg_replace("/".normalizePreg(get_ou('workstationou'))."/",get_ou('printerou'),$this->dn);
+    }
+    
+    if(!$this->is_account) return;
+    if(isset($this->parent->by_object['workgeneric'])){
+      if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+        return;
+      }
+    }elseif(isset($this->parent->by_object['termgeneric'])){
+      if($this->parent->by_object['termgeneric']->cn == "default"){
+        return;
+      }
+    }
+
+    /* If type is still unknown, the initialisation of this printer failed, abort. */
+    if(preg_match("/unknown/i",$this->BelongsTo)){
+      return;
+    }
+
+    /* save ppd configuration */
+    if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){
+      $this->PPDdialogToSave->save_ppd();
+    }
+    if($this->orig_dn != $this->dn){
+      if(!empty($this->gotoPrinterPPD)) {
+        $this->PPDdialogToSave = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+        $this->PPDdialogToSave->cn = $this->cn;
+        $this->PPDdialogToSave->generateProperties();
+        $this->PPDdialogToSave->update_ppd_url();
+      }
+    }
+
+    /* Remove previously selected ppd file.*/
+    if($this->initial_PPD != $this->gotoPrinterPPD){
+      if(!empty($this->initial_PPD)){
+        $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+        $tmp->removeModifiedPPD();
+      }
+    }
+
+    if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
+      $method="https://";
+    }else{
+      $method="http://";
+    }
+
+    /* If no ppd is selected, remove this attribute */
+    if(!empty($this->gotoPrinterPPD)) {
+      $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
+    }else{
+      $this->gotoPrinterPPD = array();
+    }
+
+    $dn= $this->dn;
+    plugin::save();
+    $ldap= $this->config->get_ldap_link();
+
+    /* reduce objectClasses to minimun */
+    $this->attrs['objectClass']= $this->objectclasses;
+
+    /* Remove all empty values */
+    if ($this->orig_dn == 'new'){
+      $attrs= array();
+      foreach ($this->attrs as $key => $val){
+        if (is_array($val) && count($val) == 0){
+          continue;
+        }
+        $attrs[$key]= $val;
+      }
+      $this->attrs= $attrs;
+    }
+
+    /* Append printer user 
+     */
+    $this->attrs['gotoUserPrinter']=array();
+    foreach($this->member['AddUser'] as $mem){
+      $this->attrs['gotoUserPrinter'][]=$mem['uid'][0];
+    }
+
+    /* Append printer group 
+     */
+    $this->attrs['gotoGroupPrinter'] = array();
+    foreach($this->member['AddGroup'] as $mem){
+      $this->attrs['gotoGroupPrinter'][]=$mem['cn'][0];
+    }
+
+    /* Append printer admin user 
+     */
+    $this->attrs['gotoUserAdminPrinter'] = array();
+    foreach($this->member['AddAdminUser'] as $mem){
+      $this->attrs['gotoUserAdminPrinter'][]=$mem['uid'][0];
+    }
+
+    /* Append printer admin group 
+     */
+    $this->attrs['gotoGroupAdminPrinter']= array();
+    foreach($this->member['AddAdminGroup'] as $mem){
+      $this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0];
+    }
+
+    if($this->orig_dn == 'new'){
+      foreach(array("gotoGroupPrinter","gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter") as $checkVar){
+        if(count($this->attrs[$checkVar])  == 0 || empty($this->attrs[$checkVar])){
+          unset($this->attrs[$checkVar]);
+        }
+      }
+    }else{
+      if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
+        $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+      }
+    }
+
+    /* Ensure to create a new object */
+    if(preg_match("/".normalizePreg(get_ou('incomingou'))."/",$this->orig_dn)){
+      $this->orig_dn = "new";
+    }
+
+    /* Move object in necessary*/
+    if (($this->orig_dn != $this->dn) && ($this->orig_dn != 'new')){
+      $this->move($this->orig_dn, $this->dn);
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cat($this->dn);
+    if(!$ldap->count()){
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
+      $ldap->cd($this->dn);
+
+      /* Remove empty values */ 
+      foreach($this->attrs as $name => $value){
+        if(empty($value)){
+          unset($this->attrs[$name]);
+        }
+      }
+
+      $ldap->add($this->attrs);
+      $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+      new log("create","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    } else {
+      $ldap->cd($this->dn);
+      $this->cleanup();
+      $ldap->modify ($this->attrs); 
+      $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+      new log("modify","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn));
+
+    if(preg_match("/printer/i",$this->BelongsTo)){
+      $this->netConfigDNS->cn = $this->cn;
+      $this->netConfigDNS->dn = $this->dn;
+      $this->netConfigDNS->save();
+    }
+  }
+
+  function generateList(){
+    $a_return=array();
+
+    foreach($this->member as $type => $values){
+      $a_return[$type]=array();
+      foreach($values as $value){
+        if((preg_match("/Group/i",$type))){
+          if(!isset($value['description'])){
+            $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0];
+          }else{
+            $a_return[$type][$value['cn'][0]]= _("Group")." : ".$value['cn'][0]." [".$value['description'][0]."]";
+          }
+        }else{
+          $a_return[$type][$value['uid'][0]]=_("User")." : ".$value['cn'][0];
+        }
+      }
+    }
+    return($a_return);
+  }
+
+  /* Return plugin informations for acl handling
+      #FIXME FAIscript seams to ununsed within this class... */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Generic"),
+          "plDescription" => _("Print generic"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 4,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("printer" => array("description"  => _("Printer"),
+                                                    "objectClass"  => "gotoPrinter"),"workstation","terminal"),
+          "plProvidedAcls"=> array(
+            "cn"                => _("Name"),
+            "base"                => _("Base") ,         
+            "description"       => _("Description"), 
+            "l"                 => _("Location"), 
+            "labeledURI"        => _("LabeledURL"), 
+            "gotoPrinterPPD"    => _("Printer PPD"),
+            "gotoUserPrinter"   => _("Permissions")) 
+          ));
+  }
+
+
+  /* Delete member */
+  function DelMember($type,$id)
+  {
+    /* Check if there was a printer "dn" given, or the "cn" */
+    foreach($this->member[$type] as $key => $printer){
+      if($printer['dn'] == $id) {
+        $id = $key;
+      }
+    }
+  
+    if(!$this->acl_is_writeable("gotoUserPrinter")){
+      print_red(sprintf(_("You are not allowed to remove the given object '%s' from the list of members of printer '%s'."),$id,$this->dn));
+      return(FALSE);
+    }
+    if(isset($this->member[$type][$id])){
+      unset($this->member[$type][$id]);
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+
+
+  /* Add given obejct to members */
+  function AddMember($type,$dn)
+  {
+    $types = array("AddUser","AddGroup","AddAdminUser","AddAdminGroup");
+    if(!in_array_ics($type, $types)){
+      print_red(sprintf(_("Illegal printer type while adding '%s' to the list of '%s' printers,"),$dn,$type));
+      return(FALSE);
+    }
+
+    if(!$this->acl_is_writeable("gotoUserPrinter")){
+      print_red(sprintf(_("You are not allowed to add the given object '%s' to the list of members of '%s'."),$dn,$this->dn));
+      return(FALSE);
+    }
+
+    /* Get name of index attributes */
+    if(preg_match("/user/i",$type)){
+      $var = "uid";
+    }else{
+      $var = "cn";
+    }
+
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($dn);
+    $ldap->cat($dn,array($var,"cn"));
+    if($ldap->count()){
+
+      $attrs = $ldap->fetch();
+
+      if(isset($attrs[$var][0])){
+        $name = $attrs[$var][0];
+
+        /* Check if this uid/cn is already assigned to any permission */
+        foreach($types as $ctype){
+
+          /* If we want to add a user, only check user/userAdmin members */
+          if((preg_match("/user/i",$type)) && (!preg_match("/user/i",$ctype))){
+            continue;
+          }
+
+          /* If we want to add a group, only check groups/adminGroups .. */
+          if((preg_match("/group/i",$type)) && (!preg_match("/group/i",$ctype))){
+            continue;
+          }
+
+          if(isset(  $this->member[$ctype][$name])){
+            print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0]));
+            return(FALSE);
+          }
+        }
+
+        /* Everything is fine. So add the given object to members */
+        $this->member[$type][$attrs[$var][0]] = $attrs ;
+      }else{
+        print_a($attrs);
+      }
+    }else{
+      print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn));
+      return(FALSE);
+    }
+    return(TRUE);
+  }
+
+
+   /* Display generic part for server copy & paste */
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("object","printer");
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    if(isset($source['macAddress'][0])){
+      $this->netConfigDNS->macAddress = $source['macAddress'][0];
+    }
+    if(isset($source['ipHostNumber'][0])){
+      $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
+    }
+
+    $source_o = new printgeneric($this->config,$source['dn'],NULL,$this->parent);
+    foreach($this->attributes as $attr){
+      $this->$attr = $source_o->$attr;
+    }
+    $this->member = $source_o -> member;
+
+    $this->gotoPrinterPPD = "";
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_selectUserToPrinterDialog.inc b/gosa-plugins/goto/admin/systems/goto/class_selectUserToPrinterDialog.inc
new file mode 100644 (file)
index 0000000..1f110e3
--- /dev/null
@@ -0,0 +1,198 @@
+<?php
+
+class selectUserToPrinterDialog 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();
+  var $objectclasses        = array("whatever");
+  var $regex                = "*";
+  var $subtree              = FALSE;
+  var $depselect            = "/";
+  var $deplist              = "/";
+
+  var $searchObjects        = "";
+  var $searchAttrs          = "";
+  var $searchAppend         = "";
+  var $baseAddition         = "";
+  var $type                 = "";
+  var $search_cat           = ""; 
+  function selectUserToPrinterDialog (&$config, $dn= NULL,$type=false )
+  {
+    plugin::plugin ($config, $dn);
+    $this->depselect = $this->config->current['BASE'];
+
+    switch($type){
+      case "AddUser" : 
+        $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))";
+        $this->searchAttrs   = array("cn","uid");
+        $this->searchAppend  = "uid"; 
+        $this->baseAddition  = get_people_ou(); 
+        $this->search_cat    = "users";
+          ;break;
+      case "AddGroup" :
+        $this->searchObjects = "(objectClass=posixGroup)";
+        $this->searchAttrs   = array("cn","description");
+        $this->searchAppend  = "cn"; 
+        $this->baseAddition  = get_groups_ou(); 
+        $this->search_cat    = "groups";
+          ;break;
+      case "AddAdminUser" : 
+        $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))";
+        $this->searchAttrs   = array("cn","uid");
+        $this->searchAppend  = "uid"; 
+        $this->baseAddition  = get_people_ou(); 
+        $this->search_cat    = "users";
+          ;break;
+      case "AddAdminGroup" :
+        $this->searchObjects = "(objectClass=posixGroup)";
+        $this->searchAttrs   = array("cn","description");
+        $this->searchAppend  = "cn"; 
+        $this->baseAddition  = get_groups_ou(); 
+        $this->search_cat    = "groups";
+          ;break;
+    }
+    $this->type = $type;
+
+  }
+
+  function execute()
+  {
+       /* Call parent execute */
+       plugin::execute();
+
+    /* Fill templating stuff */
+    $smarty= get_smarty();
+    $display= "";
+
+    if(isset($_POST['dialogissubmitted'])){
+      $this->regex=$_POST['regexPrinter'];
+      $this->depselect = $_POST['depselectPrinter'];
+    }
+    $this->subtree= isset($_POST['SubSearch']);
+
+    if((isset($_GET['search']))&&(!empty($_GET['search']))){
+      $this->regex=$_GET['search']."*";
+      $this->regex=preg_replace("/\*\*/","*",$this->regex);
+    }
+
+
+    /* Get all departments within this subtree */
+    $base = $this->config->current['BASE'];
+    $deps_res[] = array("dn"=>$this->config->current['BASE']);
+    $deps_res= array_merge($deps_res,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", array("users","groups"), $this->config->current['BASE'],
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+    /* Load possible departments */
+    $ui     = get_userinfo();
+  
+    /* Allowed user departments */
+    $udeps  = $ui->get_module_departments("users");
+
+    /* Allowed groups department */
+    $gdeps  = $ui->get_module_departments("groups");
+
+    /* Combine both arrays */
+    $tdeps  = array_unique(array_merge($udeps,$gdeps));
+
+    /* Create usable departments array */
+    $ids = $this->config->idepartments;
+    $deps = array();
+    foreach($deps_res as $dep){
+      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+        $value = $ids[$dep['dn']];
+        $deps[$dep['dn']] = $value;
+      }
+    }
+    if(!isset($deps[$this->depselect])){
+      $this->depselect = key($deps);
+    }
+
+
+
+    $tmp_printers= $this->getPrinter();
+    natcasesort($tmp_printers);
+    $smarty->assign("regexPrinter"        , $this->regex);
+    $smarty->assign("deplistPrinter"      , $deps);;//deplist);
+    $smarty->assign("depselectPrinter"    , $this->depselect);
+    $smarty->assign("gotoPrinters"        , $tmp_printers);
+    $smarty->assign("gotoPrinterKeys"     , array_flip($tmp_printers));
+    $smarty->assign("apply"               , apply_filter());
+    $smarty->assign("alphabet"            , generate_alphabet());
+    $smarty->assign("search_image"        , get_template_path('images/search.png'));
+    $smarty->assign("tree_image"          , get_template_path('images/tree.png'));
+    $smarty->assign("infoimage"           , get_template_path('images/info.png'));
+    $smarty->assign("launchimage"         , get_template_path('images/small_filter.png'));
+    $smarty->assign("deplist"             , $deps);
+    $smarty->assign("subtree", $this->subtree?"checked":"");
+
+    $display.= $smarty->fetch(get_template_path('selectUserToPrinterDialog.tpl', TRUE,dirname(__FILE__)));
+    return($display);
+  }
+
+  function check(){
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    if(empty($_POST['gotoPrinter'])){
+      $message[] = _("Please select a printer or press cancel.");
+    }
+    return $message;
+  }
+
+  /* Save to LDAP */
+  function save()
+  {
+    $a_return['type']=$this->type;
+    
+    foreach($_POST['gotoPrinter'] as $name){
+      $data = $this->getPrinter(true);
+      $a_return[$name]= $data[$name];
+    }
+    return($a_return);
+  }
+
+  /* This function generates the Printerlist
+   * All printers are returned that match regex and and depselect
+   */
+  function getPrinter($detailed = false)
+  {
+    $a_return=array();
+
+    $filter = "(&".$this->searchObjects."(cn=".$this->regex."))";
+    $base   = $this->baseAddition.$this->depselect;
+    $attrs  = $this->searchAttrs;
+    $cat    = $this->search_cat;
+
+    if ($this->subtree){
+      $res= get_list($filter,$cat,$this->depselect,$attrs, GL_SUBSEARCH);
+    } else {
+      $res= get_list($filter,$cat,$base,$attrs);
+    }
+    foreach($res as $printer){
+      if(($detailed ==true)){
+        if(isset($printer[$this->searchAppend])){
+          $a_return[$printer[$this->searchAppend][0]] = $printer;
+        }
+      }else{
+        if(isset($printer[$this->searchAppend])){
+          if(isset($printer['description'][0])){
+            $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0]." - ".$printer['description'][0]; 
+          }else{
+            $a_return[$printer[$this->searchAppend][0]] = $printer['cn'][0];
+          }
+        }
+      }
+    }
+    return($a_return);
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc
new file mode 100644 (file)
index 0000000..cdd9b8d
--- /dev/null
@@ -0,0 +1,682 @@
+<?php
+
+class termgeneric extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage terminal base objects";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Generic terminal attributes */
+  var $gotoMode= "disabled";
+  var $gotoTerminalPath= "";
+  var $gotoSwapServer= "";
+  var $gotoSyslogServer= "";
+  var $gotoSyslogServers = array();
+  var $gotoNtpServer= array();
+  var $gotoNtpServers= array();
+  var $gotoSndModule= "";
+  var $gotoFloppyEnable= "";
+  var $gotoCdromEnable= "";
+  var $ghCpuType= "-";
+  var $ghMemSize= "-";
+  var $ghUsbSupport= "-";
+  var $ghNetNic= array();
+  var $ghIdeDev= array();
+  var $ghScsiDev= array();
+  var $ghGfxAdapter= "-";
+  var $ghSoundAdapter= "-";
+  var $gotoLastUser= "-";
+  var $netConfigDNS;
+  /* Needed values and lists */
+  var $base= "";
+  var $cn= "";
+  var $orig_dn= "";
+
+  var $inheritTimeServer = true;
+
+  /* Plugin side filled */
+  var $modes= array();
+
+  /* attribute list for save action */
+  var $ignore_account= TRUE;
+  var $attributes= array("gotoMode", "gotoTerminalPath", 
+      "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer",
+      "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
+      "ghCpuType", "ghMemSize","ghUsbSupport",
+      "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser");
+  var $objectclasses= array("top", "gotoTerminal", "GOhard");
+
+  var $mapActions   = array("reboot"          => "",
+                            "instant_update"  => "softupdate",
+                            "update"          => "sceduledupdate",
+                            "reinstall"       => "install",
+                            "rescan"          => "",
+                            "memcheck"        => "memcheck",
+                            "sysinfo"         => "sysinfo");
+
+  var $fai_activated = FALSE;
+  var $view_logged = FALSE;
+
+  var $member_of_ogroup = FALSE;
+
+  function termgeneric (&$config, $dn= NULL, $parent= NULL)
+  {
+    /* Check if FAI is activated */
+    $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)){
+      $this->fai_activated = TRUE;
+    }
+
+    plugin::plugin ($config, $dn, $parent);
+
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
+      $this->member_of_ogroup = $ldap->count() >= 1;
+    }
+
+    $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
+    /* Read arrays */
+    foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
+      if (!isset($this->attrs[$val])){
+        continue;
+      }
+      for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
+        array_push($this->$val, $this->attrs[$val][$i]);
+      }
+    }
+
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+    if(isset($this->attrs['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($this->attrs['gotoNtpServer']['count']);
+      foreach($this->attrs['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+
+    /* You can't inherit the NTP service, if we are not member in an object group */
+    if(!$this->member_of_ogroup){
+      $this->inheritTimeServer = FALSE;
+    }
+
+    /* Create available ntp options */
+    $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
+    foreach($this->gotoNtpServers as $key => $server){
+      if($server == "default"){
+        unset($this->gotoNtpServers[$key]);
+      }
+    }
+
+    $this->modes["disabled"]= _("disabled");
+    $this->modes["text"]= _("text");
+    $this->modes["graphic"]= _("graphic");
+
+    /* Set base */
+    if ($this->dn == "new"){
+      $ui= get_userinfo();
+      $this->base= dn2base($ui->dn);
+    } else {
+      $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+    }
+
+    /* Create an array of all Syslog servers */
+    $tmp = $this->config->data['SERVERS']['SYSLOG'];
+    foreach($tmp as $server){
+      $visible = $server;
+      if($server == "default" && $this->member_of_ogroup) {
+        $visible = "["._("inherited")."]";
+      }
+      $this->gotoSyslogServers[$server] = $visible;
+    }
+
+    $this->orig_dn= $this->dn;
+  }
+
+  function set_acl_base($base)
+  {
+    plugin::set_acl_base($base);
+    $this->netConfigDNS->set_acl_base($base);
+  }
+
+  function set_acl_category($cat)
+  {
+    plugin::set_acl_category($cat);
+    $this->netConfigDNS->set_acl_category($cat);
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","terminal/".get_class($this),$this->dn);
+    }
+
+    /* Do we need to flip is_account state? */
+    if (isset($_POST['modify_state'])){
+      $this->is_account= !$this->is_account;
+    }
+
+    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){
+
+      /* Set FAIstate */
+      if($this->fai_activated && $this->dn != "new"){
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->cat($this->dn,array("objectClass"));
+        $res = $ldap->fetch();
+
+        $attrs = array();
+        $attrs['FAIstate'] = "";
+        if(isset($this->mapActions[$_POST['saction']])){
+          $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
+        }
+
+        for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
+          $attrs['objectClass'][] = $res['objectClass'][$i];
+        }
+
+        if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+          $attrs['objectClass'][] = "FAIobject";
+        }
+
+        if($attrs['FAIstate'] == ""){
+#FIXME we should check if FAIobject is used anymore
+          $attrs['FAIstate'] = array();
+        }
+
+        $ldap->cd($this->dn);
+        $ldap->modify($attrs);
+        show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn));
+      }
+
+      switch($_POST['saction']){
+        case 'wake':
+          $cmd= $this->config->search("termgeneric", "WAKECMD",array('tabs'));
+
+          if ($cmd == ""){
+            print_red(_("No WAKECMD definition found in your gosa.conf"));
+          } else {
+            exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval);
+            if ($retval != 0){
+              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+            }
+          }
+          break;
+
+        case 'reboot':
+          $cmd= $this->config->search("termgeneric", "REBOOTCMD",array('tabs'));
+          if ($cmd == ""){
+            print_red(_("No REBOOTCMD definition found in your gosa.conf"));
+          } else {
+            exec ($cmd." ".$this->cn, $dummy, $retval);
+            if ($retval != 0){
+              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+            }
+          }
+          break;
+
+        case 'halt':
+          $cmd= $this->config->search("termgeneric", "HALTCMD",array('tabs'));
+          if ($cmd == ""){
+            print_red(_("No HALTCMD definition found in your gosa.conf"));
+          } else {
+            exec ($cmd." ".$this->cn, $dummy, $retval);
+            if ($retval != 0){
+              print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+            }
+          }
+          break;
+      }
+    }
+
+    /* Base select dialog */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){
+        $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()){
+
+        /* A new base was selected, check if it is a valid one */
+        $tmp = $this->get_allowed_bases();
+        if(isset($tmp[$this->dialog->isSelected()])){
+          $this->base = $this->dialog->isSelected();
+        }
+        $this->dialog= false;
+      }else{
+        return($this->dialog->execute());
+      }
+    }
+
+    /* Do we represent a valid terminal? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+        _("This 'dn' has no terminal features.")."</b>";
+      return($display);
+    }
+
+    /* Add new ntp Server to our list */
+    if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
+      $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
+    }
+
+    /* Delete selected NtpServer for list of used servers  */
+    if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
+      foreach($_POST['gotoNtpServerSelected'] as $name){
+        unset($this->gotoNtpServer[$name]);
+      } 
+    }
+
+    /* Fill templating stuff */
+    $smarty= get_smarty();
+    
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    $smarty->assign("cn", $this->cn);
+    $smarty->assign("staticAddress", "");
+
+    $smarty->assign("bases", $this->get_allowed_bases());
+
+    /* tell smarty the inherit checkbox state */
+    $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
+
+    /* Check if terminal is online */
+    $query= "fping -q -r 1 -t 500 ".$this->cn;
+    exec ($query, $dummy, $retval);
+
+    /* Offline */
+    if ($retval == 0){
+      $smarty->assign("actions", array( "halt" => _("Switch off"), 
+                                        "reboot" => _("Reboot"),
+                                        "memcheck" => _("Memory test"),
+                                        "sysinfo"  => _("System analysis")));
+    } else {
+      $smarty->assign("actions", array("wake" => _("Wake up"),
+                                       "memcheck" => _("Memory test"),
+                                       "sysinfo"  => _("System analysis")));
+    }
+
+    /* Arrays */
+    $smarty->assign("modes", $this->modes);
+
+    $tmp2 = array(); 
+    foreach($this->config->data['SERVERS']['NFS'] as $server){
+      if($server != "default"){
+        $tmp2[$server]= $server;
+      }else{
+        if($this->member_of_ogroup){
+          $tmp2[$server]="["._("inherited")."]";
+        }
+      }
+    }
+  
+    $smarty->assign("nfsservers",     $tmp2);
+    $smarty->assign("syslogservers",  $this->gotoSyslogServers);
+
+    $tmp = array();
+    foreach($this->gotoNtpServers as $server){
+      if(!in_array($server,$this->gotoNtpServer)){
+        $tmp[$server] = $server;
+      }
+    }
+    
+    $smarty->assign("ntpservers",     $tmp);
+    $smarty->assign("fai_activated",$this->fai_activated);
+
+    /* Variables */
+    foreach(array("base", "gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){
+      $smarty->assign($val."_select", $this->$val);
+    }
+
+    $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
+
+    /* Show main page */
+    $str = $this->netConfigDNS->execute();
+    if(is_object($this->netConfigDNS->dialog)){
+      return($str);
+    }
+    $smarty->assign("netconfig", $str);
+    return($smarty->fetch (get_template_path('terminal.tpl', TRUE)));
+  }
+
+  function remove_from_parent()
+  {
+    if($this->acl_is_removeable()){   
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd($this->dn);
+      $ldap->cat($this->dn, array('dn'));
+      if($ldap->count()){
+        $this->netConfigDNS->remove_from_parent();
+        $ldap->rmDir($this->dn);
+  
+        new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+  
+        show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn));
+
+        /* Optionally execute a command after we're done */
+        $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+
+        /* Delete references to object groups */
+        $ldap->cd ($this->config->current['BASE']);
+        $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
+        while ($ldap->fetch()){
+          $og= new ogroup($this->config, $ldap->getDN());
+          unset($og->member[$this->dn]);
+          $og->save ();
+        }
+      }
+    }
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    /* Create a base backup and reset the
+       base directly after calling plugin::save_object();
+       Base will be set seperatly a few lines below */
+    $base_tmp = $this->base;
+    plugin::save_object();
+    $this->base = $base_tmp;
+
+    /* Set new base if allowed */
+    $tmp = $this->get_allowed_bases();
+    if(isset($_POST['base'])){
+      if(isset($tmp[$_POST['base']])){
+        $this->base= $_POST['base'];
+      }
+    }
+    
+    $this->netConfigDNS->save_object();
+
+    /* Save terminal path to parent since it is used by termstartup, too */
+    if(isset($this->parent->by_object['termstartup'])){
+      $this->parent->by_object['termstartup']->gotoTerminalPath= $this->gotoTerminalPath;
+    }
+    
+    if(isset($_POST['termgeneric_posted'])){
+      if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
+        $this->inheritTimeServer = true;
+      }else{
+        $this->inheritTimeServer = false;
+      }
+    }  
+
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
+
+  }
+
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    /* Skip IP & Mac checks if this is a template */
+    if($this->cn != "default"){
+      $message= array_merge($message, $this->netConfigDNS->check());
+    }
+
+    /* Permissions for that base? */
+    $this->dn= "cn=".$this->cn.",".get_ou('terminalou').$this->base;
+
+    if ($this->cn == ""){
+      $message[]= _("The required field 'Terminal name' is not set.");
+    }
+
+    /* Check if given name is a valid host/dns name */
+    if(!tests::is_dns_name($this->cn) ){
+      $message[] = _("Please specify a valid name for this object.");
+    }
+
+    if ($this->orig_dn == 'new'){
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd ($this->base);
+
+      /* It is possible to have a 'default' terminal on every base */
+      if($this->cn == "default"){
+        $ldap->cat($this->dn);
+      }else{
+        $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn"));
+      }
+      if ($ldap->count() != 0){
+        while ($attrs= $ldap->fetch()){
+          if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".normalizePreg(get_ou('incomingou'))."/", $ldap->getDN())){
+            continue;
+          } else {
+            if ($attrs['dn'] != $this->orig_dn){
+              $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
+              break;
+            }
+          }
+        }
+      }
+    }
+
+    /* Check for valid ntpServer selection */
+    if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
+      $message[]= _("There must be at least one NTP server selected, or the inherit mode activated.");
+    }
+
+    return ($message);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+
+    /* Move object if requested */
+    if( $this->orig_dn != 'new' && $this->dn != $this->orig_dn){
+      $this->move($this->orig_dn, $this->dn);
+    }
+
+    plugin::save();
+
+    /* Strip out 'default' values */
+    foreach (array("gotoTerminalPath", "gotoSwapServer", "gotoSyslogServer") as $val){
+      if(isset($this->attrs[$val])){
+        if ($this->attrs[$val] == "default"){
+          $this->attrs[$val]= array();
+        }
+      }
+    }
+
+    /* Add missing arrays */
+    foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
+      if (isset ($this->$val) && count ($this->$val) != 0){
+        $this->attrs["$val"]= $this->$val;
+      }
+    }
+
+    /* Remove all empty values */
+    if ($this->orig_dn == 'new'){
+      $attrs= array();
+      foreach ($this->attrs as $key => $val){
+        if (is_array($val) && count($val) == 0){
+          continue;
+        }
+        $attrs[$key]= $val;
+      }
+      $this->attrs= $attrs;
+    }
+
+    /* Set ntpServers */
+    $this->attrs['gotoNtpServer'] = array();
+    if(!$this->inheritTimeServer){
+      foreach($this->gotoNtpServer as $server){
+        $this->attrs['gotoNtpServer'][] = $server;
+      }
+    }
+
+    /* Append gosaAdministrativeUnitTag to objectClass if gosaUnitTag isset */
+    if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
+      $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    if ($this->orig_dn == 'new'){
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
+      $ldap->cd($this->dn);
+      if (!count($this->attrs['gotoNtpServer'])){
+        unset($this->attrs['gotoNtpServer']);
+      }
+      $ldap->add($this->attrs);
+      new log("create","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+    } else {
+      $ldap->cd($this->dn);
+      $this->cleanup();
+      $ldap->modify ($this->attrs); 
+      new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+    }
+    
+    /* cn=default and macAddress=- indicates that this is a template */
+    if($this->cn == "default"){
+      $this->netConfigDNS->macAddress = "-";
+    }
+
+    $this->netConfigDNS->cn = $this->cn;
+    $this->netConfigDNS->save();
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn));
+  }
+
+
+
+
+
+  /* Display generic part for server copy & paste */
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("object","terminal");
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    if(isset($source['macAddress'][0])){
+      $this->netConfigDNS->macAddress = $source['macAddress'][0];
+    }
+    if(isset($source['ipHostNumber'][0])){
+      $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
+    }
+
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+    if(isset($source['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($source['gotoNtpServer']['count']);
+      foreach($source['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+  }
+
+
+  /* Return plugin informations for acl handling */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Terminal"),
+          "plDescription" => _("Terminal generic"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 1,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("terminal" => array( "description"  => _("Terminal"),
+                                                        "objectClass"  => "gotoTerminal")),
+          "plProvidedAcls"=> array(
+            "gotoMode"            => _("Mode"),
+            "gotoTerminalPath"    => _("Root server"),
+            "gotoSwapServer"      => _("Swap server"),
+            "gotoSyslogServer"    => _("Syslog server enabled"),
+            "gotoNtpServer"       => _("Ntp server settings"),
+            "base"                => _("Base"),
+            "cn"                  => _("Name"),
+            "gotoRootPasswd"      => _("Root password"),
+            "FAIstate"            => _("Action flag"))
+          ));
+  }
+
+
+  function set_everything_to_inherited()
+  {
+    $this->gotoTerminalPath  = "default";
+    $this->gotoSwapServer    = "default" ;
+    $this->gotoSyslogServer  = "default";
+    $this->inheritTimeServer = TRUE;
+
+    /* Set workstation service attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['termservice'])){
+      foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant",
+            "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
+        $this->parent->by_object['termservice']->$name = "default";
+      }
+    }
+
+    /* Set workstation startup attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['termstartup'])){
+      $this->parent->by_object['termstartup']->gotoBootKernel = "default-inherited";
+      $this->parent->by_object['termstartup']->gotoLdapServer = "default-inherited";
+    }
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalInfo.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalInfo.inc
new file mode 100644 (file)
index 0000000..0a21884
--- /dev/null
@@ -0,0 +1,255 @@
+<?php
+
+class terminfo extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Retrieve informations about terminals";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Generic terminal attributes */
+  var $ghCpuType= "-";
+  var $ghMemSize= "-";
+  var $macAddress= "-";
+  var $ghUsbSupport= "-";
+  var $ghNetNic= array();
+  var $ghIdeDev= array();
+  var $ghScsiDev= array();
+  var $ghGfxAdapter= "-";
+  var $ghSoundAdapter= "-";
+  var $ghInventoryNumber= "-";
+  var $gotoLastUser= "-";
+  var $gotoFloppyEnable= "";
+  var $gotoCdromEnable= "";
+
+  /* Needed values and lists */
+  var $base= "";
+  var $cn= "";
+  var $view_logged = FALSE;
+
+  /* attribute list for save action */
+  var $ignore_account= TRUE;
+  var $attributes= array("cn", "gotoMode", "gotoTerminalPath", "gotoFloppyEnable",
+      "gotoCdromEnable", "ghInventoryNumber",
+      "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer",
+      "ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport",
+      "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser");
+  var $objectclasses= array("GOhard");
+
+  function terminfo (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin ($config,$dn);
+
+    /* Read arrays */
+    foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
+      if (!isset($this->attrs[$val])){
+        continue;
+      }
+      for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
+        array_push($this->$val, $this->attrs[$val][$i]);
+      }
+    }
+
+    /* Fix USB entry */
+    if ($this->ghUsbSupport == "true"){
+      $this->ghUsbSupport= _("present");
+    }
+  }
+
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","terminal/".get_class($this),$this->dn);
+    }
+
+    /* Do we represent a valid terminal? */
+    if (!$this->is_account && $this->parent === NULL){
+      echo "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+        _("This 'dn' has no terminal features.")."</b>";
+      return;
+    }
+
+    $smarty= get_smarty();
+    $display= "";
+    if(!is_callable("snmpget")){
+      print_red(_("There is no php snmp module installed, can't gather any informations."));
+
+      $smarty->assign("load", progressbar(0,100,15,true));
+      $smarty->assign("mem", progressbar(0,100,15,true));
+      $smarty->assign("swap", progressbar(0,100,15,true));
+      foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd","status","ghNetNic", "ghIdeDev", "ghScsiDev","FloppyDevice", "CdromDevice","active") as $val){
+        $smarty->assign("$val", "<i>"._("unknown status")."</i>");
+      }
+
+
+      $display ="";
+    }else
+      /* Default entry? */
+      if ($this->cn == "default"){
+        $display= "<div style='height:150px;'><br><b>";
+        $display.= _("This is a virtual terminal which has no properties to show here.");
+        $display.= "</b></div>";
+      } else {
+
+        /* Get template object */
+        $smarty->assign("staticAddress", "");
+
+        /* Prevent undefined variable .... */ 
+        $smarty->assign("load", progressbar(0,100,15,true));
+        $smarty->assign("mem", progressbar(0,100,15,true));
+        $smarty->assign("swap", progressbar(0,100,15,true));
+
+        /* Check if terminal is online */
+        $query= "fping -q -r 1 -t 500 ".$this->cn;
+        exec ($query, $dummy, $retval);
+
+        if ($retval == 0){
+          $smarty->assign("status", _("online"));
+          $smarty->assign("active", "true");
+
+          /* Fill data if we have snmp */
+          $host= $this->cn;
+
+          /* Use 'goto' as snmp community or the configured value from the config */
+          $community= 'goto';
+          $str = search_config($this->config->data['TABS'],"terminfo","SNMPCOMMUNITY");
+          if(!empty($str)){
+            $community = $str;
+          }
+
+          /* Get memory informations */
+          if(!is_callable("snmpget")){
+            $MemFree = false;
+          }else{
+            $MemFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailReal.0");
+          }
+          if ($MemFree != FALSE){
+            $MemFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemFree);
+            $MemTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalReal.0");
+            $MemTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $MemTotal);
+            if ($MemTotal != 0){
+              $smarty->assign("mem",progressbar( (int)(($MemTotal - $MemFree)*100/$MemTotal),100,15,true));
+              ;
+            }
+            $SwapFree= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memAvailSwap.0");
+            $SwapFree= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapFree);
+            $SwapTotal= @snmpget($host, $community, "UCD-SNMP-MIB::memory.memTotalSwap.0");
+            $SwapTotal= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $SwapTotal);
+            if ($SwapTotal != 0){
+#$smarty->assign("swap", (int)(($SwapTotal - $SwapFree)*100/$SwapTotal));
+              $smarty->assign("swap", progressbar(0,100,15,true));
+            }
+
+            /* Get system uptime */
+            $sysup= @snmpget($host, $community, "SNMPv2-MIB::sysUpTime.0");
+            $smarty->assign("uptime", preg_replace('/^.* ([0-9:]+)\..*$/', '\\1', $sysup));
+
+            /* Get system load */
+            $sysload= @snmpget($host, $community, "UCD-SNMP-MIB::laLoad.2");
+            $sysload= preg_replace('/^.*[=:] ([0-9.]+)$/', '\\1', $sysload);
+
+            $smarty->assign("load", progressbar($sysload*100,100,15,true));
+
+            /* Get status for key processes */
+            $processes= @snmpwalk($host, $community, "UCD-SNMP-MIB::prNames");
+            $check4= array("sshd", "cupsd", "artsd", "X", "saned");
+            foreach ($check4 as $pname){
+              $eflag= -1;
+              foreach ($processes as $key => $val){
+                $process= preg_replace('/^.*[:=] (.*)$/', '\\1', $val);
+                if ($process == $pname){
+                  $index= preg_replace('/^.*\.([0-9]+) [:=] .*$/', '\\1', $val);
+                  $res= @snmpget($host, $community, "UCD-SNMP-MIB::prErrorFlag.$index");
+                  $eflag= preg_replace('/^.*[:=] /', '', $res);
+                  break;
+                }
+              }
+              switch ($eflag){
+                case 0:
+                  $smarty->assign("$pname", "<img alt=\""._("running")."\" src=\"images/true.png\">");
+                  break;
+                case 1:
+                  $smarty->assign("$pname", "<img alt=\""._("not running")."\" src=\"images/false.png\">");
+                  break;
+                default:
+                  $smarty->assign("$pname", _("not defined"));
+              }
+            }
+          } else {
+            foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){
+              $smarty->assign("$val", "<i>"._("unknown status")."</i>");
+            }
+          }
+          /* Check for mounted partitions (show max 8 partitions) */
+          $partitions= "";
+          for ($n= 1; $n<9; $n++){
+            $device= @snmpget($host, $community, "UCD-SNMP-MIB::dskDevice.$n");
+            if ($device == ""){
+              break;
+            }
+            $device= preg_replace('/^STRING: */', '', $device);
+            $usage= @snmpget($host, $community, "UCD-SNMP-MIB::dskPercent.$n");
+            $usage= preg_replace('/^INTEGER: */', '', $usage);
+            $partitions.= "<tr><td><b>$device</b></td><td>".progressbar($usage,100,16,true)."</td></tr>\n";
+          }
+          $smarty->assign("partitions", $partitions);
+        } else {
+          $smarty->assign("status", _("offline"));
+          $smarty->assign("active", "false");
+        }
+
+        /* Set floppy and cdrom status */
+        foreach(array("Floppy", "Cdrom") as $val){
+          $name= "goto".$val."Enable";
+          if ($this->$name == "YES"){
+            $status= _("present");
+          } else {
+            $status= "-";
+          }
+          $smarty->assign($val."Device", $status);
+        }
+
+        /* Show main page */
+        foreach(array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
+          if (!count($this->$val)){
+            $this->$val= "-";
+          }
+          $smarty->assign($val, $this->$val);
+        }
+      }
+      foreach(array("ghCpuType", "ghMemSize", "macAddress", "ghUsbSupport",
+            "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "ghInventoryNumber") as $val){
+
+        $smarty->assign($val, $this->$val);
+      }
+      $display= $smarty->fetch (get_template_path('info.tpl', TRUE));
+
+    return ($display);
+  }
+
+  function remove_from_parent()
+  {
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    plugin::save_object();
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+  }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc
new file mode 100644 (file)
index 0000000..54e1d86
--- /dev/null
@@ -0,0 +1,527 @@
+<?php
+
+class termservice extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage terminal service aspects";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Generic terminal attributes */
+  var $gotoLpdEnable= FALSE;
+  var $gotoXMonitor= "";
+  var $gotoXMethod= "";
+  var $gotoXdmcpServer= "";
+  var $gotoFontPath= "";
+  var $gotoXDriver= "";
+  var $gotoXResolution= "";
+  var $gotoXColordepth= "";
+  var $gotoXHsync= "";
+  var $gotoXVsync= "";
+  var $gotoXKbModel= "";
+  var $gotoXKbLayout= "";
+  var $gotoXKbVariant= "";
+  var $gotoXMouseType= "";
+  var $gotoXMouseport= "";
+  var $gotoLpdServer= "";
+  var $gotoScannerEnable= "";
+  var $gotoScannerModel= "";
+  var $gotoScannerClients= "";
+  var $gotoScannerBackend= "";
+  var $goFonHardware= "automatic";
+
+  var $AutoSync = false;
+  var $view_logged = FALSE;
+
+  /* Needed values and lists */
+  var $ignore_account= TRUE;
+  var $base= "";
+  var $cn= "";
+  var $orig_dn= "";
+  var $XMethods= array();
+  var $XDrivers= array();
+  var $XResolutions= array();
+  var $XColordepths= array();
+  var $XKbModels= array ();
+  var $XKbLayouts= array ();
+  var $XKbVariants= array ();
+  var $MouseTypes= array();
+  var $MousePorts= array();
+  var $gotoScannerModels= array();
+  var $hardware_list= array();
+  var $used_hardware= array();
+
+
+  /* attribute list for save action */
+  var $attributes= array("cn", "gotoLpdEnable", "gotoXMonitor", "gotoXMethod", "gotoXdmcpServer",
+      "gotoFontPath", "gotoXDriver", "gotoXResolution", "gotoXColordepth",
+      "gotoXHsync", "gotoXVsync", "gotoLpdEnable", "gotoLpdServer",
+      "gotoScannerEnable", "gotoScannerModel", "gotoScannerClients",
+      "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant",
+      "gotoXMouseType", "gotoXMouseport", "goFonHardware");
+  var $objectclasses= array("GOhard");
+
+
+  function termservice (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin ($config, $dn, $parent);
+   
+    /* Get list of available xdrivers */
+    $this->XDrivers = $this->getListOfXDrivers();
+    array_unshift($this->XDrivers, "["._("unknown")."]");
+    
+    $this->XResolutions= array(
+        "default"   =>  "["._("inherited")."]"  ,
+        "640x480"   =>  "640x480",
+        "800x600"   =>  "800x600",
+        "1024x768"  =>  "1024x768",
+        "1152x864"  =>  "1152x864",
+        "1280x1024" =>  "1280x1024",
+        "1400x1050" =>  "1400x1050",
+        "1600x1200" =>  "1600x1200");
+
+    if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){
+      $file = $this->config->data['MAIN']['RESOLUTION_HOOK'];
+
+      if(is_readable($file)){
+        $str = file_get_contents($file);
+        $lines = split("\n",$str);
+        foreach($lines as $line){
+          $line = trim($line);
+          if(!empty($line)){
+            $this->XResolutions[$line]=$line;
+          }
+        }
+        //natcasesort($this->gotoXResolutions);
+      }else{
+        print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file));
+      }
+    }
+
+    $this->XColordepths= array(
+        "default"  => "["._("inherited")."]",
+        "8"        => "8 " ._("bit"),
+        "15"       => "15 "._("bit"),
+        "16"       => "16 "._("bit"),
+        "24"       => "24 "._("bit"));
+
+    $this->XKbModels['default']= "["._("inherited")."]";
+    foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex",
+          "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless",
+          "logiinetnav", "logiinternet", "macintosh", "microsoft",
+          "microsoftpro", "omnikey101", "pc101", "pc102", "pc104",
+          "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){
+      $this->XKbModels[$type] = $type;
+    }
+
+    /* Additional values will be extracted from CONFIG_DIR.keyboardLayouts */
+    $this->XKbLayouts= array ("default"=>"["._("inherited")."]","de"=> "de","intl" =>"intl","us" =>"us");
+    $this->XKbVariants= array ("default"=>"["._("inherited")."]", "nodeadkeys"=>"nodeadkeys", "basic"=>"basic");
+
+    $this->MouseTypes= array( "AUTO"      =>  "["._("inherited")."]" ,  "ImPS/2"      => "ImPS/2", 
+                              "PS/2"      =>  "PS/2"                 ,  "Microsoft"   => "Microsoft", 
+                              "Logitech"  =>  "Logitech");
+
+    $this->MousePorts= array("AUTO"             =>"["._("inherited")."]"   , "/dev/ttyS0"  => "/dev/ttyS0", 
+                             "/dev/ttyS1"       => "/dev/ttyS1"            , "/dev/psaux"  => "/dev/psaux", 
+                             "/dev/input/mice"  =>"/dev/input/mice");
+
+    /* try to read additional keyboard layouts
+     */
+    if(file_exists(CONFIG_DIR."/keyboardLayouts")){
+      if(is_readable(CONFIG_DIR."/keyboardLayouts")){
+        $str = file_get_contents(CONFIG_DIR."/keyboardLayouts");
+        $tmp = split("\n",$str);
+        foreach($tmp as $entry){
+          if((!empty($entry)) && (!preg_match("/^#/",$entry))){
+            $entry = trim($entry);
+            $tmp2 = split ("\:",$entry);
+            $la =   trim($tmp2[0]);   // What would be saved to ldap
+            $da =   trim($tmp2[1]);   // This wis displayed in the listbox
+            $this->XKbLayouts [ $la] = $da;
+          }
+        }
+      }
+    }
+
+    /* Load scanner models */
+    $fcontents = file (CONFIG_DIR."/scanner-list");
+    while (list ($line_num, $line) = each ($fcontents)) {
+      preg_match('/^(\w+) "([^"]+)" "([^"]+)" "([^"]+)"/', "$line", $matches);
+      $this->gotoScannerModels[$matches[2]." - ".$matches[3]]= $matches[1]."|".$matches[4];
+    }
+    ksort ($this->gotoScannerModels);
+
+    /* Initialize methods */
+    $this->XMethods["default"]= _("default");
+    $this->XMethods["indirect"]= _("show chooser");
+    $this->XMethods["query"]= _("direct");
+#$this->XMethods["squery"]= _("direct via ssh");
+#$this->XMethods["nquery"]= _("direct via nx");
+    $this->XMethods["load"]= _("load balanced");
+#$this->XMethods["sload"]= _("load balanced via ssh");
+#$this->XMethods["nload"]= _("load balanced via nx");
+    $this->XMethods["rdp"]= _("Windows RDP");
+    $this->XMethods["citrix"]= _("ICA client");
+
+    $this->orig_dn= $this->dn;
+
+    /* Load hardware list */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(objectClass=goFonHardware)", array('cn', 'description'));
+    while ($attrs= $ldap->fetch()){
+      $cn= $attrs['cn'][0];
+      if (isset($attrs['description'])){
+        $description= " - ".$attrs['description'][0];
+      } else {
+        $description= "";
+      }
+      $this->hardware_list[$cn]= "$cn$description";
+    }
+
+    /* Eventually colorize phones */
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware'));
+    while($attrs = $ldap->fetch()){
+        $cn = $attrs['goFonHardware'][0];
+        if(isset($this->hardware_list[$cn])){
+          $this->used_hardware[$cn]= $cn;
+        }
+    }
+
+    $this->hardware_list["automatic"]= _("automatic");
+    ksort($this->hardware_list);
+
+    /* Convert gotoLpdEnable */
+    $this->gotoLpdEnable= preg_match("/yes/i",$this->gotoLpdEnable);
+
+    /* Load hardware list */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
+    if ($ldap->count() == 1){
+      $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
+                  "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport");
+      $attrs= $ldap->fetch();
+
+      foreach ($map as $name){
+        if (!isset($attrs[$name][0])){
+          continue;
+        }
+
+        switch ($name){
+          case 'gotoXResolution':
+            $this->XResolutions['default'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+          case 'gotoXColordepth':
+            $this->XColordepths['default'] =  _("inherited").' ['.$attrs[$name][0].' '._('Bit').']';
+            break;
+          case 'gotoXKbModel':
+            $this->XKbModels['default'] =  _("inherited").' ['.$attrs[$name][0].']';
+            break;
+          case 'gotoXKbLayout':
+            $this->XKbLayouts['default'] =  _("inherited").' ['.$attrs[$name][0].']';
+            break;
+          case 'gotoXKbVariant':
+            $this->XKbVariants['default'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+          case 'gotoXMouseType':
+            $this->MouseTypes['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+          case 'gotoXMouseport':
+            $this->MousePorts['AUTO'] = _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+        }
+      }
+    }
+    if(preg_match("/\+/",$this->gotoXHsync)){
+      $this->AutoSync = true;
+      $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync);
+      $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync);
+    }
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","terminal/".get_class($this),$this->dn);
+    }
+
+    /* Do we need to flip is_account state? */
+    if (isset($_POST['modify_state'])){
+      $this->is_account= !$this->is_account;
+    }
+
+    /* Do we represent a valid terminal? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+        _("This 'dn' has no terminal features.")."</b>";
+      return ($display);
+    }
+
+    /* Show main page */
+    $smarty= get_smarty();
+
+    /* Assign acls */
+    $tmp= $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+
+    /* Arrays */ 
+    foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths",
+          "gotoScannerModels", "XKbModels","XKbVariants",
+          "MouseTypes", "MousePorts") as $val){
+      $smarty->assign("$val", $this->$val);
+    }
+    $smarty->assign("XKbLayouts",   $this->XKbLayouts);
+    $smarty->assign("XKbLayoutKeys",array_flip($this->XKbLayouts));
+  
+    $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']);
+    $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']);
+    $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
+    $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
+
+    /* Variables - select */
+    foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath", 
+          "gotoXDriver", "gotoXResolution", "gotoXColordepth", 
+          "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout",
+          "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){
+
+      $smarty->assign($val."_select", $this->$val);
+    }
+
+    /* Variables */
+    foreach(array("gotoXHsync", "gotoXVsync") as $val){
+      $smarty->assign($val, $this->$val);
+    }
+    $smarty->assign("staticAddress", "");
+
+    /* Checkboxes */
+    foreach(array("gotoLpdEnable", "gotoScannerEnable") as $val){
+      if ($this->$val == TRUE) {
+        $smarty->assign("$val", "checked");
+      } else {
+        $smarty->assign("$val", "");
+      }
+    }
+
+    /* Phone stuff */
+    $smarty->assign ("goFonHardware", $this->goFonHardware);
+    $hl= "<select size=\"1\" name=\"goFonHardware\" title=\"".
+         _("Choose the phone located at the current terminal")."\" >\n";
+    foreach ($this->hardware_list as $cn => $description){
+      if ($cn == $this->goFonHardware){
+        $selected= "selected";
+      } else {
+        $selected= "";
+      }
+      if (isset($this->used_hardware[$cn])){
+        $color= "style=\"color:#A0A0A0\"";
+      } else {
+        $color= "";
+      }
+      $hl.= "  <option $color label=\"$cn\" value=\"$cn\" $selected>$description</option>\n";
+    }
+    $hl.= "</select>\n";
+    $smarty->assign ("hardware_list", $hl);
+    $smarty->assign ("gotoXMonitor", $this->gotoXMonitor);
+
+    $smarty->assign("AutoSyncACL",$this->getacl("AutoSync"));
+
+    $smarty->assign("AutoSyncCHK"," ");
+    if($this->AutoSync){
+      $smarty->assign("AutoSyncCHK"," checked ");
+      $smarty->assign("gotoXVsyncACL", preg_replace("/w/","",$this->getacl("gotoXVsync")));
+      $smarty->assign("gotoXHsyncACL", preg_replace("/w/","",$this->getacl("gotoXHsync")));
+    }
+
+    /* Show main page */
+    return($smarty->fetch (get_template_path('terminalService.tpl', TRUE)));
+  }
+
+  function remove_from_parent()
+  {
+    new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs));
+    $this->handle_post_events("remove");
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    plugin::save_object();
+
+    /* Save checkbox state */
+    if (isset ($_POST['gotoXMethod'])){
+      foreach (array("gotoLpdEnable", "gotoScannerEnable") as $val){
+
+        if($this->acl_is_writeable($val)){
+          if (!isset ($_POST["$val"])){
+            $this->$val= FALSE;
+          } else {
+            $this->$val= TRUE;
+          }
+        }
+      }
+    } 
+
+    if(isset($_POST['gotoXDriver'])){
+      if(isset($_POST['AutoSync'])){
+        $this->AutoSync = true;
+      }else{
+        $this->AutoSync = false;
+      }
+    }
+
+    /* Default entries can use blank hsync/vsync entries */
+    if ($this->dn != "" && $this->cn != "default" && $this->cn != "default"){
+
+      /* But only if no auto sync is enabled... */
+      if (!$this->AutoSync){
+
+        /* Check vsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXVsync);
+        if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXVsync")){
+
+          $message[]= _("Please specify a valid VSync range.");
+        } elseif ($this->acl_is_writeable("gotoXVsync")){
+          list($v1,$v2)= preg_split ("/[-+]/", $val);
+          if ($v2 != ""){
+            if ($v1 > $v2){
+              $message[]= _("Please specify a valid VSync range.");
+            }
+          }
+        }
+
+        /* Check hsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXHsync);
+        if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val) && $this->acl_is_writeable("gotoXHsync")){
+
+          $message[]= _("Please specify a valid HSync range.");
+        } elseif ($this->acl_is_writeable("gotoXHsync")){
+          list($v1,$v2)= preg_split ("/[-+]/", $val);
+          if ($v2 != ""){
+            if ($v1 > $v2){
+              $message[]= _("Please specify a valid HSync range.");
+            }
+          }
+        }
+      }
+    }
+  }
+
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+    return ($message);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Convert to string */
+    $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No";
+
+    plugin::save();
+
+    /* Strip out 'default' values */
+    foreach(array("gotoXMethod", "gotoXdmcpServer", "gotoFontPath",
+          "gotoXDriver", "gotoXResolution", "gotoXColordepth",
+          "gotoLpdServer", "gotoScannerModel", "gotoXKbModel", "gotoXKbLayout",
+          "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){
+
+      if ($this->attrs[$val] == "default"){
+        $this->attrs[$val]= array();
+      }
+    }
+
+    if($this->AutoSync){
+      $this->attrs['gotoXHsync'] = "30+55";
+      $this->attrs['gotoXVsync'] = "50+70";
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+    new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/service with dn '%s' failed."),$this->dn));
+    $this->handle_post_events("modify");
+  }
+
+
+  function getListOfXDrivers()
+  {
+    $drivers = array();
+
+    /* Generate a list of xdrivers from CONFIG_DIR/xdrivers */
+    if (file_exists(CONFIG_DIR.'/xdrivers')){
+      $xdrivers = file (CONFIG_DIR.'/xdrivers');
+      foreach ($xdrivers as $line){
+        if (!preg_match ("/^#/", $line)){
+          $drivers[]= trim($line);
+        }
+      }
+    } else {
+      $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx",
+          "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc",  "nv", "nvidia",
+          "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion",
+          "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware");
+    }
+    return($drivers);
+  }
+
+
+  /* Return plugin informations for acl handling */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Service"),
+          "plDescription" => _("Terminal service"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 3,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("terminal"),
+
+          "plProvidedAcls"=> array(
+            "gotoXMonitor"            => _("Monitor"),
+            "gotoXMethod"             => _("Method"),
+            "gotoXdmcpServer"         => _("Remote desktop"),
+            "gotoFontPath"            => _("Font path"),
+            "gotoXDriver"             => _("Gfx driver"),
+            "gotoXResolution"         => _("Gfx resolution"),
+            "gotoXColordepth"         => _("Gfx color depth"),
+            "gotoXHsync"              => _("Hsync"),
+            "gotoXVsync"              => _("Vsync"),
+            "AutoSync"                => _("Auto-Sync"),
+            "gotoLpdEnable"           => _("Printer service enabled"),
+            "gotoLpdServer"           => _("Spool server"),
+            "gotoScannerEnable"       => _("Scanner enabled"),
+            "gotoScannerModel"        => _("Scanner model"),
+            "gotoXKbModel"            => _("Keyboard model"),
+            "gotoXKbLayout"           => _("Keyboard layout"),
+            "gotoXKbVariant"          => _("Keyboard variant"),
+            "gotoXMouseType"          => _("Mouse type"),
+            "gotoXMouseport"          => _("Mouse port"),
+            "goFonHardware"           => _("Telephone hardware"))
+          ));
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc
new file mode 100644 (file)
index 0000000..362bc7d
--- /dev/null
@@ -0,0 +1,582 @@
+<?php
+class termstartup extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage terminal startup options";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Generic terminal attributes */
+  var $bootmode= "G";
+  var $goLdapServerList= array();
+  var $gotoBootKernel= "default-inherit";
+  var $gotoKernelParameters= "";
+  var $gotoLdapServer= "";
+  var $gotoModules= array();
+  var $gotoTerminalPath= "";
+  var $gotoBootKernels= array();
+
+  /* Ldap server list */
+  var $gotoLdapServers    = array();
+  var $gotoLdapServerList = array();
+  var $gotoLdap_inherit   = FALSE;
+
+  /* Share */
+  var $gotoShares         = array();// Currently Share Option
+  var $gotoShare          = "";     // currently selected Share Option
+  var $gotoShareSelections= array();// Available Shares for this account in Listbox format
+  var $gotoAvailableShares= array();// Available Shares for this account
+
+
+  /* attribute list for save action */
+  var $attributes= array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters","gotoModules");
+  var $objectclasses= array("GOhard");
+  var $view_logged = FALSE;
+
+  /* Helper */
+  var $customParameters= "";
+  var $orig_dn= "";
+  var $ignore_account= TRUE;
+
+  function termstartup (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin ($config, $dn, $parent);
+
+    $this->gotoBootKernels = array("default-inherit"=>"["._("inherited")."]");
+
+    /* Get arrays */
+    foreach (array("gotoModules") as $val){
+      $this->$val = array();
+      if (isset($this->attrs["$val"]["count"])){
+        for ($i= 0; $i<$this->attrs["count"]; $i++){
+          if (isset($this->attrs["$val"][$i])){
+            array_push($this->$val, $this->attrs["$val"][$i]);
+          }
+        }
+      }
+      sort ($this->$val);
+      $this->$val= array_unique($this->$val);
+    }
+
+    /* Parse Kernel Parameters to decide what boot mode is enabled */
+    if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
+      $this->bootmode= "G";
+    } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
+      $this->bootmode= "D";
+    } elseif ($this->gotoKernelParameters == "") {
+      $this->bootmode= "G";
+    } else {
+      $this->bootmode= "T";
+    }
+    if (preg_match("/ o /", $this->gotoKernelParameters)){
+      $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
+    } else {
+      $this->customParameters= "";
+    }
+
+    /* Prepare Shares */
+    if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
+      unset($this->attrs['gotoShare']['count']);
+      foreach($this->attrs['gotoShare'] as $share){
+        $tmp = $tmp2 = array();
+        $tmp = split("\|",$share);
+        $tmp2['server']      =$tmp[0];
+        $tmp2['name']        =$tmp[1];
+        $tmp2['mountPoint']  =$tmp[2];
+        $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
+      }
+    }
+
+    $this->gotoShareSelections= $config->getShareList(true);
+    $this->gotoAvailableShares= $config->getShareList(false);
+
+    $this->orig_dn= $this->dn;
+
+    /* Get list of boot kernels */
+    if (isset($this->config->data['TABS'])){
+      $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
+
+      if (!check_command($command)){
+        $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
+            get_class($this));
+      } else {
+        $fh= popen($command, "r");
+        while (!feof($fh)) {
+          $buffer= trim(fgets($fh, 256));
+          
+          if(!empty($buffer)){
+          
+            $name=$value = $buffer;
+
+            if(preg_match("/:/",$buffer)){
+              $name = preg_replace("/:.*$/","",$buffer);
+              $value= preg_replace("/^.*:/","",$buffer);
+              $this->gotoBootKernels[$name]= $name.":".$value;
+            }else{
+              $this->gotoBootKernels[$name]= $value;
+            }
+          }
+        }
+        pclose($fh);
+      }
+
+    }
+    
+    foreach($this->config->data['SERVERS']['LDAP'] as $server) {
+      $this->gotoLdapServerList[]= $server;
+    }
+    if(isset($this->attrs['gotoLdapServer'])){
+      unset($this->attrs['gotoLdapServer']['count']);
+      sort($this->attrs['gotoLdapServer']);
+      foreach($this->attrs['gotoLdapServer'] as $value){
+        $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
+      }
+    }
+    if(!count($this->gotoLdapServers)){
+      $this->gotoLdap_inherit = TRUE;
+    }
+
+    /* Load hardware list */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
+    if ($ldap->count() == 1){
+      $map= array("gotoLdapServer");
+      $attrs= $ldap->fetch();
+
+      foreach ($map as $name){
+        if (!isset($attrs[$name][0])){
+          continue;
+        }
+
+        switch ($name){
+          case 'gotoLdapServer':
+            $this->goLdapServerList= array_merge(array('default-inherit' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList);
+            break;
+        }
+      }
+    }
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","terminal/".get_class($this),$this->dn);
+    }
+
+    /* Do we need to flip is_account state? */
+    if (isset($_POST['modify_state'])){
+      $this->is_account= !$this->is_account;
+    }
+
+    /* Do we represent a valid terminal? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+        _("This 'dn' has no terminal features.")."</b>";
+      return ($display);
+    }
+
+    /* Add module */
+    if (isset ($_POST['add_module'])){
+      if ($_POST['module'] != "" && $this->acl_is_writeable("gotoMode")){
+        $this->add_list ($this->gotoModules, $_POST['module']);
+      }
+    }
+
+    /* Delete module */
+    if (isset ($_POST['delete_module'])){
+      if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoMode")){
+        $this->del_list ($this->gotoModules, $_POST['modules_list']);
+      }
+    }
+
+    /* Show main page */
+    $smarty= get_smarty();
+
+    /* Assign acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+
+       /* In this section server shares will be defined
+     * A user can select one of the given shares and a mount point
+     *  and attach this combination to his setup.
+     */
+    $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
+    $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
+    $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
+
+    /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
+     * This entry will be, a combination of mountPoint and sharedefinitions
+     */
+    if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){
+      /* We assign a share to this user, if we don't know where to mount the share */
+      if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
+        print_red(_("You must specify a valid mount point."));
+      }else{
+        $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
+        $s_mount = $_POST['gotoShareMountPoint'];
+        /* Preparing the new assignment */
+        $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
+        $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
+      }
+    }
+
+    /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
+     * If there is no defined share selected, we will abort the deletion without any message
+     */
+    if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare'])) && $this->acl_is_writeable("gotoShare")){
+      unset($this->gotoShares[$_POST['gotoShare']]);
+    }
+
+    $smarty->assign("gotoShares",$this->printOutAssignedShares());
+    $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
+
+    /* Create divSelectBox for ldap server selection
+     */
+    $SelectBoxLdapServer = new divSelectBox("LdapServer");
+    $SelectBoxLdapServer->SetHeight(80);
+
+ /* Add new ldap server to the list */
+    if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){
+      if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){
+        $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']];
+        if(!in_array($to_add,$this->gotoLdapServers)){
+          $this->gotoLdapServers[] = $to_add;
+        }
+      }
+    }
+
+    /* Move ldap servers up and down */
+    if(!$this->gotoLdap_inherit){
+      foreach($_POST as $name => $value){
+        if(preg_match("/sort_ldap_up_/",$name)){
+          $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name);
+          $from =  $id;
+          $to   =  $id -1;
+          $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
+          if($tmp){
+            $this->gotoLdapServers = $tmp;
+          }
+          break;
+        }
+        if(preg_match("/sort_ldap_down_/",$name)){
+          $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name);
+          $from =  $id;
+          $to   =  $id +1;
+          $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
+          if($tmp){
+            $this->gotoLdapServers = $tmp;
+          }
+          break;
+        }
+        if(preg_match("/gotoLdapRemove_/",$name)){
+          $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name);
+          $value = $this->gotoLdapServers[$id];
+          $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
+          break;
+        }
+      }
+    }
+  /* Add Entries
+     */
+    foreach($this->gotoLdapServers as $key => $server){
+      if(!in_array($server,$this->gotoLdapServerList)){
+        $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
+      }
+
+      $SelectBoxLdapServer->AddEntry(
+          array(array("string" => $server),
+            array("string" =>
+              "<input class='center' type='image' src='images/sort_up.png' name='sort_ldap_up_".$key."'>&nbsp;".
+              "<input class='center' type='image' src='images/sort_down.png' name='sort_ldap_down_".$key."'>&nbsp;".
+              "<input class='center' type='image' src='images/edittrash.png' name='gotoLdapRemove_".$key."'>",
+              "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
+    }
+
+    if($this->gotoLdap_inherit){
+      $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));;
+    }else{
+      $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer"));
+    }
+
+    $list = array();
+    foreach($this->gotoLdapServerList as $key => $entry){
+      if(!in_array($entry,$this->gotoLdapServers)){
+        $list[$key] = $entry;
+      }
+    }
+    $smarty->assign("gotoLdapServers",    $SelectBoxLdapServer->DrawList());
+    $smarty->assign("gotoLdapServerList", $list);
+    $smarty->assign("gotoLdap_inherit",   $this->gotoLdap_inherit);
+    $smarty->assign("JS",  session::get('js'));
+
+    foreach (array("gotoModules" ) as $val){
+      $smarty->assign("$val", $this->$val);
+    }
+
+    /* Values */
+    foreach(array("gotoBootKernel", "customParameters") as $val){
+      $smarty->assign($val, $this->$val);
+    }
+
+    /* Radio button group */
+    if (preg_match("/G/", $this->bootmode)) {
+      $smarty->assign("graphicalbootup", "checked");
+    } else {
+      $smarty->assign("graphicalbootup", "");
+    }
+    if (preg_match("/T/", $this->bootmode)) {
+      $smarty->assign("textbootup", "checked");
+    } else {
+      $smarty->assign("textbootup", "");
+    }
+    if (preg_match("/D/", $this->bootmode)) {
+      $smarty->assign("debugbootup", "checked");
+    } else {
+      $smarty->assign("debugbootup", "");
+    }
+
+    /* Show main page */
+    return($smarty->fetch (get_template_path('terminalStartup.tpl', TRUE)));
+  }
+
+  function remove_from_parent()
+  {
+    if($this->acl_is_removeable()){
+      $this->handle_post_events("remove");
+      new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs));
+    }
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    plugin::save_object();
+
+    if(isset($_POST['TerminalStarttabPosted'])){
+      if(isset($_POST['gotoLdap_inherit'])){
+        $this->gotoLdap_inherit = TRUE;
+      }else{
+        $this->gotoLdap_inherit = FALSE;
+      }
+
+      /* Save group radio buttons */
+      if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
+        $this->bootmode= $_POST["bootmode"];
+      }
+
+      /* Save kernel parameters */
+      if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){
+        $this->customParameters= $_POST["customParameters"];
+      }
+    }
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Find proper terminal path for tftp configuration
+       FIXME: This is suboptimal when the default has changed to
+       another location! */
+    if ($this->gotoTerminalPath == "default-inherit"){
+      $ldap= $this->config->get_ldap_link();
+
+      /* Strip relevant part from dn, keep trailing ',' */
+      $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalou')."/i", "", $this->dn);
+      $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
+
+      /* Walk from top to base and try to load default values for
+         'gotoTerminalPath'. Abort when an entry is found. */
+      while (TRUE){
+        $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
+
+        $ldap->cat("cn=default,".get_ou('terminalou').$tmp.
+            $this->config->current['BASE'], array('gotoTerminalPath'));
+        $attrs= $ldap->fetch();
+        if (isset($attrs['gotoTerminalPath'])){
+          $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
+          break;
+        }
+
+        /* Nothing left? */
+        if ($tmp == ""){
+          break;
+        }
+      }
+    }
+    
+    /* Add semi automatic values */
+    // FIXME: LDAP Server may not be set here...
+    $this->gotoKernelParameters= "root=/dev/nfs nfsroot=".
+      $this->gotoTerminalPath.
+      ",ro,hard,nolock,fg,rsize=8192 ".
+      "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer);
+
+    switch ($this->bootmode){
+      case "D":
+        $this->gotoKernelParameters.= " debug";
+      break;
+      case "G":
+        $this->gotoKernelParameters.= " splash=silent";
+      break;
+    }
+    if ($this->customParameters != ""){
+      $this->gotoKernelParameters.= " o ".$this->customParameters;
+    }
+
+    plugin::save();
+
+    /* Add missing arrays */
+    foreach (array("gotoModules") as $val){
+      if (isset ($this->$val) && count ($this->$val) != 0){
+    
+        $this->attrs["$val"]= array_unique($this->$val);
+      }
+      if(!isset($this->attrs["$val"])){
+       $this->attrs["$val"]=array();
+      }
+    }
+
+    /* Prepare list of ldap servers */
+    $this->attrs['gotoLdapServer'] = array();
+    if(!$this->gotoLdap_inherit){
+      $i = 0;
+      foreach($this->gotoLdapServers as $server){
+        $i ++;
+        $this->attrs['gotoLdapServer'][] = $i.":".$server;
+      }
+    }
+
+    /* Strip out 'default' values */
+    foreach(array("gotoBootKernel") as $value){
+      if (!isset($this->attrs[$value]) || $this->attrs[$value] == "default-inherit"){
+        $this->attrs[$value] = array();
+      } 
+    }
+
+     /* prepare share settings */
+    $tmp = array();
+    foreach($this->gotoShares as $name => $settings){
+      $tmp2 = split("\|",$name);
+      $name = $tmp2[0];
+      $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
+    }
+    $this->attrs['gotoShare']=$tmp;
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/startup with dn '%s' failed."),$this->dn));
+    $this->handle_post_events("modify");
+  }
+
+  /* Add value to array, check if unique */
+  function add_list (&$array, $value)
+  {
+    if ($value != ""){
+      $array[]= $value;
+      sort($array);
+      array_unique ($array);
+    }
+  }
+
+
+  /* Delete value to array, check if unique */
+  function del_list (&$array, $list)
+  {
+    $tmp= array();
+    foreach ($array as $mod){
+      if (!in_array($mod, $list)){
+        $tmp[]= $mod;
+      }
+    }
+    $array= $tmp;
+  }
+
+   /* Generate ListBox frindly output for the defined shares
+   * Possibly Add or remove an attribute here,
+   */
+  function printOutAssignedShares()
+  {
+    $a_return = array();
+    if(is_array($this->gotoShares)){
+      foreach($this->gotoShares as $share){
+        $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
+      }
+    }
+    return($a_return);
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+
+    $source_o = new termstartup ($this->config, $source['dn']);
+
+    foreach(array("gotoModules", "gotoKernelParameters","gotoShares","customParameters","bootmode","gotoTerminalPath","gotoShares","goLdapServerList","gotoBootKernel","gotoLdapServer","gotoBootKernels") as $attr){
+      $this->$attr = $source_o->$attr;
+    }
+  }
+
+
+  function array_switch_item($ar,$from,$to)
+  {
+    if(!is_array($ar)){
+      return(false);
+    }
+    if(!isset($ar[$from])){
+      return(false);
+    }
+    if(!isset($ar[$to])){
+      return(false);
+    }
+
+    $tmp = $ar[$from];
+    $ar[$from] = $ar[$to];
+    $ar[$to] = $tmp;
+    return($ar);
+  }
+
+
+  /* Return plugin informations for acl handling */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Startup"),
+          "plDescription" => _("Terminal startup"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 5,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("terminal"),
+
+          "plProvidedAcls"=> array(
+            "gotoLdapServer"      => _("Ldap server"),
+            "gotoShare"           => _("Shares"),
+            "gotoModules"         => _("Kernel modules"),
+            "gotoBootKernel"      => _("Boot kernel"), 
+            "gotoKernelParameters"=> _("Kernel parameter"))
+          ));
+  }
+
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc
new file mode 100644 (file)
index 0000000..0f0f97a
--- /dev/null
@@ -0,0 +1,663 @@
+<?php
+
+class workgeneric extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage workstation base objects";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Generic terminal attributes */
+  var $gotoMode= "locked";
+  var $gotoSyslogServer= "";
+  var $gotoSyslogServers= array();
+  var $gotoNtpServer= array();
+  var $gotoNtpServers= array();
+  var $gotoSndModule= "";
+  var $gotoFloppyEnable= "";
+  var $gotoCdromEnable= "";
+  var $ghCpuType= "-";
+  var $ghMemSize= "-";
+  var $ghUsbSupport= "-";
+  var $ghNetNic= array();
+  var $ghIdeDev= array();
+  var $ghScsiDev= array();
+  var $ghGfxAdapter= "-";
+  var $ghSoundAdapter= "-";
+  var $gotoLastUser= "-";
+  var $FAIscript= "";
+  var $didAction= FALSE;
+  var $FAIstate= "";
+  var $view_logged = FALSE;
+
+  /* Needed values and lists */
+  var $base= "";
+  var $cn= "";
+  var $l= "";
+  var $orig_dn= "";
+
+  /* Plugin side filled */
+  var $modes= array();
+
+  var $netConfigDNS;
+
+  var $inheritTimeServer = true;
+
+  /* attribute list for save action */
+  var $ignore_account= TRUE;
+  var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer",
+      "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
+      "ghCpuType", "ghMemSize", "ghUsbSupport",
+      "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript");
+  var $objectclasses= array("top", "gotoWorkstation", "GOhard");
+
+  var $mapActions   = array("reboot"          => "",
+                            "localboot"       => "localboot",
+                            "halt"            => "",
+                            "instant_update"  => "softupdate",
+                            "update"          => "scheduledupdate",
+                            "reinstall"       => "install",
+                            "rescan"          => "",
+                            "memcheck"        => "memcheck",
+                            "sysinfo"         => "sysinfo");
+
+  
+  var $fai_activated = FALSE;
+
+  var $member_of_ogroup = FALSE;
+
+  function workgeneric (&$config, $dn= NULL, $parent= NULL)
+  {
+    $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)){
+      $this->fai_activated = TRUE;
+    }
+
+    plugin::plugin ($config, $dn, $parent);
+
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
+      $this->member_of_ogroup = $ldap->count() >= 1;
+    }
+
+    $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
+
+    /* Read arrays */
+    foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
+      if (!isset($this->attrs[$val])){
+        continue;
+      }
+      for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
+        array_push($this->$val, $this->attrs[$val][$i]);
+      }
+    }
+
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+    if(isset($this->attrs['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($this->attrs['gotoNtpServer']['count']);
+      foreach($this->attrs['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+
+    /* You can't inherit the NTP service, if we are not member in an object group */
+    if(!$this->member_of_ogroup){
+      $this->inheritTimeServer = FALSE;
+    }
+
+    /* Create available ntp options */
+    $tmp = $this->config->data['SERVERS']['NTP'];
+    $this->gotoNtpServers = array();
+    foreach($tmp as $key => $server){
+      if($server == "default") continue;
+      $this->gotoNtpServers[$server] = $server;
+    }
+
+    $this->modes["active"]= _("Activated");
+    $this->modes["locked"]= _("Locked");
+
+    /* Set base */
+    if ($this->dn == "new"){
+      $ui= get_userinfo();
+      $this->base= dn2base($ui->dn);
+    } else {
+      $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+    }
+
+    /* Create an array of all Syslog servers */
+    $tmp = $this->config->data['SERVERS']['SYSLOG'];
+    foreach($tmp as $server){
+      $visible = $server;
+      if($server == "default" && $this->member_of_ogroup) {
+        $visible = "["._("inherited")."]";
+      }
+      $this->gotoSyslogServers[$server] = $visible;
+    }
+
+    /* Save 'dn' for later referal */
+    $this->orig_dn= $this->dn;
+  }
+
+
+  function set_acl_base($base)
+  {
+    plugin::set_acl_base($base);
+    $this->netConfigDNS->set_acl_base($base);
+  }
+
+  function set_acl_category($cat)
+  {
+    plugin::set_acl_category($cat);
+    $this->netConfigDNS->set_acl_category($cat);
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","workstation/".get_class($this),$this->dn);
+    }
+
+    /* Do we need to flip is_account state? */
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }
+
+    if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate"))){
+      $cmd= $this->config->search("workgeneric", "ACTIONCMD",array('tabs'));
+      if ($cmd == ""){
+        print_red(_("No ACTIONCMD definition found in your gosa.conf"));
+      } else {
+        exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval);
+        if ($retval != 0){
+          print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+        } elseif ($_POST['saction'] != "wake") {
+
+          /* Set FAIstate */
+          if($this->fai_activated && $this->dn != "new"){
+            $ldap = $this->config->get_ldap_link();
+            $ldap->cd($this->config->current['BASE']);
+            $ldap->cat($this->dn,array("objectClass"));
+            $res = $ldap->fetch();
+
+            $attrs = array();
+            $attrs['FAIstate'] = $this->FAIstate;
+            if(isset($this->mapActions[$_POST['saction']]) && $this->mapActions[$_POST['saction']] != ""){
+              $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
+            }
+
+            for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
+              $attrs['objectClass'][] = $res['objectClass'][$i];
+            }
+
+            if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+              $attrs['objectClass'][] = "FAIobject";
+            }
+
+            if($attrs['FAIstate'] == ""){
+#FIXME we should check if FAIobject is not used anymore
+              $attrs['FAIstate'] = array();
+            }
+
+            $ldap->cd($this->dn);
+            $ldap->modify($attrs);
+            show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$this->dn));
+
+          }
+          $this->didAction= TRUE;
+        }
+      }
+    }
+
+    /* Do we represent a valid terminal? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+        _("This 'dn' has no workstation features.")."</b>";
+      return($display);
+    }
+
+    /* Base select dialog */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){
+        $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()){
+
+        /* A new base was selected, check if it is a valid one */
+        $tmp = $this->get_allowed_bases();
+        if(isset($tmp[$this->dialog->isSelected()])){
+          $this->base = $this->dialog->isSelected();
+        }
+
+        $this->dialog= false;
+      }else{
+        return($this->dialog->execute());
+      }
+    }
+
+    /* Add new ntp Server to our list */ 
+    if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
+      $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
+    }
+
+    /* Delete selected NtpServer for list of used servers  */
+    if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
+      foreach($_POST['gotoNtpServerSelected'] as $name){
+        unset($this->gotoNtpServer[$name]);
+      }
+    }
+
+    /* Fill templating stuff */
+    $smarty= get_smarty();
+
+    /* Set acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    $smarty->assign("cn", $this->cn);
+    $smarty->assign("l", $this->l);
+    $smarty->assign("bases", $this->get_allowed_bases());
+    $smarty->assign("staticAddress", "");
+
+    $tmp = array();
+    foreach($this->gotoNtpServers as $server){
+      if(!in_array($server,$this->gotoNtpServer)){
+        $tmp[$server] = $server;
+      }
+    }
+    $smarty->assign("gotoNtpServers",$tmp);
+        
+    /* Check if workstation is online */
+    $query= "fping -q -r 1 -t 500 ".$this->cn;
+    exec ($query, $dummy, $retval);
+
+    /* Offline */
+    if ($retval == 0){
+      $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
+                                       "instant_update" => _("Instant update"),
+                                       "update" => _("Scheduled update"),
+                                       "reinstall" => _("Reinstall"),
+                                       "rescan" => _("Rescan hardware"),
+                                       "memcheck" => _("Memory test"),
+                                       "localboot" => _("Force localboot"),
+                                       "sysinfo"  => _("System analysis")));
+    } else {
+      $smarty->assign("actions", array("wake" => _("Wake up"),
+                                       "reinstall" => _("Reinstall"),
+                                       "update" => _("Scheduled update"),
+                                       "memcheck" => _("Memory test"),
+                                       "localboot" => _("Force localboot"),
+                                       "sysinfo"  => _("System analysis")));
+    }
+    /* Arrays */
+    $smarty->assign("modes", $this->modes);
+    $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
+    $smarty->assign("syslogservers", $this->gotoSyslogServers);
+    $smarty->assign("fai_activated",$this->fai_activated);
+
+    $ntpser = array();
+    foreach($this->gotoNtpServers as $server){
+      if(!in_array($server,$this->gotoNtpServer)){
+        $ntpser[$server] = $server;
+      }
+    }
+    $smarty->assign("gotoNtpServers", $ntpser);
+
+    /* Variables */
+    foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
+      $smarty->assign($val."_select", $this->$val);
+    }
+
+    /* tell smarty the inherit checkbox state */
+    $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
+    $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
+
+    $str = $this->netConfigDNS->execute();
+    if(is_object($this->netConfigDNS->dialog)){
+      return($str);
+    }
+    $smarty->assign("netconfig", $str);
+
+    /* Show main page */
+    return($smarty->fetch (get_template_path('workstation.tpl', TRUE)));
+  }
+
+  function remove_from_parent()
+  {
+    if($this->acl_is_removeable()){
+
+      $this->netConfigDNS->remove_from_parent();
+      $ldap= $this->config->get_ldap_link();
+      $ldap->rmdir($this->dn);
+      new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing of system workstation/generic with dn '%s' failed."),$this->dn));
+
+      /* Optionally execute a command after we're done */
+      $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+
+      /* Delete references to object groups */
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
+      while ($ldap->fetch()){
+        $og= new ogroup($this->config, $ldap->getDN());
+        unset($og->member[$this->dn]);
+        $og->save ();
+      }
+    }
+
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+
+    /* Create a base backup and reset the
+       base directly after calling plugin::save_object();
+       Base will be set seperatly a few lines below */
+    $base_tmp = $this->base;
+    plugin::save_object();
+    $this->base = $base_tmp;
+
+    /* Save base, since this is no LDAP attribute */
+    $tmp = $this->get_allowed_bases();
+    if(isset($_POST['base'])){
+      if(isset($tmp[$_POST['base']])){
+        $this->base= $_POST['base'];
+      }
+    }
+
+    $this->netConfigDNS->save_object();
+
+    /* Set inherit mode */
+    if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
+      if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
+        $this->inheritTimeServer = true;
+      }else{
+        $this->inheritTimeServer = false;
+      }
+    }
+    
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
+  }
+
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+  
+    /* Skip IP & Mac checks if this is a template */
+    if($this->cn != "wdefault"){
+      $message= array_merge($message, $this->netConfigDNS->check());
+    }
+
+    $this->dn= "cn=".$this->cn.",".get_ou('workstationou').$this->base;
+
+    if ($this->cn == ""){
+      $message[]= _("The required field 'Workstation name' is not set.");
+    }
+
+    /* Check if given name is a valid host/dns name */
+    if(!tests::is_dns_name($this->cn)){
+      $message[] = _("Please specify a valid name for this object.");
+    }
+
+    if ($this->orig_dn != $this->dn){
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd ($this->base);
+
+      if($this->cn == "wdefault"){
+        $ldap->cat($this->dn);
+      }else{
+        $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
+      }
+      if ($ldap->count() != 0){
+        while ($attrs= $ldap->fetch()){
+          if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".get_ou('incomingou')."/", $ldap->getDN())){
+            continue;
+          } else {
+            if ($attrs['dn'] != $this->orig_dn){
+              $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
+              break;
+            }
+          }
+        }
+      }
+    }
+
+    /* Check for valid ntpServer selection */
+    if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
+      $message[]= _("There must be at least one NTP server selected, or the inherit mode activated.");
+    }
+
+    return ($message);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    plugin::save();
+
+    /* Strip out 'default' values */
+    foreach (array("gotoSyslogServer") as $val){
+
+      if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
+        $this->attrs[$val]= array();
+      }
+    }
+
+    /* Add missing arrays */
+    foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
+      if (isset ($this->$val) && count ($this->$val) != 0){
+        $this->attrs["$val"]= $this->$val;
+      }
+    }
+
+    /* Remove all empty values */
+    if ($this->orig_dn == 'new'){
+      $attrs= array();
+      foreach ($this->attrs as $key => $val){
+        if (is_array($val) && count($val) == 0){
+          continue;
+        }
+        $attrs[$key]= $val;
+      }
+      $this->attrs= $attrs;
+    }
+
+    /* Update ntp server settings */
+    if($this->inheritTimeServer){
+      if($this->is_new){
+        if(isset($this->attrs['gotoNtpServer'])){
+          unset($this->attrs['gotoNtpServer']);
+        }
+      }else{
+        $this->attrs['gotoNtpServer'] = array();
+      }
+    }else{
+      /* Set ntpServers */
+      $this->attrs['gotoNtpServer'] = array();
+      foreach($this->gotoNtpServer as $server){
+        $this->attrs['gotoNtpServer'][] = $server;
+      }
+    }
+
+    if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
+      $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    if ($this->orig_dn == 'new'){
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+      new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn));
+      if(!$this->didAction){
+        $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+      }
+    } else {
+      if ($this->orig_dn != $this->dn){
+        $this->move($this->orig_dn, $this->dn);
+      }
+      $ldap->cd($this->dn);
+      $this->cleanup();
+      $ldap->modify ($this->attrs); 
+      new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+      if(!$this->didAction){
+        $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
+      }
+    }
+
+    /* cn=default and macAddress=- indicates that this is a template */
+    if($this->cn == "wdefault"){
+      $this->netConfigDNS->macAddress = "-";
+    }
+
+    $this->netConfigDNS->cn = $this->cn;
+    $this->netConfigDNS->save();
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn));
+  }
+
+
+  /* Display generic part for server copy & paste */
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("object","workstation");
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    if(isset($source['macAddress'][0])){
+      $this->netConfigDNS->macAddress = $source['macAddress'][0];
+    }
+    if(isset($source['ipHostNumber'][0])){
+      $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
+    }
+
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+    if(isset($source['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($source['gotoNtpServer']['count']);
+      foreach($source['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+  }
+
+
+  /* Return plugin informations for acl handling 
+      #FIXME FAIscript seams to ununsed within this class... */ 
+  static function plInfo()
+  {
+    return (array(  
+          "plShortName"   => _("Generic"),
+          "plDescription" => _("Workstation generic"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("workstation" => array("description"  => _("Workstation"),
+                                                          "objectClass"  => "gotoWorkstation")),
+          "plProvidedAcls"=> array(
+            "cn"                  => _("Workstation name"),
+            "l"                   => _("Location") ,
+            "base"                => _("Base") ,
+            "gotoMode"            => _("Goto mode"), 
+            "gotoSyslogServer"    => _("Syslog server"), 
+            "gotoNtpServer"       => _("Ntp server"), 
+            "gotoRootPasswd"      => _("Root password"),
+            "FAIstate"            => _("Action flag"))
+          ));
+  }
+
+  function set_everything_to_inherited()
+  {
+    $this->gotoSyslogServer  = "default";
+    $this->inheritTimeServer = TRUE;
+
+    /* Set workstation service attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
+      foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant",
+            "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
+        $this->parent->by_object['workservice']->$name = "default"; 
+      }
+    }
+
+    /* Set workstation startup attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
+      $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
+      $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
+      $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
+    }
+  }
+}
+  // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc
new file mode 100644 (file)
index 0000000..815b52c
--- /dev/null
@@ -0,0 +1,506 @@
+<?php
+
+class workservice extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage terminal service aspects";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  var $gotoScannerEnable;
+  /* Generic terminal attributes */
+  var $gotoXMonitor= "";
+  var $gotoXDriver= "";
+  var $gotoXResolution= "";
+  var $gotoXColordepth= "";
+  var $gotoXHsync= "";
+  var $gotoXVsync= "";
+  var $AutoSync = false;
+  var $gotoXKbModel= "";
+  var $gotoXKbLayout= "";
+  var $gotoXKbVariant= "";
+  var $gotoXMouseType= "";
+  var $gotoXMouseport= "";
+  var $gotoScannerClients= "";
+  var $gotoScannerBackend= "";
+  var $goFonHardware= "automatic";
+  var $view_logged = FALSE;
+
+  /* Needed values and lists */
+  var $ignore_account= TRUE;
+  var $base= "";
+  var $cn= "";
+  var $orig_dn= "";
+  var $XMethods= array();
+  var $XDrivers= array();
+  var $XResolutions = array();
+  var $MouseTypes= array();
+  var $MousePorts= array();
+  var $hardware_list= array();
+  var $used_hardware= array();
+
+
+  /* attribute list for save action */
+  var $attributes= array("gotoXMonitor",
+      "gotoXDriver", "gotoXResolution", "gotoXColordepth",
+      "gotoXHsync", "gotoXVsync",
+      "gotoScannerEnable", "gotoScannerClients",
+      "gotoScannerBackend", "gotoXKbModel", "gotoXKbLayout", "gotoXKbVariant",
+      "gotoXMouseType", "gotoXMouseport", "goFonHardware");
+  var $objectclasses= array("GOhard");
+
+  var $XColordepths     =array();
+  var $XKbModels        =array();
+  var $XKbLayouts       =array();
+  var $XKbVariants      =array();
+
+  function workservice (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin ($config, $dn, $parent);
+
+    $this->XResolutions= array( 
+        "640x480"   =>  "640x480",
+        "800x600"   =>  "800x600",
+        "1024x768"  =>  "1024x768",
+        "1152x864"  =>  "1152x864", 
+        "1280x1024" =>  "1280x1024",
+        "1400x1050" =>  "1400x1050", 
+        "1600x1200" =>  "1600x1200");
+
+    if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){
+      $file = $this->config->data['MAIN']['RESOLUTION_HOOK'];
+
+      if(is_readable($file)){
+        $str = file_get_contents($file);
+        $lines = split("\n",$str);
+        foreach($lines as $line){
+          $line = trim($line);
+          if(!empty($line)){
+            $this->XResolutions[$line]=$line;
+          }
+        }
+        //natcasesort($this->gotoXResolutions);
+      }else{
+        print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file));
+      }
+    }
+
+    /* Get list of available xdrivers */
+    $this->XDrivers = $this->getListOfXDrivers();
+
+    array_unshift($this->XDrivers, "["._("unknown")."]");
+    $this->XColordepths= array( 
+        "8"        => "8 " ._("bit"), 
+        "15"       => "15 "._("bit"),      
+        "16"       => "16 "._("bit"),   
+        "24"       => "24 "._("bit"));
+
+    foreach(array ("btc9000", "chicony", "compaq", "dell", "dell101", "everex",
+          "flexpro", "geniuscomfy", "hp", "itouch", "jp106", "logicordless",
+          "logiinetnav", "logiinternet", "macintosh", "microsoft",
+          "microsoftpro", "omnikey101", "pc101", "pc102", "pc104",
+          "pc105", "rapidaccess", "rapidaccess2", "winbook") as $type){
+      $this->XKbModels[$type] = $type;
+    }
+
+    $this->MouseTypes= array("ImPS/2" => "ImPS/2", "PS/2" => "PS/2", "Microsoft" => "Microsoft", 
+                              "Logitech" => "Logitech");
+
+    $this->MousePorts= array("/dev/ttyS0"  =>"/dev/ttyS0", 
+                             "/dev/ttyS1"       => "/dev/ttyS1",          "/dev/psaux"  =>"/dev/psaux", 
+                             "/dev/input/mice"  => "/dev/input/mice");
+
+    /* Additional values will be extracted from CONFIG_DIR./keyboardLayouts */
+    $this->XKbLayouts= array ("de"=> "de","intl" =>"intl","us" =>"us");
+    $this->XKbVariants= array ("nodeadkeys"=>"nodeadkeys", "basic"=>"basic");
+
+    /* try to read additional keyboard layouts 
+     */
+    if(file_exists(CONFIG_DIR."/keyboardLayouts")){
+      if(is_readable(CONFIG_DIR."/keyboardLayouts")){
+        $str = file_get_contents(CONFIG_DIR."/keyboardLayouts");
+        $tmp = split("\n",$str);
+        foreach($tmp as $entry){
+          if((!empty($entry)) && (!preg_match("/^#/",$entry))){
+            $entry = trim($entry);
+            $tmp2 = split ("\:",$entry);
+            $la =   trim($tmp2[0]);   // What would be saved to ldap
+            $da =   trim($tmp2[1]);   // This wis displayed in the listbox
+            $this->XKbLayouts [ $la] = $da;  
+          } 
+        }
+      }
+    }
+
+    /* Initialize methods */
+    $this->XMethods["indirect"]= _("show chooser");
+    $this->XMethods["query"]= _("direct");
+    #$this->XMethods["squery"]= _("direct via ssh");
+    #$this->XMethods["nquery"]= _("direct via nx");
+    $this->XMethods["load"]= _("load balanced");
+    #$this->XMethods["sload"]= _("load balanced via ssh");
+    #$this->XMethods["nload"]= _("load balanced via nx");
+    $this->XMethods["rdp"]= _("Windows RDP");
+    $this->XMethods["citrix"]= _("ICA client");
+
+    $this->orig_dn= $this->dn;
+
+    /* Load hardware list */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(objectClass=goFonHardware)", array('cn', 'description'));
+    while ($attrs= $ldap->fetch()){
+      $cn= $attrs['cn'][0];
+      if (isset($attrs['description'])){
+        $description= " - ".$attrs['description'][0];
+      } else {
+        $description= "";
+      }
+      $this->hardware_list[$cn]= "$cn$description";
+    }
+
+    /* Eventually colorize phones */
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(goFonHardware=*)",array('cn','dn','goFonHardware'));
+    while($attrs = $ldap->fetch()){
+        $cn = $attrs['goFonHardware'][0];
+        if(isset($this->hardware_list[$cn])){
+          $this->used_hardware[$cn]= $cn;
+        }
+    }
+
+    if(preg_match("/\+/",$this->gotoXHsync)){
+      $this->AutoSync = true;
+      $this->gotoXHsync = preg_replace("/\+/","-",$this->gotoXHsync);
+      $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync);
+    }
+
+    $this->hardware_list["automatic"]= _("automatic");
+    ksort($this->hardware_list);
+
+    /* Load hardware list */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
+    if ($ldap->count() == 1){
+      $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
+                  "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport");
+      $attrs= $ldap->fetch();
+
+      foreach ($map as $name){
+        if (!isset($attrs[$name][0])){
+          continue;
+        }
+        
+        switch ($name){
+          case 'gotoXResolution':
+            $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions;
+            break;
+          case 'gotoXColordepth':
+            $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths;
+            break;
+          case 'gotoXKbModel':
+            $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels;
+            break;
+          case 'gotoXKbLayout':
+            $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts;
+            break;
+          case 'gotoXKbVariant':
+            $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants;
+            break;
+          case 'gotoXMouseType':
+            $this->MouseTypes= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes;
+            break;
+          case 'gotoXMouseport':
+            $this->MousePorts= array('AUTO' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts;
+            break;
+        }
+
+      }
+
+    }
+
+    /* Workaround to fill in inherited values if we've specified an objectclass */
+    $SelectedSystemType = session::get("SelectedSystemType");
+    if (isset($SelectedSystemType['ogroup']) && $SelectedSystemType['ogroup'] != 'none'){
+      $this->XResolutions= array('default' => _("inherited"));
+      $this->XColordepths= array('default' => _("inherited"));
+      $this->XKbModels= array('default' => _("inherited"));
+      $this->XKbLayouts= array('default' => _("inherited"));
+      $this->XKbVariants= array('default' => _("inherited"));
+      $this->MouseTypes= array('AUTO' => _("inherited"));
+      $this->MousePorts= array('AUTO' => _("inherited"));
+    }
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","workstation/".get_class($this),$this->dn);
+    }
+
+    /* Do we need to flip is_account state? */
+    if (isset($_POST['modify_state'])){
+      $this->is_account= !$this->is_account;
+    }
+
+    /* Do we need to flip is_account state? */
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }
+
+    /* Show main page */
+    $smarty= get_smarty();
+
+    /* Assign ACLs */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translated){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    /* Arrays */ 
+    foreach(array("XMethods", "XDrivers", "XResolutions", "XColordepths",
+          "XKbModels", "XKbVariants",
+          "MouseTypes", "MousePorts") as $val){
+      $smarty->assign("$val", $this->$val);
+    }
+    $smarty->assign("XKbLayouts"    ,$this->XKbLayouts);
+    $smarty->assign("XKbLayoutKeys" ,array_flip($this->XKbLayouts));
+
+    $smarty->assign("xdmcpservers", $this->config->data['SERVERS']['TERMINAL']);
+    $smarty->assign("fontservers", $this->config->data['SERVERS']['FONT']);
+    $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
+    $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
+
+    /* Variables - select */
+    foreach(array(
+          "gotoXDriver", "gotoXResolution", "gotoXColordepth", 
+          "gotoXKbModel", "gotoXKbLayout","gotoScannerEnable",
+          "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){
+
+      $smarty->assign($val."_select", $this->$val);
+    }
+
+    /* Variables */
+    foreach(array("gotoXHsync", "gotoXVsync") as $val){
+      $smarty->assign($val, $this->$val);
+    }
+    $smarty->assign("staticAddress", "");
+
+    /* Checkboxes */
+    foreach(array("gotoScannerEnable") as $val){
+      if ($this->$val == TRUE) {
+        $smarty->assign("$val", "checked");
+      } else {
+        $smarty->assign("$val", "");
+      }
+    }
+
+    /* Phone stuff */
+    $smarty->assign ("goFonHardware", $this->goFonHardware);
+
+    $perms = "";
+    if($this->acl_is_writeable("goFonHardware")){
+      $perms = " disabled ";
+    }
+
+    $hl= "<select size=\"1\" name=\"goFonHardware\" ".$perms." title=\"".
+      _("Choose the phone located at the current terminal")."\" >";
+    foreach ($this->hardware_list as $cn => $description){
+      if ($cn == $this->goFonHardware){
+        $selected= "selected";
+      } else {
+        $selected= "";
+      }
+      if (isset($this->used_hardware[$cn])){
+        $color= "style=\"color:#A0A0A0\"";
+      } else {
+        $color= "";
+      }
+      $hl.= "  <option $color label=\"$cn\" value=\"$cn\" $selected>$description</option>\n";
+    }
+    $hl.= "</select>\n";
+    $smarty->assign ("hardware_list", $hl);
+    $smarty->assign ("gotoXMonitor", $this->gotoXMonitor);
+
+    if($this->AutoSync){
+      $smarty->assign("AutoSyncCHK"," checked ");
+      $smarty->assign("hiddenState"," disabled ");
+    }else{
+      $smarty->assign("AutoSyncCHK"," ");
+      $smarty->assign("hiddenState","");
+    }
+
+    /* Show main page */
+    return($smarty->fetch (get_template_path('workstationService.tpl',TRUE,dirname(__FILE__))));
+  }
+
+  function remove_from_parent()
+  {
+    $this->handle_post_events("remove");
+    new log("remove","workstation/".get_class($this),$this->dn);
+  }
+
+  /* Save data to object */
+  function save_object()
+  {
+    plugin::save_object();
+
+    if((isset($_POST['gotoXDriver'])) && $this->acl_is_writeable("AutoSync")) {
+      if(isset($_POST['AutoSync'])){
+        $this->AutoSync = true;
+      }else{
+        $this->AutoSync = false;
+      }
+    }
+  }
+
+  /* Check supplied data */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    /* Default entries can use blank hsync/vsync entries */
+    if ($this->dn != "" && $this->cn != "default" && $this->cn != "wdefault"){
+
+      /* But only if no auto sync is enabled... */
+      if (!$this->AutoSync){
+
+        /* Check vsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXVsync);
+
+        if($this->acl_is_writeable("gotoXVsync")){
+          if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
+            $message[]= _("Please specify a valid VSync range.");
+          } else{
+            list($v1,$v2)= preg_split ("/[-+]/", $val);
+            if ($v2 != ""){
+              if ($v1 > $v2){
+                $message[]= _("Please specify a valid VSync range.");
+              }
+            }
+          }
+        }
+
+        /* Check hsync for correct usage */
+        $val= preg_replace ("/\s/", "", $this->gotoXHsync);
+        if($this->acl_is_writeable("gotoXHsync")){
+          if (!preg_match ("/^\d+(\.\d+)?([-]\d+(\.\d+)?)?$/", $val)){
+            $message[]= _("Please specify a valid HSync range.");
+          } else{
+            list($v1,$v2)= preg_split ("/[-+]/", $val);
+            if ($v2 != ""){
+              if ($v1 > $v2){
+                $message[]= _("Please specify a valid HSync range.");
+              }
+            }
+          }
+        }
+      }
+    }
+
+    return ($message);
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* remove objectclass GOhard if this is an ogroup tab */
+    if(isset($this->parent->by_object['ogroup'])){
+      $this->objectclasses = array();
+    }
+
+    plugin::save();
+
+    /* Strip out 'default' values */
+    foreach(array(
+          "gotoXDriver", "gotoXResolution", "gotoXColordepth",
+          "gotoXKbModel", "gotoXKbLayout",
+          "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport") as $val){
+
+      if ($this->attrs[$val] == "default"){
+        $this->attrs[$val]= array();
+      }
+    }
+
+    if($this->AutoSync){
+      $this->attrs['gotoXHsync'] = "30+55";
+      $this->attrs['gotoXVsync'] = "50+70";
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+    new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/service with dn '%s' failed."),$this->dn));
+    $this->handle_post_events("modify");
+  }
+
+
+  function getListOfXDrivers()
+  {
+    /* Generate a list of xdrivers from CONFIG_DIR./xdrivers */
+    $drivers = array();
+    if (file_exists(CONFIG_DIR.'/xdrivers')){
+      $xdrivers = file (CONFIG_DIR.'/xdrivers');
+      foreach ($xdrivers as $line){
+        if (!preg_match ("/^#/", $line)){
+          $drivers[]= trim($line);
+        }
+      }
+    } else {
+      $drivers = array("ati", "atimisc", "chips", "cirrus", "cyrix", "fbdev", "fglrx",
+          "i128", "i740", "i810", "imstt", "mga", "neomagic", "newport", "nsc",  "nv", "nvidia",
+          "r128", "radeon", "rendition", "s3", "s3virge", "savage", "siliconmotion",
+          "sis", "tdfx", "tga", "trident", "tseng", "vesa", "vga", "vmware");
+    }
+    return($drivers);
+  }
+
+
+  /* Return plugin informations for acl handling */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Service"),
+          "plDescription" => _("Workstation service"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 10,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("workstation","ogroups"), 
+
+          "plProvidedAcls"=> array(
+            "gotoXMonitor"          => _("Monitor"),
+            "gotoXDriver"           => _("Gfx driver"),
+            "gotoXResolution"       => _("Gfx resolution"),
+            "gotoXColordepth"       => _("Gfx color depth"),
+            "gotoXHsync"            => _("Hsync"),
+            "gotoXVsync"            => _("Vsync"),
+            "AutoSync"              => _("Use DDC"),
+            "gotoScannerEnable"     => _("Scanner enabled"),
+            "gotoXKbModel"          => _("Keyboard model"),
+            "gotoXKbLayout"         => _("Keyboard layout"),
+            "gotoXKbVariant"        => _("Keyboard variant"),
+            "gotoXMouseType"        => _("Mouse type"),
+            "gotoXMouseport"        => _("Mouse port"),
+            "goFonHardware"         => _("Telephone hardware")) 
+            ));
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc
new file mode 100644 (file)
index 0000000..c74b376
--- /dev/null
@@ -0,0 +1,1293 @@
+<?php
+class workstartup extends plugin
+{
+  /* CLI vars */
+  var $cli_summary= "Manage terminal startup options";
+  var $cli_description= "Some longer text\nfor help";
+  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+  /* Ldap server list */
+  var $gotoLdapServers    = array();
+  var $gotoLdapServerList = array();
+  var $gotoLdap_inherit   = FALSE;
+
+  /* Generic terminal attributes */
+  var $bootmode             = "G";
+  var $gotoBootKernel       = "default-inherited";
+  var $gotoKernelParameters = "";
+  var $gotoLdapServer       = "default-inherited";
+  var $gotoModules          = array();
+  var $gotoAutoFs           = array();
+  var $gotoFilesystem       = array();
+  var $gotoTerminalPath     = "";
+  var $gotoBootKernels      = array();
+
+  /* attribute list for save action */
+  var $attributes           = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", 
+                                    "FAIclass", "FAIstatus", "gotoShare","FAIdebianMirror", "FAIrelease");
+  var $objectclasses        = array("GOhard", "FAIobject");
+
+  /* Share */
+  var $gotoShares         = array();// Currently Share Option
+  var $gotoShare          = "";     // currently selected Share Option
+  var $gotoShareSelections= array();// Available Shares for this account in Listbox format
+  var $gotoAvailableShares= array();// Available Shares for this account
+
+  /* Helper */
+  var $customParameters   = "";
+  var $orig_dn            = "";
+  var $ignore_account     = TRUE;
+  /* FAI class selection */ 
+  var $FAIclass           = array();  // The currently selected classes 
+  var $FAIrelease         = "";
+  var $FAIdebianMirror    = "auto";
+
+  var $cache              = array(); // Used as cache in fai mehtods
+
+  var $FAIstatus          = "";
+  var $FAIclasses         = array();
+
+  var $view_logged        = FALSE;
+  
+  /* FAI class selection */
+  var $InheritedFAIclass       = array();
+  var $InheritedFAIrelease     = "";
+  var $InheritedFAIdebianMirror= "auto";
+
+  var $CopyPasteVars    = array("gotoModules","gotoShares");
+  var $fai_activated    = FALSE;
+  var $o_group_dn       = "";
+  var $member_of_ogroup = FALSE;
+
+  function workstartup (&$config, $dn= NULL, $parent= NULL)
+  {
+    /* Check if FAI is active */
+    $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)){
+      $this->fai_activated = TRUE;
+    }else{
+      $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare");
+      $this->objectclasses  = array("GOhard");
+    }
+
+    plugin::plugin ($config, $dn, $parent);
+
+    /* Check object group membership */
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn","dn"));
+      if($ldap->count()){
+        $this->member_of_ogroup = TRUE;
+        $attrs = $ldap->fetch();
+        $this->o_group_dn = $attrs['dn'];
+      }
+    }
+
+    /* Creating a list of valid Mirrors 
+     * none will not be saved to ldap.
+     */
+    $ldap   = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    foreach($this->config->data['SERVERS']['LDAP'] as $server) {
+      $this->gotoLdapServerList[]= $server; 
+    }
+
+    /* Get list of assigned ldap servers 
+     */ 
+    if(isset($this->attrs['gotoLdapServer'])){
+      unset($this->attrs['gotoLdapServer']['count']);
+      sort($this->attrs['gotoLdapServer']);
+      foreach($this->attrs['gotoLdapServer'] as $value){
+        $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
+      }
+    }
+    if(!count($this->gotoLdapServers) && $this->member_of_ogroup){ 
+      $this->gotoLdap_inherit = TRUE;
+    }
+
+    /* FAI Initialization
+       Skip this if FAI is not activated 
+     */
+    if($this->fai_activated) {
+
+      $this->update_fai_cache(TRUE);
+
+      /* Parse used FAIclasses (stored as string).
+       * The single classes are seperated by ' '.
+       * There is also the release type given, after first
+       *  occurrence of ':'.
+       */
+      $this->FAIclass =array();
+      if(isset($this->attrs['FAIclass'][0])){
+        $tmp = split(" ",$this->attrs['FAIclass'][0]);
+        $tmp2 =array();  
+
+        foreach($tmp as $class){
+          if( ":" == $class[0] ) {
+            $this->FAIrelease = trim(substr($class, 1));
+          }else{
+            $tmp2[$class] = $class;
+          }
+        }
+        $this->FAIclass = $tmp2;
+      }
+    }
+
+    /* Get arrays */
+    foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
+      if (isset($this->attrs["$val"]["count"])){
+        for ($i= 0; $i<$this->attrs["count"]; $i++){
+          if (isset($this->attrs["$val"][$i])){
+            array_push($this->$val, $this->attrs["$val"][$i]);
+          }
+        }
+      }
+      sort ($this->$val);
+      $this->$val= array_unique($this->$val);
+    }
+
+    /* Parse Kernel Parameters to decide what boot mode is enabled */
+    if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
+      $this->bootmode= "G";
+    } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
+      $this->bootmode= "D";
+    } elseif ($this->gotoKernelParameters == "") {
+      $this->bootmode= "G";
+    } else {
+      $this->bootmode= "T";
+    }
+    if (preg_match("/ o /", $this->gotoKernelParameters)){
+      $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
+    } else {
+      $this->customParameters= "";
+    }
+
+    /* Prepare Shares */
+    if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
+      unset($this->attrs['gotoShare']['count']);
+      foreach($this->attrs['gotoShare'] as $share){
+        $tmp = $tmp2 = array();
+        $tmp = split("\|",$share);
+        $tmp2['server']      =$tmp[0];
+        $tmp2['name']        =$tmp[1];
+        $tmp2['mountPoint']  =$tmp[2];
+        $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
+      }
+    }
+
+    $this->gotoShareSelections= $config->getShareList(true);
+    $this->gotoAvailableShares= $config->getShareList(false);
+    $tmp2 = array();
+  
+
+    $this->orig_dn= $this->dn;
+
+    /* Handle inheritance value "default" */
+    if ($this->member_of_ogroup){
+      $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']'); 
+    }
+
+    /* If we are member in an object group,
+     *  we have to handle inherited values.
+     * So you can see what is inherited.
+     */
+    if ($this->member_of_ogroup){
+
+      if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
+        $this->FAIdebianMirror = "inherited";
+      }
+
+      if($this->fai_activated){
+        $map= array("gotoBootKernel","FAIclass","FAIdebianMirror");
+      }else{
+        $map= array("gotoBootKernel");
+      }
+
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cat($this->o_group_dn);
+      $attrs= $ldap->fetch();
+
+      foreach ($map as $name){
+        if (!isset($attrs[$name][0])){
+          continue;
+        }
+
+        switch ($name){
+          case 'gotoBootKernel':
+            $this->gotoBootKernels['default-inherited']=  _("inherited").' ['.$attrs[$name][0].']' ;
+            break;
+
+          case 'FAIclass':
+            $str = split(":",$attrs[$name][0]);
+            $this->InheritedFAIclass    = split("\ ",trim($str[0]));
+            $this->InheritedFAIrelease  = trim($str[1]);
+            break;
+
+          case 'FAIdebianMirror':
+            $this->InheritedFAIdebianMirror = $attrs[$name][0];
+            break;
+        }
+      }
+    }
+
+
+    if($this->fai_activated){
+
+      /* Check if the current mirror is available 
+       */
+      if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
+        if(count($this->FAIclass)){
+          print_red(sprintf(_("The selected FAI mirror '%s' is no longer available, the mirror was set to 'auto'."),
+                $this->FAIdebianMirror));
+        }
+        $this->FAIdebianMirror = "auto";
+        $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
+        $this->cache =array();
+        $this->update_fai_cache();
+        
+      }
+  
+      /* Check if the current mirror is available 
+       */
+      if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
+        $new_release = key($this->cache['SERVERS'][$this->FAIdebianMirror]); 
+        if(count($this->FAIclass)){
+          print_red(sprintf(_("The selected FAI release '%s' is not available for mirror '%s', the release was set to '%s'."),
+                $this->FAIrelease,$this->FAIdebianMirror,$new_release));
+        }
+        $this->FAIrelease = $new_release;
+        $this->cache =array();
+        $this->update_fai_cache();
+      }
+    }
+
+    /* Get list of boot kernels */
+    if (isset($this->config->data['TABS'])){
+      $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
+      if (!check_command($command)){
+        $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
+            get_class($this));
+      } else {
+        $fh= popen($command, "r");
+        while (!feof($fh)) {
+          $buffer= trim(fgets($fh, 256));
+          if(!empty($buffer)){
+            $name=$value = $buffer;
+            if(preg_match("/:/",$buffer)){
+              $name = preg_replace("/:.*$/","",$buffer);
+              $value= preg_replace("/^.*:/","",$buffer);
+              $this->gotoBootKernels[$name]= $name.":".$value;
+            }else{
+              $this->gotoBootKernels[$name]= $value;
+            }
+          }
+        }
+        pclose($fh);
+      }
+    }
+
+    /* Turn to default, if we've nothing to inherit */
+    if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
+      $this->gotoBootKernel= "default";
+    }
+  }
+
+  
+  function check()
+  {
+    $messages = array();
+    
+    /* Call common method to give check the hook */
+    $messages= plugin::check();
+
+    /* If there are packages selected, but no mirror show error */   
+    if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
+      $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
+    }
+
+    return($messages);
+  }
+
+  function execute()
+  {
+       /* Call parent execute */
+       plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","workstation/".get_class($this),$this->dn);
+    }
+
+    /* Do we need to flip is_account state? */
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }
+
+    /* Do we represent a valid terminal? */
+    if (!$this->is_account && $this->parent === NULL){
+      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+        _("This 'dn' has no terminal features.")."</b>";
+      return ($display);
+    }
+
+    /* Add module */
+    if (isset ($_POST['add_module'])){
+      if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){
+        $this->add_list ($this->gotoModules, $_POST['module']);
+      }
+    }
+
+    /* Delete module */
+    if (isset ($_POST['delete_module'])){
+      if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){
+        $this->del_list ($this->gotoModules, $_POST['modules_list']);
+      }
+    }
+
+    /* FAI class management */
+    if($this->fai_activated){
+      if(((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))) && ($this->acl_is_writeable("FAIclass"))){
+        $found = 0 ; 
+
+        /* If this new class/profile will attach a second partition table
+         * to our list of classes, abort and show a message.
+         */
+        foreach($this->FAIclass as $name){
+          if(isset($this->FAIclassInfo[$name])){
+            foreach($this->FAIclassInfo[$name] as $atr){
+              if(isset($atr['obj'])){
+                if($atr['obj'] == "FAIpartitionTable"){
+                  $found ++ ; 
+                }
+              }
+            }
+          }
+        }
+
+        if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
+          print_red(_("There is already a profile in your selection that contain partition table configurations."));
+        }else{
+          $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
+        }
+      }
+
+      $sort = false;
+
+      /* Move one used class class one position up or down */
+      if($this->acl_is_writeable("FAIclass")){
+        foreach($_POST as $name => $val){
+
+          $sort_type = false;
+          if((preg_match("/sort_up/",$name))&&(!$sort)){
+            $sort_type = "sort_up_";
+          }
+          if((preg_match("/sort_down/",$name))&&(!$sort)){
+            $sort_type = "sort_down_";
+          }
+
+          if(($sort_type)&&(!$sort)){
+            $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/".$sort_type."/i","",$name)));
+            $sort = true;
+
+            $last = -1;
+            $change_down  = -1;
+
+            /* Create array with numeric index */ 
+            $tmp = array();
+            foreach($this->FAIclass as $class){
+              $tmp [] = $class;
+            }
+
+            /* Walk trough array */
+            foreach($tmp as $key => $faiName){
+              if($faiName == $value){
+                if($sort_type == "sort_up_"){
+                  if($last != -1){
+                    $change_down= $last;
+                  }
+                }else{
+                  if(isset($tmp[$key+1])){
+                    $change_down = $key;
+                  }
+                }
+              }
+              $last = $key;
+            }
+
+            $tmp2 = array();
+            $skip = false;    
+
+            foreach($tmp as $ky => $vl){
+
+              if($ky == $change_down){
+                $skip = $vl;
+              }else{
+                $tmp2[$vl] = $vl;
+              }
+              if(($skip != false)&&($ky != $change_down)){
+                $tmp2[$skip]  = $skip;
+                $skip =false;
+              }
+            }   
+            $this->FAIclass = $tmp2; 
+          }
+
+          if(preg_match("/fai_remove/i",$name)){
+            $value = base64_decode(preg_replace("/_.*$/i","",preg_replace("/fai_remove_/i","",$name)));
+            unset($this->FAIclass[$value]);
+          }
+        }
+      }
+
+      /* Delete selected class from our list */
+      if($this->acl_is_writeable("FAIclass")){
+        if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
+          if(isset($this->FAIclass[$_POST['FAIclassSel']])){
+            unset($this->FAIclass[$_POST['FAIclassSel']]);
+          }
+        }
+      }
+    }// END fai handling
+
+    /* Show main page */
+    $smarty= get_smarty();
+
+    /* Assign ACLs to smarty */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    } 
+
+    $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
+
+    /* In this section server shares will be defined
+     * A user can select one of the given shares and a mount point
+     *  and attach this combination to his setup.
+     */
+    $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
+    $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
+
+    /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
+     * This entry will be, a combination of mountPoint and sharedefinitions
+     */
+    if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) {
+      /* We assign a share to this user, if we don't know where to mount the share */
+      if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
+        print_red(_("You must specify a valid mount point."));
+      }else{
+        if(count($this->gotoAvailableShares)){
+          $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
+          $s_mount = $_POST['gotoShareMountPoint'];
+          /* Preparing the new assignment */
+          $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
+          $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
+        }
+      }
+    }
+
+    /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
+     * If there is no defined share selected, we will abort the deletion without any message
+     */
+    if(($this->acl_is_writeable("gotoShare"))&& (isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
+      unset($this->gotoShares[$_POST['gotoShare']]);
+    }
+
+    $smarty->assign("gotoShares",$this->printOutAssignedShares());
+    $smarty->assign("gotoSharesCount",count($this->printOutAssignedShares()));
+    $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
+    $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
+
+    /* Create divSelectBox for ldap server selection
+     */
+    $SelectBoxLdapServer = new divSelectBox("LdapServer");
+    $SelectBoxLdapServer->SetHeight(130);
+
+    /* Add new ldap server to the list */
+    if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){
+      if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){
+        $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']];
+        if(!in_array($to_add,$this->gotoLdapServers)){
+          $this->gotoLdapServers[] = $to_add;
+        }
+      }
+    }
+    
+    /* Move ldap servers up and down */
+    if(!$this->gotoLdap_inherit){
+      foreach($_POST as $name => $value){
+        if(preg_match("/sort_ldap_up_/",$name)){
+          $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name);
+          $from =  $id;  
+          $to   =  $id -1;
+          $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
+          if($tmp){
+            $this->gotoLdapServers = $tmp;
+          }
+          break;
+        }
+        if(preg_match("/sort_ldap_down_/",$name)){
+          $id = preg_replace("/^sort_ldap_down_([0-9]*)_(x|y)$/","\\1",$name);
+          $from =  $id;  
+          $to   =  $id +1;
+          $tmp = $this->array_switch_item($this->gotoLdapServers,$from,$to);
+          if($tmp){
+            $this->gotoLdapServers = $tmp;
+          }
+          break;
+        }
+        if(preg_match("/gotoLdapRemove_/",$name)){
+          $id = preg_replace("/^gotoLdapRemove_([0-9]*)_(x|y)$/","\\1",$name);
+          $value = $this->gotoLdapServers[$id];
+          $this->gotoLdapServers = array_remove_entries(array($value),$this->gotoLdapServers);
+          break;
+        }
+      } 
+    }
+  
+    /* Add Entries 
+     */
+    foreach($this->gotoLdapServers as $key => $server){
+      if(!in_array($server,$this->gotoLdapServerList)){
+        $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
+      }
+
+      $SelectBoxLdapServer->AddEntry(
+          array(array("string" => $server),
+            array("string" => 
+              "<input class='center' type='image' src='images/sort_up.png' name='sort_ldap_up_".$key."'>&nbsp;".
+              "<input class='center' type='image' src='images/sort_down.png' name='sort_ldap_down_".$key."'>&nbsp;".
+              "<input class='center' type='image' src='images/edittrash.png' name='gotoLdapRemove_".$key."'>",
+              "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
+    }    
+
+    if($this->gotoLdap_inherit){
+      $smarty->assign("gotoLdapServerACL_inherit", preg_replace("/w/","",$this->getacl("gotoLdapServer")));;
+    }else{
+      $smarty->assign("gotoLdapServerACL_inherit", $this->getacl("gotoLdapServer"));
+    }
+    
+    $list = array();
+    foreach($this->gotoLdapServerList as $key => $entry){
+      if(!in_array($entry,$this->gotoLdapServers)){
+        $list[$key] = $entry;
+      }
+    }
+    $smarty->assign("gotoLdapServers",    $SelectBoxLdapServer->DrawList());
+    $smarty->assign("gotoLdapServerList", $list);
+    $smarty->assign("gotoLdap_inherit",   $this->gotoLdap_inherit);
+    $smarty->assign("JS",  session::get('js'));
+
+    foreach (array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $val){
+      $smarty->assign("$val", $this->$val);
+    }
+
+    /* Values */
+    foreach(array("gotoBootKernel", "customParameters", "gotoShare","FAIclasses","FAIclass","FAIdebianMirror","FAIrelease") as $val){
+      $smarty->assign($val, $this->$val);
+    }
+
+    $smarty->assign("fai_activated",$this->fai_activated);
+
+    /* Create FAI output */
+    if($this->fai_activated){
+
+      $this->update_fai_cache();
+
+      $smarty->assign("FAIservers"  , $this->cache['SERVERS']);
+      $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror);
+      $smarty->assign("FAIrelease"  , $this->FAIrelease);
+      $smarty->assign("FAIclasses"  , $this->selectable_classes());
+
+      $smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
+
+      $div = new divSelectBox("WSFAIscriptClasses");
+      $div -> SetHeight("110");
+      $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
+      $str_down   = " &nbsp;<input type='image' src='images/sort_down.png'  name='sort_down_%s'  value='%s'>";
+      $str_remove = " &nbsp;<input type='image' src='images/edittrash.png'  name='fai_remove_%s' value='%s'>";
+      $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
+
+      /* Get classes */
+      if($this->FAIdebianMirror == "inherited"){
+        $tmp = $this->InheritedFAIclass;
+      }else{
+        $tmp = $this->FAIclass;
+      }
+
+      /* Get invalid classes */
+      $invalid = $this->get_invalid_classes($tmp);
+
+      /* Draw every single entry */
+      $i = 1;
+      foreach($tmp as $class){
+
+        /* Mark invalid classes. (Not in selected release)
+         */
+        $marker = "";
+        if(in_array_ics($class,$invalid)){
+          $marker = "&nbsp;<font color='red'>("._("Not available in current setup").")</font>";
+        }
+
+        /* Create up/down priority icons  
+         * Skip this, if we have inherited the FAI classes.
+         */
+        if($this->FAIdebianMirror == "inherited"){
+          $str = "";
+        }else{
+          if($i==1){
+            $str = $str_empty.$str_down.$str_remove;
+          }elseif($i == count($this->FAIclass)){
+            $str = $str_up.$str_empty.$str_remove;
+          }else{
+            $str = $str_up.$str_down.$str_remove;
+          }
+        }
+        $i ++ ; 
+
+        /* Get Description tag 
+         *  There may be several FAI objects with the same class name, 
+         *   use the description from FAIprofile, if possible.
+         */  
+        $desc = ""; 
+        if(isset($this->cache['CLASSES'][$this->FAIrelease][$class])){
+          foreach($this->cache['CLASSES'][$this->FAIrelease][$class] as $types ){
+            if(isset($types['Desc'])){
+              $desc= $types['Desc'];
+              if($types['Type'] == "FAIprofile"){
+                break;
+              }
+            }
+          }
+        }
+        if(!empty($desc)){
+          $desc = "&nbsp;[".trim($desc)."]";
+        }        
+
+        $div->AddEntry(array(
+              array("string"=>$class.$desc.$marker),
+              array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
+              ));
+      }  
+      $smarty->assign("FAIScriptlist",$div->DrawList()); 
+    }// END FAI output generation 
+
+    /* Radio button group */
+    if (preg_match("/G/", $this->bootmode)) {
+      $smarty->assign("graphicalbootup", "checked");
+    } else {
+      $smarty->assign("graphicalbootup", "");
+    }
+    if (preg_match("/T/", $this->bootmode)) {
+      $smarty->assign("textbootup", "checked");
+    } else {
+      $smarty->assign("textbootup", "");
+    }
+    if (preg_match("/D/", $this->bootmode)) {
+      $smarty->assign("debugbootup", "checked");
+    } else {
+      $smarty->assign("debugbootup", "");
+    }
+
+    /* Show main page */
+    return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
+  }
+
+
+  function remove_from_parent()
+  {
+    $this->handle_post_events("remove");
+    new log("remove","workstation/".get_class($this),$this->dn);
+  }
+
+
+  /* Save data to object */
+  function save_object()
+  {
+    $old_mirror  = $this->FAIdebianMirror;
+    plugin::save_object();
+
+    /* Update release */
+    if($old_mirror != $this->FAIdebianMirror){
+      if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
+        $this->FAIrelease      = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
+      }
+    }
+
+    if(isset($_POST['WorkstationStarttabPosted'])){
+      if(isset($_POST['gotoLdap_inherit'])){
+        $this->gotoLdap_inherit = TRUE;
+      }else{
+        $this->gotoLdap_inherit = FALSE;
+      }
+
+      /* Save group radio buttons */
+      if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
+        $this->bootmode= $_POST["bootmode"];
+      }
+
+      /* Save kernel parameters */
+      if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){
+        $this->customParameters= $_POST["customParameters"];
+      }
+    }
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+
+    /* Depending on the baseobject (Ogroup / WS) we
+     *  use another set of objectClasses
+     * In case of WS itself, we use  "array("GOhard", "FAIobject");"
+     * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
+     */
+    if(isset($this->parent->by_object['ogroup'])){
+      $this->objectclasses = array("gotoWorkstationTemplate");
+    }elseif(isset($this->parent->by_object['workgeneric'])){
+      $this->objectclasses = array("GOhard");
+    }elseif(isset($this->parent->by_object['servgeneric'])){
+      $this->objectclasses = array("GOhard","gotoWorkstationTemplate");
+    }else{
+      print "Object Type Configuration : unknown";
+      exit();
+    }
+
+    /* Append FAI class */
+    if($this->fai_activated){
+      $this->objectclasses[]  = "FAIobject";
+    }
+
+    /* Find proper terminal path for tftp configuration
+       FIXME: This is suboptimal when the default has changed to
+       another location! */
+    if (($this->gotoTerminalPath == "default")){
+      $ldap= $this->config->get_ldap_link();
+
+      /* Strip relevant part from dn, keep trailing ',' */
+      $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalou')."/i", "", $this->dn);
+      $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
+
+      /* Walk from top to base and try to load default values for
+         'gotoTerminalPath'. Abort when an entry is found. */
+      while (TRUE){
+        $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
+
+        $ldap->cat("cn=default,".get_ou('terminalou').$tmp.
+            $this->config->current['BASE'], array('gotoTerminalPath'));
+        $attrs= $ldap->fetch();
+        if (isset($attrs['gotoTerminalPath'])){
+          $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
+          break;
+        }
+
+        /* Nothing left? */
+        if ($tmp == ""){
+          break;
+        }
+      }
+    }
+
+    /* Add semi automatic values */
+    // FIXME: LDAP Server may not be set here...
+    $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer);
+
+    switch ($this->bootmode){
+      case "D":
+        $this->gotoKernelParameters.= " debug";
+      break;
+      case "G":
+        $this->gotoKernelParameters.= " splash=silent";
+      break;
+    }
+    if ($this->customParameters != ""){
+      $this->gotoKernelParameters.= " o ".$this->customParameters;
+    }
+
+    plugin::save();
+
+    unset( $this->attrs['FAIrelease'] );
+    
+    $str = "";
+
+    /* Skip FAI attribute handling if not necessary */
+    if($this->fai_activated){
+      if($this->FAIdebianMirror == "inherited"){
+        $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array(); 
+      }else{
+        foreach($this->FAIclass as $class){
+          $str .= $class." ";
+        }
+        $str .= ":" . $this->FAIrelease;
+        $this->attrs['FAIclass']= "";
+        $this->attrs['FAIclass']= trim($str);
+
+        if(empty($this->attrs['FAIclass'])){
+          $this->attrs['FAIclass'] = array();
+        }
+      }
+    }
+  
+    /* Add missing arrays */
+    foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
+      if (isset ($this->$val) && count ($this->$val) != 0){
+    
+        $this->attrs["$val"]= array_unique($this->$val);
+      }
+      if(!isset($this->attrs["$val"])) $this->attrs["$val"]=array();
+    }
+
+    /* Prepare list of ldap servers */
+    $this->attrs['gotoLdapServer'] = array();
+    if(!$this->gotoLdap_inherit){
+      $i = 0;
+      foreach($this->gotoLdapServers as $server){
+        $i ++;
+        $this->attrs['gotoLdapServer'][] = $i.":".$server;
+      }
+    }
+
+    if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){
+      $this->attrs['gotoBootKernel']= array();
+    }
+
+    /* if mirror == none stop saving this attribute */
+    if($this->FAIdebianMirror == "none"){
+      $this->FAIdebianMirror = "";
+    }
+   
+    /* Get FAIstate from object, the generic tab could have changed it during execute */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+
+
+    /* Skip FAI attribute handling if not necessary */
+    if($this->fai_activated){
+      $ldap->cat($this->dn,array("FAIstate"));
+      $checkFAIstate = $ldap->fetch();
+
+      /* Remove FAI objects if no FAI class is selected */ 
+      if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
+        $this->attrs['FAIclass']        = array();
+        $this->attrs['FAIdebianMirror'] = array();
+      }
+    }
+
+
+    /* prepare share settings */
+    $tmp = array();
+    foreach($this->gotoShares as $name => $settings){
+      $tmp2= split("\|",$name);
+      $name = $tmp2[0];
+      $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
+    }
+    $this->attrs['gotoShare']=$tmp;
+
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+    new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/startup with dn '%s' failed."),$this->dn));
+    $this->handle_post_events("modify");
+  }
+
+
+  /* Add value to array, check if unique */
+  function add_list (&$array, $value)
+  {
+    if ($value != ""){
+      $array[]= $value;
+      sort($array);
+      array_unique ($array);
+    }
+  }
+
+
+  /* Delete value to array, check if unique */
+  function del_list (&$array, $list)
+  {
+    $tmp= array();
+    foreach ($array as $mod){
+      if (!in_array($mod, $list)){
+        $tmp[]= $mod;
+      }
+    }
+    $array= $tmp;
+  }
+
+  /* Generate ListBox frindly output for the defined shares
+   * Possibly Add or remove an attribute here,
+   */
+  function printOutAssignedShares()
+  {
+    $a_return = array();
+    if(is_array($this->gotoShares)){
+      foreach($this->gotoShares as $share){
+        $a_return[$share['name']."|".$share['server']]= $share['name']." [".$share['server']."]";
+      }
+    }
+    return($a_return);
+  }
+
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);    
+    $source_o = new workstartup ($this->config, $source['dn']);
+    foreach(array("FAIclass","gotoModules", "gotoAutoFs", "gotoFilesystem",
+          "gotoKernelParameters","gotoShares","customParameters") as $attr){
+      $this->$attr = $source_o->$attr;
+    }
+  }
+
+  
+  function array_switch_item($ar,$from,$to)
+  {
+    if(!is_array($ar)){
+      return(false);
+    }
+    if(!isset($ar[$from])){
+      return(false);
+    }
+    if(!isset($ar[$to])){
+      return(false);
+    }
+
+    $tmp = $ar[$from];
+    $ar[$from] = $ar[$to];    
+    $ar[$to] = $tmp;    
+    return($ar);
+  }
+
+
+  /* Return plugin informations for acl handling */ 
+  static function plInfo()
+  {
+    return (array( 
+          "plShortName"   => _("Startup"),
+          "plDescription" => _("System startup"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 9,
+          "plSection"     => array("administration"),           
+          "plCategory"    => array("workstation","server","ogroups"),
+
+          "plProvidedAcls"=> array(
+            "gotoLdapServer"        => _("Ldap server"),
+            "gotoBootKernel"        => _("Boot kernel"),
+            "gotoKernelParameters"  => _("Kernel parameter"),
+
+            "gotoModules"           => _("Kernel modules"),
+            "gotoShare"             => _("Shares"),
+
+            "FAIclass"              => _("FAI classes"),
+            "FAIdebianMirror"       => _("Debian mirror"),
+            "FAIrelease"            => _("Debian release"),
+
+            "FAIstatus"             => _("FAI status flag")) // #FIXME is this acl realy necessary ?
+          ));
+  }
+
+
+  /* Updates release dns 
+   *  and reads all classes for the current release, 
+   *  if not already done ($this->cache).
+   */
+  function update_fai_cache($first_call = FALSE)
+  {
+    $force = FALSE;
+
+    /* Get the list of available servers and their releases. 
+     */
+    if($force || !isset($this->cache['SERVERS'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("FAIrepository"));
+      $this->cache['SERVERS'] = array();
+
+      /* Only add inherit option, if we are part in an object group
+       */
+      if($this->member_of_ogroup){
+        $this->cache['SERVERS']['inherited']=array();
+      }
+
+      /* Add auto value  
+       */
+      $this->cache['SERVERS']['auto'] = array();
+      $sort_by = array("auto");
+      $server_tmp = array("auto"=>array());
+      while($attr = $ldap->fetch()){
+        if(isset($attr['FAIrepository'])){
+          for($i = 0 ; $i < $attr['FAIrepository']['count'] ; $i ++ ){
+            $rep = $attr['FAIrepository'][$i];
+            $tmp = split("\|",$rep);
+            if(count($tmp)==4){
+              $sections = split(",",$tmp[3]);
+              $release  = $tmp[2];
+              $server   = $tmp[1];
+              $url      = $tmp[0];
+              $server_tmp[$url][$release]=$release;
+              $server_tmp['auto'][$release]=$release;
+              $sort_by[$url] = $url;
+            }
+          }
+        }
+      }
+      natcasesort($sort_by);
+      foreach($sort_by as $name){
+        $releases = $server_tmp[$name];
+        natcasesort($releases);
+        $this->cache['SERVERS'][$name] = $releases; 
+      }
+    }
+
+    /* Build up arrays, without checks */
+    if(!$first_call){
+
+      /* Check if the selected mirror is available */
+      if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
+        $this->FAIdebianMirror = "auto";
+        $this->FAIrelease      = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
+        trigger_error("There was a problem with the selected FAIdebianMirror. This mirror ('".$this->FAIdebianMirror."') is not available");
+      }
+
+      /* Check if the selected release is available */
+      if($this->FAIdebianMirror != "inherited" && !isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
+        trigger_error("There was a problem with the selected FAIrelease. This release ('".$this->FAIrelease."') is not available");
+        $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
+      }
+    }
+
+    /* Get classes for release from cache. 
+     * Or build cache
+     */
+    if($this->FAIdebianMirror == "inherited"){
+      $release = $this->InheritedFAIrelease;
+    }else{
+      $release = $this->FAIrelease;
+    }
+    if($force || !isset($this->cache['CLASSES'][$release])){
+
+      /*  Create a list of available releases.
+       *  $this->cache['RELEASE_DNS'][ou=siga...,c=de]         = "siga";
+       *  $this->cache['RELEASE_DNS'][ou=siga,ou=rc1,...,c=de] = "siga/rc1";
+       */
+      if($force || !isset($this->cache['RELEASE_DNS'])){
+        $this->cache['RELEASE_DNS'] = array();
+        $fai_ou_parts = preg_replace("/\/.*$/","",$this->FAIrelease);
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->search("(objectClass=FAIbranch)",array("ou"));
+        while($attrs = $ldap->fetch()){
+          if(preg_match("/".normalizePreg(get_ou("faiou"))."/",$attrs['dn'])){
+            $this->cache['RELEASE_DNS'][$attrs['dn']] = $this->dn_to_release_name($attrs['dn']);
+          }
+        }
+      }
+
+      /* Create list of available classes for the currenlty selected release.
+       */
+      $base = array_search($release,$this->cache['RELEASE_DNS']);
+      $this->cache['CLASSES'][$release] = array();
+
+      if(class_exists("FAI")){
+        if(!empty($base)){
+          $filter = "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)".
+            "(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)".
+            "(objectClass=FAIpartitionTable))";
+          $list = FAI::get_all_objects_for_given_base($base,$filter,TRUE);
+          foreach($list as $attrs){
+            $info = $this->analyse_fai_object($attrs);
+            if(count($info)){
+              $this->cache['CLASSES'][$release][$attrs['cn'][0]][] = $info;
+            }
+          }
+        }
+      }else{
+        print_red(_("Could not load available classes, the fai extension plugin seems not to be installed."));
+      }
+
+      /* Add object caught from external hook
+       */
+      $lines= $this->GetHookElements();
+      foreach ($lines as $hline){
+        $entries= split(";", $hline);
+        $server = $entries['0'];
+        $url    = $entries['1'];
+        if (!empty($url)){
+          
+          /* Split releases */
+          if (isset($entries[2])){
+            $releases= split(",", $entries[2]);
+
+            foreach ($releases as $release_data){
+              $release= preg_replace('/:.*$/', '', $release_data);
+              $sections = split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
+              $classes  = split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
+              $this->cache['SERVERS'][$url][$release]=$release;
+              $this->cache['SERVERS']['auto'][$release]=$release; 
+              foreach ($classes as $class){
+                if ($class != ""){
+                  $this->cache['CLASSES'][$release][$class]= array();
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
+
+  /* This function return an array containing all 
+   *  invalid classes for the selected server/release
+   */
+  function get_invalid_classes($classes)
+  {
+    $this->update_fai_cache();
+    if($this->FAIdebianMirror == "inherited"){
+      $release_classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
+    }else{
+      $release_classes = $this->cache['CLASSES'][$this->FAIrelease];
+    }
+
+
+    /* Detect all classes that are not valid 
+     *  for the selected release 
+     */
+    $NA = array();
+    foreach($classes as $class){
+      if(!isset($release_classes[$class])){
+        $NA[] = $class;
+      }
+    }
+    return($NA);
+  }  
+
+  
+  /* Get all selectable classes for the ui select box
+   */
+  function selectable_classes()
+  {
+    $this->update_fai_cache();
+
+    if($this->FAIdebianMirror == "inherited"){
+      $classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
+    }else{
+      $classes = $this->cache['CLASSES'][$this->FAIrelease];
+    }
+
+    $Abbr ="";
+    $ret= array();
+    foreach($classes as $class_name => $class_types){
+      if(!in_array($class_name,$this->FAIclass)){
+        foreach($class_types as $type){
+          if(!preg_match("/".$type['Abbr']."/",$Abbr)){
+            $Abbr .= $type['Abbr']." ";
+          }
+        }
+        $ret[$class_name] = trim($Abbr);
+      }
+    }
+    uksort($ret, 'strnatcasecmp');
+    return($ret);
+  }
+
+
+  /* Analyse FAI object and return an array with usefull informations like 
+   *  FAIobject type.
+   */
+  function analyse_fai_object($attr)
+  {
+    $tmp2 = array();
+    if(!isset($attr['description'])){
+      $attr['description'][0] ="";
+    }
+    if(in_array('FAIpackageList',$attr['objectClass'])){
+      $tmp2["Type"]   = 'FAIpackageList'; 
+      $tmp2["Abbr"]   = 'Pl';
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    if(in_array('FAItemplate',$attr['objectClass'])){
+      $tmp2["Type"]      = 'FAItemplate'; 
+      $tmp2["Abbr"]      = 'T'; 
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    if(in_array('FAIvariable',$attr['objectClass'])){
+      $tmp2["Type"]      = 'FAIvariable'; 
+      $tmp2["Abbr"]      = 'V'; 
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    if(in_array('FAIscript',$attr['objectClass'])){
+      $tmp2["Type"]        = 'FAIscript'; 
+      $tmp2["Abbr"]        = 'S'; 
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    if(in_array('FAIhook',$attr['objectClass'])){
+      $tmp2["Type"]          = 'FAIhook'; 
+      $tmp2["Abbr"]          = 'H'; 
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    if(in_array('FAIpartitionTable',$attr['objectClass'])){
+      $tmp2["Type"]= 'FAIpartitionTable'; 
+      $tmp2["Abbr"]= 'Pt'; 
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    if(in_array('FAIprofile',$attr['objectClass'])){
+      $tmp2["Type"]= 'FAIprofile'; 
+      $tmp2["Abbr"]= 'P'; 
+      $tmp2["Desc"]  = $attr['description'][0];
+    }
+    return($tmp2);
+  }
+
+
+  /* Return repository hook output, if possible.
+   */
+  function GetHookElements()
+  {
+    $ret = array();
+    $cmd= $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs'));
+    if(!empty($cmd)){
+      $res = shell_exec($cmd);
+      $res2 = trim($res);
+      if((!$res)){
+        print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s' please check your gosa.conf."),$cmd));
+      }elseif(empty($res2)){
+        print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd));
+      }else{
+        $tmp = split("\n",$res);
+        foreach($tmp as $line){
+          if(empty($line)) continue;
+          $ret[]= $line;
+        }
+      }
+    }
+    return($ret);
+  }
+
+
+  /* This function creates the release name out of a dn 
+   *  e.g. "ou=1.0rc2,ou=siga,ou=fai,..." => "siga/1.0rc2"
+   */
+  function dn_to_release_name($dn)
+  {
+    $relevant = preg_replace("/,".normalizePreg(get_ou("faiou")).".*$/","",$dn);
+    $parts    = array_reverse(split("\,",$relevant));
+    $str ="";
+    foreach($parts as $part){
+      $str .= preg_replace("/^ou=/","",$part)."/";
+    }
+    return(preg_replace("/\/$/","",$str)); 
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/gencd.tpl b/gosa-plugins/goto/admin/systems/goto/gencd.tpl
new file mode 100644 (file)
index 0000000..f0c4496
--- /dev/null
@@ -0,0 +1,20 @@
+<p>
+ <b>{t}CD-Install-Image generation{/t}</b>
+</p>
+<p>
+  {t}This option enables you to generate FAI install CD images for the selected workstation. The procedure may take about 10 minutes to complete, so please be patient after pressing the 'Create ISO-Image' button.{/t}
+</p>
+
+<p class="plugbottom">
+  <input type=submit name="cd_create" value="{t}Create ISO-Image{/t}">
+  &nbsp;
+  <input type=submit name="cd_cancel" value="{t}Cancel{/t}">
+</p>
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       nextfield= 'new_password';
+       focus_field('new_password');
+  -->
+</script>
diff --git a/gosa-plugins/goto/admin/systems/goto/gencd_frame.tpl b/gosa-plugins/goto/admin/systems/goto/gencd_frame.tpl
new file mode 100644 (file)
index 0000000..4c53bda
--- /dev/null
@@ -0,0 +1,3 @@
+<iframe src='{$src}' style='width:100%; height:550px;background-color:#FFFFFF;'>
+       {t}Your browser does not supprt iframes.{/t}
+</iframe>
diff --git a/gosa-plugins/goto/admin/systems/goto/info.tpl b/gosa-plugins/goto/admin/systems/goto/info.tpl
new file mode 100644 (file)
index 0000000..e088c59
--- /dev/null
@@ -0,0 +1,135 @@
+<h2><img class="center" alt="" align="middle" src="images/info_small.png"> {t}System information{/t}</h2>
+<table summary="" style="width:100%;">
+ <tr>
+  <td style="vertical-align:top; width:50%">
+   <table summary="">
+    <tr>
+     <td style="vertical-align:top"><b>{t}CPU{/t}</b></td><td>{$ghCpuType}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Memory{/t}</b></td><td>{$ghMemSize}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Boot MAC{/t}</b></td><td>{$macAddress}</td>
+    </tr>
+    <tr>
+     <td style="vertical-align:top;"><b>{t}USB support{/t}</b></td><td>{$ghUsbSupport}<div style="height:20px;"></div></td>
+    </tr>
+    <tr>
+     <td><b>{t}System status{/t}</b></td>
+     <td>{$status}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Inventory number{/t}</b></td>
+     <td>{$ghInventoryNumber}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Last login{/t}</b></td>
+     <td>{$gotoLastUser}</td>
+    </tr>
+   </table>
+  </td>
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  <td>
+   <table summary="">
+    <tr>
+     <td style="vertical-align:top"><b>{t}Network devices{/t}</b></td>
+     <td>
+      {foreach item=netcard from=$ghNetNic}
+        {$netcard}<br>
+      {/foreach}
+     </td>
+    </tr>
+    <tr><td colspan=2><div style="height:10px;"></div></td></tr>
+    <tr>
+     <td style="vertical-align:top;"><b>{t}IDE devices{/t}</b></td>
+     <td>
+       {foreach item=idedev from=$ghIdeDev}
+         {$idedev}<br>
+       {/foreach}
+     </td>
+    </tr>
+    <tr><td colspan=2><div style="height:10px;"></div></td></tr>
+    <tr>
+     <td style="vertical-align:top;"><b>{t}SCSI devices{/t}</b></td>
+     <td>
+       {foreach item=scsidev from=$ghScsiDev}
+         {$scsidev}<br>
+       {/foreach}
+     </td>
+    </tr>
+    <tr>
+     <td><b>{t}Floppy device{/t}</b></td>
+     <td>{$FloppyDevice}</td>
+    </tr>
+    <tr>
+     <td><b>{t}CDROM device{/t}</b></td>
+     <td>{$CdromDevice}</td>
+    </tr>
+    <tr><td colspan=2><div style="height:10px;"></div></td></tr>
+    <tr>
+     <td style="vertical-align:top"><b>{t}Graphic device{/t}</b></td>
+     <td>{$ghGfxAdapter}</td>
+    </tr>
+    <tr>
+     <td style="vertical-align:top"><b>{t}Audio device{/t}</b></td>
+     <td>{$ghSoundAdapter}</td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+
+{if $active eq "true"}
+<br>
+<h2 style="border-top:1px solid #A0A0A0; padding-top:5px;"><img class="center" alt="" align="middle" src="images/lamp.png"> {t}System status{/t}</h2>
+<table summary="" style="width:100%">
+ <tr>
+  <td style="vertical-align:top; width:50%">
+   <table summary="">
+    <tr>
+     <td><b>{t}Up since{/t}</b></td><td>{$uptime}</td>
+    </tr>
+    <tr>
+     <td><b>{t}CPU load{/t}</b></td><td>{$load}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Memory usage{/t}</b></td><td>{$mem}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Swap usage{/t}</b></td><td>{$swap}</td>
+    </tr>
+    <tr>
+     <td colspan=2>&nbsp;</td>
+    </tr>
+    {$partitions}
+   </table>
+  </td>
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  <td style="vertical-align:top;">
+   <table summary="">
+    <tr>
+     <td><b>{t}SSH service{/t}</b></td><td>{$sshd}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Print service{/t}</b></td><td>{$cupsd}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Scan service{/t}</b></td><td>{$saned}</td>
+    </tr>
+    <tr>
+     <td><b>{t}Sound service{/t}</b></td><td>{$artsd}</td>
+    </tr>
+    <tr>
+     <td><b>{t}GUI{/t}</b></td><td>{$X}</td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+{/if}
+
diff --git a/gosa-plugins/goto/admin/systems/goto/printer.tpl b/gosa-plugins/goto/admin/systems/goto/printer.tpl
new file mode 100644 (file)
index 0000000..e4ba965
--- /dev/null
@@ -0,0 +1,150 @@
+<table summary="" width="100%">
+ <tr>
+  <td style="vertical-align:top; width:50%; border-right:1px solid #B0B0B0">
+{if $StandAlone }
+   <h2>{t}General{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="cn" >{t}Printer name{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$cnACL}
+      <input name="cn" id="cn" size=20 maxlength=60 value="{$cn}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="description">{t}Description{/t}</LABEL></td>
+     <td>
+{render acl=$descriptionACL}
+      <input id="description" name="description" size=25 maxlength=80 value="{$description}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+      <td colspan=2>&nbsp;</td>
+    </tr>
+    <tr>
+     <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$baseACL}
+      <select id="base" size="1" name="base" title="{t}Choose subtree to place user in{/t}">
+       {html_options options=$bases selected=$base_select}
+      </select>
+{/render}
+{render acl=$baseACL disable_picture='images/folder_gray.png'}
+      <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
+  <td>
+{/if}
+   <h2>{t}Details{/t}</h2>
+   <table summary="">
+     <tr>
+       <td><LABEL for="l">{t}Printer location{/t}</LABEL></td>
+       <td>
+{render acl=$lACL}
+        <input id="l" name="l" size=25 maxlength=80 value="{$l}">
+{/render}
+       </td>
+     </tr>
+     <tr>
+       <td><LABEL for="labeledURI">{t}Printer URL{/t}</LABEL>{$must}</td>
+       <td>
+{render acl=$labeledURIACL}
+        <input id="labeledURI" name="labeledURI" size=25 maxlength=80 value="{$labeledURI}">
+{/render}
+       </td>
+     </tr>
+   </table>
+   <table summary="">
+    <tr> 
+     <td>
+      <br>
+      {t}Driver{/t}: <i>{$driverInfo}</i>&nbsp;
+{render acl=$gotoPrinterPPDACL mode=read_active}
+       <input type="submit" name="EditDriver" value="{t}Edit{/t}">
+{/render}
+{render acl=$gotoPrinterPPDACL}
+       <input type="submit" name="RemoveDriver" value="{t}Remove{/t}">
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+
+<h2><img class="center" alt="" align="middle" src="images/closedlock.png"> {t}Permissions{/t}</h2>
+<table summary="" width="100%">
+ <tr>
+  <td style="border-right:1px solid #B0B0B0; width:50%">
+   <table style="width:100%" summary=''>
+    <tr>
+     <td>
+      {t}Users which are allowed to use this printer{/t}<br>
+{render acl=$gotoUserPrinterACL}
+      <select size="1" name="UserMember[]" title="{t}Users{/t}" style="width:100%;height:120px;"  multiple>
+       {html_options options=$UserMembers values=$UserMemberKeys}
+      </select><br>
+{/render}
+{render acl=$gotoUserPrinterACL}
+      <input type="submit" value="{t}Add user{/t}"  name="AddUser">
+{/render}
+{render acl=$gotoUserPrinterACL}
+      <input type="submit" value="{t}Add group{/t}" name="AddGroup">
+{/render}
+{render acl=$gotoUserPrinterACL}
+      <input type="submit" value="{t}Delete{/t}" name="DelUser">
+{/render}
+     </td>
+    </tr>
+   </table> 
+  </td>
+  <td>
+   <table style="width:100%" summary=''>
+    <tr>
+     <td>
+      {t}Users which are allowed to administrate this printer{/t}<br>
+{render acl=$gotoUserPrinterACL}
+           <select size="1" name="AdminMember[]" title="{t}Admins{/t}" style="width:100%;height:120px;"  multiple>
+                    {html_options options=$AdminMembers values=$AdminMemberKeys}
+                   </select><br>
+{/render}
+{render acl=$gotoUserPrinterACL}
+       <input type="submit" value="{t}Add user{/t}"  name="AddAdminUser">
+{/render}
+{render acl=$gotoUserPrinterACL}
+       <input type="submit" value="{t}Add group{/t}" name="AddAdminGroup">
+{/render}
+{render acl=$gotoUserPrinterACL}
+       <input type="submit" value="{t}Delete{/t}" name="DelAdmin">
+{/render}
+  
+     </td>
+    </tr>
+   </table>
+   
+  </td>
+ </tr>
+</table>
+
+
+{if $netconfig ne ''}
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+{$netconfig}
+{/if}
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+
+  <!-- // First input field on page
+  if(document.mainform.cn)
+       focus_field('cn');
+  -->
+</script>
diff --git a/gosa-plugins/goto/admin/systems/goto/scanner-list b/gosa-plugins/goto/admin/systems/goto/scanner-list
new file mode 100644 (file)
index 0000000..3ebf2a1
--- /dev/null
@@ -0,0 +1,533 @@
+abaton "Abaton" "Scan 300/GS" "SCSI"
+abaton "Abaton" "Scan 300/S" "SCSI"
+agfafocus "AGFA" "Focus GS Scanner" "SCSI"
+agfafocus "AGFA" "Focus Lineart Scanner" "SCSI"
+agfafocus "AGFA" "Focus II" "SCSI"
+agfafocus "AGFA" "Focus Color" "SCSI"
+agfafocus "AGFA" "Focus Color Plus" "SCSI"
+agfafocus "Siemens" "S9036" "SCSI"
+apple "Apple" "Apple Scanner" "SCSI"
+apple "Apple" "OneScanner" "SCSI"
+apple "Apple" "ColorOneScanner" "SCSI"
+artec "Artec/Ultima" "AT3" "SCSI"
+artec "Artec/Ultima" "A6000C" "SCSI"
+artec "Artec/Ultima" "A6000C PLUS" "SCSI"
+artec "Artec/Ultima" "AT6" "SCSI"
+artec "Artec/Ultima" "AT12" "SCSI"
+artec "Artec/Ultima" "AM12S" "SCSI"
+artec "BlackWidow" "BW4800SP" "SCSI"
+artec "Plustek" "OpticPro 19200S" "SCSI"
+artec_eplus48u "Artec" "E+ 48U" "USB"
+artec_eplus48u "Tevion" "MD9693" "USB"
+artec_eplus48u "Medion" "MD9693" "USB"
+artec_eplus48u "Medion" "MD9705" "USB"
+artec_eplus48u "Medion" "MD4394" "USB"
+artec_eplus48u "Trust" "Easy Webscan 19200" "USB"
+artec_eplus48u "Memorex" "Mem 48 u" "USB"
+as6e "Artec/Ultima" "AS6E" "Parport"
+avision "Avision" "AV100CS" "SCSI"
+avision "Avision" "AV100IIICS" "SCSI"
+avision "Avision" "AV100S" "SCSI"
+avision "Avision" "AV240SC" "SCSI"
+avision "Avision" "AV260CS" "SCSI"
+avision "Avision" "AV360CS" "SCSI"
+avision "Avision" "AV363CS" "SCSI"
+avision "Avision" "AV420CS" "SCSI"
+avision "Avision" "AV6120" "SCSI"
+avision "Avision" "AV620CS" "SCSI"
+avision "Avision" "AV620CS Plus" "SCSI"
+avision "Avision" "AV630CS" "SCSI"
+avision "Avision" "AV630CSL" "SCSI"
+avision "Avision" "AV6240" "SCSI"
+avision "Avision" "AV600U" "USB"
+avision "Avision" "AV660S" "USB"
+avision "Avision" "AV680S" "USB"
+avision "Avision" "AV690U" "USB"
+avision "Avision" "AV800S" "SCSI"
+avision "Avision" "AV810C" "SCSI"
+avision "Avision" "AV820" "SCSI"
+avision "Avision" "AV820C" "SCSI"
+avision "Avision" "AV820C Plus" "SCSI"
+avision "Avision" "AV830C" "SCSI"
+avision "Avision" "AV830C Plus" "SCSI"
+avision "Avision" "AV880" "SCSI"
+avision "Avision" "AV880C" "SCSI"
+avision "Avision" "AV8000S" "SCSI"
+avision "Avision" "AVA3" "SCSI"
+avision "Hewlett-Packard" "ScanJet 5300C" "USB"
+avision "Hewlett-Packard" "ScanJet 5370C" "USB"
+avision "Hewlett-Packard" "ScanJet 7400c" "USB"
+avision "Minolta" "FS-V1" "USB"
+avision "Mitsubishi" "MCA-ADFC" "SCSI"
+avision "Mitsubishi" "S1200C" "SCSI"
+avision "Mitsubishi" "S600C" "SCSI"
+avision "Mitsubishi" "SS600" "SCSI"
+avision "Fujitsu" "ScanPartner" "SCSI"
+avision "Fujitsu" "ScanPartner 10" "SCSI"
+avision "Fujitsu" "ScanPartner 10C" "SCSI"
+avision "Fujitsu" "ScanPartner 15C" "SCSI"
+avision "Fujitsu" "ScanPartner 300C" "SCSI"
+avision "Fujitsu" "ScanPartner 600C" "SCSI"
+avision "Fujitsu" "ScanPartner Jr" "SCSI"
+bh "Bell and Howell" "COPISCAN II 6338" "SCSI"
+bh "Bell and Howell" "COPISCAN II 2135" "SCSI"
+bh "Bell and Howell" "COPISCAN II 2137(A)" "SCSI"
+bh "Bell and Howell" "COPISCAN II 2138A" "SCSI"
+bh "Bell and Howell" "COPISCAN II 3238" "SCSI"
+bh "Bell and Howell" "COPISCAN II 3338(A)" "SCSI"
+canon "Canon" "CanoScan 300" "SCSI"
+canon "Canon" "CanoScan 600" "SCSI"
+canon "Canon" "CanoScan 620S" "SCSI"
+canon "Canon" "CanoScan 2700F" "SCSI"
+canon "Canon" "CanoScan 2710" "SCSI"
+canon630u "Canon" "CanoScan fb630u" "USB"
+canon630u "Canon" "CanoScan fb636u" "USB"
+canon_pp "Canon" "CanoScan FB310P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan FB610P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan FB320P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan FB620P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan FB330P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan FB630P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan N340P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan N640P" "Parport (ECP)"
+canon_pp "Canon" "CanoScan N640P ex" "Parport (ECP)"
+coolscan "Nikon" "LS-20" "SCSI"
+coolscan "Nikon" "LS-30" "SCSI"
+coolscan "Nikon" "LS-2000" "SCSI"
+coolscan "Nikon" "LS-1000" "SCSI"
+coolscan2 "Nikon" "LS 30" "SCSI"
+coolscan2 "Nikon" "LS 2000" "SCSI"
+coolscan2 "Nikon" "LS 40 ED" "USB"
+coolscan2 "Nikon" "LS 4000 ED" "IEEE1394"
+coolscan2 "Nikon" "LS 8000 ED" "IEEE1394"
+dc210 "Kodak" "DC210" "Serial port"
+dc240 "Kodak" "DC240" "Serial port"
+dc25 "Kodak" "DC25" "Serial port"
+dc25 "Kodak" "DC20" "Serial port"
+dmc "Polaroid" "DMC" "SCSI"
+epson "Epson" "GT-5000" "Parport"
+epson "Epson" "Actionscanner II" "Parport"
+epson "Epson" "GT-6000" "SCSI Parport"
+epson "Epson" "ES-300C" "SCSI Parport"
+epson "Epson" "GT-5500" "SCSI"
+epson "Epson" "GT-6500" "Parport"
+epson "Epson" "ES-600C" "Parport"
+epson "Epson" "ES-1200C" "Parport"
+epson "Epson" "GT-7000" "SCSI"
+epson "Epson" "GT-8000" "SCSI"
+epson "Epson" "ES-8500" "SCSI"
+epson "Epson" "Perfection 636S" "SCSI"
+epson "Epson" "Perfection 636U" "USB"
+epson "Epson" "Perfection 610" "USB"
+epson "Epson" "Perfection 640" "USB"
+epson "Epson" "Perfection 1200S" "SCSI"
+epson "Epson" "Perfection 1200U" "USB"
+epson "Epson" "Perfection 1200Photo" "USB"
+epson "Epson" "Perfection 1240" "SCSI USB"
+epson "Epson" "Perfection 1640" "SCSI USB"
+epson "Epson" "Perfection 1650" "USB"
+epson "Epson" "Perfection 1660" "USB"
+epson "Epson" "Perfection 2400" "USB"
+epson "Epson" "Perfection 2450" "USB IEEE-1394"
+epson "Epson" "Perfection 3200" "USB"
+epson "Epson" "Expression 636" "SCSI"
+epson "Epson" "Expression 800" "SCSI"
+epson "Epson" "Expression 1600" "SCSI USB IEEE-1394"
+epson "Epson" "Expression 1680" "SCSI USB IEEE-1394"
+epson "Epson" "FilmScan 200" "SCSI"
+epson "Epson" "CX-3200" "USB"
+epson "Epson" "CX-5200" "USB"
+fujitsu "Fujitsu" "M3096G" "SCSI"
+fujitsu "Fujitsu" "M3091DCd" "SCSI"
+fujitsu "Fujitsu" "M3092DCd" "SCSI"
+fujitsu "Fujitsu" "M3093GXim" "SCSI"
+fujitsu "Fujitsu" "M3093GDim" "SCSI"
+fujitsu "Fujitsu" "M4097" "SCSI"
+fujitsu "Fujitsu" "fi-4340C" "SCSI"
+gt68xx "Mustek" "BearPaw 1200 CS" "USB"
+gt68xx "Mustek" "BearPaw 1200 CU" "USB"
+gt68xx "Mustek" "BearPaw 1200 CU Plus" "USB"
+gt68xx "Mustek" "BearPaw 1200 TA" "USB"
+gt68xx "Mustek" "BearPaw 2400 CS" "USB"
+gt68xx "Mustek" "BearPaw 2400 CS Plus" "USB"
+gt68xx "Mustek" "BearPaw 2400 CU" "USB"
+gt68xx "Mustek" "BearPaw 2400 CU Plus" "USB"
+gt68xx "Mustek" "BearPaw 2400 TA" "USB"
+gt68xx "Mustek" "BearPaw 2400 TA Plus" "USB"
+gt68xx "Mustek" "ScanExpress 1200 UB Plus" "USB"
+gt68xx "Mustek" "ScanExpress A3 USB" "USB"
+gt68xx "Mustek" "ScanExpress 2400 USB" "USB"
+gt68xx "Plustek" "OpticPro 1248U" "USB"
+gt68xx "Plustek" "OpticPro UT16B" "USB"
+gt68xx "Artec" "Ultima 2000" "USB"
+gt68xx "Artec" "Ultima 2000 e+" "USB"
+gt68xx "Boeder" "Sm@rtScan Slim Edition" "USB"
+gt68xx "Packard Bell" "Diamond 1200" "USB"
+gt68xx "Medion/Lifetec/Tevion/Cytron" "LT 9452" "USB"
+gt68xx "Medion/Lifetec/Tevion/Cytron" "MD/LT 9375" "USB"
+gt68xx "Medion/Lifetec/Tevion/Cytron" "MD/LT 9385" "USB"
+gt68xx "Medion/Lifetec/Tevion/Cytron" "MD 9458" "USB"
+gt68xx "Trust" "Flat Scan USB 19200" "USB"
+gt68xx "Trust" "Compact Scan USB 19200" "USB"
+gt68xx "Lexmark" "X70" "USB"
+gt68xx "Lexmark" "X73" "USB"
+gt68xx "Genius" "Colorpage Vivid3x" "USB"
+hp "Hewlett-Packard" "ScanJet Plus" "Propietary"
+hp "Hewlett-Packard" "ScanJet IIc" "SCSI"
+hp "Hewlett-Packard" "ScanJet IIp" "SCSI"
+hp "Hewlett-Packard" "ScanJet IIcx" "SCSI"
+hp "Hewlett-Packard" "ScanJet 3c" "SCSI"
+hp "Hewlett-Packard" "ScanJet 3p" "SCSI"
+hp "Hewlett-Packard" "ScanJet 4c" "SCSI"
+hp "Hewlett-Packard" "ScanJet 4p" "SCSI"
+hp "Hewlett-Packard" "ScanJet 4100C" "USB"
+hp "Hewlett-Packard" "ScanJet 5p" "SCSI"
+hp "Hewlett-Packard" "ScanJet 5100C" "Parport"
+hp "Hewlett-Packard" "ScanJet 5200C" "Parport USB"
+hp "Hewlett-Packard" "ScanJet 6100C" "SCSI"
+hp "Hewlett-Packard" "ScanJet 6200C" "SCSI USB"
+hp "Hewlett-Packard" "ScanJet 6250C" "SCSI USB"
+hp "Hewlett-Packard" "ScanJet 6300C" "SCSI USB"
+hp "Hewlett-Packard" "ScanJet 6350C" "SCSI USB"
+hp "Hewlett-Packard" "ScanJet 6390C" "SCSI USB"
+hp "Hewlett-Packard" "PhotoSmart PhotoScanner" "SCSI"
+hpsj5s "Hewlett-Packard" "ScanJet 5s" "Parport (EPP)"
+leo "LEO" "LEOScan S3" "SCSI"
+leo "Across Technologies" "FS-1130" "SCSI"
+leo "Genius" "FS-1130 Colorpage Scanner" "SCSI"
+matsushita "Panasonic" "KV-SS25" "SCSI"
+matsushita "Panasonic" "KV-SS25D" "SCSI"
+matsushita "Panasonic" "KV-SS50" "SCSI"
+matsushita "Panasonic" "KV-SS55" "SCSI"
+matsushita "Panasonic" "KV-SS50EX" "SCSI"
+matsushita "Panasonic" "KV-SS55EX" "SCSI"
+matsushita "Panasonic" "KV-SS850" "SCSI"
+matsushita "Panasonic" "KV-SS855" "SCSI"
+microtek "Microtek" "Scanmaker E6" "SCSI"
+microtek "Microtek" "Scanmaker E3" "SCSI"
+microtek "Microtek" "Scanmaker E2" "SCSI"
+microtek "Microtek" "Scanmaker 35t+" "SCSI"
+microtek "Microtek" "Scanmaker 45t" "SCSI"
+microtek "Microtek" "Scanmaker 35" "SCSI"
+microtek "Microtek" "Scanmaker III" "SCSI"
+microtek "Microtek" "Scanmaker IISP" "SCSI"
+microtek "Microtek" "Scanmaker IIHR" "SCSI"
+microtek "Microtek" "Scanmaker IIG" "SCSI"
+microtek "Microtek" "Scanmaker II" "SCSI"
+microtek "Microtek" "Scanmaker 600Z(S)" "SCSI"
+microtek "Microtek" "Scanmaker 600G(S)" "SCSI"
+microtek "Microtek" "Color PageWiz" "SCSI (Parport)"
+microtek "Agfa" "Arcus II" "SCSI"
+microtek "Agfa" "StudioScan" "SCSI"
+microtek "Agfa" "StudioScan II" "SCSI"
+microtek "Agfa" "StudioScan IIsi" "SCSI"
+microtek "Agfa" "DuoScan" "SCSI"
+microtek2 "Microtek" "ScanMaker E3plus" "Parport"
+microtek2 "Microtek" "ScanMaker E3plus" "SCSI"
+microtek2 "Microtek" "ScanMaker X6" "SCSI"
+microtek2 "Microtek" "ScanMaker X6EL" "SCSI"
+microtek2 "Microtek" "ScanMaker X6USB" "USB"
+microtek2 "Microtek" "ScanMaker V300" "SCSI"
+microtek2 "Microtek" "ScanMaker V300" "Parport"
+microtek2 "Microtek" "ScanMaker V310" "SCSI"
+microtek2 "Microtek" "ScanMaker V310" "Parport"
+microtek2 "Microtek" "ScanMaker V600" "SCSI"
+microtek2 "Microtek" "ScanMaker V600" "Parport"
+microtek2 "Microtek" "ScanMaker 330" "SCSI"
+microtek2 "Microtek" "ScanMaker 630" "SCSI"
+microtek2 "Microtek" "ScanMaker 636" "SCSI"
+microtek2 "Microtek" "ScanMaker 9600XL" "SCSI"
+microtek2 "Microtek" "ScanMaker 9600XL" "SCSI"
+microtek2 "Microtek" "Phantom 330CX" "Parport"
+microtek2 "Microtek" "SlimScan C3" "Parport"
+microtek2 "Microtek" "Phantom 636" "SCSI"
+microtek2 "Microtek" "Phantom 636CX" "Parport"
+microtek2 "Microtek" "SlimScan C6" "USB"
+microtek2 "Microtek" "ScanMaker V6USL" "SCSI"
+microtek2 "Microtek" "ScanMaker V6USL" "USB"
+microtek2 "Microtek" "ScanMaker X12USL" "SCSI"
+microtek2 "Vobis" "HighScan" "SCSI"
+microtek2 "Scanport" "SQ300" "Parport?"
+microtek2 "Scanport" "SQ2030" "Parport"
+microtek2 "Scanport" "SQ4836" "SCSI"
+mustek "Mustek" "Paragon MFS-6000CX" "SCSI"
+mustek "Mustek" "Paragon MFS-12000CX" "SCSI"
+mustek "Mustek" "Paragon MFC-600S" "SCSI"
+mustek "Mustek" "Paragon 600 II CD" "SCSI"
+mustek "Mustek" "ScanMagic 600 II SP" "SCSI"
+mustek "Mustek" "Paragon MFC-800S" "SCSI"
+mustek "Mustek" "Paragon 800 II SP" "SCSI"
+mustek "Mustek" "Paragon MFS-6000SP" "SCSI"
+mustek "Mustek" "Paragon MFS-8000SP" "SCSI"
+mustek "Mustek" "Paragon MFS-1200SP" "SCSI"
+mustek "Mustek" "Paragon MFS-12000SP" "SCSI"
+mustek "Mustek" "ScanExpress 6000SP" "SCSI"
+mustek "Mustek" "ScanExpress 12000SP" "SCSI"
+mustek "Mustek" "ScanExpress 12000SP Plus" "SCSI"
+mustek "Mustek" "Paragon 1200 III SP" "SCSI"
+mustek "Mustek" "Paragon 1200 LS" "SCSI"
+mustek "Mustek" "ScanMagic 9636S" "SCSI"
+mustek "Mustek" "ScanMagic 9636S Plus" "SCSI"
+mustek "Mustek" "ScanExpress A3 SP" "SCSI"
+mustek "Mustek" "Paragon 1200 SP Pro" "SCSI"
+mustek "Mustek" "Paragon 1200 A3 Pro" "SCSI"
+mustek "Mustek" "Paragon 600 II N" "Proprietary"
+mustek "Trust" "Imagery 1200" "SCSI"
+mustek "Trust" "Imagery 1200 SP" "SCSI"
+mustek "Trust" "Imagery 4800 SP" "SCSI"
+mustek "Trust" "SCSI Connect 19200" "SCSI"
+mustek "Trust" "SCSI excellence series 19200" "SCSI"
+mustek "Primax" "Compact 4800 SCSI" "SCSI"
+mustek_pp "Mustek" "ScanExpress 6000 P" "Parport (EPP)"
+mustek_pp "Mustek" "ScanExpress 600 SEP" "Parport (EPP)"
+mustek_pp "Mustek" "ScanMagic 4800 P" "Parport (EPP)"
+mustek_pp "Mustek" "600 III EP Plus" "Parport (EPP)"
+mustek_pp "Mustek" "ScanExpress 600 CP" "Parport (EPP)"
+mustek_pp "Mustek" "ScanMagic 600 CP" "Parport (EPP)"
+mustek_pp "Mustek" "1200 CP" "Parport (EPP)"
+mustek_pp "Mustek" "1200 CP+" "Parport (EPP)"
+mustek_pp "Medion/Tevion/LifeTec" "MD 9848" "Parport (EPP)"
+mustek_pp "Medion/Tevion/LifeTec" "MD/LT 935x" "Parport (EPP)"
+mustek_pp "Medion/Tevion/LifeTec" "MD/LT 985x" "Parport (EPP)"
+mustek_pp "Medion/Tevion/LifeTec" "MD/LT 9890" "Parport (EPP)"
+mustek_pp "Targa" "Funline TS12 EP" "Parport (EPP)"
+mustek_pp "Targa" "Funline TS6 EP" "Parport (EPP)"
+mustek_pp "Trust Easy Connect" "9600+" "Parport (EPP)"
+mustek_pp "Viviscan" "Compact II" "Parport (EPP)"
+mustek_pp "Cybercom" "9352" "Parport (EPP)"
+mustek_pp "Gallery" "4800" "Parport (EPP)"
+mustek_usb "Mustek" "ScanExpress 600 CU" "USB"
+mustek_usb "Mustek" "ScanExpress 1200 CU" "USB"
+mustek_usb "Mustek" "ScanExpress 1200 CU Plus" "USB"
+mustek_usb "Mustek" "ScanExpress 1200 UB" "USB"
+mustek_usb "Trust" "Compact Scan USB 19200" "USB"
+nec "NEC" "PC-IN500/4C" "SCSI"
+pie "Devcom" "9636PRO" "SCSI"
+pie "Devcom" "9636S" "SCSI"
+pie "Devcom" "9630S" "SCSI"
+pie "PIE" "ScanAce 1236S" "SCSI"
+pie "PIE" "ScanAce 1230S" "SCSI"
+pie "PIE" "ScanAce II" "SCSI"
+pie "PIE" "ScanAce III" "SCSI"
+pie "PIE" "ScanAce Plus" "SCSI"
+pie "PIE" "ScanAce II Plus" "SCSI"
+pie "PIE" "ScanAce III Plus" "SCSI"
+pie "PIE" "ScanAce V" "SCSI"
+pie "PIE" "ScanAce ScanMedia" "SCSI"
+pie "PIE" "ScanAce ScanMedia II" "SCSI"
+pie "PIE" "ScanAce 630S" "SCSI"
+pie "PIE" "ScanAce 636S" "SCSI"
+pie "Adlib" "JetScan630" "SCSI"
+pie "Adlib" "JetScan636PRO" "SCSI"
+plustek "Plustek" "OpticPro 4800P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 4830P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 600P/6000P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 4831P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 9630P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 9630PL" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 9600P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 1236P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 12000P/96000P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 9636P" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 9636P+/Turbo" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 9636T" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro 12000T" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro AI3" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro P8" "Parport"
+plustek "Plustek" "OpticPro P12" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro PT12" "Parport (SPP, EPP)"
+plustek "Plustek" "OpticPro U12" "USB"
+plustek "Plustek" "OpticPro UT12" "USB"
+plustek "Plustek" "OpticPro UT16" "USB"
+plustek "Plustek" "OpticPro U24" "USB"
+plustek "Plustek" "OpticPro UT24" "USB"
+plustek "Plustek" "OpticPro 19200S" "SCSI"
+plustek "Primax" "Colorado 4800" "Parport (SPP, EPP)"
+plustek "Primax" "Compact 4800 Direct" "Parport (SPP, EPP)"
+plustek "Primax" "Compact 4800 Direct-30" "Parport (SPP, EPP)"
+plustek "Primax" "Compact 9600 Direct-30" "Parport (SPP, EPP)"
+plustek "Genius" "Colorpage Vivid III V2" "Parport (SPP, EPP)"
+plustek "Genius" "Colorpage Vivid Pro II Film" "Parport (SPP, EPP)"
+plustek "Genius" "Colorpage HR6 V2" "USB"
+plustek "Genius" "Colorpage HR7" "USB"
+plustek "Genius" "Colorpage HR6A" "USB"
+plustek "Genius" "Colorpage HR7LE" "USB"
+plustek "Genius" "Colorpage HR6X" "USB"
+plustek "Aries" "Scan-It Pro 4800" "Parport (SPP, EPP)"
+plustek "BrightScan" "BrighScan OpticPro" "Parport (SPP, EPP)"
+plustek "Mustek" "BearPaw 1200" "USB"
+plustek "Mustek" "BearPaw 2400" "USB"
+plustek "Hewlett-Packard" "ScanJet 2100C" "USB"
+plustek "Hewlett-Packard" "ScanJet 2200C" "USB"
+plustek "Epson" "Perfection 1250" "USB"
+plustek "Epson" "Perfection 1250Photo" "USB"
+plustek "Epson" "Perfection 1260" "USB"
+plustek "Epson" "Perfection 1260Photo" "USB"
+plustek "Umax" "UMAX 3400" "USB"
+plustek "Umax" "UMAX 5400" "USB"
+plustek "Canon" "CanoScan N650U/N656U" "USB"
+plustek "Canon" "CanoScan N1220U" "USB"
+plustek "Canon" "CanoScan N670U/N676U" "USB"
+plustek "Canon" "CanoScan N1240U" "USB"
+plustek "Canon" "CanoScan LiDE20" "USB"
+plustek "Canon" "CanoScan LiDE30" "USB"
+qcam "Connectix" "Color QuickCam" "Parport"
+qcam "Connectix" "Greyscale QuickCam" "Parport"
+ricoh "Ricoh" "Ricoh IS50" "SCSI"
+ricoh "Ricoh" "Ricoh IS60" "SCSI"
+s9036 "Siemens" "9036 Flatbed scanner" "SCSI"
+sceptre "Sceptre" "Vividscan S1200" "SCSI"
+sceptre "Komodo" "S1200" "SCSI"
+sharp "Sharp" "JX-610" "SCSI"
+sharp "Sharp" "JX-250" "SCSI"
+sharp "Sharp" "JX-320" "SCSI"
+sharp "Sharp" "JX-325" "SCSI"
+sharp "Sharp" "JX-330" "SCSI"
+sharp "Sharp" "JX-350" "SCSI"
+sm3600 "Microtek" "ScanMaker 3600" "USB"
+sm3600 "Microtek" "ScanMaker 3700" "USB"
+sm3600 "Microtek" "ScanMaker 3750" "USB"
+SnapScan "AGFA" "SnapScan 300" "SCSI"
+SnapScan "AGFA" "SnapScan 310" "SCSI"
+SnapScan "AGFA" "SnapScan 600" "SCSI"
+SnapScan "AGFA" "SnapScan 1236s" "SCSI"
+SnapScan "AGFA" "SnapScan 1236u" "USB"
+SnapScan "AGFA" "SnapScan 1212u" "USB"
+SnapScan "AGFA" "SnapScan e10" "USB"
+SnapScan "AGFA" "SnapScan e20" "USB"
+SnapScan "AGFA" "SnapScan e25" "USB"
+SnapScan "AGFA" "SnapScan e26" "USB"
+SnapScan "AGFA" "SnapScan e40" "USB"
+SnapScan "AGFA" "SnapScan e42" "USB"
+SnapScan "AGFA" "SnapScan e50" "USB"
+SnapScan "AGFA" "SnapScan e52" "USB"
+SnapScan "AGFA" "SnapScan e60" "USB"
+SnapScan "Benq" "300f" "SCSI"
+SnapScan "Benq" "310s" "SCSI"
+SnapScan "Benq" "610s" "SCSI"
+SnapScan "Benq" "610plus" "SCSI"
+SnapScan "Benq" "620s" "SCSI"
+SnapScan "Benq" "310u" "USB"
+SnapScan "Benq" "320u" "USB"
+SnapScan "Benq" "340u" "USB"
+SnapScan "Benq" "620u" "USB"
+SnapScan "Benq" "640u" "USB"
+SnapScan "Benq" "640bu" "USB"
+SnapScan "Benq" "1240" "USB"
+SnapScan "Benq" "3300" "USB"
+SnapScan "Benq" "4300" "USB"
+SnapScan "Benq" "5000" "USB"
+SnapScan "Benq" "5300" "USB"
+SnapScan "Guillemot / Hercules" "Maxi Scan A4 Deluxe (SCSI)" "SCSI"
+SnapScan "Guillemot / Hercules" "Scan@home Touch 1248 (USB)" "USB"
+SnapScan "Mitsubishi" "Diamondview 648UT" "USB"
+SnapScan "Mitsubishi" "Diamondview 650U" "USB"
+sp15c "Fujitsu" "SP15C" "SCSI"
+st400 "Siemens" "ST400" "SCSI"
+st400 "Siemens" "ST800" "SCSI"
+tamarack "Tamarack" "Artiscan 6000C" "SCSI"
+tamarack "Tamarack" "Artiscan 8000C" "SCSI"
+tamarack "Tamarack" "Artiscan 12000C" "SCSI"
+teco1 "Relisys" "RELI 2412" "SCSI"
+teco1 "Relisys" "AVEC 2400" "SCSI"
+teco1 "Relisys" "RELI 4830" "SCSI"
+teco1 "Relisys" "AVEC 2412" "SCSI"
+teco1 "Relisys" "AVEC 4800" "SCSI"
+teco1 "Relisys" "AVEC 4816" "SCSI"
+teco1 "Relisys" "RELI DS6" "SCSI"
+teco1 "Relisys" "RELI DS15" "SCSI"
+teco1 "Relisys" "RELI 2400" "SCSI"
+teco1 "Relisys" "RELI 4816" "SCSI"
+teco1 "Relisys" "RELI 9600" "SCSI"
+teco1 "Relisys" "RELI 9612" "SCSI"
+teco1 "Relisys" "RELI 9624" "SCSI"
+teco1 "Relisys" "RELI 9630" "SCSI"
+teco1 "Actown" "ACT Scan I 30" "SCSI"
+teco1 "Dextra" "DF-600P" "SCSI"
+teco1 "Dextra" "DF-1200T+" "SCSI"
+teco1 "Dextra" "DF-4830T" "SCSI"
+teco1 "Dextra" "DF-9624" "SCSI"
+teco2 "Relisys" "AVEC Super 3" "SCSI"
+teco2 "Relisys" "SCORPIO Super 3" "SCSI"
+teco2 "Relisys" "APOLLO Express 6" "SCSI"
+teco2 "Relisys" "SCORPIO Pro" "SCSI"
+teco2 "Relisys" "SCORPIO Pro-S" "SCSI"
+teco2 "Primax" "Profi 9600" "SCSI"
+teco2 "Primax" "Profi 19200" "SCSI"
+teco3 "Relisys" "Infinity Scorpio" "SCSI"
+teco3 "Plustek" "OpticPro 2400SP" "SCSI"
+teco3 "PIOTECH" "Splendeur 3024" "SCSI"
+teco3 "Trust" "Imagery 2400 SP" "SCSI"
+teco3 "Trust" "Imagery 4800 SP+" "SCSI"
+teco3 "Trust" "Imagery 9600 SP" "SCSI"
+umax "UMAX" "Vista S6" "SCSI"
+umax "UMAX" "Vista S6E" "SCSI"
+umax "UMAX" "UMAX S-6E" "SCSI"
+umax "UMAX" "UMAX S-6EG" "SCSI"
+umax "UMAX" "Vista-S8" "SCSI"
+umax "UMAX" "Supervista S-12" "SCSI"
+umax "UMAX" "UMAX S-12" "SCSI"
+umax "UMAX" "UMAX S-12G" "SCSI"
+umax "UMAX" "Astra 600S" "SCSI"
+umax "UMAX" "Astra 610S" "SCSI"
+umax "UMAX" "Astra 1200S" "SCSI"
+umax "UMAX" "Astra 1220S" "SCSI"
+umax "UMAX" "Astra 2100S" "SCSI"
+umax "UMAX" "Astra 2200 (SU)" "SCSI"
+umax "UMAX" "Astra 2200 (SU)" "USB"
+umax "UMAX" "Astra 2400S" "SCSI"
+umax "UMAX" "Astra 6400" "IEEE-1394"
+umax "UMAX" "Astra 6450" "IEEE-1394"
+umax "UMAX" "Astra MX3" "SCSI"
+umax "UMAX" "Astra MX3" "USB"
+umax "UMAX" "Mirage D-16L" "SCSI"
+umax "UMAX" "Mirage II" "SCSI"
+umax "UMAX" "Mirage IIse" "SCSI"
+umax "UMAX" "PSD" "SCSI"
+umax "UMAX" "PowerLook" "SCSI"
+umax "UMAX" "PL-II" "SCSI"
+umax "UMAX" "PowerLook III" "SCSI"
+umax "UMAX" "PowerLook 270" "SCSI"
+umax "UMAX" "PowerLook 270plus" "SCSI"
+umax "UMAX" "PowerLook 1100" "IEEE-1394"
+umax "UMAX" "PowerLook 2000" "SCSI"
+umax "UMAX" "PowerLook 2100XL" "SCSI"
+umax "UMAX" "PowerLook 3000" "SCSI"
+umax "UMAX" "Gemini D-16" "SCSI"
+umax "UMAX" "UMAX VT600" "SCSI"
+umax "UMAX" "Vista-T630" "SCSI"
+umax "UMAX" "UC 630" "SCSI"
+umax "UMAX" "UG 630" "SCSI"
+umax "UMAX" "UG 80" "SCSI"
+umax "UMAX" "UC 840" "SCSI"
+umax "UMAX" "UC 1200S" "SCSI"
+umax "UMAX" "UC 1200SE" "SCSI"
+umax "UMAX" "UC 1260" "SCSI"
+umax "Linotype Hell" "Jade" "SCSI"
+umax "Linotype Hell" "Jade" "SCSI"
+umax "Linotype Hell" "Jade2" "SCSI"
+umax "Linotype Hell" "Saphir" "SCSI"
+umax "Linotype Hell" "Saphir2" "SCSI"
+umax "Linotype Hell" "Saphir3" "SCSI"
+umax "Linotype Hell" "Saphir Ultra" "SCSI"
+umax "Linotype Hell" "Saphir Ultra II" "SCSI"
+umax "Linotype Hell" "Saphir HiRes" "SCSI"
+umax "Linotype Hell" "Opal" "SCSI"
+umax "Linotype Hell" "Opal Ultra" "SCSI"
+umax "Linotype Hell" "Linoscan 1400" "SCSI"
+umax "Vobis" "Highscreen Scanboostar Premium" "SCSI"
+umax "EDGE" "KTX-9600US" "SCSI"
+umax "Epson" "Perfection 600" "SCSI"
+umax "Escom" "Image Scanner 256" "SCSI"
+umax "Escort" "Galleria 600" "SCSI"
+umax "Genius" "ColorPage-HR5 (Pro)" "SCSI"
+umax "Nikon" "AX-110 / Scantouch 110" "SCSI"
+umax "Nikon" "AX-210" "SCSI"
+umax1220u "UMAX" "Astra 1220U" "USB"
+umax1220u "UMAX" "Astra 2000U" "USB"
+umax1220u "UMAX" "Astra 2200U" "USB"
+umax_pp "UMAX" "Astra 1220P" "Parport (EPP)"
+umax_pp "UMAX" "Astra 2000P" "Parport (EPP)"
+umax_pp "UMAX" "Astra 1600P" "Parport (EPP)"
+umax_pp "UMAX" "Astra 610P" "Parport (EPP)"
+umax_pp "Hewlett-Packard" "Scanjet 3200C" "Parport (EPP)"
diff --git a/gosa-plugins/goto/admin/systems/goto/selectUserToPrinterDialog.tpl b/gosa-plugins/goto/admin/systems/goto/selectUserToPrinterDialog.tpl
new file mode 100644 (file)
index 0000000..c60be22
--- /dev/null
@@ -0,0 +1,70 @@
+    <input type="hidden" name="dialogissubmitted" value="1">
+
+       <table summary="{t}Select printer to add{/t}" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+        <tr>
+            <td style="width:600px">
+                               <div class="contentboxh" style="height:20px;">
+                               <p class="contentboxh" style="font-size:12px">
+                                       <b><LABEL for="gotoPrinter">{t}Select entries to add{/t}</LABEL></b>
+                               </p>
+                               </div>
+                               <div class="contentboxb">
+                               <p class="contentboxb" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                               <select style="width:600px;height:450px;" size=20 name="gotoPrinter[]" id="gotoPrinter" multiple>
+                               {html_options values=$gotoPrinterKeys output=$gotoPrinters}
+                               <option disabled>&nbsp;</option>
+                                        </select><br>
+                                       </p>
+                               </div>
+            </td>
+            <td valign="top">
+                               <div class="contentboxh" style="height:20px">
+                               <p class="contentboxh" style="font-size:12px"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+                               </div>
+                               <div class="contentboxb">
+                               <table summary="" style="width:100%;border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                               {$alphabet}
+                               </table>
+                                       <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                                               <tr>
+                                                       <td>
+                                                               <input type='checkbox' name='SubSearch' value='1' title='{t}Select to search within subtrees{/t}' onClick='document.mainform.submit();' {$subtree}>&nbsp;{t}Search in subtrees{/t}
+                                                       </td>
+                                               </tr>
+                                       </table>
+                               <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                                       <tr>
+                                               <td>
+                                                       <label for="dspselectPrinter"><img class="center" alt="" src="{$tree_image}" align="middle" title="{t}Display members of department{/t}"></label>
+                                               </td>
+                                               <td style="width:99%">
+                                                       <select style="width:99%" name="depselectPrinter" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
+                                                         {html_options options=$deplistPrinter selected=$depselectPrinter}
+                                                       </select>
+                                               </td>
+                                       </tr>
+                               </table>
+                                       <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for='filter'><img class="center" alt="Search" src="{$search_image}" align="middle" title="{t}Display members matching{/t}">
+                                                                       </LABEL>
+                                                               </td>
+                                                       <td width="99%">
+                                                                       <input id='filter' style='width:99%' type='text' name='regexPrinter' maxlength='20' value='{$regexPrinter}' 
+                                                                                       title='{t}Regular expression for matching member names{/t}' onChange="mainform.submit()">
+                                                               </td>
+                                                       </tr>
+                                               </table>
+                                       {$apply}
+                               </div>
+               </td>
+       </tr>
+    </table>
+
+       <p class="seperator">&nbsp;</p>
+    <p align="right">
+    <input type="submit" name="PrinterSave"     value="{t}Add{/t}">
+    <input type="submit" name="PrinterCancel"   value="{t}Cancel{/t}">
+    </p>
+
diff --git a/gosa-plugins/goto/admin/systems/goto/tabs_printers.inc b/gosa-plugins/goto/admin/systems/goto/tabs_printers.inc
new file mode 100644 (file)
index 0000000..739777a
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+class printtabs extends tabs
+{
+
+  function printtabs($config, $data, $dn,$category)
+  {
+
+    /* Save dn */
+    $this->dn= $dn;
+    $this->config= $config;
+
+    $baseobject= NULL;
+
+    foreach ($data as $tab){
+      $this->by_name[$tab['CLASS']]= $tab['NAME'];
+
+      if ($baseobject === NULL){
+        $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
+        $this->by_object[$tab['CLASS']]= $baseobject;
+      } else {
+        $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
+      }
+
+      $this->by_object[$tab['CLASS']]->parent= &$this;
+      $this->by_object[$tab['CLASS']]->set_acl_category($category);
+
+      /* Initialize current */
+      if ($this->current == ""){
+        $this->current= $tab['CLASS'];
+      }
+    }
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function save_object($save_current= FALSE)
+  {
+    tabs::save_object($save_current);
+  }
+
+
+  function save($ignore_account= FALSE)
+  {
+    /* Check for new 'dn', in order to propagate the
+       'dn' to all plugins */
+    $baseobject= $this->by_object['printgeneric'];
+    $this->dn= "cn=$baseobject->cn,".get_ou('printerou').$baseobject->base;
+    $baseobject->dn= $this->dn;
+
+    foreach ($this->by_object as $key => $obj){
+      $this->by_object[$key]->dn= $this->dn;
+    }
+
+    tabs::save(FALSE);
+  }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/tabs_terminal.inc b/gosa-plugins/goto/admin/systems/goto/tabs_terminal.inc
new file mode 100644 (file)
index 0000000..ea9207f
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+
+class termtabs extends tabs
+{
+
+  function termtabs($config, $data, $dn, $category)
+  {
+    /* Save dn */
+    $this->dn= $dn;
+    $this->config= $config;
+
+    $baseobject= NULL;
+
+    foreach ($data as $tab){
+      $this->by_name[$tab['CLASS']]= $tab['NAME'];
+
+      if ($baseobject === NULL){
+        $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
+        $this->by_object[$tab['CLASS']]= $baseobject;
+      } else {
+        $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
+      }
+
+      $this->by_object[$tab['CLASS']]->parent= &$this;
+      $this->by_object[$tab['CLASS']]->set_acl_category($category);
+
+      /* Initialize current */
+      if ($this->current == ""){
+        $this->current= $tab['CLASS'];
+      }
+    }
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function save_object($save_current= FALSE)
+  {
+    tabs::save_object($save_current);
+
+    /* Update reference, transfer variables */
+    if(isset($this->by_object['termstartup'])){
+      $this->by_object['termstartup']->gotoTerminalPath= $this->by_object['termgeneric']->gotoTerminalPath;
+    }
+    
+    $base_obj = $this->by_object['termgeneric'];
+    foreach($this->by_object as $name => $plug){
+      $this->by_object[$name]->cn = $base_obj->cn;
+    }
+  }
+
+
+  function save($ignore_account= FALSE)
+  {
+    /* Check for new 'dn', in order to propagate the
+       'dn' to all plugins */
+    $baseobject= $this->by_object['termgeneric'];
+    $this->dn= "cn=".$baseobject->cn.",".get_ou('terminalou').$baseobject->base;
+    $baseobject->dn= $this->dn;
+
+    foreach ($this->by_object as $key => $obj){
+      $this->by_object[$key]->dn= $this->dn;
+      $this->by_object[$key]->cn= $baseobject->cn;
+    }
+
+    tabs::save(TRUE);
+    if(isset($this->by_object['printgeneric'])){
+      if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
+        $this->by_object['printgeneric']->remove_from_parent();
+      }
+    }
+  }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/tabs_workstation.inc b/gosa-plugins/goto/admin/systems/goto/tabs_workstation.inc
new file mode 100644 (file)
index 0000000..3d6bac2
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+
+class worktabs extends tabs
+{
+
+  function worktabs($config, $data, $dn,$category)
+  {
+    
+    /* Save dn */
+    $this->dn= $dn;
+    $this->config= $config;
+
+    $baseobject= NULL;
+
+    foreach ($data as $tab){
+      $this->by_name[$tab['CLASS']]= $tab['NAME'];
+
+      if ($baseobject === NULL){
+        $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
+        $this->by_object[$tab['CLASS']]= $baseobject;
+      } else {
+        $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
+      }
+
+      $this->by_object[$tab['CLASS']]->parent= &$this;
+      $this->by_object[$tab['CLASS']]->set_acl_category($category);
+
+      /* Initialize current */
+      if ($this->current == ""){
+        $this->current= $tab['CLASS'];
+      }
+    }
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function save_object($save_current= FALSE)
+  {
+    tabs::save_object($save_current);
+
+    /* Assign current cn */
+    $baseobject= $this->by_object['workgeneric'];
+    foreach ($this->by_object as $key => $obj){
+      $this->by_object[$key]->cn= $baseobject->cn;
+    }
+  }
+
+
+  function save($ignore_account= FALSE)
+  {
+    /* Check for new 'dn', in order to propagate the
+       'dn' to all plugins */
+    $baseobject= $this->by_object['workgeneric'];
+    $this->dn= "cn=".$baseobject->cn.",".get_ou('workstationou').$baseobject->base;
+    $baseobject->dn= $this->dn;
+
+    foreach ($this->by_object as $key => $obj){
+      $this->by_object[$key]->dn= $this->dn;
+      $this->by_object[$key]->cn= $baseobject->cn;
+    }
+
+    tabs::save(TRUE);
+
+    if(isset($this->by_object['printgeneric'])){
+      if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
+        $this->by_object['printgeneric']->remove_from_parent();
+      }
+    }
+  }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/systems/goto/terminal.tpl b/gosa-plugins/goto/admin/systems/goto/terminal.tpl
new file mode 100644 (file)
index 0000000..dc088f8
--- /dev/null
@@ -0,0 +1,176 @@
+<h2><img class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Properties{/t}</h2>
+<table summary="" style="width:100%;">
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+   <table summary="">
+    <tr>
+     {if $cn eq 'default'}
+     <td colspan=2>{t}Terminal template{/t}</td>
+     {else}
+     <td><LABEL for="cn">{t}Terminal name{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$cnACL}
+      <input name="cn" id="cn" size=18 maxlength=60 value="{$cn}">
+{/render}
+     </td>
+     {/if}
+    </tr>
+    <tr>
+     <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
+     <td>
+
+{render acl=$baseACL}
+      <select id="base" size="1" name="base" title="{t}Choose subtree to place group in{/t}">
+       {html_options options=$bases selected=$base_select}
+      </select>
+{/render}
+{render acl=$baseACL disable_picture='images/folder_gray.png'}
+        <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+{/render}
+     </td>
+    </tr>
+   </table>
+{if $member_of_ogroup}
+   <br>
+   <br>
+   <br>
+   <input type='submit' name='inheritAll' value='{t}Inherit all{/t}'>
+{/if}
+  </td>
+  <td style="vertical-align:top;border-left:1px solid #A0A0A0;" >
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoMode">{t}Mode{/t}</LABEL></td>
+     <td>
+{render acl=$gotoModeACL}
+      <select id="gotoMode" name="gotoMode" title="{t}Select terminal mode{/t}">
+       {html_options options=$modes selected=$gotoMode_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoSyslogServer">{t}Syslog server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoSyslogServerACL}
+      <select name="gotoSyslogServer" id="gotoSyslogServer" title="{t}Choose server to use for logging{/t}">
+       {html_options options=$syslogservers selected=$gotoSyslogServer_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+       </table>
+  </td>
+ </tr>
+</table>
+<p class="seperator" style="margin:0px; padding:0px;">&nbsp;</p>
+<table style="width:100%;">
+ <tr>
+  <td style="width:50%;vertical-align:top;">
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoTerminalPath">{t}Root server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoTerminalPathACL}
+      <select name="gotoTerminalPath" id="gotoTerminalPath" title="{t}Select NFS root filesystem to use{/t}">
+       {html_options options=$nfsservers selected=$gotoTerminalPath_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoSwapServer">{t}Swap server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoSwapServerACL}
+      <select name="gotoSwapServer" id="gotoSwapServer" title="{t}Choose NFS filesystem to place swap files on{/t}">
+       {html_options options=$nfsservers selected=$gotoSwapServer_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
+  <td style="border-left:1px solid #A0A0A0;">
+       <table width="100%">
+    <tr>
+        <td colspan="2">
+{if $member_of_ogroup}
+{render acl=$gotoNtpServerACL}
+               <input type="checkbox" value="1" name="inheritTimeServer"
+                       {if $inheritTimeServer } checked {/if} 
+                       onClick="javascript:
+                                       changeState('gotoNtpServerSelected');
+                                       changeState('gotoNtpServers');
+                                       changeState('addNtpServer');
+                                       changeState('delNtpServer');">{t}Inherit time server attributes{/t}
+{/render}
+{else}
+       <input disabled type='checkbox' name='option_disabled'>{t}Inherit time server attributes{/t}
+{/if}
+        </td>
+       </tr>
+       <tr>
+     <td colspan="2" style='padding-left:14px;padding-top:5px;'><LABEL for="gotoNtpServerSelected">{t}NTP server{/t}</LABEL><br>
+{render acl=$gotoNtpServerACL}
+      <select name="gotoNtpServerSelected[]" id="gotoNtpServerSelected" multiple size=5 style="width:100%;"
+                       title="{t}Choose server to use for synchronizing time{/t}" {if $inheritTimeServer} disabled {/if}>
+       {html_options options=$gotoNtpServer_select}
+      </select>
+{/render}
+        <br>
+{render acl=$gotoNtpServerACL}
+      <select name="gotoNtpServers" id="gotoNtpServers" {if $inheritTimeServer} disabled {/if} >
+       {html_options values=$ntpservers output=$ntpservers }
+      </select>
+{/render}
+{render acl=$gotoNtpServerACL}
+               <input type="submit" name="addNtpServer" value="{t}Add{/t}"             id="addNtpServer"
+                {if $inheritTimeServer} disabled {/if}>
+{/render}
+{render acl=$gotoNtpServerACL}
+               <input type="submit" name="delNtpServer" value="{t}Delete{/t}"  id="delNtpServer" 
+                {if $inheritTimeServer} disabled {/if}>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+ </tr>
+</table>
+
+{if $cn neq 'default'}
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+
+{$netconfig}
+{/if}
+
+{if $fai_activated}
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+<h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
+<table summary="">
+ <tr>
+  <td>
+{render acl=$gotoNtpServerACL}
+   <select size="1" name="saction" title="{t}Select action to execute for this terminal{/t}">
+    <option disabled>&nbsp;</option>
+    {html_options options=$actions}
+   </select>
+{/render}
+  </td>
+  <td>
+{render acl=$gotoNtpServerACL}
+   <input type=submit name="action" value="{t}Execute{/t}">
+{/render}
+  </td>
+ </tr>
+</table>
+{/if}
+
+<input type="hidden" name="termgeneric_posted" value="1">
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('cn');
+  -->
+</script>
diff --git a/gosa-plugins/goto/admin/systems/goto/terminalService.tpl b/gosa-plugins/goto/admin/systems/goto/terminalService.tpl
new file mode 100644 (file)
index 0000000..72ba28b
--- /dev/null
@@ -0,0 +1,269 @@
+<table style="width:100%;" summary="">
+ <tr>
+  <td style="width:33%; vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/keyboard.png"> {t}Keyboard{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoXKbModel">{t}Model{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXKbModelACL}
+      <select id="gotoXKbModel" name="gotoXKbModel" title="{t}Choose keyboard model{/t}" >
+       {html_options options=$XKbModels selected=$gotoXKbModel_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXKbLayout">{t}Layout{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXKbLayoutACL}
+      <select id="gotoXKbLayout" name="gotoXKbLayout" title="{t}Choose keyboard layout{/t}" >
+       {html_options options=$XKbLayouts selected=$gotoXKbLayout_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXKbVariant">{t}Variant{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXKbVariantACL}
+      <select id="gotoXKbVariant" name="gotoXKbVariant" title="{t}Choose keyboard variant{/t}" >
+       {html_options options=$XKbVariants selected=$gotoXKbVariant_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  
+  <td style="vertical-align:top;width:32%">
+   <h2><img class="center" alt="" align="middle" src="images/mouse.png"> {t}Mouse{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoXMouseType">{t}Type{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXMouseTypeACL}
+      <select name="gotoXMouseType" id="gotoXMouseType" title="{t}Choose mouse type{/t}" >
+       {html_options options=$MouseTypes selected=$gotoXMouseType_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXMouseport">{t}Port{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXMouseportACL}
+      <select id="gotoXMouseport" name="gotoXMouseport" title="{t}Choose mouse port{/t}" >
+       {html_options options=$MousePorts selected=$gotoXMouseport_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  
+  <td style="vertical-align:top;width:33%">
+   <h2><img class="center" alt="" align="middle" src="images/select_phone.png"> {t}Telephone hardware{/t}</h2>
+   <table style="width:100%" border=0 summary="">
+    <tr>
+     <td>{t}Telephone{/t}&nbsp;
+{render acl=$goFonHardwareACL}
+         {$hardware_list}
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+ </tr>
+</table>
+
+<table style="width:100%;" summary="">
+ <tr><td colspan=5><p class="plugbottom" style="text-align:left;"></p></td></tr>
+ <tr>
+   <td style="width:33%;vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/hardware.png"> {t}Graphic device{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoXDriver">{t}Driver{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXDriverACL}
+      <select id="gotoXDriver" name="gotoXDriver" title="{t}Choose graphic driver that is needed by the installed graphic board{/t}" >
+       {html_options values=$XDrivers output=$XDrivers selected=$gotoXDriver_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXResolution">{t}Resolution{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXResolutionACL}
+      <select id="gotoXResolution" name="gotoXResolution" title="{t}Choose screen resolution used in graphic mode{/t}" >
+       {html_options options=$XResolutions selected=$gotoXResolution_select}
+      </select>
+{/render }
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXColordepth">{t}Color depth{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXColordepthACL}
+      <select id="gotoXColordepth" name="gotoXColordepth" title="{t}Choose colordepth used in graphic mode{/t}" >
+       {html_options options=$XColordepths selected=$gotoXColordepth_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+   </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+
+   <td style="width:32%; vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/display.png"> {t}Display device{/t}</h2>
+   <table summary="">
+    <tr>
+     <td>{t}Type{/t}</td>
+     <td>{$gotoXMonitor}</td>
+    </tr>
+    <tr>
+     <td>
+{render acl=$AutoSyncACL}
+      <input type="checkbox" name="AutoSync" value="1" {$AutoSyncCHK} onChange="changeState('gotoXHsync');changeState('gotoXVsync');">
+{/render}
+     </td>
+     <td>{t}Use DDC for automatic detection{/t}</td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXHsync">{t}HSync{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXHsyncACL}
+       <input id="gotoXHsync" name="gotoXHsync" size=10 maxlength=60 
+                value="{$gotoXHsync}" title="{t}Horizontal refresh frequency for installed monitor{/t}"> kHz</td>
+{/render}
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXVsync">{t}VSync{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXVsyncACL}
+      <input id="gotoXVsync"  name="gotoXVsync" size=10 maxlength=60 
+                value="{$gotoXVsync}" title="{t}Vertical refresh frequency for installed monitor{/t}"> Hz</td>
+{/render}
+    </tr>
+   </table>
+
+   </td>
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+
+  <td style="width:33%; vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/server.png"> {t}Remote desktop{/t}</h2>
+   <table summary="">
+    <tr>
+     <td></td>
+     <td><LABEL for="gotoXMethod">{t}Connect method{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXMethodACL}
+      <select name="gotoXMethod" id="gotoXMethod" title="{t}Choose method to connect to terminal server{/t}" >
+       {html_options options=$XMethods selected=$gotoXMethod_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td></td>
+     <td><LABEL for="gotoXdmcpServer">{t}Terminal server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoXdmcpServerACL}
+      <select id="gotoXdmcpServer" name="gotoXdmcpServer" title="{t}Select specific terminal server to use{/t}" >
+       {html_options values=$xdmcpservers output=$xdmcpservers selected=$gotoXdmcpServer_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td></td>
+     <td><LABEL for="gotoFontPath">{t}Font server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoFontPathACL}
+      <select name="gotoFontPath" id="gotoFontPath" title="{t}Select specific font server to use{/t}" >
+       {html_options values=$fontservers output=$fontservers selected=$gotoFontPath_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+   
+  </td>
+ </tr>
+</table>
+
+<table style="width:100%;" summary="">
+ <tr><td colspan=3><p class="plugbottom" style="margin-top:0px;"></p></td></tr>
+
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/printer.png"><LABEL for="gotoLpdEnable"> {t}Print device{/t}</LABEL></h2>
+{render acl=$gotoLpdEnableACL}
+   <input id="gotoLpdEnable" type=checkbox name="gotoLpdEnable" value="1" {$gotoLpdEnable} title="{t}Select to start IPP based printing service on terminal{/t}">
+{/render}
+   {t}Provide print services{/t}
+   <br>
+
+   <table summary="">
+   <tr>
+     <td><div style="width:20px;"></div></td>
+     <td><LABEL for="gotoLpdServer">{t}Spool server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoLpdServerACL}
+      <select name="gotoLpdServer" id="gotoLpdServer" title="{t}Select NFS filesystem to place spool files on{/t}" >
+       {html_options values=$nfsservers output=$nfsservers selected=$gotoLpdServer_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+  </table>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+
+  <td style="vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/scanner.png"> {t}Scan device{/t}</h2>
+{render acl=$gotoScannerEnableACL}
+   <input type=checkbox name="gotoScannerEnable" value="1" title="{t}Select to start SANE scan service on terminal{/t}" {$gotoScannerEnable} >
+{/render}
+   {t}Provide scan services{/t}
+   <br>
+   <table summary="">
+    <tr>
+     <td><div style="width:20px;"></div></td>
+     <td><LABEL for="gotoScannerModel">{t}Model{/t}</LABEL></td>
+     <td>
+{render acl=$gotoScannerEnableACL}
+      <select name="gotoScannerModel" id="gotoScannerModel" title="{t}Select scanner driver to use{/t}" >
+       {html_options values=$gotoScannerModels output=$gotoScannerModels selected=$gotoScannerModel_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+  </table>
+
+  </td>
+ </tr>
+</table>
+
+<div style="height:40px;"></div>
diff --git a/gosa-plugins/goto/admin/systems/goto/terminalStartup.tpl b/gosa-plugins/goto/admin/systems/goto/terminalStartup.tpl
new file mode 100644 (file)
index 0000000..ccfacfb
--- /dev/null
@@ -0,0 +1,142 @@
+<h2><img class="center" alt="" align="middle" src="images/penguin.png"> {t}Boot parameters{/t}</h2>
+<table summary="" style="width:100%;">
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+
+   <table summary="" style="width:100%">
+    <tr>
+     <td style="width:30%"><LABEL for="gotoBootKernel">{t}Boot kernel{/t}</LABEL></td>
+     <td>
+{render acl=$gotoBootKernelACL}
+       <select id="gotoBootKernel" name="gotoBootKernel">
+       {html_options options=$gotoBootKernels  selected=$gotoBootKernel}
+       <option disabled>&nbsp;</option>
+       </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="customParameters">{t}Custom options{/t}</LABEL></td>
+     <td>
+{render acl=$gotoKernelParametersACL}
+      <input name="customParameters" id="customParameters"  size=25 maxlength=500
+                value="{$customParameters}" title="{t}Enter any parameters that should be passed to the kernel as append line during bootup{/t}"></td>
+{/render}
+    </tr>
+    <tr>
+     <td colspan="2" style='vertical-align:top;padding-top:3px;width:100%'><LABEL for="gotoLdapServer">{t}LDAP server{/t}</LABEL>
+{render acl=$gotoLdapServerACL}
+(<input type='checkbox' name='gotoLdap_inherit' {if $gotoLdap_inherit} checked {/if} value="1"
+      onClick="document.mainform.submit();" class='center'>
+&nbsp;{t}inherit from group{/t})
+{if !$JS}
+      <input type='image' src="images/list_reload.png" alt='{t}Reload{/t}' class='center'>
+{/if}
+{/render}
+{render acl=$gotoLdapServerACL_inherit}
+        {$gotoLdapServers}
+{/render}
+{render acl=$gotoLdapServerACL_inherit}
+      <select name='ldap_server_to_add' id='ldap_server_to_add'>
+        {html_options options=$gotoLdapServerList}
+    </select>
+{/render}
+{render acl=$gotoLdapServerACL_inherit}
+      <input type='submit' name='add_ldap_server' value="{t}Add{/t}" id='add_ldap_server'>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+     &nbsp;
+  </td>
+  
+  <td style="vertical-align:top;">
+{render acl=$gotoKernelParametersACL}
+    <input type="radio" name="bootmode" value="G" title="{t}Select if terminal supports graphical startup with progress bar{/t}" {$graphicalbootup}>
+{/render}
+    {t}use graphical bootup{/t}
+    <br>
+{render acl=$gotoKernelParametersACL}
+    <input type="radio" name="bootmode" value="T" title="{t}Select if terminal should boot in text mode{/t}" {$textbootup}>
+{/render}
+    {t}use standard linux textual bootup{/t}
+    <br>
+{render acl=$gotoKernelParametersACL}
+    <input type="radio" name="bootmode" value="D" title="{t}Select to get more verbose output during startup{/t}" {$debugbootup}>
+{/render}
+    {t}use debug mode for startup{/t}
+  </td>
+ </tr>
+</table>
+
+<table summary="" style="width:100%;">
+ <tr><td colspan=2><p class="plugbottom" style="margin-top:0px;"></p></td></tr>
+
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+   <h2>
+    <img class="center" alt="" align="middle" src="images/hardware.png"> {t}Kernel modules (format: name parameters){/t}
+   </h2>
+{render acl=$gotoModulesACL}
+    <select style="width:100%;" name="modules_list[]" size=15 multiple title="{t}Add additional modules to load on startup{/t}">
+     {html_options values=$gotoModules output=$gotoModules}
+        <option disabled>&nbsp;</option>
+    </select>
+{/render}
+    <br>
+{render acl=$gotoModulesACL}
+    <input name="module" size=30 align=middle maxlength=30>
+{/render}
+{render acl=$gotoModulesACL}
+    <input type=submit value="{t}Add{/t}" name="add_module">&nbsp;
+{/render}
+{render acl=$gotoModulesACL}
+    <input type=submit value="{t}Delete{/t}" name="delete_module">
+{/render}
+  </td>
+
+  <td style="padding-left:10px;border-left:1px solid #A0A0A0;vertical-align:top">
+        <h2><img class="center" alt="" src="images/fai_partitionTable.png" align="middle">&nbsp;<LABEL for="gotoShare">{t}Shares{/t}</LABEL></h2>
+        <table summary="" style="width:100%">
+                <tr>
+                        <td>
+{render acl=$gotoShareACL}
+                        <select style="width:100%;" name="gotoShare" multiple size=15 id="gotoShare">
+                               {html_options values=$gotoShareKeys output=$gotoShares}
+                               <option disabled>&nbsp;</option>
+                        </select>
+{/render}
+                                <br>
+{render acl=$gotoShareACL}
+                               <select name="gotoShareSelection">
+                                       {html_options values=$gotoShareSelectionKeys output=$gotoShareSelections}
+                                       <option disabled>&nbsp;</option>
+                                </select>
+{/render}
+{render acl=$gotoShareACL}
+                                <input type="text" size=15 name="gotoShareMountPoint" value="{t}Mountpoint{/t}">
+{/render}
+{render acl=$gotoShareACL}
+                                <input type="submit" name="gotoShareAdd" value="{t}Add{/t}">
+{/render}
+{render acl=$gotoShareACL}
+                                <input type="submit" name="gotoShareDel" value="{t}Remove{/t}">
+{/render}
+                        </td>
+                </tr>
+        </table>
+  </td>
+ </tr>
+</table>
+<input type='hidden' name='TerminalStarttabPosted' value="1">
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('gotoLdapServer');
+  -->
+</script>
diff --git a/gosa-plugins/goto/admin/systems/goto/workstation.tpl b/gosa-plugins/goto/admin/systems/goto/workstation.tpl
new file mode 100644 (file)
index 0000000..ba84899
--- /dev/null
@@ -0,0 +1,157 @@
+<h2><img class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Properties{/t}</h2>
+<table summary="" style="width:100%;">
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+   <table summary="">
+    <tr>
+{if $cn eq 'wdefault'}
+     <td colspan=2>{t}Workstation template{/t}</td>
+{else}
+     <td><LABEL for="cn">{t}Workstation name{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$cnACL}
+      <input name="cn" id="cn" size=18 maxlength=60 value="{$cn}">
+{/render}
+     </td>
+{/if}
+    </tr>
+    <tr>
+     <td><LABEL for="cn">{t}Location{/t}</LABEL></td>
+     <td>
+{render acl=$lACL}
+      <input name="l" id="l" size=18 maxlength=60 value="{$l}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$baseACL}
+      <select id="base" size="1" name="base" title="{t}Choose subtree to place group in{/t}">
+       {html_options options=$bases selected=$base_select}
+      </select>
+{/render}
+{render acl=$baseACL disable_picture='images/folder_gray.png'}
+        <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+{/render}
+     </td>
+    </tr>
+   </table>
+{if $member_of_ogroup}
+   <br>
+   <br>
+   <br>
+   <input type='submit' name='inheritAll' value='{t}Inherit all{/t}'>
+{/if}
+  </td>
+  <td  style="vertical-align:top;border-left:1px solid #A0A0A0;">
+   <table summary="">
+    <tr>
+     <td>{t}Mode{/t}</td>
+     <td>
+{render acl=$gotoModeACL}
+      <select name="gotoMode" title="{t}Select terminal mode{/t}">
+       {html_options options=$modes selected=$gotoMode_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoSyslogServer">{t}Syslog server{/t}</LABEL></td>
+     <td>
+{render acl=$gotoSyslogServerACL}
+      <select id="gotoSyslogServer" name="gotoSyslogServer" title="{t}Choose server to use for logging{/t}">
+       {html_options options=$syslogservers selected=$gotoSyslogServer_select}
+      </select>
+{/render}
+     </td>
+    </tr>
+   </table>
+<p class="seperator">&nbsp;</p>
+   <table width="100%">
+    <tr>
+     <td colspan="2">
+{if $member_of_ogroup}
+{render acl=$gotoNtpServerACL}
+        <input type="checkbox" value="1" name="inheritTimeServer"
+            {if $inheritTimeServer } checked {/if}
+            onClick="javascript:
+                    changeState('gotoNtpServerSelected');
+                    changeState('gotoNtpServers');
+                    changeState('addNtpServer');
+                    changeState('delNtpServer');">{t}Inherit time server attributes{/t}
+{/render}
+{else}
+       <input disabled type='checkbox' name='option_disabled'>{t}Inherit time server attributes{/t}
+{/if}
+     </td>
+    </tr>
+    <tr>
+     <td colspan="2" style='padding-left:14px;padding-top:5px;'><LABEL for="gotoNtpServerSelected">{t}NTP server{/t}</LABEL><br>
+{render acl=$gotoNtpServerACL}
+      <select name="gotoNtpServerSelected[]" id="gotoNtpServerSelected" multiple size=5 style="width:100%;"
+            title="{t}Choose server to use for synchronizing time{/t}" {if $inheritTimeServer} disabled {/if}>
+       {html_options options=$gotoNtpServer_select}
+      </select>
+{/render}
+     <br>
+{render acl=$gotoNtpServerACL}
+      <select name="gotoNtpServers" id="gotoNtpServers" {if $inheritTimeServer} disabled {/if} >
+       {html_options options=$gotoNtpServers}
+      </select>
+{/render}
+{render acl=$gotoNtpServerACL}
+        <input type="submit" name="addNtpServer" value="{t}Add{/t}"     id="addNtpServer"
+         {if $inheritTimeServer} disabled {/if}>
+{/render}
+{render acl=$gotoNtpServerACL}
+        <input type="submit" name="delNtpServer" value="{t}Delete{/t}"  id="delNtpServer" 
+         {if $inheritTimeServer} disabled {/if}>
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+{if $cn neq 'wdefault'}
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+
+{$netconfig}
+{/if}
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+
+{if $fai_activated}
+<h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
+<table summary="">
+ <tr>
+  <td>
+{render acl=$FAIstateACL}
+   <select size="1" name="saction" title="{t}Select action to execute for this terminal{/t}">
+    <option>&nbsp;</option>
+    {html_options options=$actions}
+   </select>
+{/render}
+  </td>
+  <td>
+   <input type=submit name="action" value="{t}Execute{/t}">
+  </td>
+ </tr>
+</table>
+{/if}
+<input type="hidden" name="workgeneric_posted" value="1">
+ {if $cn eq 'wdefault'}
+<!-- Place cursor -->
+               <script language="JavaScript" type="text/javascript">
+                 <!-- // First input field on page
+                       focus_field('l');
+                 -->
+               </script>
+     {else}
+               <script language="JavaScript" type="text/javascript">
+                 <!-- // First input field on page
+                       focus_field('cn');
+                 -->
+               </script>
+     {/if}
+
diff --git a/gosa-plugins/goto/admin/systems/goto/workstationService.tpl b/gosa-plugins/goto/admin/systems/goto/workstationService.tpl
new file mode 100644 (file)
index 0000000..e5171fe
--- /dev/null
@@ -0,0 +1,224 @@
+<table style="width:100%;" summary="">
+ <tr>
+  <td style="width:33%; vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/keyboard.png"> {t}Keyboard{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoXKbModel">{t}Model{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXKbModelACL}
+      <select id="gotoXKbModel" name="gotoXKbModel" title="{t}Choose keyboard model{/t}">
+       {html_options options=$XKbModels selected=$gotoXKbModel_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXKbLayout">{t}Layout{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXKbLayoutACL}
+      <select id="gotoXKbLayout" name="gotoXKbLayout" title="{t}Choose keyboard layout{/t}">
+       {html_options options=$XKbLayouts selected=$gotoXKbLayout_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXKbVariant">{t}Variant{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXKbVariantACL}
+      <select id="gotoXKbVariant" name="gotoXKbVariant" title="{t}Choose keyboard variant{/t}">
+       {html_options options=$XKbVariants selected=$gotoXKbVariant_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+   </table>
+
+  </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  
+  <td style="vertical-align:top;width:32%">
+   <h2><img class="center" alt="" align="middle" src="images/mouse.png"> {t}Mouse{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoXMouseType">{t}Type{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXMouseTypeACL}
+      <select name="gotoXMouseType" id="gotoXMouseType" title="{t}Choose mouse type{/t}">
+       {html_options options=$MouseTypes selected=$gotoXMouseType_select}
+      </select>
+     </td>
+{/render}
+
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXMouseport">{t}Port{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXMouseportACL}
+      <select id="gotoXMouseport" name="gotoXMouseport" title="{t}Choose mouse port{/t}">
+       {html_options options=$MousePorts selected=$gotoXMouseport_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+   </table>
+
+  </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  
+  <td style="vertical-align:top;width:33%">
+   <h2><img class="center" alt="" align="middle" src="images/select_phone.png"> {t}Telephone hardware{/t}</h2>
+   <table style="width:100%" border=0 summary="">
+    <tr>
+     <td>{t}Telephone{/t}&nbsp;
+
+{render acl=$goFonHardwareACL}
+         {$hardware_list}
+{/render}
+
+     </td>
+    </tr>
+   </table>
+
+  </td>
+ </tr>
+</table>
+
+<table style="width:100%;" summary="">
+ <tr><td colspan=5><p class="plugbottom" style="text-align:left;"></p></td></tr>
+ <tr>
+   <td style="width:33%;vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/hardware.png"> {t}Graphic device{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="gotoXDriver">{t}Driver{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXDriverACL}
+      <select id="gotoXDriver" name="gotoXDriver" title="{t}Choose graphic driver that is needed by the installed graphic board{/t}">
+       {html_options values=$XDrivers output=$XDrivers selected=$gotoXDriver_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXResolution">{t}Resolution{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXResolutionACL}
+      <select id="gotoXResolution" name="gotoXResolution" title="{t}Choose screen resolution used in graphic mode{/t}">
+       {html_options options=$XResolutions selected=$gotoXResolution_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXColordepth">{t}Color depth{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXColordepthACL}
+      <select id="gotoXColordepth" name="gotoXColordepth" title="{t}Choose colordepth used in graphic mode{/t}">
+       {html_options options=$XColordepths selected=$gotoXColordepth_select}
+      </select>
+{/render}
+
+     </td>
+    </tr>
+   </table>
+   </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+
+   <td style="width:32%; vertical-align:top;">
+   <h2><img class="center" alt="" align="middle" src="images/display.png"> {t}Display device{/t}</h2>
+   <table summary="">
+    <tr>
+     <td>{t}Type{/t}</td>
+     <td>{if $gotoXMonitor==""}{t}unknown{/t}{/if}{$gotoXMonitor}</td>
+    </tr>
+    <tr>
+       <td>
+
+{render acl=$AutoSyncACL}
+        <input type="checkbox" name="AutoSync" value="1" {$AutoSyncCHK} onChange="changeState('gotoXHsync');changeState('gotoXVsync');">
+{/render}
+
+        </td>
+       <td>{t}Use DDC for automatic detection{/t}</td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXHsync">{t}HSync{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXHsyncACL}
+       <input id="gotoXHsync" name="gotoXHsync" size=10 maxlength=60 {$hiddenState}
+                value="{$gotoXHsync}" title="{t}Horizontal refresh frequency for installed monitor{/t}"> kHz
+{/render}
+
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="gotoXVsync">{t}VSync{/t}</LABEL></td>
+     <td>
+
+{render acl=$gotoXVsyncACL}
+       <input id="gotoXVsync"  name="gotoXVsync" size=10 maxlength=60 {$hiddenState}
+                value="{$gotoXVsync}" title="{t}Vertical refresh frequency for installed monitor{/t}"> Hz
+{/render}
+
+     </td>
+    </tr>
+   </table>
+
+   </td>
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+
+  <td style="width:33%; vertical-align:top;">
+  
+
+   <h2><img class="center" alt="" align="middle" src="images/scanner.png"> {t}Scan device{/t}</h2>
+
+{render acl=$gotoScannerEnableACL}
+   <input type=checkbox name="gotoScannerEnable" value="1" title="{t}Select to start SANE scan service on terminal{/t}" {$gotoScannerEnable}>
+{/render}
+
+   {t}Provide scan services{/t}
+   <br>
+       </td>
+ </tr>
+</table>
+
+
+<div style="height:40px;"></div>
+
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('gotoXKbModel');
+  -->
+</script>
+
+
+
+
diff --git a/gosa-plugins/goto/admin/systems/goto/workstationStartup.tpl b/gosa-plugins/goto/admin/systems/goto/workstationStartup.tpl
new file mode 100644 (file)
index 0000000..0801a09
--- /dev/null
@@ -0,0 +1,232 @@
+<table summary="" style="width:100%;">
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+<h2><img class="center" alt="" align="middle" src="images/penguin.png"> {t}Boot parameters{/t}</h2>
+
+   <table summary="" style="width:100%">
+    <tr>
+     <td><LABEL for="gotoBootKernel">{t}Boot kernel{/t}</LABEL></td>
+     <td style="width:70%">
+{render acl=$gotoBootKernelACL}
+        <select id="gotoBootKernel" name="gotoBootKernel">
+         {html_options options=$gotoBootKernels selected=$gotoBootKernel}
+       </select>
+{/render}
+      </td>
+    </tr>
+    <tr>
+     <td><LABEL for="customParameters">{t}Custom options{/t}</LABEL></td>
+     <td>
+{render acl=$gotoKernelParametersACL}
+       <input name="customParameters" id="customParameters" size=25 maxlength=500
+                value="{$customParameters}" title="{t}Enter any parameters that should be passed to the kernel as append line during bootup{/t}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td colspan="2" style='vertical-align:top;padding-top:3px;'><LABEL for="gotoLdapServer">{t}LDAP server{/t}</LABEL>
+{render acl=$gotoLdapServerACL}
+{if $member_of_ogroup}
+(<input type='checkbox' name='gotoLdap_inherit' {if $gotoLdap_inherit} checked {/if} value="1"
+       onClick="document.mainform.submit();" class='center'>
+&nbsp;{t}inherit from group{/t})
+{if !$JS}
+       <input type='image' src="images/list_reload.png" alt='{t}Reload{/t}' class='center'>
+{/if}
+{/if}
+{/render}
+{render acl=$gotoLdapServerACL_inherit}
+         {$gotoLdapServers}    
+{/render}
+{render acl=$gotoLdapServerACL_inherit}
+       <select name='ldap_server_to_add' id='ldap_server_to_add'>
+         {html_options options=$gotoLdapServerList}    
+    </select>
+{/render}
+{render acl=$gotoLdapServerACL_inherit}
+       <input type='submit' name='add_ldap_server' value="{t}Add{/t}" id='add_ldap_server'>
+{/render}
+     </td>
+    </tr>
+   </table>
+
+  </td>
+
+  <td style="border-left:1px solid #A0A0A0">
+     &nbsp;
+  </td>
+  
+  <td style="vertical-align:top;">
+
+       {if $fai_activated}
+
+               {if $FAIdebianMirror == "inherited"}
+
+                       <table>
+                               <tr>
+                                       <td>
+                                               <h2><img class="center" alt="" align="middle" src="images/fai_profile.png">&nbsp;{t}FAI server{/t}
+                                               </h2>
+                                       </td>
+                                       <td>
+                                               <h2><img class="center" alt="" align="middle" src="images/fai_profile.png">&nbsp;{t}Release{/t}
+                                               </h2>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+       {render acl=$FAIdebianMirrorACL}
+                                               <select name="FAIdebianMirror" {$FAIdebianMirrorACL} onchange='document.mainform.submit()'>
+                                                       {foreach from=$FAIservers item=val key=key}
+                                                               <option value="{$key}" {if $FAIdebianMirror == $key} selected {/if}>{$key}</option>
+                                                       {/foreach}
+                                               </select>
+       {/render}
+                                       </td>
+                                       <td>
+                                               <select name="FAIrelease"  disabled>
+                                               {html_options options=$InheritedFAIrelease output=$InheritedFAIrelease selected=$InheritedFAIrelease}
+                                               </select>
+                                       </td>
+                               </tr>
+                       </table>
+                       <h2>
+                               <img class="center" alt="" align="middle" src="images/fai_profile.png">&nbsp;{t}Assigned FAI classes{/t}
+                       </h2>
+       {render acl=$FAIclassACL}
+                       {$FAIScriptlist}        
+       {/render}
+               {else}
+
+                       <table>
+                               <tr>
+                                       <td>
+                                               <h2><img class="center" alt="" align="middle" src="images/fai_profile.png">&nbsp;{t}FAI server{/t}
+                                               </h2>
+                                       </td>
+                                       <td>
+                                               <h2><img class="center" alt="" align="middle" src="images/fai_profile.png">&nbsp;{t}Release{/t}
+                                               </h2>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
+       {render acl=$FAIdebianMirrorACL}
+                                               <select name="FAIdebianMirror" {$FAIdebianMirrorACL} onchange='document.mainform.submit()'>
+                                                       {foreach from=$FAIservers item=val key=key}
+                                                               <option value="{$key}" {if $FAIdebianMirror == $key} selected {/if}>{$key}</option>
+                                                       {/foreach}
+                                               </select>
+       {/render}
+       {if $javascript eq 'false'}
+       {render acl=$FAIdebianMirrorACL}
+               <input type="submit" value="{t}set{/t}" name="refresh">
+       {/render}
+       {/if}
+                                       </td>
+                                       <td>
+       {render acl=$FAIreleaseACL}
+                                               <select name="FAIrelease"  onchange='document.mainform.submit()' {$FAIclassACL}>
+                                                       {foreach from=$FAIservers.$FAIdebianMirror item=val key=key}
+                                                               <option value="{$val}" {if $FAIrelease == $key} selected {/if}>{$val}</option>
+                                                       {/foreach}
+                                               </select>
+       {/render}
+                                       </td>
+                               </tr>
+                       </table>
+                       <h2>
+                               <img class="center" alt="" align="middle" src="images/fai_profile.png">&nbsp;{t}Assigned FAI classes{/t}
+                       </h2>
+       {render acl=$FAIclassACL}
+                       {$FAIScriptlist}        
+       {/render}
+
+       {render acl=$FAIclassACL}
+                       <select name="FAIclassesSel">
+                               {foreach from=$FAIclasses item=val key=key}
+                                       <option value="{$key}">{$key}&nbsp;[{$val}]</option>
+                               {/foreach}
+                       </select>       
+       {/render}
+       {render acl=$FAIclassACL}
+                       <input name="AddClass" value="{t}Add{/t}" type="submit"> 
+       {/render}
+       <!--            <input name="DelClass" value="{t}Delete{/t}" type="submit"> -->
+               {/if}
+
+               {else}
+
+                       <h2>{t}FAI Object assignment disabled. You can't use this feature until FAI is activated.{/t}</h2>                      
+
+               {/if}
+               </td>
+       </tr>
+</table>
+
+<table summary="" style="width:100%;">
+ <tr><td colspan=2><p class="plugbottom" style="margin-top:0px;"></p></td></tr>
+
+ <tr>
+  <td style="width:50%; vertical-align:top; border-right:1px solid #B0B0B0">
+   <h2>
+    <img class="center" alt="" align="middle" src="images/hardware.png"> {t}Kernel modules (format: name parameters){/t}
+   </h2>
+{render acl=$gotoModulesACL}
+    <select style="width:100%; height:150px;" name="modules_list[]" size=15 multiple title="{t}Add additional modules to load on startup{/t}">
+     {html_options values=$gotoModules output=$gotoModules}
+        <option disabled>&nbsp;</option>
+    </select>
+{/render}
+    <br>
+{render acl=$gotoModulesACL}
+    <input name="module" size=30 align=middle maxlength=30>
+{/render}
+{render acl=$gotoModulesACL}
+    <input type=submit value="{t}Add{/t}" name="add_module">&nbsp;
+{/render}
+{render acl=$gotoModulesACL}
+    <input type=submit value="{t}Delete{/t}" name="delete_module">
+{/render}
+  </td>
+
+  <td style="vertical-align:top;">
+        <h2><img class="center" alt="" src="images/fai_partitionTable.png" align="middle">&nbsp;<LABEL for="gotoShare">{t}Shares{/t}</LABEL></h2>
+        <table summary="" style="width:100%">
+                <tr>
+                        <td>
+{render acl=$gotoShareACL}
+                        <select style="width:100%;height:150px;" name="gotoShare" multiple size=4 id="gotoShare">
+                                            {html_options values=$gotoShareKeys output=$gotoShares}
+                                                               <option disabled>&nbsp;</option>
+                                </select>
+{/render}
+                                <br>
+{render acl=$gotoShareACL}
+                        <select name="gotoShareSelection">
+                                                   {html_options values=$gotoShareSelectionKeys output=$gotoShareSelections}
+                                                       <option disabled>&nbsp;</option>
+                                </select>
+{/render}
+{render acl=$gotoShareACL}
+                                <input type="text" size=15 name="gotoShareMountPoint" value="{t}Mountpoint{/t}">
+{/render}
+{render acl=$gotoShareACL}
+                                <input type="submit" name="gotoShareAdd" value="{t}Add{/t}">
+{/render}
+{render acl=$gotoShareACL}
+                                <input type="submit" name="gotoShareDel" value="{t}Remove{/t}" {if $gotoSharesCount == 0} disabled {/if}>
+{/render}
+                        </td>
+                </tr>
+        </table>
+  </td>
+ </tr>
+</table>
+<input name="WorkstationStarttabPosted" type="hidden" value="1">
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('gotoLdapServer');
+  -->
+</script>