summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 18c3128)
raw | patch | inline | side by side (parent: 18c3128)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 6 Sep 2005 11:19:19 +0000 (11:19 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 6 Sep 2005 11:19:19 +0000 (11:19 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1311 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/FAI/askClassName.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/class_askClassName.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/class_faiManagement.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/class_faiPartitionTable.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/class_faiPartitionTableEntry.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/faiPartitionTable.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/faiPartitionTableEntry.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/headpage.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/main.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/tabsPartition.inc | [new file with mode: 0644] | patch | blob |
diff --git a/plugins/admin/FAI/askClassName.tpl b/plugins/admin/FAI/askClassName.tpl
--- /dev/null
@@ -0,0 +1,49 @@
+<div style="font-size: 18px;">
+ {$headline}
+ <br><br>
+</div>
+ {t}Please select a class name for this object. The class name specifies a set of configurations.{/t}
+ <br>
+ {t}Every Class name must be unique. But it can be used for diffrent objects at the same time.\n
+ If you use this class name in a profile, all object with this class name will be included to this profile.{/t}
+ <br>
+ <br>
+ {t}The list box below shows all available class names you can use, for this object, to avoid duplicates.{/t}
+<br>
+<br>
+<table >
+ <tr>
+ <td colspan="2"><b>
+ {t}You can select one the following class names for this object.{/t}
+ </b></td>
+ </tr>
+ <tr>
+ <td><b>{t}Available class names.{/t}</b>
+ </td>
+ <td>
+ <select name="SelectedClass" title="{t}Choose class name{/t}" style="width:120px;">
+ {html_options values=$ClassNameKeys output=$ClassNames}
+ </select>
+ <input type="submit" name="UseSelectedClass" value="{t}Use{/t}" {$ClassNamesAvailable}>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><br>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><b>
+ {t}Please enter your class name here, if want to create a new class.{/t}
+ </b></td>
+ </tr>
+ <tr>
+ <td><b>{t}A new class name.</b>{/t}
+ </td>
+ <td>
+ <input type="text" name="UseTextInputName" value="" style="width:120px;">
+ <input type="submit" name="UseNewClass" value="{t}Use{/t}">
+ </td>
+ </tr>
+</table>
+<p class="seperator"> </p>
+
diff --git a/plugins/admin/FAI/class_askClassName.inc b/plugins/admin/FAI/class_askClassName.inc
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+
+class askClassName extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $objectClass = false;
+ var $forbidden =array();
+ var $ClassName = "";
+ var $ClassAlreadyExists = false;
+
+ function askClassName ($config, $dn= NULL,$ui = false, $objectClass)
+ {
+ $this->ui = $ui;
+ $this->objectClass = $objectClass;
+ plugin::plugin ($config, $dn);
+ }
+
+ function execute()
+ {
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* The faifilter contais
+ The base for all fai objects
+ */
+ $faifilter = $_SESSION['faifilter'];
+
+ /* First search for every ou, in given fai base
+ * With a second search detect all object that belong to the different ous.
+ */
+ $ldap = $this->config->get_ldap_link();
+ $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $faifilter['base'], array("cn","description","objectClass"),TRUE);
+ $used=array();
+
+ $delete = array();
+ foreach($res as $objecttypes){
+ $res2 = get_list2($this->ui->subtreeACL, "(objectClass=*)",
+ FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
+ foreach($res2 as $object){
+
+ /* skip class names with this type of object */
+ if(in_array($this->objectClass,$object['objectClass'])){
+ $delete[] = $object['cn'][0];
+ }
+
+ /* Skip profiles */
+ if(!in_array("FAIprofile",$object['objectClass'])){
+ $used[$object['cn'][0]]= $object['cn'][0];
+ }
+ }
+ }
+
+ /* Create headline
+ * Depending on the object type we want to create, a different headline will be shown
+ */
+ switch($this->objectClass) {
+ case "FAIpartitionTable": $str =_("Create new FAI object - partition table.");break;
+ case "FAIpackageList" : $str =_("Create new FAI object - package list.");break;
+ case "FAIscript" : $str =_("Create new FAI object - set of scripts.");break;
+ case "FAIvariable" : $str =_("Create new FAI object - set of variables.");break;
+ case "FAIhook" : $str =_("Create new FAI object - set of hooks.");break;
+ case "FAIprofile" : $str =_("Create new FAI object - profile.");break;
+ case "FAItemplate" : $str =_("Create new FAI object - template.");break;
+ default : $str =_("Create nre FAI object");break;
+ }
+ $smarty->assign("headline",$str);
+
+ /* Save forbidden class names
+ */
+ $this->forbidden = $delete;
+
+ /* Delete all class names which already have this type of object
+ */
+ foreach($delete as $del){
+ unset($used[$del]);
+ }
+
+ /* if there is no class name which is missing the type
+ * of objectClass wew want to create now, disable selectBox
+ */
+ if(count ($used)==0){
+ $smarty->assign("ClassNamesAvailable", " disabled ");
+ }else{
+ $smarty->assign("ClassNamesAvailable", "");
+ }
+ $smarty->assign("ClassNames", $used);
+ $smarty->assign("ClassNameKeys", $used);
+ $display.= $smarty->fetch(get_template_path('askClassName.tpl', TRUE));
+ return($display);
+ }
+
+ /* Get posts and set class name
+ */
+ function save_object()
+ {
+ if(isset($_POST['UseNewClass'])){
+ $this->ClassName = $_POST['UseTextInputName'];
+ $this->ClassAlreadyExists = true;
+ }
+
+ if(isset($_POST['UseSelectedClass'])){
+ $this->ClassAlreadyExists = false;
+ $this->ClassName = $_POST['SelectedClass'];
+ }
+ }
+
+
+ /* Check given class name
+ * A class name For each object type,
+ */
+ function check()
+ {
+ $message= array();
+ if(empty($this->ClassName)){
+ $message[]=_("The given class name is empty.");
+ }
+
+ if(in_array($this->ClassName,$this->forbidden)){
+ $message[]=_("The specified class name is already in use for this object type.");
+ }
+ return ($message);
+ }
+
+
+ /* Return the class name */
+ function save()
+ {
+ return($this->ClassName);
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/FAI/class_faiManagement.inc b/plugins/admin/FAI/class_faiManagement.inc
--- /dev/null
@@ -0,0 +1,451 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+require "tabsPartition.inc";
+
+class faiManagement extends plugin
+{
+ /* Definitions */
+ var $plHeadline = "FAI management";
+ var $plDescription = "Fully Automatic Installation - management";
+
+ /* CLI vars */
+ var $cli_summary = "Handling of FAI entries";
+ var $cli_description = "This plugin represents a management tool\n
+ which allows us to manage all needed attributes for fully automatic installations (FAI)";
+ var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* Headpage attributes */
+ var $departments= array();
+ var $deptabs= NULL;
+
+ /* attribute list for save action */
+ var $attributes = array(); // Attributes Managed by this plugin, none,
+ // because this is only an overview over all objects already defined in FAI.
+ var $objectclasses = array(); // ObjectClasses which the attributes are related to
+ var $dialog = array(); // This object contains every dialog we have currently opened
+
+ var $objects = array(); // This array contains all available objects shown in divlist
+ var $is_dialog = false;
+
+ /* construction/reconstruction
+ * The Filter ($faifilter stored in $_SESSION['faifilter']) defines the last
+ * selected department and filter options
+ * If it is not defined already we create a new fresh faifilter.
+ */
+ function faiManagement ($config, $ui)
+ {
+ /* #WT ??? Whats That */
+ $this->ui = $ui;
+
+ /* Set current dn to "", wherefore ? */
+ $this->dn = "";
+
+ /* Assign config */
+ $this->config = $config;
+
+ /* Get global filter config */
+ if (!is_global("faifilter")){
+ $base = get_base_from_people($ui->dn);
+ $faifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$base,
+ "regex" => "*");
+ $faifilter['ShowProfiles'] = true;
+ $faifilter['ShowTemplates'] = true;
+ $faifilter['ShowScripts'] = true;
+ $faifilter['ShowHooks'] = true;
+ $faifilter['ShowVariables'] = true;
+ $faifilter['ShowPackages'] = true;
+ $faifilter['ShowPartitions']=true;
+ register_global("faifilter", $faifilter);
+ }
+ }
+
+ function execute()
+ {
+ $display = "";
+ $smarty = get_smarty();
+ $s_action = "";
+ $s_entry = "";
+ /* filter management
+ * Filter will be changed if POST['regex'] or $_GET['search'] isset
+ * New Filter will be stored in session and is used to generate list contents
+ */
+ $faifilter = $_SESSION['faifilter'];
+
+ /* Filter is posted by apply button
+ * Check every single chkbox
+ */
+ if(isset($_POST['regex'])){
+ $faifilter['regex'] = $_POST['regex']."*";
+ foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
+ if(isset($_POST[$attrs])){
+ $faifilter[$attrs] = true;
+ }else{
+ $faifilter[$attrs] = false;
+ }
+ }
+ }
+
+ /* Check ImageButton posts
+ * Create new tab ich new_xx is posted
+ */
+ foreach($_POST as $key => $val){
+ if(preg_match("/create_partition/i",$key)){
+ $s_action = "new_partition";
+ }elseif(preg_match("/UseNewClass/",$key)){
+ $s_action = "select_class_name_finished";
+ }elseif(preg_match("/UseSelectedClass/",$key)){
+ $s_action = "select_class_name_finished";
+ }elseif(preg_match("/^entry_edit_.*/",$key)){
+ $s_entry = preg_replace("/^entry_edit_/","",$key);
+ $s_entry = preg_replace("/_.*$/","",$s_entry);
+
+ $s_action = "edit";
+ }
+
+ }
+
+ if($s_action == "edit"){
+ $entry = $this->objects[$s_entry];
+ switch($entry['type']){
+ case "FAIpartitionTable" :
+ $this->dn = $entry['dn'];
+ $this->dialog= new tabsPartition($this->config,
+ $this->config->data['TABS']['PARTITIONTABS'],$this->dn);
+ $this->is_dialog = true;
+ ;break;
+ default :;break;
+ }
+
+ }
+
+
+ /* Dialog handling */
+ if($s_action == "new_partition"){
+ $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
+ }
+
+ if($s_action == "select_class_name_finished"){
+ $this->dialog->save_object();
+ if(count($this->dialog->check())!=0){
+ foreach($this->dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->dn = "new" ;
+ $name = $this->dialog->save();
+ $this->dialog = new tabsPartition($this->config,
+ $this->config->data['TABS']['PARTITIONTABS'],$this->dn);
+ $this->dialog->by_object['faiPartitionTable']->cn = $name;
+ $this->is_dialog = true;
+ }
+ }
+
+
+ /* Search is set */
+ if(isset($_GET['search'])){
+ $faifilter['regex']=$_GET['search']."*";
+ }
+
+ /* remove double asterisks and save new filter */
+ $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
+ $_SESSION['faifilter']= $faifilter;
+
+ $this->reload();
+
+ /* Edit dialog was canceled
+ * Remove dialog an show management dialog
+ */
+ if(isset($_POST['edit_cancel'])){
+ unset($this->dialog);
+ $this->dialog=NULL;
+ $this->is_dialog = false;
+ }
+
+
+ /* This check if the given tab could be saved
+ * If it was possible to save it, remove dialog object.
+ * If it wasn't possible, show errors and keep dialog.
+ */
+ if(isset($_POST['edit_finish'])){
+ $this->dialog->save_object();
+ if(count($this->dialog->check())!=0){
+ foreach($this->dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->dialog->save();
+ unset($this->dialog);
+ $this->dialog=NULL;
+ $this->is_dialog=false;
+ }
+ }
+
+
+ /* If dialog is set, but $this->is_dialog==false, then
+ * only the "abort" button is shown, this are dialogs that must not be saved.
+ * If is_dialog == true, we are currently editing tab objects.
+ * Here we need both, save and cancel
+ */
+
+ if($this->dialog != NULL){
+ $display .= $this->dialog->execute();
+ /* Don't show buttons if tab dialog requests this */
+ if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
+
+ }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
+ $display.= "<p style=\"text-align:right\">\n";
+ $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
+ $display.= " \n";
+ $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "</p>";
+ }elseif(!isset($this->dialog->current)){
+ $display.= "<p style=\"text-align:right\">\n";
+ $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "</p>";
+ }
+ return($display);
+ }
+
+ /* Show Management template
+ * The following code will only be reached if no dialog (tabs or dialogs)
+ * are currently opened.
+ * Assign all reguired vars to template engine
+ */
+
+ /* Create listhead, it will be shown on top of the divlist.
+ * It provides general navigation and object creation
+ */
+ $faihead =
+ "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
+ " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
+
+ " <input type='image' src='images/select_new_server.png' align='middle'
+ title='"._("New partition table")."' name='Create_partition' alt='"._("Partition")."'> ".
+
+ " <input type='image' src='images/zip.png' align='middle'
+ title='"._("New packages")."' name='' alt='"._("Partition")."'> ".
+
+ "</div>";
+
+
+ /* Create list with objects */
+ $divlist = new divlist("faiManagement");
+ $divlist->SetEntriesPerPage(20);
+ $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
+
+ $divlist->SetHeader(array(
+ array("string" => " "),
+ array("string" => _("FAI objects / ObjectClasses")),
+ array("string" => _("Object type")),
+ array("string" => _("Obtions"), "attach" => "style='border:none'" )));
+
+
+ $action = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='entry_edit_%s' title='"._("Edit user")."'>";
+
+ /* Attach objects */
+ foreach($this->objects as $key => $value){
+ $info= "";
+ $img = "";
+ $type = $value['type'];
+ $abort=false;
+
+ switch($type) {
+ case "FAIpartitionTable" :
+ if(!$faifilter['ShowPartitions']){
+ $abort = true;
+ }
+ $img="<img src='images/server.png' title='Partition table' alt='PT'>";
+ $info = _("Partition table");
+ break;
+ case "FAIpackageList" :
+ if(!$faifilter['ShowPackages']){
+ $abort = true;
+ }
+ $img="<img src='images/zip.png' title='Package list' alt='PL'>";
+ $info = _("Package list");
+ break;
+ case "FAIscript" :
+ if(!$faifilter['ShowScripts']){
+ $abort = true;
+ }
+ $img="<img src='images/edit.png' title='Set of scripts' alt='S'>";
+ $info = _("Script set");
+ break;
+ case "FAIvariable" :
+ if(!$faifilter['ShowVariables']){
+ $abort = true;
+ }
+ $img="<img src='images/log_critical.png' title='Variable set' alt='V'>";
+ $info = _("Varialbe set");
+ break;
+ case "FAIhook" :
+ if(!$faifilter['ShowHooks']){
+ $abort = true;
+ }
+ $img="<img src='images/rightarrow.png' title='Hooks' alt='H'>";
+ $info = _("Hook set");
+ break;
+ case "FAIprofile" :
+ if(!$faifilter['ShowProfiles']){
+ $abort = true;
+ }
+ $img="<img src='images/tree.png' title='Profile' alt='P'>";
+ $info = _("Profile")." (".$value['FAIclass']." )";
+ break;
+ case "FAItemplate" :
+ if(!$faifilter['ShowTemplates']){
+ $abort = true;
+ }
+ $img="<img src='images/folder.png' title='Template' alt='T'>";
+ $info = _("Template");
+ break;
+ default :
+ $img="<img src='images/empty.png' >";$info = "";break;
+
+ }
+ if(!$abort) {
+ if((isset($value['description']))&&(!empty($value['description']))){
+ $desc= " [".$value['description']."]";
+ }else{
+ $desc= "";
+ }
+
+ $field1 = array("string" => $img , "attach" => "style='height:26px;width=20px;'");
+ $field2 = array("string" => $value['cn'].$desc , "attach" => "");
+ $field3 = array("string" => $info, "attach" => "");
+ $field4 = array("string" => sprintf($action,$key) , "attach" => "style='border-right:none;'");
+ $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+
+ }
+ }
+
+ foreach($faifilter as $attrs => $value){
+ if($value){
+ $smarty->assign($attrs."CHK", " checked ");
+ }else{
+ $smarty->assign($attrs."CHK", " ");
+ }
+ }
+
+ /* Assign all reguired vars to template engine */
+ $smarty->assign("faihead" , $faihead);
+ $smarty->assign("failist" , $divlist->DrawList());
+ $smarty->assign("regex" , $faifilter['regex']);
+ $smarty->assign("infoimage" , get_template_path('images/info.png'));
+ $smarty->assign("launchimage" , get_template_path('images/launch.png'));
+ $smarty->assign("alphabet" , generate_alphabet());
+ $smarty->assign("apply" , apply_filter());
+ $smarty->assign("search_image" , get_template_path('images/search.png'));
+
+ $display = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
+ return ($display);
+ }
+
+
+ function reload()
+ {
+ /* Create a new list of FAI object
+ * Object list depends on faifilter['regex']
+ * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
+ */
+ $faifilter= get_global('faifilter');
+ // Added for dirlist function...
+
+ /* Set base for all searches */
+ $base= $faifilter['base'];
+ $regex = $faifilter['regex'];
+
+ /* Array to save objects */
+ $objects = array();
+
+ $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",
+ FALSE, $base, array("cn","description","objectClass"),TRUE);
+
+ foreach($res as $objecttypes){
+ $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
+ FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
+ foreach($res2 as $object){
+ $type= "";
+ unset($object['objectClass']['count']);
+ if(!isset($object['description'][0])){
+ $object['description'][0]="";
+ }
+
+ /* Clean up object informations */
+ $obj['cn'] = $object['cn'][0];
+ $obj['dn'] = $object['dn'];
+ $obj['description'] = $object['description'][0];
+ $obj['objectClass'] = $object['objectClass'];
+
+ if(in_array("FAIpartitionTable",$obj['objectClass'])){
+ $type = "FAIpartitionTable";
+ }elseif(in_array("FAIpackageList",$obj['objectClass'])){
+ $type = "FAIpackageList";
+ }elseif(in_array("FAIscript",$obj['objectClass'])){
+ $type = "FAIscript";
+ }elseif(in_array("FAIvariable",$obj['objectClass'])){
+ $type = "FAIvariable";
+ }elseif(in_array("FAIhook",$obj['objectClass'])){
+ $type = "FAIhook";
+ }elseif(in_array("FAIprofile",$obj['objectClass'])){
+ $obj['FAIclass'] = $object['FAIclass'][0];
+ $type = "FAIprofile";
+ }elseif(in_array("FAItemplate",$obj['objectClass'])){
+ $type = "FAItemplate";
+ }
+ $this->objects[$obj['cn'].$type] = $obj;
+ $this->objects[$obj['cn'].$type]['type']=$type;
+
+ }
+ }
+ reset ($this->objects);
+ }
+
+ function remove_from_parent()
+ {
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd ($this->dn);
+ $ldap->recursive_remove();
+
+ /* Optionally execute a command after we're done */
+ $this->postremove();
+
+ /* Delete references to object groups */
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+ while ($ldap->fetch()){
+ $og= new ogroup($this->config, $ldap->getDN());
+ unset($og->member[$this->dn]);
+ $og->save ();
+ }
+
+ }
+
+ function remove_lock()
+ {
+ if (isset($this->dn)){
+ del_lock ($this->dn);
+ }
+ }
+
+}
+
+?>
diff --git a/plugins/admin/FAI/class_faiPartitionTable.inc b/plugins/admin/FAI/class_faiPartitionTable.inc
--- /dev/null
@@ -0,0 +1,236 @@
+<?php
+
+class faiPartitionTable extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes = array("cn","description");
+ var $objectclasses= array("top","FAIclass","FAIpartitionTable");
+
+ var $cn = "";
+ var $description = "";
+ var $disks = array();
+ var $is_dialog = false;
+ var $dialog = NULL;
+ function faiPartitionTable ($config, $dn= NULL)
+ {
+ plugin::plugin ($config, $dn);
+
+ $this->partitions = array();
+
+ /* If "dn==new" we try to create a new entry
+ * Else we must read all objects from ldap taht belong to this entry
+ * First read disks from ldap ... and then the partition definitions for the disks
+ */
+ if($dn != "new"){
+ $this->dn =$dn;
+
+ /* Read all disks from ldap taht are defined fot this partition table
+ */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->dn);
+ $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))",array("*"));
+ while($object = $ldap->fetch()){
+ $this->disks[$object['cn'][0]]['dn'] = $object['dn'];
+ $this->disks[$object['cn'][0]]['cn'] = $object['cn'][0];
+ if(isset($object['description'][0])){
+ $this->disks[$object['cn'][0]]['description'] = $object['description'][0];
+ }else{
+ $this->disks[$object['cn'][0]]['description'] = "";
+ }
+ $this->disks[$object['cn'][0]]['partitions'] = array();
+ }
+
+ /* read all partitions for each disk
+ */
+ foreach($this->disks as $name => $disk){
+ $ldap->cd ($disk['dn']);
+ $ldap->search("(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))",array("*"));
+ while($partition = $ldap->fetch()){
+
+ /* remove count ... from ldap result
+ */
+ foreach($partition as $key=>$val){
+ if((is_numeric($key))||($key=="count")||($key=="dn")){
+ unset($partition[$key]);
+ }else{
+ $partition[$key] = $val[0];
+ }
+ }
+
+ $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition;
+ }
+ }
+ }
+ }
+
+ function execute()
+ {
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* Add Disk to this Partitionset
+ * This code adds a new HDD to the disks
+ * A new Dialog will be opened
+ */
+ if(isset($_POST['AddDisk'])){
+ $this->dialog = new faiPartitionTableEntry($this->config,$this->dn);
+ $this->is_dialog = true;
+ }
+
+ if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){
+ $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$this->disks[$_POST['disks']]);
+ $this->is_dialog = true;
+ }
+
+ if(isset($_POST['CancelDisk'])){
+ unset($this->dialog);
+ $this->dialog = NULL;
+ $this->is_dialog=false;
+ }
+
+ if(isset($_POST['SaveDisk'])){
+ $this->dialog->save_object();
+ if(count($this->dialog->check())){
+ foreach($this->dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $disk = $this->dialog->save();
+ $this->disks[$disk['cn']]=$disk;
+ unset($this->dialog);
+ $this->dialog = NULL;
+ $this->is_dialog=false;
+ }
+ }
+
+ if(isset($this->dialog)){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+ foreach($this->attributes as $attrs){
+ $smarty->assign($attrs,$this->$attrs);
+ if($this->$attrs){
+ $smarty->assign($attrs."CHK"," ");
+ }else{
+ $smarty->assign($attrs."CHK"," disabled ");
+ }
+ }
+
+ $disks = array();
+ foreach($this->partitions as $part){
+ $disks[$part['cn']] = $part['cn']." [".$part['description']."]";
+ }
+
+
+ $disks = $this->getDisks();
+ $smarty->assign("disks" ,$disks);
+ $smarty->assign("diskKeys",array_flip($disks));
+ $display.= $smarty->fetch(get_template_path('faiPartitionTable.tpl', TRUE));
+ return($display);
+ }
+
+ function getDisks(){
+ $a_return = array();
+ foreach($this->disks as $key => $disk){
+ $cnt = count( $disk['partitions']);
+ if(!empty($disk['description'])){
+ $a_return[$key]= $disk['cn']." [".$disk['description']."] - "._("Number of Partitions")." :".$cnt;
+ }else{
+ $a_return[$key]= $disk['cn']." - "._("Number of Partitions")." :".$cnt;
+ }
+ }
+ return($a_return);
+ }
+
+ function remove_from_parent()
+ {
+ /* This cannot be removed... */
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ plugin::save_object();
+ foreach($this->attributes as $attrs){
+ if(isset($_POST[$attrs])){
+ $this->$attrs = $_POST[$attrs];
+ }
+ }
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ $message= array();
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ plugin::save();
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn);
+ if($ldap->count()){
+ $ldap->cd ($this->dn);
+ $ldap->rmdir_recursive($this->dn);
+ show_ldap_error($ldap->get_error());
+ }
+ $ldap->cd($this->dn);
+ $ldap->create_missing_trees($this->dn);
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ show_ldap_error($ldap->get_error());
+
+ foreach($this->disks as $cn=>$disk){
+ $disk_cn = "cn=".$cn.",".$this->dn;
+ $disk_attrs['cn'] = $disk['cn'];
+ $disk_attrs['description'] = $disk['description'];
+ $disk_attrs['objectClass']=array("top","FAIclass","FAIpartitionDisk");
+
+ $ldap->cd($disk_cn);
+ $ldap->create_missing_trees($disk_cn);
+ $ldap->cd($disk_cn);
+ $ldap->add($disk_attrs);
+ show_ldap_error($ldap->get_error());
+
+ foreach($disk['partitions'] as $key => $partition){
+ $partition_attrs = array();
+ foreach($partition as $key => $value){
+ if(!empty($value)){
+ $partition_attrs[$key]=$value;
+ }else{
+ unset($partition_attrs[$key]);
+ }
+ }
+
+ $partition_dn = "cn=".$partition_attrs['cn'].",".$disk_cn;
+ $partition_attrs['objectClass'] = array("top","FAIclass","FAIpartitionEntry");
+
+ $ldap->cd($partition_dn);
+ $ldap->create_missing_trees($partition_dn);
+ $ldap->cd($partition_dn);
+ $ldap->add($partition_attrs);
+ show_ldap_error($ldap->get_error());
+ }
+ }
+ $this->handle_post_events("add");
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/FAI/class_faiPartitionTableEntry.inc b/plugins/admin/FAI/class_faiPartitionTableEntry.inc
--- /dev/null
@@ -0,0 +1,322 @@
+<?php
+
+class faiPartitionTableEntry extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes = array("DISK_cn","DISK_description");
+ var $objectclasses= array();
+
+ var $DISK_cn = "";
+ var $DISK_description = "";
+
+ var $partitions = array();
+ var $UsedAttrs = array();
+ var $AvailableDiskNames = array();
+ var $is_edit = false;
+ var $old_cn = "";
+
+ function faiPartitionTableEntry ($config, $dn= NULL,$disk=false)
+ {
+ plugin::plugin ($config, $dn);
+ $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
+ "FAImountOptions","FAIfsOptions","FAIpartitionFlags");
+
+ $this->AvailableDiskNames = array();
+ foreach(array("a","b","c","d","e","f","g","h") as $ts){
+ $this->AvailableDiskNames["hd".$ts]= "hd".$ts;
+ }
+
+ if($disk){
+ foreach($disk['partitions'] as $name => $values){
+ foreach($this->UsedAttrs as $attr){
+ if(!isset($values[$attr])){
+ $disk['partitions'][$name][$attr]="";
+ }
+ }
+ }
+
+
+ $this->DISK_cn = $disk['cn'];
+ $this->DISK_description = $disk['description'];
+ $this->partitions = $disk['partitions'];
+ $this->is_edit = true;
+ $this->old_cn = $disk['cn'];
+ }
+ }
+
+ function execute()
+ {
+ /* Fill templating stuff */
+ $smarty = get_smarty();
+ $s_action = "";
+ $s_entry = "";
+ $display = "";
+
+ /* Assign values
+ * And Checkbox selection
+ */
+ foreach($this->attributes as $attrs){
+ $smarty->assign($attrs,$this->$attrs);
+ if($this->$attrs){
+ $smarty->assign($attrs."CHK"," ");
+ }else{
+ $smarty->assign($attrs."CHK"," disabled ");
+ }
+ }
+
+ /* Check all Posts if there is something usefull for us,
+ * For example : Delete is posted as Delete_1
+ * The number specifies the index we want to delete
+ */
+ foreach($_POST as $name => $value){
+ if(preg_match("/Delete_.*/",$name)){
+ $tmp = split("_",$name);
+ $s_action = "remove";
+ $s_entry = $tmp[1];
+ }
+ }
+
+ /* To remove a partition we unset the index posted.
+ * We must sort the index again, else we possibly got problems
+ * with partitions order.
+ */
+ if($s_action == "remove"){
+ unset($this->partitions[$s_entry]);
+ $tmp= array();
+ foreach($this->partitions as $part){
+ $tmp[count($tmp)+1]=$part;
+ }
+ $this->partitions = $tmp;
+
+ }
+
+ /* To add a partitions we only append an empty
+ * array to the already defined partitions.
+ */
+ if(isset($_POST['AddPartition'])){
+ foreach($this->UsedAttrs as $attr){
+ $tmp[$attr] = "";
+ }
+ $this->partitions[count($this->partitions)+1]=$tmp;
+ }
+
+ /* Tell smarty which Disknames are available.
+ */
+ $smarty->assign("cns", $this->AvailableDiskNames);
+
+ /* $setup contains a table with the partitions.
+ */
+ $smarty->assign("setup", $this->generateParts());
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* The user can't change a diskname
+ * if we are currently in edit mode for the specified disk
+ */
+ if($this->is_edit){
+ $smarty->assign("DISK_cnACL"," disabled ");
+ }else{
+ $smarty->assign("DISK_cnACL","");
+ }
+
+ /* Fetch template and show the result
+ */
+ $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE));
+ return($display);
+ }
+
+ function generateParts()
+ {
+ /* Define Arrays with allowed syntax */
+ $PartitionTypes = array("primary","logical");
+ $FAIfsTypes = array("ext2","ext3","xfs","swap","reiserfs","dos fat 16","win fat 32");
+
+ /* Display Header */
+ $str = "<table>";
+ $str .= "<tr>";
+ $str .= "<td>"._("Nr")."</td>";
+ $str .= "<td>"._("Name")."</td>";
+ $str .= "<td>"._("Description")."</td>";
+ $str .= "<td>"._("Type")."</td>";
+ $str .= "<td>"._("FS type")."</td>";
+ $str .= "<td>"._("Mount point")."</td>";
+ $str .= "<td>"._("Size in MB")."</td>";
+ $str .= "<td>"._("Mount options")."</td>";
+ $str .= "<td>"._("FS option")."</td>";
+ $str .= "<td>"._("Preserve")."</td>";
+ $str .= "<td></td>";
+ $str .= "</tr>";
+
+ /* Walk through all defined partitions.
+ * Create a new row for each partition and append it to
+ * the header defined above.
+ * To be able to check the posts later, we append a key to each single postfield. like cn_1 ... cn_2
+ */
+ foreach($this->partitions as $key => $part){
+
+ /* Generate Partition select box
+ */
+ $PartitionType = "<select name='FAIpartitionType_".$key."'>";
+ foreach($PartitionTypes as $type){
+ if($part['FAIpartitionType'] == $type){
+ $PartitionType .="<option value='".$type."' selected >".$type."</option>";
+ }else{
+ $PartitionType .="<option value='".$type."'>".$type."</option>";
+ }
+ }
+ $PartitionType.="</select>";
+
+
+ /* Generate fsType select box
+ */
+ $FAIfsType= "<select name='FAIfsType_".$key."'>";
+ foreach($FAIfsTypes as $type){
+ if($part['FAIfsType'] == $type){
+ $FAIfsType .="<option value='".$type."' selected >".$type."</option>";
+ }else{
+ $FAIfsType .="<option value='".$type."'>".$type."</option>";
+ }
+ }
+ $FAIfsType.="</select>";
+
+ $str .= "<tr>";
+ $str .= "<td>".($key)."</td>";
+ $str .= "<td><input name='cn_".$key."' value='".$part['cn']."' maxlength='8' style='width:80px;'></td>";
+ $str .= "<td><input name='description_".$key."' value='".$part['description']."' maxlength='8' style='width:80px;'></td>";
+ $str .= "<td>".$PartitionType."</td>";
+ $str .= "<td>".$FAIfsType."</td>";
+ $str .= "<td><input name='FAImountPoint_".$key."' value='".$part['FAImountPoint']."' ></td>";
+ $str .= "<td><input name='FAIpartitionSize_".$key."' value='".$part['FAIpartitionSize']."' style='width:200px;'></td>";
+ $str .= "<td><input name='FAImountOptions_".$key."' value='".$part['FAImountOptions']."' style='width:100px;'></td>";
+ $str .= "<td><input name='FAIfsOptions_".$key."' value='".$part['FAIfsOptions']."' style='width:100px;'></td>";
+ if($part['FAIpartitionFlags']!=false){
+ $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked></td>";
+ }else{
+ $str .= "<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve'></td>";
+ }
+ $str .= "<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."'></td>";
+ $str .= "</tr>";
+ }
+ $str.="</table>";
+ return($str);
+
+ }
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['TableEntryFrameSubmitted'])){
+ plugin::save_object();
+
+ /* Check base attributes */
+ foreach($this->attributes as $attrs){
+ if(isset($_POST[$attrs])){
+ $this->$attrs = $_POST[$attrs];
+ }
+ }
+
+ foreach($this->partitions as $key => $part){
+ foreach($this->UsedAttrs as $attrs){
+ if(isset($_POST[$attrs."_".$key])){
+ $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key];
+ }else{
+ $this->partitions[$key][$attrs] = false;
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ $message= array();
+
+ /* Check descriptions
+ */
+ if(empty($this->DISK_description)){
+ $message[] = _("Please enter a description for your disk.");
+ }
+ if(preg_match("/[^0-9a-z]/",$this->DISK_description)){
+ $message[] = _("Please enter a valid description for your disk. Only a-Z 0-9 are allowed.");
+ }
+
+ /* check every partition.
+ * if there is an invalid value defined, append an errorstr to message
+ */
+ foreach($this->partitions as $key => $part){
+ if((empty($part['cn']))||(preg_match("/[^0-9a-z]/",$part['cn']))){
+ $message[]=sprintf(_("Please enter a valid name for partition %s." ),($key));
+ }
+
+ if(empty($part['description'])){
+ $message[]=sprintf(_("Please enter a valid description for partition %s." ),($key));
+ }
+
+ if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){
+ $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key));
+ }
+
+ $tmp = split("-",$part['FAIpartitionSize']);
+ if(count($tmp)!=2){
+ $message[]=sprintf(_("Please enter a range for partition size, 'from-to', for partition %s."),($key));
+ }elseif((!is_numeric($tmp[0]))||(!is_numeric($tmp[1]))){
+ $message[]=sprintf(_("Please enter a valid range for partition %s."),($key));
+ }elseif($tmp[0]>=$tmp[1]){
+ $message[]=sprintf(_("Please enter a valid range for partition %s."),($key));
+ }
+ }
+
+
+ /* Only show 5 errors */
+ $cnt = 0;
+ if(count($message)>5){
+ foreach($message as $msg){
+ if($cnt < 5){
+ $tmp2[]=$msg;
+ }
+ $cnt ++;
+ }
+ $tmp2[] = "...";
+ $message = $tmp2;
+ }
+
+ return ($message);
+ }
+
+
+ function save()
+ {
+ /* This function returns the new or edited disk with its partitions.
+ * If the disk was edited and not a new one, we reset the name of the disk
+ * to keep the correct index.
+ */
+
+ if($this->is_edit){
+ $tmp['cn'] = $this->old_cn;
+ }else{
+ $tmp['cn'] = $this->DISK_cn;
+ }
+
+ foreach($this->partitions as $key=>$val) {
+ $this->partitions[$key]['FAIpartitionNr']=$key;
+ }
+
+ $tmp['description'] = $this->DISK_description;
+ $tmp['partitions'] = $this->partitions;
+
+ return($tmp);
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/FAI/faiPartitionTable.tpl b/plugins/admin/FAI/faiPartitionTable.tpl
--- /dev/null
@@ -0,0 +1,36 @@
+<h2>{t}FAI partition table{/t}
+<br><br>
+<table>
+ <tr>
+ <td>
+ {t}Name{/t}
+ </td>
+ <td>
+ <input value="{$cn}" disabled>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}Description{/t}
+ </td>
+ <td>
+ <input value="{$description}" {$description} name="description">
+ </td>
+ </tr>
+</table>
+<br>
+<br>
+<h2>{t}Already defined disk{/t}</h2>
+<table width="100%">
+ <tr>
+ <td>
+ <select name="disks" title="{t}Choose a disk to delete or edit{/t}" style="width:450px;height:250px;" multiple>
+ {html_options values=$diskKeys output=$disks}
+ </select><br>
+ <input type="submit" name="AddDisk" value="{t}Add{/t}">
+ <input type="submit" name="EditDisk" value="{t}Edit{/t}">
+ <input type="submit" name="DelDisk" value="{t}Delete{/t}">
+ </td>
+ </tr>
+</table>
+
diff --git a/plugins/admin/FAI/faiPartitionTableEntry.tpl b/plugins/admin/FAI/faiPartitionTableEntry.tpl
--- /dev/null
@@ -0,0 +1,33 @@
+<h2>{t}FAI partition table entry{/t}
+<input type="hidden" name="TableEntryFrameSubmitted" value="1">
+<br><br>
+<table>
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <select name="DISK_cn" title="{t}Choose a disc name{/t}" {$DISK_cnACL}>
+ {html_options values=$cns output=$cns selected=$DISK_cn}
+ </select><br>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Description{/t}
+ </td>
+ <td><input name="DISK_description" value="{$DISK_description}">
+ </td>
+ </tr>
+</table>
+<br>
+<p class="seperator"> </p>
+<br>
+{$setup}
+<br>
+<input type="submit" name="AddPartition" value="{t}Add partition{/t}" >
+<br>
+<br>
+<p class="seperator"> </p>
+<div style="align:right;" align="right">
+<input type="submit" name="SaveDisk" value="{t}Save{/t}" >
+<input type="submit" name="CancelDisk" value="{t}cancel{/t}" >
+</div>
diff --git a/plugins/admin/FAI/headpage.tpl b/plugins/admin/FAI/headpage.tpl
--- /dev/null
@@ -0,0 +1,61 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:600px">
+ <div class="contentboxh">
+ <p class="contentboxh">
+ {t}List of FAI objects (Fully Automatic Installation){/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$faihead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$failist}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh">
+ <p class="contentboxh"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <p class="contentboxb">
+ {t}This menu allows you to create, delete and edit selected FAI obejcts. Having a large size of objects, you might prefer the range selectors on top of this list.{/t}
+ </p>
+ </div>
+ <br>
+ <div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ <tr><td><input type="checkbox" name="ShowProfiles" {$ShowProfilesCHK}>{t}Show profiles{/t}</td></tr>
+ <tr><td><input type="checkbox" name="ShowTemplates" {$ShowTemplatesCHK}>{t}Show templates{/t}</td></tr>
+ <tr><td><input type="checkbox" name="ShowScripts" {$ShowScriptsCHK}>{t}Show scripts{/t}</td></tr>
+ <tr><td><input type="checkbox" name="ShowHooks" {$ShowHooksCHK}>{t}Show hooks{/t}</td></tr>
+ <tr><td><input type="checkbox" name="ShowVariables" {$ShowVariablesCHK}>{t}Show variables{/t}</td></tr>
+ <tr><td><input type="checkbox" name="ShowPackages" {$ShowPackagesCHK}>{t}Show packages{/t}</td></tr>
+ <tr><td><input type="checkbox" name="ShowPartitions" {$ShowPartitionsCHK}>{t}Show partitions{/t}</td></tr>
+ </table>
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ <tr>
+ <td>
+ <LABEL for "regex"><img alt="{t}Display objects matching{/t}" src="{$search_image}" align=middle title='{t}Display objects matching{/t}'></LABEL>
+ </td>
+ <td width="99%">
+ <input type='text' name='regex' maxlength='20' style='width:99%' value='{$regex}' id='filter'
+ title='{t}Regular expression for matching object names{/t}' onChange="mainform.submit()">
+ </td>
+ </tr>
+ </table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table summary="">
+
+<input type="hidden" name="ignore">
diff --git a/plugins/admin/FAI/main.inc b/plugins/admin/FAI/main.inc
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+if ($remove_lock){
+ if(isset($_SESSION['FAI'])){
+ $FAI= $_SESSION['FAI'];
+ $FAI->remove_lock();
+ del_lock ($ui->dn);
+ sess_del ('FAI');
+ }
+} else {
+ /* Create usermanagement object on demand */
+ if (!isset($_SESSION['FAI']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ $_SESSION['FAI']= new faiManagement($config, $ui);
+ }
+ $FAI= $_SESSION['FAI'];
+ $output= $FAI->execute();
+
+ /* Page header*/
+ if (isset($_SESSION['objectinfo'])){
+ $display= print_header(get_template_path('images/department.png'), _("FAI management"), "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$_SESSION['objectinfo']);
+ } else {
+ $display= print_header(get_template_path('images/department.png'), _("FAI management"));
+ }
+
+ /* Reset requested? */
+ if (isset($_GET['reset']) && $_GET['reset'] == 1){
+ del_lock ($ui->dn);
+ sess_del ('FAI');
+ }
+
+ /* Show and save dialog */
+ $FAI->save_object();
+ $display.= $output;
+ $_SESSION['FAI']= $FAI;
+}
+
+?>
diff --git a/plugins/admin/FAI/tabsPartition.inc b/plugins/admin/FAI/tabsPartition.inc
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+class tabsPartition extends tabs
+{
+ var $base= "";
+
+ function tabsPartition($config, $data, $dn)
+ {
+ tabs::tabs($config, $data, $dn);
+ }
+
+ function check()
+ {
+ return (tabs::check(TRUE));
+ }
+
+
+ function save()
+ {
+ $baseobject= $this->by_object['faiPartitionTable'];
+
+ // cn=FAIBASE,ou=disk,ou=fai,ou=configs,ou=systems,dc=gonicus,dc=de
+ $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+
+ // Old .. $new_dn= 'ou='.$baseobject->ou.','.$baseobject->base;
+
+ if ($this->dn != $new_dn && $this->dn != "new"){
+
+ /* if( new_dn is subtree of this->dn ) */
+ $cnt1 = count(split(",",$this->dn));
+ $cnt2 = count(split(",",$new_dn));
+ if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){
+ print_red(_("Try to move tree failed. Destination tree is subtree of source tree."));
+ }else{
+ $baseobject->recursive_move($this->dn, $new_dn);
+ }
+ }
+ $this->dn= $new_dn;
+
+ tabs::save(TRUE);
+ }
+
+}
+
+?>