From: cajus Date: Thu, 17 Jan 2008 13:11:16 +0000 (+0000) Subject: Added admin stuff X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a58a64a5ddcf918a3f5e3411e372d7d5d11a6a97;p=gosa.git Added admin stuff git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8447 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc b/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc new file mode 100644 index 000000000..247acf972 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_applicationGeneric.inc @@ -0,0 +1,572 @@ + "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= "\"\" ". + _("This 'dn' is no application.").""; + 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 ="

"._("Application settings")."

+ + + + + +
". + _("Application name"). + " + +
"; + $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 index 000000000..c7810321e --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_applicationManagement.inc @@ -0,0 +1,647 @@ +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 = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* 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.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + 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 index 000000000..9f11eb6b9 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_applicationParameters.inc @@ -0,0 +1,248 @@ + "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; $ioption_name); $i++){ + if (isset($_POST["remove$i"])){ + $k= 0; + $on= array(); + $ov= array(); + for ($j= 0; $joption_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= ""; + 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.="". + " ". + " ". + " ". + ""; + } + } + $table.= "
"._("Variable").""._("Default value")."
". + " ". + " ". + " ". + "
". + "
". + " ". + "
"; + $table.=""; + + /* 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; $ioption_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; $ioption_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; $ioption_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 index 000000000..f70d5c618 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/class_divListApplication.inc @@ -0,0 +1,323 @@ +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 = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "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.= ""; + } else { + $options.= ""; + } + } + } + + /* 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")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Application")."|appl_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("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.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("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 = "%s"; + $editlink = "%s"; + $userimg = "User"; + $applimg = "A"; + $empty = ""; + + /* 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.= " "; + + $actions.= " "; + } + } + + /* Add edit icon */ + $actions.= ""; + + + 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.= ""; + }else{ + $actions.= " "; + } + + $title = "title='".preg_replace('/ /', ' ', @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 = "".$display.""; + break; + } + } + } + + /* Create each field */ + $field0 = array("string" => "" , + "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 = "".$num_app_str." ".$num_apps."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $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 index 000000000..b50ed7eb8 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/generic.tpl @@ -0,0 +1,152 @@ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+{render acl=$cnACL} + +{/render} +
+{render acl=$gosaApplicationNameACL} + +{/render} +
+{render acl=$gosaApplicationExecuteACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
+{render acl=$baseACL} + +{/render} +{if !$isReleaseApplikation} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +{/if} +
+
+   + + + + + + +
+ +
+ +
+  
+ + +{render acl=$gosaApplicationIconACL} + +{/render} +{render acl=$gosaApplicationIconACL} + +{/render} +{render acl=$gosaApplicationIconACL} + +{/render} +
+
+ +

 

+ +

{t}Options{/t} {t}Options{/t}

+ + + + + +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Only executable for members{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Replace user configuration on startup{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Place icon on members desktop{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Place entry in members startmenu{/t} +
+{render acl=$gosaApplicationFlagsACL} + +{/render} + {t}Place entry in members launch bar{/t} +
+ +

 

+ + + + + +
+

{t}Script{/t} {t}Script{/t}

+{render acl=$gotoLogonScriptACL} + +{/render} +{render acl=$gotoLogonScriptACL} + +{/render} +{render acl=$gotoLogonScriptACL} + +{/render} + +
+ +
+ + + diff --git a/gosa-plugins/goto/admin/applications/main.inc b/gosa-plugins/goto/admin/applications/main.inc new file mode 100644 index 000000000..7b748386a --- /dev/null +++ b/gosa-plugins/goto/admin/applications/main.inc @@ -0,0 +1,55 @@ +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"), "\"\" ".@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 index 000000000..57c221971 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/parameters.tpl @@ -0,0 +1,2 @@ +{$table} +
diff --git a/gosa-plugins/goto/admin/applications/release_select.tpl b/gosa-plugins/goto/admin/applications/release_select.tpl new file mode 100644 index 000000000..d58738f05 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/release_select.tpl @@ -0,0 +1,16 @@ +
+
+

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+
diff --git a/gosa-plugins/goto/admin/applications/remove.tpl b/gosa-plugins/goto/admin/applications/remove.tpl new file mode 100644 index 000000000..8598ed857 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$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} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-plugins/goto/admin/applications/tabs_application.inc b/gosa-plugins/goto/admin/applications/tabs_application.inc new file mode 100644 index 000000000..5b6e82989 --- /dev/null +++ b/gosa-plugins/goto/admin/applications/tabs_application.inc @@ -0,0 +1,59 @@ +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 index 000000000..bc870eb74 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc @@ -0,0 +1,256 @@ +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 index 000000000..77c582575 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/class_deviceManagement.inc @@ -0,0 +1,557 @@ +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 = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* 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.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + 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 index 000000000..e9d5f8522 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/class_divListDevices.inc @@ -0,0 +1,303 @@ +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 = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "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.= ""; + } else { + $options.= ""; + } + } + } + + /* 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")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Device")."|device_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("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.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("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 = "%s"; + $editlink = "%s"; + $userimg = "User"; + $deviceimg = "A"; + $empty = ""; + + /* 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.= " "; + $actions.= " "; + } + + $actions.= ""; + + /* Add delete button */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + }else{ + $actions.= " "; + } + + $title = "title='".preg_replace('/ /', ' ', @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 = "".$display.""; + break; + } + } + } + + + /* Create each field */ + $field0 = array("string" => "" , + "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 = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $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 index 000000000..863851e44 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/deviceGeneric.tpl @@ -0,0 +1,75 @@ + +

{t}Devices{/t}

+ + + + +
+ + + + + + + + + + + + + + + + + +
+ + +
{$must} + + +
+ + +
+ + +
+
+ + + + + + + + + + + + + + +
{$must} + + +  
{$must} + + +
{$must} + + +
+
+ + + + diff --git a/gosa-plugins/goto/admin/devices/main.inc b/gosa-plugins/goto/admin/devices/main.inc new file mode 100644 index 000000000..45209ca64 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/main.inc @@ -0,0 +1,57 @@ +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"), "\"\" ".@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 index 000000000..44d688246 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/paste_deviceGeneric.tpl @@ -0,0 +1,25 @@ + +

{t}Devices{/t}

+ + + + +
+ + + + + +
{$must} + + +
+
+ + + + diff --git a/gosa-plugins/goto/admin/devices/remove.tpl b/gosa-plugins/goto/admin/devices/remove.tpl new file mode 100644 index 000000000..643056cd3 --- /dev/null +++ b/gosa-plugins/goto/admin/devices/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$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} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-plugins/goto/admin/devices/tabs_devices.inc b/gosa-plugins/goto/admin/devices/tabs_devices.inc new file mode 100644 index 000000000..0feddfc4e --- /dev/null +++ b/gosa-plugins/goto/admin/devices/tabs_devices.inc @@ -0,0 +1,38 @@ +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 index 000000000..da73758aa --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc @@ -0,0 +1,345 @@ +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 = ""; + + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $this->AddHeader(array("string" => " ", "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.= ""; + } else { + $options.= ""; + } + } + } + + /* 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")." ". + "  "; + + /* Create Layers menu */ + $s = ".|"._("Actions")."|\n"; + $s .= "..|". + " "._("Create")."|\n"; + + /* Append create options */ + if(preg_match("/c/",$acl)) { + $s.= "...|". + " "._("Mime type")."|mime_new|\n"; + } + + /* Multiple options */ + $s.= "..|---|\n"; + $s.= "..|". + " "._("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.= "..|". + " "._("Copy")."|"."multiple_copy_systems|\n"; + $s.= "..|". + " "._("Cut")."|"."multiple_cut_systems|\n"; + + if($this->parent->CopyPasteHandler->entries_queued()){ + $img = ""; + $s.="..|".$img." "._("Paste")."|editPaste|\n"; + }else{ + $img = ""; + $s.="..|".$img." "._("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 = "%s"; + $editlink = "%s"; + $userimg = "User"; + $mimeimg = "A"; + $empty = ""; + + /* 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.= " "; + $actions.= " "; + } + + $actions.= ""; + + /* Add delete button */ + if(preg_match("/d/",$acl)){ + $actions.= ""; + }else{ + $actions.= " "; + } + + $title = "title='".preg_replace('/ /', ' ', @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 = "".$display.""; + break; + } + } + } + + + /* Create each field */ + $field0 = array("string" => "" , + "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 = "".$num_obj_str." ".$num_objs."    "; + $str.= "".$num_dep_str." ".$num_deps."    "; + + $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 index 000000000..03867ebab --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc @@ -0,0 +1,758 @@ + "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= "   +   + "; + }else{ + $Pattern_Actions= ""; + } + + if($this->acl_is_writeable("gotoMimeApplication")){ + $Apps_Actions = "   +   + "; + }else{ + $Apps_Actions= ""; + } + + if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ + $EApps_Actions = "   +   + "; + }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 index 000000000..7af6280d7 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc @@ -0,0 +1,666 @@ +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 = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + + /* 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.= "

\n"; + $display.= "\n"; + $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } + $display.= "\n"; + $display.= "

"; + } + 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 index 000000000..1cb6d7549 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/generic.tpl @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

[M] {t}Generic{/t}

+
+ + + + + + + + + + + + + +{if !$isReleaseMimeType} + + + + + +{/if} +
+ {t}Mime type{/t}{$must} + +{render acl=$gotoMimeGroupACL} + +{/render} +
+ {t}Mime group{/t} + +{render acl=$gotoMimeGroupACL} + +{/render} +
+ {t}Description{/t} + +{render acl=$descriptionACL} + +{/render} +
+ {render acl=$baseACL} + + {/render} + {if !$isReleaseMimeType} + {render acl=$baseACL disable_picture='images/folder_gray.png'} + + {/render} + {/if} +
+ +
+ + + + + +
+
+ {t}Mime icon{/t} +
+  
+ +{render acl=$gotoMimeIconACL} + +{/render} +{render acl=$gotoMimeIconACL} + +{/render} +
+
+

 

+
+

{t}Left click{/t} {t}Left click{/t}

+
+ {t}File patterns{/t}{$must} +{render acl=$gotoMimeFilePatternACL} + {$gotoMimeFilePatterns} +{/render} + +{render acl=$gotoMimeFilePatternACL} + +{/render} +{render acl=$gotoMimeFilePatternACL} + +{/render} + + {t}Applications{/t} +{render acl=$gotoMimeApplicationACL} + {$gotoMimeApplications} +{/render} + +{render acl=$gotoMimeApplicationACL} + +{/render} +{render acl=$gotoMimeApplicationACL} + +{/render} +{render acl=$gotoMimeApplicationACL} + +{/render} +
+

 

+
+

{t}Embedding{/t} {t}Embedding{/t}

+
+ + + + + +
+{render acl=$gotoMimeLeftClickActionACL} + +{/render} + {t}Show file in embedded viewer{/t} +
+ +{render acl=$gotoMimeLeftClickActionACL} + +{/render} + {t}Show file in external viewer{/t} +
+ +{render acl=$gotoMimeLeftClickActionACL} + +{/render} + {t}Ask whether to save to local disk{/t} +
+ +
+ {t}Applications{/t} +{render acl=$gotoMimeEmbeddedApplicationACL} + {$gotoMimeEmbeddedApplications} +{/render} +{render acl=$gotoMimeEmbeddedApplicationACL} + +{/render} +{render acl=$gotoMimeEmbeddedApplicationACL} + +{/render} +{render acl=$gotoMimeEmbeddedApplicationACL} + +{/render} +
+ + + diff --git a/gosa-plugins/goto/admin/mimetypes/main.inc b/gosa-plugins/goto/admin/mimetypes/main.inc new file mode 100644 index 000000000..de9214254 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/main.inc @@ -0,0 +1,57 @@ +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"), "\"\" ".@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 index 000000000..34b5e0751 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/paste_generic.tpl @@ -0,0 +1,31 @@ + + + + + + + +
+

 {t}Generic{/t}

+
+ + + + + + + + + + +
+ {t}Mime type{/t} + + +
+ {t}Description{/t} + + +
+ +
diff --git a/gosa-plugins/goto/admin/mimetypes/release_select.tpl b/gosa-plugins/goto/admin/mimetypes/release_select.tpl new file mode 100644 index 000000000..d58738f05 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/release_select.tpl @@ -0,0 +1,16 @@ +
+
+

[F]{t}Branches{/t}

+
+
+ + + + +
+ {t}Current release{/t}  + +
+
diff --git a/gosa-plugins/goto/admin/mimetypes/remove.tpl b/gosa-plugins/goto/admin/mimetypes/remove.tpl new file mode 100644 index 000000000..30c423318 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/remove.tpl @@ -0,0 +1,23 @@ +
+  {t}Warning{/t} +
+

+ {$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} +

+

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+ {if $multiple} + +   + + {else} + +   + + {/if} +

+ diff --git a/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc new file mode 100644 index 000000000..38570fde2 --- /dev/null +++ b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc @@ -0,0 +1,61 @@ +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 index 000000000..8e4bf44ac --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl @@ -0,0 +1,31 @@ +

{t}Integrating unknown devices{/t}

+

+ {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} +

+ + + + + + + +
+ + + + + + + +
+
+

+{$netconfig} + + + +

diff --git a/gosa-plugins/goto/admin/systems/goto/SelectDeviceType.tpl b/gosa-plugins/goto/admin/systems/goto/SelectDeviceType.tpl new file mode 100644 index 000000000..d25acbf49 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/SelectDeviceType.tpl @@ -0,0 +1,46 @@ +
+

+{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} +
+
+

+

+
+{t}Please select a system type and an optional bundle of predefined settings to be inherited.{/t} +
+
+

+
+ + + + + +
+ + + + +
+ {t}System type{/t}  + +
+
+ + + + +
+ {t}Choose an object group as template{/t}  + +
+
+

 

+

+ + +

diff --git a/gosa-plugins/goto/admin/systems/goto/chooser.tpl b/gosa-plugins/goto/admin/systems/goto/chooser.tpl new file mode 100644 index 000000000..3e8bf95f9 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/chooser.tpl @@ -0,0 +1,21 @@ +

{t}Choose the kind of system component you want to create{/t}

+ +

+ {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} +

+ +{t}Linux thin client template{/t}
+{t}Linux workstation template{/t}
+{t}Linux Server{/t}
+ +{t}Network printer{/t}
+{t}Phone{/t}
+{t}Other network component{/t}
+ +

+ +   + +

+ + 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 index 000000000..79009908e --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc @@ -0,0 +1,74 @@ +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 index 000000000..c17b8ef5f --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_SelectDeviceType.inc @@ -0,0 +1,85 @@ + "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 index 000000000..9eec1acaf --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc @@ -0,0 +1,1046 @@ + "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= "\"\" ". + _("This 'dn' has no printer features.").""; + 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", "".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD).""); + }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."),"".$this->cn."")); + }else{ + $smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"".$this->cn."")); + } + $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 index 000000000..1f110e355 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_selectUserToPrinterDialog.inc @@ -0,0 +1,198 @@ + "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 index 000000000..cdd9b8d68 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc @@ -0,0 +1,682 @@ + "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= "\"\" ". + _("This 'dn' has no terminal features.").""; + 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 index 000000000..0a21884d2 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalInfo.inc @@ -0,0 +1,255 @@ + "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 "\"\" ". + _("This 'dn' has no terminal features.").""; + 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", ""._("unknown status").""); + } + + + $display =""; + }else + /* Default entry? */ + if ($this->cn == "default"){ + $display= "

"; + $display.= _("This is a virtual terminal which has no properties to show here."); + $display.= "
"; + } 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", "\""._("running")."\""); + break; + case 1: + $smarty->assign("$pname", "\""._("not"); + break; + default: + $smarty->assign("$pname", _("not defined")); + } + } + } else { + foreach(array("uptime", "sshd", "X", "saned", "artsd", "cupsd") as $val){ + $smarty->assign("$val", ""._("unknown status").""); + } + } + /* 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.= "$device".progressbar($usage,100,16,true)."\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 index 000000000..54e1d865d --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc @@ -0,0 +1,527 @@ + "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= "\"\" ". + _("This 'dn' has no terminal features.").""; + 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= "\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 index 000000000..362bc7d8c --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc @@ -0,0 +1,582 @@ + "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= "\"\" ". + _("This 'dn' has no terminal features.").""; + 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." (missing)"; + } + + $SelectBoxLdapServer->AddEntry( + array(array("string" => $server), + array("string" => + " ". + " ". + "", + "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 index 000000000..0f0f97a98 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc @@ -0,0 +1,663 @@ + "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= "\"\" ". + _("This 'dn' has no workstation features.").""; + 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 index 000000000..815b52c0c --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationService.inc @@ -0,0 +1,506 @@ + "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= "\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 index 000000000..c74b37617 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationStartup.inc @@ -0,0 +1,1293 @@ + "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= "\"\" ". + _("This 'dn' has no terminal features.").""; + 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." (missing)"; + } + + $SelectBoxLdapServer->AddEntry( + array(array("string" => $server), + array("string" => + " ". + " ". + "", + "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 = "  "; + $str_down = "  "; + $str_remove = "  "; + $str_empty = "  \"\""; + + /* 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 = " ("._("Not available in current setup").")"; + } + + /* 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 = " [".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 index 000000000..f0c449677 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/gencd.tpl @@ -0,0 +1,20 @@ +

+ {t}CD-Install-Image generation{/t} +

+

+ {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} +

+ +

+ +   + +

+ + + 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 index 000000000..4c53bdab5 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/gencd_frame.tpl @@ -0,0 +1,3 @@ + diff --git a/gosa-plugins/goto/admin/systems/goto/info.tpl b/gosa-plugins/goto/admin/systems/goto/info.tpl new file mode 100644 index 000000000..e088c595a --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/info.tpl @@ -0,0 +1,135 @@ +

{t}System information{/t}

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
{t}CPU{/t}{$ghCpuType}
{t}Memory{/t}{$ghMemSize}
{t}Boot MAC{/t}{$macAddress}
{t}USB support{/t}{$ghUsbSupport}
{t}System status{/t}{$status}
{t}Inventory number{/t}{$ghInventoryNumber}
{t}Last login{/t}{$gotoLastUser}
+
+   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Network devices{/t} + {foreach item=netcard from=$ghNetNic} + {$netcard}
+ {/foreach} +
{t}IDE devices{/t} + {foreach item=idedev from=$ghIdeDev} + {$idedev}
+ {/foreach} +
{t}SCSI devices{/t} + {foreach item=scsidev from=$ghScsiDev} + {$scsidev}
+ {/foreach} +
{t}Floppy device{/t}{$FloppyDevice}
{t}CDROM device{/t}{$CdromDevice}
{t}Graphic device{/t}{$ghGfxAdapter}
{t}Audio device{/t}{$ghSoundAdapter}
+
+ +{if $active eq "true"} +
+

{t}System status{/t}

+ + + + + + +
+ + + + + + + + + + + + + + + + + {$partitions} +
{t}Up since{/t}{$uptime}
{t}CPU load{/t}{$load}
{t}Memory usage{/t}{$mem}
{t}Swap usage{/t}{$swap}
 
+
+   + + + + + + + + + + + + + + + + + +
{t}SSH service{/t}{$sshd}
{t}Print service{/t}{$cupsd}
{t}Scan service{/t}{$saned}
{t}Sound service{/t}{$artsd}
{t}GUI{/t}{$X}
+
+{/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 index 000000000..e4ba965b9 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/printer.tpl @@ -0,0 +1,150 @@ + + + + + +
+{if $StandAlone } +

{t}General{/t}

+ + + + + + + + + + + + + + + + +
{$must} +{render acl=$cnACL} + +{/render} +
+{render acl=$descriptionACL} + +{/render} +
 
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+
+{/if} +

{t}Details{/t}

+ + + + + + + + + +
+{render acl=$lACL} + +{/render} +
{$must} +{render acl=$labeledURIACL} + +{/render} +
+ + + + +
+
+ {t}Driver{/t}: {$driverInfo}  +{render acl=$gotoPrinterPPDACL mode=read_active} + +{/render} +{render acl=$gotoPrinterPPDACL} + +{/render} +
+
+ +

 

+ +

{t}Permissions{/t}

+ + + + + +
+ + + + +
+ {t}Users which are allowed to use this printer{/t}
+{render acl=$gotoUserPrinterACL} +
+{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +
+ +
+ + + + +
+ {t}Users which are allowed to administrate this printer{/t}
+{render acl=$gotoUserPrinterACL} +
+{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} +{render acl=$gotoUserPrinterACL} + +{/render} + +
+ +
+ + +{if $netconfig ne ''} +

 

+{$netconfig} +{/if} + + + diff --git a/gosa-plugins/goto/admin/systems/goto/scanner-list b/gosa-plugins/goto/admin/systems/goto/scanner-list new file mode 100644 index 000000000..3ebf2a102 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/scanner-list @@ -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 index 000000000..c60be2297 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/selectUserToPrinterDialog.tpl @@ -0,0 +1,70 @@ + + + + + + + +
+
+

+ +

+
+
+

+
+

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + +
+  {t}Search in subtrees{/t} +
+ + + + + +
+ + + +
+ + + + + +
+ + + +
+ {$apply} +
+
+ +

 

+

+ + +

+ 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 index 000000000..739777a7e --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/tabs_printers.inc @@ -0,0 +1,62 @@ +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 index 000000000..ea9207faf --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/tabs_terminal.inc @@ -0,0 +1,77 @@ +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 index 000000000..3d6bac27c --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/tabs_workstation.inc @@ -0,0 +1,75 @@ +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 index 000000000..dc088f867 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/terminal.tpl @@ -0,0 +1,176 @@ +

{t}Properties{/t}

+ + + + + +
+ + + {if $cn eq 'default'} + + {else} + + + {/if} + + + + + +
{t}Terminal template{/t}{$must} +{render acl=$cnACL} + +{/render} +
{$must} + +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+{if $member_of_ogroup} +
+
+
+ +{/if} +
+ + + + + + + + + +
+{render acl=$gotoModeACL} + +{/render} +
+{render acl=$gotoSyslogServerACL} + +{/render} +
+
+

 

+ + + + + +
+ + + + + + + + + +
+{render acl=$gotoTerminalPathACL} + +{/render} +
+{render acl=$gotoSwapServerACL} + +{/render} +
+
+ + + + + + + +
+{if $member_of_ogroup} +{render acl=$gotoNtpServerACL} + {t}Inherit time server attributes{/t} +{/render} +{else} + {t}Inherit time server attributes{/t} +{/if} +

+{render acl=$gotoNtpServerACL} + +{/render} +
+{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +
+ +
+ +{if $cn neq 'default'} +

 

+ +{$netconfig} +{/if} + +{if $fai_activated} +

 

+

{t}Action{/t}

+ + + + + +
+{render acl=$gotoNtpServerACL} + +{/render} + +{render acl=$gotoNtpServerACL} + +{/render} +
+{/if} + + + + diff --git a/gosa-plugins/goto/admin/systems/goto/terminalService.tpl b/gosa-plugins/goto/admin/systems/goto/terminalService.tpl new file mode 100644 index 000000000..72ba28b1a --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/terminalService.tpl @@ -0,0 +1,269 @@ + + + + + + + + + + + + +
+

{t}Keyboard{/t}

+ + + + + + + + + + + + + +
+{render acl=$gotoXKbModelACL} + +{/render} +
+{render acl=$gotoXKbLayoutACL} + +{/render} +
+{render acl=$gotoXKbVariantACL} + +{/render} +
+ +
+   + +

{t}Mouse{/t}

+ + + + + + + + + +
+{render acl=$gotoXMouseTypeACL} + +{/render} +
+{render acl=$gotoXMouseportACL} + +{/render} +
+ +
+   + +

{t}Telephone hardware{/t}

+ + + + +
{t}Telephone{/t}  +{render acl=$goFonHardwareACL} + {$hardware_list} +{/render} +
+ +
+ + + + + + + + + + + + + +

+

{t}Graphic device{/t}

+ + + + + + + + + + + + + +
+{render acl=$gotoXDriverACL} + +{/render} +
+{render acl=$gotoXResolutionACL} + +{/render } +
+{render acl=$gotoXColordepthACL} + +{/render} +
+
+   + +

{t}Display device{/t}

+ + + + + + + + + + + + +{/render} + + + + +{/render} + +
{t}Type{/t}{$gotoXMonitor}
+{render acl=$AutoSyncACL} + +{/render} + {t}Use DDC for automatic detection{/t}
+{render acl=$gotoXHsyncACL} + kHz
+{render acl=$gotoXVsyncACL} + Hz
+ +
+   + +

{t}Remote desktop{/t}

+ + + + + + + + + + + + + + + + +
+{render acl=$gotoXMethodACL} + +{/render} +
+{render acl=$gotoXdmcpServerACL} + +{/render} +
+{render acl=$gotoFontPathACL} + +{/render} +
+ +
+ + + + + + + + + +

+

+{render acl=$gotoLpdEnableACL} + +{/render} + {t}Provide print services{/t} +
+ + + + + + + +
+{render acl=$gotoLpdServerACL} + +{/render} +
+ +
+   + +

{t}Scan device{/t}

+{render acl=$gotoScannerEnableACL} + +{/render} + {t}Provide scan services{/t} +
+ + + + + + +
+{render acl=$gotoScannerEnableACL} + +{/render} +
+ +
+ +
diff --git a/gosa-plugins/goto/admin/systems/goto/terminalStartup.tpl b/gosa-plugins/goto/admin/systems/goto/terminalStartup.tpl new file mode 100644 index 000000000..ccfacfbaa --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/terminalStartup.tpl @@ -0,0 +1,142 @@ +

{t}Boot parameters{/t}

+ + + + + + + + +
+ + + + + + + + + +{/render} + + + + +
+{render acl=$gotoBootKernelACL} + +{/render} +
+{render acl=$gotoKernelParametersACL} +
+{render acl=$gotoLdapServerACL} +( + {t}inherit from group{/t}) +{if !$JS} + +{/if} +{/render} +{render acl=$gotoLdapServerACL_inherit} + {$gotoLdapServers} +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +
+ +
+   + +{render acl=$gotoKernelParametersACL} + +{/render} + {t}use graphical bootup{/t} +
+{render acl=$gotoKernelParametersACL} + +{/render} + {t}use standard linux textual bootup{/t} +
+{render acl=$gotoKernelParametersACL} + +{/render} + {t}use debug mode for startup{/t} +
+ + + + + + + + + +

+

+ {t}Kernel modules (format: name parameters){/t} +

+{render acl=$gotoModulesACL} + +{/render} +
+{render acl=$gotoModulesACL} + +{/render} +{render acl=$gotoModulesACL} +   +{/render} +{render acl=$gotoModulesACL} + +{/render} +
+

 

+ + + + +
+{render acl=$gotoShareACL} + +{/render} +
+{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +
+
+ + + + diff --git a/gosa-plugins/goto/admin/systems/goto/workstation.tpl b/gosa-plugins/goto/admin/systems/goto/workstation.tpl new file mode 100644 index 000000000..ba8489947 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/workstation.tpl @@ -0,0 +1,157 @@ +

{t}Properties{/t}

+ + + + + +
+ + +{if $cn eq 'wdefault'} + +{else} + + +{/if} + + + + + + + + + +
{t}Workstation template{/t}{$must} +{render acl=$cnACL} + +{/render} +
+{render acl=$lACL} + +{/render} +
{$must} +{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} + +{/render} +
+{if $member_of_ogroup} +
+
+
+ +{/if} +
+ + + + + + + + + +
{t}Mode{/t} +{render acl=$gotoModeACL} + +{/render} +
+{render acl=$gotoSyslogServerACL} + +{/render} +
+

 

+ + + + + + + +
+{if $member_of_ogroup} +{render acl=$gotoNtpServerACL} + {t}Inherit time server attributes{/t} +{/render} +{else} + {t}Inherit time server attributes{/t} +{/if} +

+{render acl=$gotoNtpServerACL} + +{/render} +
+{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +{render acl=$gotoNtpServerACL} + +{/render} +
+
+{if $cn neq 'wdefault'} +

 

+ +{$netconfig} +{/if} +

 

+ +{if $fai_activated} +

{t}Action{/t}

+ + + + + +
+{render acl=$FAIstateACL} + +{/render} + + +
+{/if} + + {if $cn eq 'wdefault'} + + + {else} + + {/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 index 000000000..e5171fe01 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/workstationService.tpl @@ -0,0 +1,224 @@ + + + + + + + + + + + + +
+

{t}Keyboard{/t}

+ + + + + + + + + + + + + +
+ +{render acl=$gotoXKbModelACL} + +{/render} + +
+ +{render acl=$gotoXKbLayoutACL} + +{/render} + +
+ +{render acl=$gotoXKbVariantACL} + +{/render} + +
+ +
+   + +

{t}Mouse{/t}

+ + + + +{/render} + + + + + + +
+ +{render acl=$gotoXMouseTypeACL} + +
+ +{render acl=$gotoXMouseportACL} + +{/render} + +
+ +
+   + +

{t}Telephone hardware{/t}

+ + + + +
{t}Telephone{/t}  + +{render acl=$goFonHardwareACL} + {$hardware_list} +{/render} + +
+ +
+ + + + + + + + + + + + + +

+

{t}Graphic device{/t}

+ + + + + + + + + + + + + +
+ +{render acl=$gotoXDriverACL} + +{/render} + +
+ +{render acl=$gotoXResolutionACL} + +{/render} + +
+ +{render acl=$gotoXColordepthACL} + +{/render} + +
+
+   + +

{t}Display device{/t}

+ + + + + + + + + + + + + + + + + +
{t}Type{/t}{if $gotoXMonitor==""}{t}unknown{/t}{/if}{$gotoXMonitor}
+ +{render acl=$AutoSyncACL} + +{/render} + + {t}Use DDC for automatic detection{/t}
+ +{render acl=$gotoXHsyncACL} + kHz +{/render} + +
+ +{render acl=$gotoXVsyncACL} + Hz +{/render} + +
+ +
+   + + + +

{t}Scan device{/t}

+ +{render acl=$gotoScannerEnableACL} + +{/render} + + {t}Provide scan services{/t} +
+
+ + +
+ + + + + + diff --git a/gosa-plugins/goto/admin/systems/goto/workstationStartup.tpl b/gosa-plugins/goto/admin/systems/goto/workstationStartup.tpl new file mode 100644 index 000000000..0801a091b --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/workstationStartup.tpl @@ -0,0 +1,232 @@ + + + + + + + + +
+

{t}Boot parameters{/t}

+ + + + + + + + + + + + + +
+{render acl=$gotoBootKernelACL} + +{/render} +
+{render acl=$gotoKernelParametersACL} + +{/render} +
+{render acl=$gotoLdapServerACL} +{if $member_of_ogroup} +( + {t}inherit from group{/t}) +{if !$JS} + +{/if} +{/if} +{/render} +{render acl=$gotoLdapServerACL_inherit} + {$gotoLdapServers} +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +{render acl=$gotoLdapServerACL_inherit} + +{/render} +
+ +
+   + + + {if $fai_activated} + + {if $FAIdebianMirror == "inherited"} + + + + + + + + + + +
+

 {t}FAI server{/t} +

+
+

 {t}Release{/t} +

+
+ {render acl=$FAIdebianMirrorACL} + + {/render} + + +
+

+  {t}Assigned FAI classes{/t} +

+ {render acl=$FAIclassACL} + {$FAIScriptlist} + {/render} + {else} + + + + + + + + + + +
+

 {t}FAI server{/t} +

+
+

 {t}Release{/t} +

+
+ {render acl=$FAIdebianMirrorACL} + + {/render} + {if $javascript eq 'false'} + {render acl=$FAIdebianMirrorACL} + + {/render} + {/if} + + {render acl=$FAIreleaseACL} + + {/render} +
+

+  {t}Assigned FAI classes{/t} +

+ {render acl=$FAIclassACL} + {$FAIScriptlist} + {/render} + + {render acl=$FAIclassACL} + + {/render} + {render acl=$FAIclassACL} + + {/render} + + {/if} + + {else} + +

{t}FAI Object assignment disabled. You can't use this feature until FAI is activated.{/t}

+ + {/if} +
+ + + + + + + + + +

+

+ {t}Kernel modules (format: name parameters){/t} +

+{render acl=$gotoModulesACL} + +{/render} +
+{render acl=$gotoModulesACL} + +{/render} +{render acl=$gotoModulesACL} +   +{/render} +{render acl=$gotoModulesACL} + +{/render} +
+

 

+ + + + +
+{render acl=$gotoShareACL} + +{/render} +
+{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +{render acl=$gotoShareACL} + +{/render} +
+
+ + +