From: cajus Date: Mon, 19 Sep 2005 07:40:36 +0000 (+0000) Subject: Adapted path and image X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1d9578d8ee2d5a59bd4f9777785ef8567ab8cef1;p=gosa.git Adapted path and image git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1391 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/TODO b/TODO index 1176b72d7..fbe5d7adc 100644 --- a/TODO +++ b/TODO @@ -19,6 +19,10 @@ Things to fix before 2.4: * Addressbook shows up with windows workstations +* Rework environment tab + +* Rework printer tabs + Target for 2.5: =============== diff --git a/contrib/gosa.conf b/contrib/gosa.conf index 19c616676..6fb4f98dc 100644 --- a/contrib/gosa.conf +++ b/contrib/gosa.conf @@ -31,14 +31,16 @@ path="plugins/admin/departments" /> + + -
diff --git a/html/images/fai.png b/html/images/fai.png index 313a66152..f0a23d6f3 100644 Binary files a/html/images/fai.png and b/html/images/fai.png differ diff --git a/plugins/admin/FAI/askClassName.tpl b/plugins/admin/FAI/askClassName.tpl deleted file mode 100644 index b73f9624e..000000000 --- a/plugins/admin/FAI/askClassName.tpl +++ /dev/null @@ -1,48 +0,0 @@ -
- {$headline} -

-
- {t}Please select a class name for this object. The class name specifies a set of configurations.{/t} -
- {t}Every Class name must be unique. But it can be used for different objects at the same time.
If you use this class name in a profile, all object with this class name will be included to this profile.{/t} -
-
- {t}The list box below shows all available class names you may use, for this object, to avoid duplicates.{/t} -
-
- - - - - - - - - - - - - - - - - - -
- {t}You can select of one the following class names for this object.{/t} -
{t}Available class names.{/t} - - - -

-
- {t}Please enter your class name here, if want to create a new class.{/t} -
{t}A new class name.{/t} - - - -
-

 

- diff --git a/plugins/admin/FAI/class_askClassName.inc b/plugins/admin/FAI/class_askClassName.inc deleted file mode 100644 index a2b380e16..000000000 --- a/plugins/admin/FAI/class_askClassName.inc +++ /dev/null @@ -1,149 +0,0 @@ - "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 name */ - 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 bundle.");break; - case "FAIscript" : $str =_("Create new FAI object - script bundle.");break; - case "FAIvariable" : $str =_("Create new FAI object - variable bundle.");break; - case "FAIhook" : $str =_("Create new FAI object - hook bundle.");break; - case "FAIprofile" : $str =_("Create new FAI object - profile.");break; - case "FAItemplate" : $str =_("Create new FAI object - template.");break; - default : $str =_("Create new 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 for this type - * of objectClass, we only can create a new one, 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 - */ - 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."); - } - - if(preg_match("/[^a-z0-9]/i",$this->ClassName)){ - $message[]=_("Please enter a valid class name. Only 0-9 a-z is allowed here."); - } - - 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_faiHook.inc b/plugins/admin/FAI/class_faiHook.inc deleted file mode 100644 index c7edf194c..000000000 --- a/plugins/admin/FAI/class_faiHook.inc +++ /dev/null @@ -1,291 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIhook"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIhookEntry"; - var $subClasses = array("top","FAIclass","FAIhookEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiHookEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAItask","FAIscript"); - var $sub64coded = array("FAItask","FAIscript"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - var $SubObjects = array(); // All leafobjects of this object - - function faiHook ($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); - - while($object = $ldap->fetch()){ - /* Set status for save management */ - - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; - - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - - } - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->is_dialog=true; - } - - /* Edit selected Sub Object */ - if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); - $this->is_dialog=true; - } - - /* Remove Sub object */ - if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ - if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ - $this->SubObjects[$_POST['SubObject']]['status']= "delete"; - }else{ - unset($this->SubObjects[$_POST['SubObject']]); - } - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - - /* Perform post check*/ - $this->dialog->save_object(); - - /* Get messages */ - $msgs = $this->dialog->check(); - - /* print errors */ - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - - /* Get return object */ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - - /* Depending on status, set new status */ - if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - } - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - - /* Print dialog if $this->dialog is set */ - if($this->dialog){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - $smarty->assign("SubObjects",$this->getList()); - $smarty->assign("SubObjectKeys",array_flip($this->getList())); - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('faiHook.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - } - - - /* 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(); - $str = utf8_encode("üöä"); - if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\-.,;:_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $ldap->cat($this->dn); - if($ldap->count()!=0){ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error()); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode($obj[$codeIt]); - } - - $tmp = array(); - foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - $tmp[$attrs] = $obj[$attrs]; - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status'] == "delete"){ - $ldap->cd($sub_dn); - $ldap->rmdir_recursive($sub_dn); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - $ldap->cd($sub_dn); - $ldap->modify($tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - $ldap->cd($sub_dn); - $ldap->create_missing_trees($sub_dn); - $ldap->cd($sub_dn); - $ldap->add($tmp); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error()); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiHookEntry.inc b/plugins/admin/FAI/class_faiHookEntry.inc deleted file mode 100644 index a73c49382..000000000 --- a/plugins/admin/FAI/class_faiHookEntry.inc +++ /dev/null @@ -1,123 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("Object_cn","Object_description","Object_FAIscript","Object_FAItask"); - var $objectclasses= array(); - - var $orig_cn = ""; - - var $Object_dn = ""; - var $Object_cn = ""; - var $Object_FAItask = ""; - var $Object_FAIscript = ""; - var $Object_description = ""; - var $Object_status = "new"; - - function faiHookEntry ($config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if($dn != "new"){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = "Object_".$name; - $this->$oname=$value; - } - }else{ - $this->Object_status = "new"; - $this->orig_cn = false; - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - } - - for($i =1 ; $i <= 100 ; $i++){ - $Object_FAIprioritys[$i]=$i; - } - $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); - $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if(isset($_POST['SubObjectFormSubmitted'])){ - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - - /* Check supplied data */ - function check() - { - $message= array(); - if(empty($this->Object_FAItask)) { - $message[]=_("Please enter a value for task."); - } - if(empty($this->Object_FAIscript)) { - $message[]=_("Please enter a value for script."); - } - - $str = utf8_encode("üöä"); - - if(empty($this->Object_description)){ - $message[] = _("Please enter a description."); - } - - if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ - $message[] = _("Invalid character in description. Please enter a valid description."); - } - - if(empty($this->Object_cn)){ - $message[] = _("Please enter a name."); - } - - if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ - $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $attr = preg_replace("/^Object_/","",$attrs); - $tmp[$attr] = $this->$attrs; - } - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->Object_status; - return($tmp); - } -} -// 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 deleted file mode 100644 index 7ec7329f6..000000000 --- a/plugins/admin/FAI/class_faiManagement.inc +++ /dev/null @@ -1,600 +0,0 @@ - "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) - { - $this->ui = $ui; - - /* Set current dn to "", */ - $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("/create_script/i",$key)){ - $s_action = "new_script"; - }elseif(preg_match("/create_hook/i",$key)){ - $s_action = "new_hook"; - }elseif(preg_match("/create_variable/i",$key)){ - $s_action = "new_variable"; - }elseif(preg_match("/create_template/i",$key)){ - $s_action = "new_template"; - }elseif(preg_match("/create_package/i",$key)){ - $s_action = "new_package"; - }elseif(preg_match("/create_profile/i",$key)){ - $s_action = "new_profile"; - }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"; - }elseif(preg_match("/^entry_delete_.*/",$key)){ - $s_entry = preg_replace("/^entry_delete_/","",$key); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_action = "delete"; - } - - } - - /* Confirm dialog - * Delte object - */ - if ($s_action=="delete"){ - - /* Get 'dn' from posted termlinst */ - $this->dn= $this->objects[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl= get_permissions ($this->dn, $this->ui->subtreeACL); - $this->acl= get_module_permission($acl, "FAIclass", $this->dn); - if (chkacl($this->acl, "delete") == ""){ - - /* 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->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), $this->dn)); - 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 component!")); - } - } - - /* Deltetion was confirmed, so delete this entry - */ - if (isset($_POST['delete_terminal_confirm'])){ - - /* Some nice guy may send this as POST, so we've to check - for the permissions again. */ - if (chkacl($this->acl, "delete") == ""){ - - /* Find out more about the object type */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn); - $attrs = $ldap->fetch(); - - $type = $this->get_type($attrs); - - $this->dialog= new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn); - $this->dialog->set_acl(array($this->acl)); - - $this->dialog->by_object[$type[1]]->remove_from_parent (); - unset ($this->dialog); - gosa_log ("System object'".$this->dn."' has been removed"); - $this->dialog= NULL; - - /* Terminal list has changed, reload it. */ - $this->reload (); - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - print_red (_("You are not allowed to delete this component!")); - gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ". - "deletion."); - } - - /* Remove lock file after successfull deletion */ - del_lock ($this->dn); - } - - /* Edit Entry */ - if($s_action == "edit"){ - $entry = $this->objects[$s_entry]; - - $a_setup = ($this->get_type($entry)); - - $this->dn = $entry['dn']; - - $this->dialog= new $a_setup[0]($this->config, - $this->config->data['TABS'][$a_setup[2]],$this->dn); - $this->is_dialog = true; - } - - - /* Dialog handling */ - if($s_action == "new_partition"){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable"); - } - - /* Dialog handling */ - if($s_action == "new_script"){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript"); - } - - /* Dialog handling */ - if($s_action == "new_hook"){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook"); - } - - /* Dialog handling */ - if($s_action == "new_variable"){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable"); - } - - /* Dialog handling */ - if($s_action == "new_template"){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate"); - } - - /* Dialog handling */ - if($s_action == "new_package"){ - $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList"); - } - - /* New Profile */ - if($s_action == "new_profile"){ - $this->dn = "new" ; - $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile"))); - - $this->dialog = new $a_setup[0]($this->config, - $this->config->data['TABS'][$a_setup[2]],$this->dn); - $this->is_dialog = true; - - } - - 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" ; - $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass))); - $name = $this->dialog->save(); - - $this->dialog = new $a_setup[0]($this->config, - $this->config->data['TABS'][$a_setup[2]],$this->dn); - $this->dialog->by_object[$a_setup[1]]->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; - - /* 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.= "

\n"; - $display.= "\n"; - $display.= " \n"; - $display.= "\n"; - $display.= "

"; - }elseif(!isset($this->dialog->current)){ - $display.= "

\n"; - $display.= "\n"; - $display.= "

"; - } - 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 = - "
 ". - - "  ". - - "  ". - - "  ". - - "  ". - - "  ". - - "  ". - - "\"\" ". - - "  ". - - "
"; - - $this->reload(); - - /* 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 group")), - array("string" => _("Options"), "attach" => "style='border:none'" ))); - - - $action = ""; - $action .= ""; - - /* 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="PT"; - $info = _("Partition table"); - break; - case "FAIpackageList" : - if(!$faifilter['ShowPackages']){ - $abort = true; - } - $img="PL"; - $info = _("Package list"); - break; - case "FAIscript" : - if(!$faifilter['ShowScripts']){ - $abort = true; - } - $img="S"; - $info = _("Script set"); - break; - case "FAIvariable" : - if(!$faifilter['ShowVariables']){ - $abort = true; - } - $img="V"; - $info = _("Variable set"); - break; - case "FAIhook" : - if(!$faifilter['ShowHooks']){ - $abort = true; - } - $img="H"; - $info = _("Hook set"); - break; - case "FAIprofile" : - if(!$faifilter['ShowProfiles']){ - $abort = true; - } - $img="P"; - $info = _("Profile")." (".$value['FAIclass']." )"; - break; - case "FAItemplate" : - if(!$faifilter['ShowTemplates']){ - $abort = true; - } - $img="T"; - $info = _("Template"); - break; - default : - $img="";$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" => preg_replace("/%KEY%/",$key,$action) , "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(); - - $this->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[strtolower($obj['cn']).$obj['cn'].$type] = $obj; - $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; - - } - } - ksort($this->objects); - reset ($this->objects); - } - - function remove_lock() - { - if (isset($this->dn)){ - del_lock ($this->dn); - } - } - - function get_type($array){ - if(in_array("FAIpartitionTable",$array['objectClass'])){ - return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS")); - } - if(in_array("FAIscript",$array['objectClass'])){ - return(array("tabsScript","faiScript","FAISCRIPTTABS")); - } - if(in_array("FAItemplate",$array['objectClass'])){ - return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS")); - } - if(in_array("FAIhook",$array['objectClass'])){ - return(array("tabsHook","faiHook","FAIHOOKTABS")); - } - if(in_array("FAIvariable",$array['objectClass'])){ - return(array("tabsVariable","faiVariable","FAIVARIABLETABS")); - } - if(in_array("FAIprofile",$array['objectClass'])){ - return(array("tabsProfile","faiProfile","FAIPROFILETABS")); - } - - if(in_array("FAIpackageList",$array['objectClass'])){ - return(array("tabsPackage","faiPackage","FAIPACKAGETABS")); - } - } - -} - -?> diff --git a/plugins/admin/FAI/class_faiPackage.inc b/plugins/admin/FAI/class_faiPackage.inc deleted file mode 100644 index 78c9a18b6..000000000 --- a/plugins/admin/FAI/class_faiPackage.inc +++ /dev/null @@ -1,143 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description","FAIpackage"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIpackageList"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = ""; - var $subClasses = array("top","FAIclass","FAIscriptEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = ""; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description"); - var $sub64coded = array(); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - var $SubObjects = array(); // All leafobjects of this object - - function faiPackage ($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - $this->dn =$dn; - } - - $this->FAIpackage = "test"; - } - - function execute() - { - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - } - - - /* 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(); - $str = utf8_encode("üöä"); - if((empty($this->description))){ - $message[]=_("Please enter a valid description."); - } - if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $ldap->cat($this->dn); - if($ldap->count()!=0){ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error()); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiPartitionTable.inc b/plugins/admin/FAI/class_faiPartitionTable.inc deleted file mode 100644 index db65fed85..000000000 --- a/plugins/admin/FAI/class_faiPartitionTable.inc +++ /dev/null @@ -1,380 +0,0 @@ - "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 $base64_encode = array("FAImountPoint","FAImountOptions","FAIfsOptions","description"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $disks = array(); // All defined Disks - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - - function faiPartitionTable ($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which 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]]['status'] = "edited"; - $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]; - } - } - /* Append fetched partitions - */ - $partition['status']="edited"; - - foreach($this->base64_encode as $attrs){ - $partition[$attrs] = base64_decode($partition[$attrs]); - } - $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'])){ - $usedDiskNames =array(); - foreach($this->disks as $key=>$disk){ - $usedDiskNames[]= $key; - } - $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); - $this->is_dialog = true; - } - - /* Edit disk. - * Open dialog which allows us to edit the selected entry - */ - if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){ - $usedDiskNames =array(); - foreach($this->disks as $key=>$disk){ - if($key != $_POST['disks']){ - $usedDiskNames[]= $key; - } - } - $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$_POST['disks']]); - $this->is_dialog = true; - } - - /* Edit aborted, close dialog, without saving anything - */ - if(isset($_POST['CancelDisk'])){ - unset($this->dialog); - $this->dialog = NULL; - $this->is_dialog=false; - } - - /* Dialog saved - * Save given data from Dialog, if no error is occured - */ - 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(); - if(isset($disk['rename'])){ - if($this->disks[$disk['rename']['from']]['status']=="edited"){ - $this->disks[$disk['rename']['from']]['status']="delete"; - }else{ - unset($this->disks[$disk['rename']['from']]); - } - - foreach($disk['partitions'] as $key => $val){ - if($disk['partitions'][$key]['status']!="delete"){ - $disk['partitions'][$key]['status']= "new"; - } - } - - $disk['status']="new"; - $disk['cn']= $disk['rename']['to']; - } - - $this->disks[$disk['cn']]=$disk; - unset($this->dialog); - $this->dialog = NULL; - $this->is_dialog=false; - } - } - - /* Delete selected disk drive from list - * Assign delete status for all its partitions - */ - if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){ - $disk = $_POST['disks']; - if($this->disks[$disk]['status']=="edited"){ - $this->disks[$disk."-delete"]=$this->disks[$disk]; - unset($this->disks[$disk]); - $disk = $disk."-delete"; - $this->disks[$disk]['status']="delete"; - foreach($this->disks[$disk]['partitions'] as $name => $value ){ - if($value['status']=="edited"){ - $this->disks[$disk]['partitions'][$name]['status']="delete"; - }else{ - unset($this->disks[$disk]['partitions'][$name]); - } - } - }else{ - unset($this->disks[$disk]); - } - } - - /* Display dialog if one is defined - */ - if(isset($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - /* Assign all attributes to smarty engine - */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - if($this->$attrs){ - $smarty->assign($attrs."CHK"," "); - }else{ - $smarty->assign($attrs."CHK"," disabled "); - } - } - - $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(){ - /* Return all available disks for this partition table - * Return in listBox friendly array - */ - $a_return = array(); - foreach($this->disks as $key => $disk){ - if($disk['status'] != "delete"){ - $cnt=0; - foreach($disk['partitions'] as $val){ - if($val['status']!="delete"){ - $cnt ++; - } - } - 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); - } - - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - - /* 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(); - - $str = utf8_encode("üöä"); - if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - - if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){ - $message[]=_("Please enter a valid name."); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - - plugin::save(); - /* Save current settings. - * 1 : We must save the partition table, with its description and cn - * 2 : Append Disk with cn and description. - * 3 : Save partitions for each disk - */ - - $ldap = $this->config->get_ldap_link(); - - if($this->new){ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - show_ldap_error($ldap->get_error()); - }else{ - /* Add partition table to ldap - */ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - show_ldap_error($ldap->get_error()); - } - - - /* Sort entries, because we must delete entries with status="delete" first */ - $order = array(); - foreach($this->disks as $key => $disk){ - if($disk['status'] == "delete"){ - $order[$key] = $disk; - } - } - foreach($this->disks as $key => $disk){ - if($disk['status'] != "delete"){ - $order[$key] = $disk; - } - } - - /* Append all disks to ldap */ - foreach($order as $cn=>$disk){ - $disk_dn = "cn=".$disk['cn'].",".$this->dn; - $disk_attrs['cn'] = $disk['cn']; - $disk_attrs['description'] = $disk['description']; - $disk_attrs['objectClass'] = array("top","FAIclass","FAIpartitionDisk"); - - if($disk['status'] == "delete"){ - $ldap->cd($disk_dn); - $ldap->rmdir_recursive($disk_dn); - }elseif($disk['status']== "edited"){ - $ldap->cd($disk_dn); - $ldap->modify($disk_attrs); - }elseif($disk['status']== "new"){ - $ldap->cd($disk_dn); - $ldap->create_missing_trees($disk_dn); - $ldap->cd($disk_dn); - $ldap->add($disk_attrs); - }else{ - print_red("unknown status while saving disks"); - } - - show_ldap_error($ldap->get_error()); - if($disk['status']!="delete") - /* Add all partitions */ - foreach($disk['partitions'] as $key => $partition){ - $partition_attrs = array(); - - foreach($this->base64_encode as $attrs){ - $partition[$attrs] = base64_encode($partition[$attrs]); - } - - foreach($partition as $key => $value){ - if(!empty($value)){ - $partition_attrs[$key]=$value; - }else{ - unset($partition_attrs[$key]); - } - } - - $partition_dn = "cn=".$partition_attrs['cn'].",".$disk_dn; - $partition_attrs['objectClass'] = array("top","FAIclass","FAIpartitionEntry"); - - unset($partition_attrs['status']); - unset($partition_attrs['old_cn']); - - if(($partition['status'] == "delete")&&($disk['status']!="new")){ - $ldap->cd($partition_dn); - $ldap->rmdir_recursive($partition_dn); - }elseif($partition['status'] == "new"){ - $ldap->cd($partition_dn); - $ldap->create_missing_trees($partition_dn); - $ldap->cd($partition_dn); - $ldap->add($partition_attrs); - }elseif($partition['status'] == "edited"){ - $ldap->cd($partition_dn); - $ldap->modify($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 deleted file mode 100644 index 878ffafe9..000000000 --- a/plugins/admin/FAI/class_faiPartitionTableEntry.inc +++ /dev/null @@ -1,450 +0,0 @@ - "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 = ""; - var $status = "new"; - var $deletePartitions = array(); - - function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false) - { - plugin::plugin ($config, $dn); - $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", - "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); - - /* Generate available disknames, to avoid duplicates in cn */ - $this->AvailableDiskNames = array(); - foreach(array("a","b","c","d","e","f","g","h") as $ts){ - if(!in_array("hd".$ts,$usedDiskNames)){ - $this->AvailableDiskNames["hd".$ts]= "hd".$ts; - } - } - - $this->AvailableDiskNames['disk1']= "disk1"; - $this->AvailableDiskNames['disk2']= "disk2"; - /* Default status is new */ - $this->status = "new"; - - /* We want to edit an entry */ - if($disk){ - - /* Set disk status */ - $this->status = $disk['status']; - - /* Walk through partitions */ - foreach($disk['partitions'] as $name => $values){ - - /* If a partition is already marked as delete, attach it to deletePartitions only. */ - if($values['status'] == "delete"){ - unset($disk['partitions'][$name]); - $this->deletePartitions[]=$values; - }else{ - - /* Set status, to know which partition must be deleted from ldap - new : Neu partition entry // save - edited : Update partition entry in ldap - deleted: Remove partition from ldap - */ - - /* If status is not new, set to edit mode. - * New means that this partition currently wasn't saved to ldap. - */ - if($disk['partitions'][$name]['status']!="new"){ - $disk['partitions'][$name]['status']="edited"; - } - - $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn']; - - /* Assign empty attributes, if attribute is missing */ - foreach($this->UsedAttrs as $attr){ - if(!isset($values[$attr])){ - $disk['partitions'][$name][$attr]=""; - } - } - } - } - - /* Set default attributes */ - $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"){ - if($this->partitions[$s_entry]['status'] == "edited"){ - $this->deletePartitions[]= $this->partitions[$s_entry]; - unset($this->partitions[$s_entry]); - }else{ - 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] = ""; - } - $tmp["old_cn"] = ""; - $tmp['status']="new"; - $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 = ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - - /* 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){ - if($part['status']!="delete"){ - /* Generate Partition select box - */ - $PartitionType = ""; - - - /* Generate fsType select box - */ - $FAIfsType= ""; - - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - $str .= ""; - if($part['FAIpartitionFlags']!=false){ - $str .= ""; - }else{ - $str .= ""; - } - $str .= ""; - $str .= ""; - } - } - $str.="
"._("Nr").""._("Name").""._("Description").""._("Type").""._("FS type").""._("Mount point").""._("Size in MB").""._("Mount options").""._("FS option").""._("Preserve")."
".($key)."".$PartitionType."".$FAIfsType."
"; - 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."); - } - - $str = utf8_encode("üöä"); - if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->DISK_description)){ - $message[]=_("Please enter a valid description."); - } - - /* check every partition. - * if there is an invalid value defined, append an errorstr to message - */ - - /* Array that contain every partitionname mountpoint etc already assigned */ - $alreadyUsed = array(); - foreach($this->UsedAttrs as $attrs){ - $alreadyUsed[$attrs] = array(); - } - - 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(in_array($part['cn'],$alreadyUsed['cn'])){ - $message[]=sprintf(_("please enter a unique name for partition %s"),($key)); - } - - if(in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint'])){ - $message[]=sprintf(_("please enter a unique mount point 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)); - } - - if($part['FAIfsType'] == "swap"){ - if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){ - $message[]=sprintf(_("File system type 'swap' is already used, change file system type 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)); - }elseif($this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key)){ - $message[]=$this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key); - } - foreach($this->UsedAttrs as $attrs){ - $alreadyUsed[$attrs][$key] = $part[$attrs]; - } - } - - - /* 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); - } - - - /* This function checks the selected partition sizes - * If a size setting overlap with another, it returns an error msg - */ - function checkSize($current,$others,$ckey){ - $tmp = split("-",$current); - $from = $tmp[0]; - $to = $tmp[1]; - foreach($others as $key=> $other){ - $tmp = split("-",$other); - $oth_from = $tmp[0]; - $oth_to = $tmp[1]; - /* surrounds another entry */ - if( (($from <= $oth_from)&&($to >= $oth_to))|| // inside - (($from >= $oth_from)&&($to <= $oth_to))|| // outside - (($to >= $oth_from)&&($to <= $oth_to)) || // overlap at right - (($from >= $oth_from)&&($from <= $oth_to)) ){ // overlap left - $message =sprintf( _("Size settings for partition %s, overlap with size settings for partition %s."),$ckey,$key); - return($message); - } - } - return(false); - } - - 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. - */ - - /* Check partition rename - */ - foreach($this->partitions as $key => $part){ - if($part['cn'] != $part['old_cn']){ - if($part['status'] == "edited"){ - - $tmp = $part; - $tmp['status']= "delete"; - $tmp['cn'] = $part['old_cn']; - - $this->deletePartitions[] = $tmp; - } - $this->partitions[$key]['old_cn']=$part['cn']; - $this->partitions[$key]['status']="new"; - } - } - - $tmp = array(); - $tmp['cn'] = $this->DISK_cn; - - /* Attach partitions */ - foreach($this->partitions as $key=>$val) { - $this->partitions[$key]['FAIpartitionNr']=$key; - } - - /* Attach deleted */ - foreach($this->deletePartitions as $key=>$val) { - $this->partitions[$key."-delete"]=$val; - $this->partitions[$key."-delete"]['status']="delete"; - } - - $tmp['description'] = $this->DISK_description; - $tmp['partitions'] = $this->partitions; - $tmp['status'] = $this->status; - - /* If hdd name has changed, tell partitionTable to rename it */ - if(($this->is_edit)&&($this->old_cn != $this->DISK_cn)){ - $tmp['rename']['from'] = $this->old_cn; - $tmp['rename']['to'] = $this->DISK_cn; - } - - return($tmp); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiProfile.inc b/plugins/admin/FAI/class_faiProfile.inc deleted file mode 100644 index 517b85240..000000000 --- a/plugins/admin/FAI/class_faiProfile.inc +++ /dev/null @@ -1,267 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description","FAIclass"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIprofile"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIscriptEntry"; - var $subClasses = array("top","FAIclass","FAIscriptEntry"); - - /* Specific attributes */ - var $old_cn = ""; - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - var $FAIclass = ""; // Classnames used for this profile - var $FAIclasses = array(); // Contains classname seperated in an array - var $FAIAllclasses = array(); // Contains all possible Classnames - - function faiProfile($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - $ldap=$this->config->get_ldap_link(); - - $tmp = split(" ",$this->FAIclass); - - foreach($tmp as $class){ - if(!empty($class)){ - $this->FAIclasses[trim($class)] = trim($class); - } - } - natcasesort($this->FAIclasses); - reset($this->FAIclasses) ; - - $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTAble","FAIpackage"); - - $sort = array(); - - $base = $_SESSION['faifilter']['base']; - $ldap->cd($base); - $ldap->search("(objectClass=*)",array("*")); - while($attrs = $ldap->fetch()){ - foreach($categories as $cat){ - if(in_array($cat,$attrs['objectClass'])){ - $this->FAIAllclasses[$attrs['cn'][0]][$cat]=$attrs; - $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; - } - } - } - ksort($sort); - foreach($sort as $name){ - $tmp[$name] =$this->FAIAllclasses[$name]; - } - $this->FAIAllclasses = array(); - $this->FAIAllclasses = $tmp; - - if($dn != "new"){ - $this->dn =$dn; - } - $this->old_cn = $this->cn; - } - - function execute() - { - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - $s_entry = ""; - $s_action = ""; - - /* Remove class name From list */ - foreach($_POST as $name => $post){ - if(preg_match("/DEL_/i",$name)){ - $s_action = "delete"; - $s_entry = preg_replace("/DEL_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); - }elseif(preg_match("/Add_class/i",$name)){ - $s_action = "add"; - } - } - - if($s_action == "delete"){ - unset($this->FAIclasses[$s_entry]); - } - - if($s_action == "add"){ - $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses); - $this->is_dialog =true; - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - $this->dialog->save_object(); - $msgs= $this->dialog->check(); - if(count($msgs)){ - print_red($msgs); - }else{ - $ret = $this->dialog->save(); - foreach($ret as $class){ - $this->FAIclasses[$class] =$class; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - } - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - - if(isset($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - $divlist =new divlist("Profile"); - $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); - $divlist->SetEntriesPerPage(10); - - $divlist->SetHeader(array(array("string"=>"Class name"), - array("string"=>"Objects","attach"=>"style='width:120px;'"), - array("string"=>"Options","attach"=>"style='border-right:none;width:60px;'"))); - $listhead = - "
". - " ". - "
"; - - $objTypes['FAIhook'] = ""; - $objTypes['FAItemplate'] = ""; - $objTypes['FAIscript'] = ""; - $objTypes['FAIvariable'] = ""; - $objTypes['FAIpackages'] = ""; - $objTypes['FAIpartitionTable'] = ""; - - $actions = ""; - - foreach($this->FAIclasses as $usedClass){ - $str = ""; - if(isset($this->FAIAllclasses[$usedClass])){ - foreach($this->FAIAllclasses[$usedClass] as $class => $obj){ - $str.= $objTypes[$class]; - } - } - - $field1 = array("string"=> $usedClass,"attach"=>""); - $field2 = array("string"=> $str,"attach"=>""); - $field3 = array("string"=> preg_replace("/%KEY%/",$usedClass,$actions),"attach"=>"style='border-right:none;'"); - $divlist->AddEntry(array($field1,$field2,$field3)); - } - - $smarty->assign("divlisthead" ,$listhead); - $smarty->assign("divlist" ,$divlist->DrawList()); - - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE)); - return($display); - } - - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - } - - /* 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(); - $str = utf8_encode("üöä"); - if((empty($this->description))){ - $message[] =_("Please specify a description for this profile."); - } - - if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - - if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){ - $message[]=_("Please enter a valid name. Only 0-9 a-Z are allowed here."); - } - - if(count($this->FAIclasses) == 0){ - $message[]=_("Please assign at least one class to this profile."); - } - - $ldap = $this->config->get_ldap_link(); - $ldap->cd($_SESSION['faifilter']['base']); - $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*")); - - if($ldap->count()){ - $message[]=_("There is already a profile with this class name defined."); - } - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $this->FAIclass = ""; - foreach($this->FAIclasses as $class){ - $this->FAIclass.=$class." "; - } - - $this->attrs['FAIclass']=trim($this->FAIclass); - - $ldap->cat($this->dn); - if($ldap->count()!=0){ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error()); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiProfileEntry.inc b/plugins/admin/FAI/class_faiProfileEntry.inc deleted file mode 100644 index b38614e3b..000000000 --- a/plugins/admin/FAI/class_faiProfileEntry.inc +++ /dev/null @@ -1,233 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array(); - var $objectclasses= array(); - - /* Array with available class names */ - var $FAIAllclasses = array(); - - function faiProfileEntry ($config, $dn= NULL,$used=array(),$objects=false) - { - plugin::plugin ($config, $dn); - - /* Search only in fai tree */ - $base = $_SESSION['faifilter']['base']; - - /* Create array with categories to be able to sort different types of objects */ - $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackage"); - - /* Read out all objects from fai tree */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($base); - $ldap->search("(| (objectClass=FAIscript)(objectClass=FAItemplate)(objectClass=FAIhook)(objectClass=FAIvariable) - (objectClass=FAIpartitionTable)(objectClass=FAIpackage))",array("*")); - while($attrs = $ldap->fetch()){ - - /* Only use objects which have cn set */ - if((isset($attrs['cn'][0]))&&(!in_array($attrs['cn'][0],$used))){ - foreach($categories as $cat){ - if(in_array($cat,$attrs['objectClass'])){ - - /* Append different types of objects */ - $this->FAIAllclasses[$attrs['cn'][0]]['objects'][$cat]=$cat; - - /* Set selected status to false */ - $this->FAIAllclasses[$attrs['cn'][0]]['status']=false; - - $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; - } - } - } - } - - ksort($sort); - foreach($sort as $name){ - $tmp[$name] =$this->FAIAllclasses[$name]; - } - $this->FAIAllclasses = array(); - $this->FAIAllclasses = $tmp; - - - /* If no search filter is set, create one */ - if (!is_global("SUBfaifilter")){ - $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$base, "Sregex" => "*"); - $SUBfaifilter['SShowTemplates'] = false; - $SUBfaifilter['SShowScripts'] = false; - $SUBfaifilter['SShowHooks'] = false; - $SUBfaifilter['SShowVariables'] = false; - $SUBfaifilter['SShowPackages'] = false; - $SUBfaifilter['SShowPartitions']= false; - register_global("SUBfaifilter", $SUBfaifilter); - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - $SUBfaifilter = $_SESSION['SUBfaifilter']; - - /* If someone used the apply button, update searchfilter */ - if(isset($_POST['Sregex'])){ - foreach($SUBfaifilter as $key => $val){ - if(!isset($_POST[$key])){ - $SUBfaifilter[$key] = false; - }else{ - $SUBfaifilter[$key] =$_POST[$key]; - } - } - $SUBfaifilter['Sregex']= $_POST['Sregex']; - if(!strstr($SUBfaifilter['Sregex'],"*")){ - $SUBfaifilter['Sregex'] = $SUBfaifilter['Sregex']."*"; - } - } - - /* Save current searchfilter in session*/ - $_SESSION['SUBfaifilter']= $SUBfaifilter; - - /* Check if we used a checkboxe from the list, to select dselect an entry */ - foreach($_POST as $name => $value){ - foreach($this->FAIAllclasses as $class => $obj){ - if(isset($_POST["ON_PAGE_".$class])){ - if(isset($_POST['USE_'.$class])){ - $this->FAIAllclasses[$class]['status']=true; - }else{ - $this->FAIAllclasses[$class]['status']=false; - } - } - } - } - - /* Create different picture for each object type */ - $objTypes['FAIhook'] = " "; - $objTypes['FAItemplate'] = " "; - $objTypes['FAIscript'] = " "; - $objTypes['FAIvariable'] = " "; - $objTypes['FAIpackages'] = " "; - $objTypes['FAIpartitionTable'] = " "; - - /* assign basic attributes */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - } - - /* Assign all filter attributes to smarty */ - foreach($SUBfaifilter as $key => $val){ - if(($key != "base")&&($key != "Sregex")){ - if($val){ - $smarty->assign($key."CHK", " checked "); - }else{ - $smarty->assign($key."CHK", ""); - } - }else{ - $smarty->assign($key,$val); - } - } - - /* Create a divlist to display all available class names with the depending object types */ - $divlist = new divlist("ProfileEntry"); - $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); - $divlist->SetEntriesPerPage(20); - $divlist->SetHeader(array(array("string"=>"Class name"), - array("string"=>"Objects"))); - - /* Action button allows us to delete an entry */ - $action = " - "; - - /* Check every single class name to match the current search filter */ - foreach($this->FAIAllclasses as $usedClass => $classes){ - - $fi = str_replace("*",".*",$SUBfaifilter['Sregex']); - - $abort = false; - if(!preg_match("/".$fi."/",$usedClass)){ - $abort = true; - } - if(($SUBfaifilter['SShowScripts'])&&(!in_array('FAIscript',$classes['objects']))){ - $abort = true; - } - if(($SUBfaifilter['SShowTemplates'])&&(!in_array('FAItemplate',$classes['objects']))){ - $abort = true; - } - if(($SUBfaifilter['SShowHooks'])&&(!in_array('FAIhook',$classes['objects']))){ - $abort = true; - } - if(($SUBfaifilter['SShowVariables'])&&(!in_array('FAIvariable',$classes['objects']))){ - $abort = true; - } - if(($SUBfaifilter['SShowPartitions'])&&(!in_array('FAIpartitionTable',$classes['objects']))){ - $abort = true; - } - if(($SUBfaifilter['SShowPackages'])&&(!in_array('FAIpackages',$classes['objects']))){ - $abort = true; - } - - if(!$abort){ - $str = ""; - foreach($classes['objects'] as $class => $obj){ - $str.= $objTypes[$obj]; - } - - /* Is this entry selected */ - if($classes['status']==true){ - $action_check = preg_replace("/%CHECK%/"," checked ",$action); - }else{ - $action_check = preg_replace("/%CHECK%/","",$action); - } - - /* Append to list */ - $field1 = array("string"=> preg_replace("/%KEY%/",$usedClass,$action_check).$usedClass,"attach"=>""); - $field2 = array("string"=> $str,"attach"=>""); - $divlist->AddEntry(array($field1,$field2)); - } - } - - $smarty->assign("faihead" , ""); - $smarty->assign("failist" , $divlist->DrawList()); - $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(TRUE)); - $smarty->assign("search_image" , get_template_path('images/search.png')); - - $display.= $smarty->fetch(get_template_path('faiProfileEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - } - - /* Check supplied data */ - function check() - { - $message= array(); - return ($message); - } - - function save() - { - $tmp = array(); - foreach($this->FAIAllclasses as $class => $obj){ - if($obj['status']==true){ - $tmp[$class]=$class; - } - } - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiScript.inc b/plugins/admin/FAI/class_faiScript.inc deleted file mode 100644 index 3ee246aca..000000000 --- a/plugins/admin/FAI/class_faiScript.inc +++ /dev/null @@ -1,281 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIscript"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIscriptEntry"; - var $subClasses = array("top","FAIclass","FAIscriptEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiScriptEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAIpriority","FAIscript"); - var $sub64coded = array("FAIscript"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - var $SubObjects = array(); // All leafobjects of this object - - function faiScript ($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); - - while($object = $ldap->fetch()){ - /* Set status for save management */ - - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; - } - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->is_dialog=true; - } - - /* Edit selected Sub Object */ - if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); - $this->is_dialog=true; - } - - /* Remove Sub object */ - if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ - if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ - $this->SubObjects[$_POST['SubObject']]['status']= "delete"; - }else{ - unset($this->SubObjects[$_POST['SubObject']]); - } - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - } - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - - /* Print dialog if $this->dialog is set */ - if($this->dialog){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - $smarty->assign("SubObjects",$this->getList()); - $smarty->assign("SubObjectKeys",array_flip($this->getList())); - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('faiScript.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - } - - - /* 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(); - $str = utf8_encode("üöä"); - if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $ldap->cat($this->dn); - if($ldap->count()!=0){ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error()); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode($obj[$codeIt]); - } - - $tmp = array(); - foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - $tmp[$attrs] = $obj[$attrs]; - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status'] == "delete"){ - $ldap->cd($sub_dn); - $ldap->rmdir_recursive($sub_dn); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - $ldap->cd($sub_dn); - $ldap->modify($tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - $ldap->cd($sub_dn); - $ldap->create_missing_trees($sub_dn); - $ldap->cd($sub_dn); - $ldap->add($tmp); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error()); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiScriptEntry.inc b/plugins/admin/FAI/class_faiScriptEntry.inc deleted file mode 100644 index 903230055..000000000 --- a/plugins/admin/FAI/class_faiScriptEntry.inc +++ /dev/null @@ -1,135 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("Object_cn","Object_description","Object_FAIpriority","Object_FAIscript"); - var $objectclasses= array(); - - var $orig_cn = ""; - - var $Object_dn = ""; - var $Object_cn = ""; - var $Object_FAIpriority = ""; - var $Object_FAIscript = ""; - var $Object_description = ""; - var $Object_status = "new"; - - function faiScriptEntry ($config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if($dn != "new"){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = "Object_".$name; - $this->$oname=$value; - } - }else{ - $this->Object_status = "new"; - $this->orig_cn = false; - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - if(isset($_POST['ImportUpload'])){ - if(($_FILES['ImportFile']['error']!=0)){ - print_red(_("Please select a valid file.")); - }else - if(($_FILES['ImportFile']['size']==0)){ - print_red(_("Selected file is empty.")); - }else{ - $str = file_get_contents($_FILES['ImportFile']['tmp_name']); - $this->Object_FAIscript = $str; - } - } - - - - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - } - - for($i =1 ; $i <= 100 ; $i++){ - $Object_FAIprioritys[$i]=$i; - } - $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); - $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if(isset($_POST['SubObjectFormSubmitted'])){ - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - - /* Check supplied data */ - function check() - { - $message= array(); - - $str = utf8_encode("üöä"); - - if(empty($this->Object_FAIscript)){ - $message[]=_("Please specify a script."); - } - - if(empty($this->Object_description)){ - $message[] = _("Please enter a description."); - } - - if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ - $message[] = _("Invalid character in description. Please enter a valid description."); - } - - if(empty($this->Object_cn)){ - $message[] = _("Please enter a name."); - } - - if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ - $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $attr = preg_replace("/^Object_/","",$attrs); - $tmp[$attr] = $this->$attrs; - } - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->Object_status; - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiTemplate.inc b/plugins/admin/FAI/class_faiTemplate.inc deleted file mode 100644 index 2c4377543..000000000 --- a/plugins/admin/FAI/class_faiTemplate.inc +++ /dev/null @@ -1,279 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAItemplate"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAItemplateEntry"; - var $subClasses = array("top","FAIclass","FAItemplateEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiTemplateEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAItemplateFile","FAItemplatePath"); - var $sub64coded = array("FAItemplateFile","FAItemplatePath"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - var $SubObjects = array(); // All leafobjects of this object - - function faiTemplate ($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); - - while($object = $ldap->fetch()){ - /* Set status for save management */ - - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; - } - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->is_dialog=true; - } - - /* Edit selected Sub Object */ - if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); - $this->is_dialog=true; - } - - /* Remove Sub object */ - if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ - if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ - $this->SubObjects[$_POST['SubObject']]['status']= "delete"; - }else{ - unset($this->SubObjects[$_POST['SubObject']]); - } - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - } - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - - /* Print dialog if $this->dialog is set */ - if($this->dialog){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - $smarty->assign("SubObjects",$this->getList()); - $smarty->assign("SubObjectKeys",array_flip($this->getList())); - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('faiTemplate.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - } - - - /* 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(); - $str = utf8_encode("üöä"); - if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $ldap->cat($this->dn); - if($ldap->count()!=0){ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error()); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode($obj[$codeIt]); - } - $tmp = array(); - foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - $tmp[$attrs] = $obj[$attrs]; - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status'] == "delete"){ - $ldap->cd($sub_dn); - $ldap->rmdir_recursive($sub_dn); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - $ldap->cd($sub_dn); - $ldap->modify($tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - $ldap->cd($sub_dn); - $ldap->create_missing_trees($sub_dn); - $ldap->cd($sub_dn); - $ldap->add($tmp); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error()); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiTemplateEntry.inc b/plugins/admin/FAI/class_faiTemplateEntry.inc deleted file mode 100644 index 24d8d821b..000000000 --- a/plugins/admin/FAI/class_faiTemplateEntry.inc +++ /dev/null @@ -1,124 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("Object_cn","Object_description","Object_FAItemplateFile","Object_FAItemplatePath"); - var $objectclasses= array(); - - var $orig_cn = ""; - - var $Object_dn = ""; - var $Object_cn = ""; - var $Object_FAItemplateFile = ""; - var $Object_FAItemplatePath = ""; - var $Object_description = ""; - var $Object_status = "new"; - - function faiTemplateEntry ($config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if($dn != "new"){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = "Object_".$name; - $this->$oname=$value; - } - }else{ - $this->Object_status = "new"; - $this->orig_cn = false; - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - } - - for($i =1 ; $i <= 100 ; $i++){ - $Object_FAIprioritys[$i]=$i; - } - $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); - $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if(isset($_POST['SubObjectFormSubmitted'])){ - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - - /* Check supplied data */ - function check() - { - $message= array(); - if(empty($this->Object_FAItemplateFile)){ - $message[]=_("Please specify a value for attribute 'file'."); - } - - if(empty($this->Object_FAItemplatePath)){ - $message[]=_("Please specify a value for attribute 'path'."); - } - - $str = utf8_encode("üöä"); - - if(empty($this->Object_description)){ - $message[] = _("Please enter a description."); - } - - if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ - $message[] = _("Invalid character in description. Please enter a valid description."); - } - - if(empty($this->Object_cn)){ - $message[] = _("Please enter a name."); - } - - if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ - $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); - } - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $attr = preg_replace("/^Object_/","",$attrs); - $tmp[$attr] = $this->$attrs; - } - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->Object_status; - - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiVariable.inc b/plugins/admin/FAI/class_faiVariable.inc deleted file mode 100644 index 606f18c3e..000000000 --- a/plugins/admin/FAI/class_faiVariable.inc +++ /dev/null @@ -1,281 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account = TRUE; - - /* Attributes for this Object */ - var $attributes = array("cn","description"); - - /* ObjectClasses for this Object*/ - var $objectclasses = array("top","FAIclass","FAIvariable"); - - /* Class name of the Ldap ObjectClass for the Sub Object */ - var $subClass = "FAIvariableEntry"; - var $subClasses = array("top","FAIclass","FAIvariableEntry"); - - /* Class name of the php class which allows us to edit a Sub Object */ - var $subClassName = "faiVariableEntry"; - - /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAIvariableContent"); - var $sub64coded = array("FAIvariableContent"); - - /* Specific attributes */ - var $cn = ""; // The class name for this object - var $description = ""; // The description for this set of partitions - var $is_dialog = false; // specifies which buttons will be shown to save or abort - var $dialog = NULL; // a dialog, e.g. new disk dialog - var $SubObjects = array(); // All leafobjects of this object - - function faiVariable ($config, $dn= NULL) - { - /* Load Attributes */ - plugin::plugin ($config, $dn); - - /* If "dn==new" we try to create a new entry - * Else we must read all objects from ldap which belong to this entry. - * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. - */ - if($dn != "new"){ - $this->dn =$dn; - - /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) - */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); - - while($object = $ldap->fetch()){ - /* Set status for save management */ - - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; - } - } - - foreach($this->sub64coded as $codeIt){ - $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); - } - - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; - } - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty= get_smarty(); - $display= ""; - - /* Add new sub object */ - if(isset($_POST['AddSubObject'])){ - $this->dialog= new $this->subClassName($this->config,"new"); - $this->is_dialog=true; - } - - /* Edit selected Sub Object */ - if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); - $this->is_dialog=true; - } - - /* Remove Sub object */ - if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ - if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ - $this->SubObjects[$_POST['SubObject']]['status']= "delete"; - }else{ - unset($this->SubObjects[$_POST['SubObject']]); - } - } - - /* Save Dialog */ - if(isset($_POST['SaveSubObject'])){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)>0){ - foreach($msgs as $msg){ - print_red($msg); - } - }else{ - $obj = $this->dialog->save(); - if(isset($obj['remove'])){ - if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ - $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ - unset($this->SubObjects[$obj['remove']['from']]); - } - $obj['status'] = "new"; - $this->SubObjects[$obj['remove']['to']] = $obj; - unset($this->SubObjects[$obj['remove']['to']]['remove']); - }else{ - $this->SubObjects[$obj['cn']]=$obj; - } - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - } - - /* Cancel Dialog */ - if(isset($_POST['CancelSubObject'])){ - $this->is_dialog=false; - unset($this->dialog); - $this->dialog=NULL; - } - - /* Print dialog if $this->dialog is set */ - if($this->dialog){ - $this->dialog->save_object(); - $display = $this->dialog->execute(); - return($display); - } - - $smarty->assign("SubObjects",$this->getList()); - $smarty->assign("SubObjectKeys",array_flip($this->getList())); - /* Assign variables */ - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,$this->$attrs); - } - - $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE)); - return($display); - } - - /* Generate listbox friendly SubObject list - */ - function getList(){ - $a_return=array(); - foreach($this->SubObjects as $obj){ - if($obj['status'] != "delete"){ - $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; - } - } - return($a_return); - } - - /* Delete me, and all my subtrees - */ - function remove_from_parent() - { - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->dn); - $ldap->rmdir_recursive($this->dn); - $this->handle_post_events("remove"); - } - - - /* 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(); - $str = utf8_encode("üöä"); - if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ - $message[]=_("Please enter a valid description."); - } - return ($message); - } - - - /* Save to LDAP */ - function save() - { - plugin::save(); - - $ldap = $this->config->get_ldap_link(); - - $ldap->cat($this->dn); - if($ldap->count()!=0){ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - /* Write FAIscript to ldap*/ - $ldap->cd($this->dn); - $ldap->create_missing_trees($this->dn); - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error()); - - /* Prepare FAIscriptEntry to write it to ldap - * First sort array. - * Because we must delete old entries first. - * After deletion, we perform add and modify - */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - - foreach($Objects as $name => $obj){ - - foreach($this->sub64coded as $codeIt){ - $obj[$codeIt]=base64_encode($obj[$codeIt]); - } - - $tmp = array(); - foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ - $obj[$attrs] = array(); - } - $tmp[$attrs] = $obj[$attrs]; - } - - $tmp['objectClass'] = $this->subClasses; - - $sub_dn = "cn=".$obj['cn'].",".$this->dn; - - if($obj['status'] == "delete"){ - $ldap->cd($sub_dn); - $ldap->rmdir_recursive($sub_dn); - $this->handle_post_events("remove"); - }elseif($obj['status'] == "edited"){ - $ldap->cd($sub_dn); - $ldap->modify($tmp); - $this->handle_post_events("modify"); - }elseif($obj['status']=="new"){ - $ldap->cd($sub_dn); - $ldap->create_missing_trees($sub_dn); - $ldap->cd($sub_dn); - $ldap->add($tmp); - $this->handle_post_events("add"); - } - show_ldap_error($ldap->get_error()); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/class_faiVariableEntry.inc b/plugins/admin/FAI/class_faiVariableEntry.inc deleted file mode 100644 index 3f993cb90..000000000 --- a/plugins/admin/FAI/class_faiVariableEntry.inc +++ /dev/null @@ -1,118 +0,0 @@ - "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - /* attribute list for save action */ - var $ignore_account= TRUE; - var $attributes = array("Object_cn","Object_description","Object_FAIvariableContent"); - var $objectclasses= array(); - - var $orig_cn = ""; - var $Object_dn = ""; - var $Object_cn = ""; - var $Object_FAIvariableContent = ""; - var $Object_description = ""; - var $Object_status = "new"; - - function faiVariableEntry ($config, $dn= NULL,$object=false) - { - plugin::plugin ($config, $dn); - if($dn != "new"){ - $this->orig_cn= $object['cn']; - $this->dn=$object['dn']; - foreach($object as $name=>$value){ - $oname = "Object_".$name; - $this->$oname=$value; - } - }else{ - $this->Object_status = "new"; - $this->orig_cn = false; - } - } - - function execute() - { - /* Fill templating stuff */ - $smarty = get_smarty(); - $display = ""; - - foreach($this->attributes as $attrs){ - $smarty->assign($attrs,stripslashes($this->$attrs)); - } - - for($i =1 ; $i <= 100 ; $i++){ - $Object_FAIprioritys[$i]=$i; - } - $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); - $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE)); - return($display); - } - - /* Save data to object */ - function save_object() - { - if(isset($_POST['SubObjectFormSubmitted'])){ - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - }else{ - $this->$attrs = ""; - } - } - } - } - - /* Check supplied data */ - function check() - { - $message= array(); - - $str = utf8_encode("üöä"); - if(empty($this->Object_FAIvariableContent)) { - $message[]=_("Please specify a value for the attribute 'content'."); - } - - if(empty($this->Object_description)){ - $message[] = _("Please enter a description."); - } - - if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ - $message[] = _("Invalid character in description. Please enter a valid description."); - } - - if(empty($this->Object_cn)){ - $message[] = _("Please enter a name."); - } - - if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ - $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); - } - - return ($message); - } - - function save() - { - $tmp=array(); - foreach($this->attributes as $attrs){ - $attr = preg_replace("/^Object_/","",$attrs); - $tmp[$attr] = $this->$attrs; - } - - if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ - $tmp['remove']['from'] = $this->orig_cn; - $tmp['remove']['to'] = $tmp['cn']; - } - - $tmp['dn'] = $this->dn; - $tmp['status'] = $this->Object_status; - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/plugins/admin/FAI/faiHook.tpl b/plugins/admin/FAI/faiHook.tpl deleted file mode 100644 index 0a3d8e6aa..000000000 --- a/plugins/admin/FAI/faiHook.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
-   - -

  - -


- - - - -
-
- - - -
-
diff --git a/plugins/admin/FAI/faiHookEntry.tpl b/plugins/admin/FAI/faiHookEntry.tpl deleted file mode 100644 index 2dd86e4fc..000000000 --- a/plugins/admin/FAI/faiHookEntry.tpl +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t} {$must} - - -
- {t}Description{/t} {$must} - - -
-
-   - -

 {t}Hook attributes{/t}

- - - - - - - - - -
- - - -
- - - -
-
-

 

-
-
-   - -
- diff --git a/plugins/admin/FAI/faiPackage.tpl b/plugins/admin/FAI/faiPackage.tpl deleted file mode 100644 index d72310d6d..000000000 --- a/plugins/admin/FAI/faiPackage.tpl +++ /dev/null @@ -1,29 +0,0 @@ - - - - -
-

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
diff --git a/plugins/admin/FAI/faiPartitionTable.tpl b/plugins/admin/FAI/faiPartitionTable.tpl deleted file mode 100644 index 6d3f6229a..000000000 --- a/plugins/admin/FAI/faiPartitionTable.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
-   - -

  - -


- - - - -
-
- - - -
-
diff --git a/plugins/admin/FAI/faiPartitionTableEntry.tpl b/plugins/admin/FAI/faiPartitionTableEntry.tpl deleted file mode 100644 index 776905dae..000000000 --- a/plugins/admin/FAI/faiPartitionTableEntry.tpl +++ /dev/null @@ -1,40 +0,0 @@ - -
-

 {t}Generic{/t}

- - - - - - - - - -
 {$must} - - -
 {$must} - - -
-
-

 

-
-

 {t}Partition entries{/t}

-{$setup} -
- -
-
-

 

-
-
- - -
diff --git a/plugins/admin/FAI/faiProfile.tpl b/plugins/admin/FAI/faiProfile.tpl deleted file mode 100644 index 11185d262..000000000 --- a/plugins/admin/FAI/faiProfile.tpl +++ /dev/null @@ -1,46 +0,0 @@ -

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
- - - - - -
-
-

- -

-
-
- - {$divlisthead} -
-
-
-
- {$divlist} - -
-
diff --git a/plugins/admin/FAI/faiProfileEntry.tpl b/plugins/admin/FAI/faiProfileEntry.tpl deleted file mode 100644 index b49352384..000000000 --- a/plugins/admin/FAI/faiProfileEntry.tpl +++ /dev/null @@ -1,69 +0,0 @@ - - - - - -
-
-

- {t}List of FAI objects (Fully Automatic Installation){/t} -

-
-
- {$faihead} -
-
-
- {$failist} - -
-
-
-

[i]{t}Information{/t}

-
-
-

- {t}This menu allows you to select FAI class names and to add them to the currently edited profile.{/t} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - - - -
{t}Show only classes with templates{/t}
{t}Show only classes with scripts{/t}
{t}Show only classes with hooks{/t}
{t}Show only classes with variables{/t}
{t}Show only classes with packages{/t}
{t}Show only classes with partitions{/t}
- - - - - -
- - - -
- {$apply} -
-
-
- - -
- diff --git a/plugins/admin/FAI/faiScript.tpl b/plugins/admin/FAI/faiScript.tpl deleted file mode 100644 index 0d405a102..000000000 --- a/plugins/admin/FAI/faiScript.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
-   - -

  - -


- - - - -
-
- - - -
-
diff --git a/plugins/admin/FAI/faiScriptEntry.tpl b/plugins/admin/FAI/faiScriptEntry.tpl deleted file mode 100644 index e5d7a7018..000000000 --- a/plugins/admin/FAI/faiScriptEntry.tpl +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t} {$must} - - -
- {t}Description{/t} {$must} - - -
-
-   - -

 {t}Script attributes{/t}

- - - - - -
- - - -
-
-

 

-

  - -

-
- {t}Import script{/t}   -   - -
-
- - - - -
- -
- -
-
-   - -
- diff --git a/plugins/admin/FAI/faiTemplate.tpl b/plugins/admin/FAI/faiTemplate.tpl deleted file mode 100644 index e310be27c..000000000 --- a/plugins/admin/FAI/faiTemplate.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
-   - -

  - -


- - - - -
-
- - - -
-
diff --git a/plugins/admin/FAI/faiTemplateEntry.tpl b/plugins/admin/FAI/faiTemplateEntry.tpl deleted file mode 100644 index 44c3bf8cd..000000000 --- a/plugins/admin/FAI/faiTemplateEntry.tpl +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t} {$must} - - -
- {t}Description{/t} {$must} - - -
-
-   - -

 {t}Template attributes{/t}

- - - - - - - - - -
- - - -
- - - -
-
-

 

-
-
-   - -
- diff --git a/plugins/admin/FAI/faiVariable.tpl b/plugins/admin/FAI/faiVariable.tpl deleted file mode 100644 index cc3871e7d..000000000 --- a/plugins/admin/FAI/faiVariable.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -
-

 {t}Generic{/t}


- - - - - - - - - -
- - - -
- - - -
-
-   - -

  - -


- - - - -
-
- - - -
-
diff --git a/plugins/admin/FAI/faiVariableEntry.tpl b/plugins/admin/FAI/faiVariableEntry.tpl deleted file mode 100644 index 131e7d1a3..000000000 --- a/plugins/admin/FAI/faiVariableEntry.tpl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - -
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t} {$must} - - -
- {t}Description{/t} {$must} - - -
-
-   - -

 {t}Variable attributes{/t}

- - - - - -
- - - -
-
-

 

-
-
-   - -
- diff --git a/plugins/admin/FAI/headpage.tpl b/plugins/admin/FAI/headpage.tpl deleted file mode 100644 index 2a4714c95..000000000 --- a/plugins/admin/FAI/headpage.tpl +++ /dev/null @@ -1,61 +0,0 @@ - - - - - -
-
-

- {t}List of FAI objects (Fully Automatic Installation){/t} -

-
-
- {$faihead} -
-
-
- {$failist} - -
-
-
-

[i]{t}Information{/t}

-
-
-

- {t}This menu allows you to create, delete and edit FAI objects.{/t} -

-
-
-
-

[F]{t}Filters{/t}

-
-
- - {$alphabet} -
- - - - - - - - -
{t}Show profiles{/t}
{t}Show templates{/t}
{t}Show scripts{/t}
{t}Show hooks{/t}
{t}Show variables{/t}
{t}Show packages{/t}
{t}Show partitions{/t}
- - - - - -
- - - -
- {$apply} -
-
- - diff --git a/plugins/admin/FAI/main.inc b/plugins/admin/FAI/main.inc deleted file mode 100644 index 36d3c5021..000000000 --- a/plugins/admin/FAI/main.inc +++ /dev/null @@ -1,55 +0,0 @@ -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/fai.png'), _("FAI management"), "\"\" ".$_SESSION['objectinfo']); - } else { - $display= print_header(get_template_path('images/fai.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/remove.tpl b/plugins/admin/FAI/remove.tpl deleted file mode 100644 index 2d1deeec4..000000000 --- a/plugins/admin/FAI/remove.tpl +++ /dev/null @@ -1,18 +0,0 @@ -
- {t}Warning{/t} -
- -

- {$warning} - {t}This includes all object informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press Delete to continue or Cancel to abort.{/t} -

- -

- -   - -

diff --git a/plugins/admin/FAI/tabsHook.inc b/plugins/admin/FAI/tabsHook.inc deleted file mode 100644 index f438f8236..000000000 --- a/plugins/admin/FAI/tabsHook.inc +++ /dev/null @@ -1,42 +0,0 @@ -by_object['faiHook']; - - $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); - } - -} - -?> diff --git a/plugins/admin/FAI/tabsPackage.inc b/plugins/admin/FAI/tabsPackage.inc deleted file mode 100644 index fdb1cb505..000000000 --- a/plugins/admin/FAI/tabsPackage.inc +++ /dev/null @@ -1,42 +0,0 @@ -by_object['faiPackage']; - - $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); - } - -} - -?> diff --git a/plugins/admin/FAI/tabsPartition.inc b/plugins/admin/FAI/tabsPartition.inc deleted file mode 100644 index d61396d67..000000000 --- a/plugins/admin/FAI/tabsPartition.inc +++ /dev/null @@ -1,45 +0,0 @@ -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); - } - -} - -?> diff --git a/plugins/admin/FAI/tabsProfile.inc b/plugins/admin/FAI/tabsProfile.inc deleted file mode 100644 index 97dcdb073..000000000 --- a/plugins/admin/FAI/tabsProfile.inc +++ /dev/null @@ -1,42 +0,0 @@ -by_object['faiProfile']; - - $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); - } - -} - -?> diff --git a/plugins/admin/FAI/tabsScript.inc b/plugins/admin/FAI/tabsScript.inc deleted file mode 100644 index cb6dcf302..000000000 --- a/plugins/admin/FAI/tabsScript.inc +++ /dev/null @@ -1,42 +0,0 @@ -by_object['faiScript']; - - $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); - } - -} - -?> diff --git a/plugins/admin/FAI/tabsTemplate.inc b/plugins/admin/FAI/tabsTemplate.inc deleted file mode 100644 index ada68ce91..000000000 --- a/plugins/admin/FAI/tabsTemplate.inc +++ /dev/null @@ -1,42 +0,0 @@ -by_object['faiTemplate']; - - $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); - } - -} - -?> diff --git a/plugins/admin/FAI/tabsVariable.inc b/plugins/admin/FAI/tabsVariable.inc deleted file mode 100644 index 86a8851f0..000000000 --- a/plugins/admin/FAI/tabsVariable.inc +++ /dev/null @@ -1,42 +0,0 @@ -by_object['faiVariable']; - - $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); - } - -} - -?> diff --git a/plugins/admin/fai/askClassName.tpl b/plugins/admin/fai/askClassName.tpl new file mode 100644 index 000000000..b73f9624e --- /dev/null +++ b/plugins/admin/fai/askClassName.tpl @@ -0,0 +1,48 @@ +
+ {$headline} +

+
+ {t}Please select a class name for this object. The class name specifies a set of configurations.{/t} +
+ {t}Every Class name must be unique. But it can be used for different objects at the same time.
If you use this class name in a profile, all object with this class name will be included to this profile.{/t} +
+
+ {t}The list box below shows all available class names you may use, for this object, to avoid duplicates.{/t} +
+
+ + + + + + + + + + + + + + + + + + +
+ {t}You can select of one the following class names for this object.{/t} +
{t}Available class names.{/t} + + + +

+
+ {t}Please enter your class name here, if want to create a new class.{/t} +
{t}A new class name.{/t} + + + +
+

 

+ diff --git a/plugins/admin/fai/class_askClassName.inc b/plugins/admin/fai/class_askClassName.inc new file mode 100644 index 000000000..a2b380e16 --- /dev/null +++ b/plugins/admin/fai/class_askClassName.inc @@ -0,0 +1,149 @@ + "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 name */ + 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 bundle.");break; + case "FAIscript" : $str =_("Create new FAI object - script bundle.");break; + case "FAIvariable" : $str =_("Create new FAI object - variable bundle.");break; + case "FAIhook" : $str =_("Create new FAI object - hook bundle.");break; + case "FAIprofile" : $str =_("Create new FAI object - profile.");break; + case "FAItemplate" : $str =_("Create new FAI object - template.");break; + default : $str =_("Create new 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 for this type + * of objectClass, we only can create a new one, 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 + */ + 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."); + } + + if(preg_match("/[^a-z0-9]/i",$this->ClassName)){ + $message[]=_("Please enter a valid class name. Only 0-9 a-z is allowed here."); + } + + 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_faiHook.inc b/plugins/admin/fai/class_faiHook.inc new file mode 100644 index 000000000..c7edf194c --- /dev/null +++ b/plugins/admin/fai/class_faiHook.inc @@ -0,0 +1,291 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIhook"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIhookEntry"; + var $subClasses = array("top","FAIclass","FAIhookEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiHookEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAItask","FAIscript"); + var $sub64coded = array("FAItask","FAIscript"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $SubObjects = array(); // All leafobjects of this object + + function faiHook ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); + + while($object = $ldap->fetch()){ + /* Set status for save management */ + + foreach($this->subAttributes as $attrs){ + if(!isset($object[$attrs][0])){ + $this->SubObjects[$object['cn'][0]][$attrs]=""; + }else{ + $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; + } + } + + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; + $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + + foreach($this->sub64coded as $codeIt){ + $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); + } + + } + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->is_dialog=true; + } + + /* Edit selected Sub Object */ + if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); + $this->is_dialog=true; + } + + /* Remove Sub object */ + if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ + if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ + $this->SubObjects[$_POST['SubObject']]['status']= "delete"; + }else{ + unset($this->SubObjects[$_POST['SubObject']]); + } + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + + /* Perform post check*/ + $this->dialog->save_object(); + + /* Get messages */ + $msgs = $this->dialog->check(); + + /* print errors */ + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + + /* Get return object */ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + + /* Depending on status, set new status */ + if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + } + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + + /* Print dialog if $this->dialog is set */ + if($this->dialog){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + $smarty->assign("SubObjects",$this->getList()); + $smarty->assign("SubObjectKeys",array_flip($this->getList())); + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiHook.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + + /* 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(); + $str = utf8_encode("üöä"); + if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\-.,;:_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode($obj[$codeIt]); + } + + $tmp = array(); + foreach($this->subAttributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + $tmp[$attrs] = $obj[$attrs]; + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status'] == "delete"){ + $ldap->cd($sub_dn); + $ldap->rmdir_recursive($sub_dn); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + $ldap->cd($sub_dn); + $ldap->modify($tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + $ldap->cd($sub_dn); + $ldap->create_missing_trees($sub_dn); + $ldap->cd($sub_dn); + $ldap->add($tmp); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error()); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiHookEntry.inc b/plugins/admin/fai/class_faiHookEntry.inc new file mode 100644 index 000000000..a73c49382 --- /dev/null +++ b/plugins/admin/fai/class_faiHookEntry.inc @@ -0,0 +1,123 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("Object_cn","Object_description","Object_FAIscript","Object_FAItask"); + var $objectclasses= array(); + + var $orig_cn = ""; + + var $Object_dn = ""; + var $Object_cn = ""; + var $Object_FAItask = ""; + var $Object_FAIscript = ""; + var $Object_description = ""; + var $Object_status = "new"; + + function faiHookEntry ($config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if($dn != "new"){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = "Object_".$name; + $this->$oname=$value; + } + }else{ + $this->Object_status = "new"; + $this->orig_cn = false; + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + } + + for($i =1 ; $i <= 100 ; $i++){ + $Object_FAIprioritys[$i]=$i; + } + $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); + $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if(isset($_POST['SubObjectFormSubmitted'])){ + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + + /* Check supplied data */ + function check() + { + $message= array(); + if(empty($this->Object_FAItask)) { + $message[]=_("Please enter a value for task."); + } + if(empty($this->Object_FAIscript)) { + $message[]=_("Please enter a value for script."); + } + + $str = utf8_encode("üöä"); + + if(empty($this->Object_description)){ + $message[] = _("Please enter a description."); + } + + if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ + $message[] = _("Invalid character in description. Please enter a valid description."); + } + + if(empty($this->Object_cn)){ + $message[] = _("Please enter a name."); + } + + if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ + $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $attr = preg_replace("/^Object_/","",$attrs); + $tmp[$attr] = $this->$attrs; + } + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->Object_status; + return($tmp); + } +} +// 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 new file mode 100644 index 000000000..7ec7329f6 --- /dev/null +++ b/plugins/admin/fai/class_faiManagement.inc @@ -0,0 +1,600 @@ + "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) + { + $this->ui = $ui; + + /* Set current dn to "", */ + $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("/create_script/i",$key)){ + $s_action = "new_script"; + }elseif(preg_match("/create_hook/i",$key)){ + $s_action = "new_hook"; + }elseif(preg_match("/create_variable/i",$key)){ + $s_action = "new_variable"; + }elseif(preg_match("/create_template/i",$key)){ + $s_action = "new_template"; + }elseif(preg_match("/create_package/i",$key)){ + $s_action = "new_package"; + }elseif(preg_match("/create_profile/i",$key)){ + $s_action = "new_profile"; + }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"; + }elseif(preg_match("/^entry_delete_.*/",$key)){ + $s_entry = preg_replace("/^entry_delete_/","",$key); + $s_entry = preg_replace("/_.*$/","",$s_entry); + $s_action = "delete"; + } + + } + + /* Confirm dialog + * Delte object + */ + if ($s_action=="delete"){ + + /* Get 'dn' from posted termlinst */ + $this->dn= $this->objects[$s_entry]['dn']; + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl= get_permissions ($this->dn, $this->ui->subtreeACL); + $this->acl= get_module_permission($acl, "FAIclass", $this->dn); + if (chkacl($this->acl, "delete") == ""){ + + /* 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->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), $this->dn)); + 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 component!")); + } + } + + /* Deltetion was confirmed, so delete this entry + */ + if (isset($_POST['delete_terminal_confirm'])){ + + /* Some nice guy may send this as POST, so we've to check + for the permissions again. */ + if (chkacl($this->acl, "delete") == ""){ + + /* Find out more about the object type */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat($this->dn); + $attrs = $ldap->fetch(); + + $type = $this->get_type($attrs); + + $this->dialog= new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn); + $this->dialog->set_acl(array($this->acl)); + + $this->dialog->by_object[$type[1]]->remove_from_parent (); + unset ($this->dialog); + gosa_log ("System object'".$this->dn."' has been removed"); + $this->dialog= NULL; + + /* Terminal list has changed, reload it. */ + $this->reload (); + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this component!")); + gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ". + "deletion."); + } + + /* Remove lock file after successfull deletion */ + del_lock ($this->dn); + } + + /* Edit Entry */ + if($s_action == "edit"){ + $entry = $this->objects[$s_entry]; + + $a_setup = ($this->get_type($entry)); + + $this->dn = $entry['dn']; + + $this->dialog= new $a_setup[0]($this->config, + $this->config->data['TABS'][$a_setup[2]],$this->dn); + $this->is_dialog = true; + } + + + /* Dialog handling */ + if($s_action == "new_partition"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable"); + } + + /* Dialog handling */ + if($s_action == "new_script"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript"); + } + + /* Dialog handling */ + if($s_action == "new_hook"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook"); + } + + /* Dialog handling */ + if($s_action == "new_variable"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable"); + } + + /* Dialog handling */ + if($s_action == "new_template"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate"); + } + + /* Dialog handling */ + if($s_action == "new_package"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList"); + } + + /* New Profile */ + if($s_action == "new_profile"){ + $this->dn = "new" ; + $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile"))); + + $this->dialog = new $a_setup[0]($this->config, + $this->config->data['TABS'][$a_setup[2]],$this->dn); + $this->is_dialog = true; + + } + + 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" ; + $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass))); + $name = $this->dialog->save(); + + $this->dialog = new $a_setup[0]($this->config, + $this->config->data['TABS'][$a_setup[2]],$this->dn); + $this->dialog->by_object[$a_setup[1]]->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; + + /* 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.= "

\n"; + $display.= "\n"; + $display.= " \n"; + $display.= "\n"; + $display.= "

"; + }elseif(!isset($this->dialog->current)){ + $display.= "

\n"; + $display.= "\n"; + $display.= "

"; + } + 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 = + "
 ". + + "  ". + + "  ". + + "  ". + + "  ". + + "  ". + + "  ". + + "\"\" ". + + "  ". + + "
"; + + $this->reload(); + + /* 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 group")), + array("string" => _("Options"), "attach" => "style='border:none'" ))); + + + $action = ""; + $action .= ""; + + /* 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="PT"; + $info = _("Partition table"); + break; + case "FAIpackageList" : + if(!$faifilter['ShowPackages']){ + $abort = true; + } + $img="PL"; + $info = _("Package list"); + break; + case "FAIscript" : + if(!$faifilter['ShowScripts']){ + $abort = true; + } + $img="S"; + $info = _("Script set"); + break; + case "FAIvariable" : + if(!$faifilter['ShowVariables']){ + $abort = true; + } + $img="V"; + $info = _("Variable set"); + break; + case "FAIhook" : + if(!$faifilter['ShowHooks']){ + $abort = true; + } + $img="H"; + $info = _("Hook set"); + break; + case "FAIprofile" : + if(!$faifilter['ShowProfiles']){ + $abort = true; + } + $img="P"; + $info = _("Profile")." (".$value['FAIclass']." )"; + break; + case "FAItemplate" : + if(!$faifilter['ShowTemplates']){ + $abort = true; + } + $img="T"; + $info = _("Template"); + break; + default : + $img="";$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" => preg_replace("/%KEY%/",$key,$action) , "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(); + + $this->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[strtolower($obj['cn']).$obj['cn'].$type] = $obj; + $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; + + } + } + ksort($this->objects); + reset ($this->objects); + } + + function remove_lock() + { + if (isset($this->dn)){ + del_lock ($this->dn); + } + } + + function get_type($array){ + if(in_array("FAIpartitionTable",$array['objectClass'])){ + return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS")); + } + if(in_array("FAIscript",$array['objectClass'])){ + return(array("tabsScript","faiScript","FAISCRIPTTABS")); + } + if(in_array("FAItemplate",$array['objectClass'])){ + return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS")); + } + if(in_array("FAIhook",$array['objectClass'])){ + return(array("tabsHook","faiHook","FAIHOOKTABS")); + } + if(in_array("FAIvariable",$array['objectClass'])){ + return(array("tabsVariable","faiVariable","FAIVARIABLETABS")); + } + if(in_array("FAIprofile",$array['objectClass'])){ + return(array("tabsProfile","faiProfile","FAIPROFILETABS")); + } + + if(in_array("FAIpackageList",$array['objectClass'])){ + return(array("tabsPackage","faiPackage","FAIPACKAGETABS")); + } + } + +} + +?> diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc new file mode 100644 index 000000000..78c9a18b6 --- /dev/null +++ b/plugins/admin/fai/class_faiPackage.inc @@ -0,0 +1,143 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description","FAIpackage"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIpackageList"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = ""; + var $subClasses = array("top","FAIclass","FAIscriptEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = ""; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description"); + var $sub64coded = array(); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $SubObjects = array(); // All leafobjects of this object + + function faiPackage ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + } + + $this->FAIpackage = "test"; + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + + /* 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(); + $str = utf8_encode("üöä"); + if((empty($this->description))){ + $message[]=_("Please enter a valid description."); + } + if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc new file mode 100644 index 000000000..db65fed85 --- /dev/null +++ b/plugins/admin/fai/class_faiPartitionTable.inc @@ -0,0 +1,380 @@ + "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 $base64_encode = array("FAImountPoint","FAImountOptions","FAIfsOptions","description"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $disks = array(); // All defined Disks + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + + function faiPartitionTable ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which 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]]['status'] = "edited"; + $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]; + } + } + /* Append fetched partitions + */ + $partition['status']="edited"; + + foreach($this->base64_encode as $attrs){ + $partition[$attrs] = base64_decode($partition[$attrs]); + } + $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'])){ + $usedDiskNames =array(); + foreach($this->disks as $key=>$disk){ + $usedDiskNames[]= $key; + } + $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); + $this->is_dialog = true; + } + + /* Edit disk. + * Open dialog which allows us to edit the selected entry + */ + if((isset($_POST['EditDisk']))&&(isset($_POST['disks']))){ + $usedDiskNames =array(); + foreach($this->disks as $key=>$disk){ + if($key != $_POST['disks']){ + $usedDiskNames[]= $key; + } + } + $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$_POST['disks']]); + $this->is_dialog = true; + } + + /* Edit aborted, close dialog, without saving anything + */ + if(isset($_POST['CancelDisk'])){ + unset($this->dialog); + $this->dialog = NULL; + $this->is_dialog=false; + } + + /* Dialog saved + * Save given data from Dialog, if no error is occured + */ + 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(); + if(isset($disk['rename'])){ + if($this->disks[$disk['rename']['from']]['status']=="edited"){ + $this->disks[$disk['rename']['from']]['status']="delete"; + }else{ + unset($this->disks[$disk['rename']['from']]); + } + + foreach($disk['partitions'] as $key => $val){ + if($disk['partitions'][$key]['status']!="delete"){ + $disk['partitions'][$key]['status']= "new"; + } + } + + $disk['status']="new"; + $disk['cn']= $disk['rename']['to']; + } + + $this->disks[$disk['cn']]=$disk; + unset($this->dialog); + $this->dialog = NULL; + $this->is_dialog=false; + } + } + + /* Delete selected disk drive from list + * Assign delete status for all its partitions + */ + if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){ + $disk = $_POST['disks']; + if($this->disks[$disk]['status']=="edited"){ + $this->disks[$disk."-delete"]=$this->disks[$disk]; + unset($this->disks[$disk]); + $disk = $disk."-delete"; + $this->disks[$disk]['status']="delete"; + foreach($this->disks[$disk]['partitions'] as $name => $value ){ + if($value['status']=="edited"){ + $this->disks[$disk]['partitions'][$name]['status']="delete"; + }else{ + unset($this->disks[$disk]['partitions'][$name]); + } + } + }else{ + unset($this->disks[$disk]); + } + } + + /* Display dialog if one is defined + */ + if(isset($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /* Assign all attributes to smarty engine + */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + if($this->$attrs){ + $smarty->assign($attrs."CHK"," "); + }else{ + $smarty->assign($attrs."CHK"," disabled "); + } + } + + $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(){ + /* Return all available disks for this partition table + * Return in listBox friendly array + */ + $a_return = array(); + foreach($this->disks as $key => $disk){ + if($disk['status'] != "delete"){ + $cnt=0; + foreach($disk['partitions'] as $val){ + if($val['status']!="delete"){ + $cnt ++; + } + } + 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); + } + + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + + /* 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(); + + $str = utf8_encode("üöä"); + if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + + if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){ + $message[]=_("Please enter a valid name."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + + plugin::save(); + /* Save current settings. + * 1 : We must save the partition table, with its description and cn + * 2 : Append Disk with cn and description. + * 3 : Save partitions for each disk + */ + + $ldap = $this->config->get_ldap_link(); + + if($this->new){ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + show_ldap_error($ldap->get_error()); + }else{ + /* Add partition table to ldap + */ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + } + + + /* Sort entries, because we must delete entries with status="delete" first */ + $order = array(); + foreach($this->disks as $key => $disk){ + if($disk['status'] == "delete"){ + $order[$key] = $disk; + } + } + foreach($this->disks as $key => $disk){ + if($disk['status'] != "delete"){ + $order[$key] = $disk; + } + } + + /* Append all disks to ldap */ + foreach($order as $cn=>$disk){ + $disk_dn = "cn=".$disk['cn'].",".$this->dn; + $disk_attrs['cn'] = $disk['cn']; + $disk_attrs['description'] = $disk['description']; + $disk_attrs['objectClass'] = array("top","FAIclass","FAIpartitionDisk"); + + if($disk['status'] == "delete"){ + $ldap->cd($disk_dn); + $ldap->rmdir_recursive($disk_dn); + }elseif($disk['status']== "edited"){ + $ldap->cd($disk_dn); + $ldap->modify($disk_attrs); + }elseif($disk['status']== "new"){ + $ldap->cd($disk_dn); + $ldap->create_missing_trees($disk_dn); + $ldap->cd($disk_dn); + $ldap->add($disk_attrs); + }else{ + print_red("unknown status while saving disks"); + } + + show_ldap_error($ldap->get_error()); + if($disk['status']!="delete") + /* Add all partitions */ + foreach($disk['partitions'] as $key => $partition){ + $partition_attrs = array(); + + foreach($this->base64_encode as $attrs){ + $partition[$attrs] = base64_encode($partition[$attrs]); + } + + foreach($partition as $key => $value){ + if(!empty($value)){ + $partition_attrs[$key]=$value; + }else{ + unset($partition_attrs[$key]); + } + } + + $partition_dn = "cn=".$partition_attrs['cn'].",".$disk_dn; + $partition_attrs['objectClass'] = array("top","FAIclass","FAIpartitionEntry"); + + unset($partition_attrs['status']); + unset($partition_attrs['old_cn']); + + if(($partition['status'] == "delete")&&($disk['status']!="new")){ + $ldap->cd($partition_dn); + $ldap->rmdir_recursive($partition_dn); + }elseif($partition['status'] == "new"){ + $ldap->cd($partition_dn); + $ldap->create_missing_trees($partition_dn); + $ldap->cd($partition_dn); + $ldap->add($partition_attrs); + }elseif($partition['status'] == "edited"){ + $ldap->cd($partition_dn); + $ldap->modify($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 new file mode 100644 index 000000000..878ffafe9 --- /dev/null +++ b/plugins/admin/fai/class_faiPartitionTableEntry.inc @@ -0,0 +1,450 @@ + "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 = ""; + var $status = "new"; + var $deletePartitions = array(); + + function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false) + { + plugin::plugin ($config, $dn); + $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize", + "FAImountOptions","FAIfsOptions","FAIpartitionFlags"); + + /* Generate available disknames, to avoid duplicates in cn */ + $this->AvailableDiskNames = array(); + foreach(array("a","b","c","d","e","f","g","h") as $ts){ + if(!in_array("hd".$ts,$usedDiskNames)){ + $this->AvailableDiskNames["hd".$ts]= "hd".$ts; + } + } + + $this->AvailableDiskNames['disk1']= "disk1"; + $this->AvailableDiskNames['disk2']= "disk2"; + /* Default status is new */ + $this->status = "new"; + + /* We want to edit an entry */ + if($disk){ + + /* Set disk status */ + $this->status = $disk['status']; + + /* Walk through partitions */ + foreach($disk['partitions'] as $name => $values){ + + /* If a partition is already marked as delete, attach it to deletePartitions only. */ + if($values['status'] == "delete"){ + unset($disk['partitions'][$name]); + $this->deletePartitions[]=$values; + }else{ + + /* Set status, to know which partition must be deleted from ldap + new : Neu partition entry // save + edited : Update partition entry in ldap + deleted: Remove partition from ldap + */ + + /* If status is not new, set to edit mode. + * New means that this partition currently wasn't saved to ldap. + */ + if($disk['partitions'][$name]['status']!="new"){ + $disk['partitions'][$name]['status']="edited"; + } + + $disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn']; + + /* Assign empty attributes, if attribute is missing */ + foreach($this->UsedAttrs as $attr){ + if(!isset($values[$attr])){ + $disk['partitions'][$name][$attr]=""; + } + } + } + } + + /* Set default attributes */ + $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"){ + if($this->partitions[$s_entry]['status'] == "edited"){ + $this->deletePartitions[]= $this->partitions[$s_entry]; + unset($this->partitions[$s_entry]); + }else{ + 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] = ""; + } + $tmp["old_cn"] = ""; + $tmp['status']="new"; + $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 = ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + + /* 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){ + if($part['status']!="delete"){ + /* Generate Partition select box + */ + $PartitionType = ""; + + + /* Generate fsType select box + */ + $FAIfsType= ""; + + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + if($part['FAIpartitionFlags']!=false){ + $str .= ""; + }else{ + $str .= ""; + } + $str .= ""; + $str .= ""; + } + } + $str.="
"._("Nr").""._("Name").""._("Description").""._("Type").""._("FS type").""._("Mount point").""._("Size in MB").""._("Mount options").""._("FS option").""._("Preserve")."
".($key)."".$PartitionType."".$FAIfsType."
"; + 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."); + } + + $str = utf8_encode("üöä"); + if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->DISK_description)){ + $message[]=_("Please enter a valid description."); + } + + /* check every partition. + * if there is an invalid value defined, append an errorstr to message + */ + + /* Array that contain every partitionname mountpoint etc already assigned */ + $alreadyUsed = array(); + foreach($this->UsedAttrs as $attrs){ + $alreadyUsed[$attrs] = array(); + } + + 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(in_array($part['cn'],$alreadyUsed['cn'])){ + $message[]=sprintf(_("please enter a unique name for partition %s"),($key)); + } + + if(in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint'])){ + $message[]=sprintf(_("please enter a unique mount point 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)); + } + + if($part['FAIfsType'] == "swap"){ + if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){ + $message[]=sprintf(_("File system type 'swap' is already used, change file system type 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)); + }elseif($this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key)){ + $message[]=$this->checkSize($part['FAIpartitionSize'],$alreadyUsed['FAIpartitionSize'],$key); + } + foreach($this->UsedAttrs as $attrs){ + $alreadyUsed[$attrs][$key] = $part[$attrs]; + } + } + + + /* 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); + } + + + /* This function checks the selected partition sizes + * If a size setting overlap with another, it returns an error msg + */ + function checkSize($current,$others,$ckey){ + $tmp = split("-",$current); + $from = $tmp[0]; + $to = $tmp[1]; + foreach($others as $key=> $other){ + $tmp = split("-",$other); + $oth_from = $tmp[0]; + $oth_to = $tmp[1]; + /* surrounds another entry */ + if( (($from <= $oth_from)&&($to >= $oth_to))|| // inside + (($from >= $oth_from)&&($to <= $oth_to))|| // outside + (($to >= $oth_from)&&($to <= $oth_to)) || // overlap at right + (($from >= $oth_from)&&($from <= $oth_to)) ){ // overlap left + $message =sprintf( _("Size settings for partition %s, overlap with size settings for partition %s."),$ckey,$key); + return($message); + } + } + return(false); + } + + 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. + */ + + /* Check partition rename + */ + foreach($this->partitions as $key => $part){ + if($part['cn'] != $part['old_cn']){ + if($part['status'] == "edited"){ + + $tmp = $part; + $tmp['status']= "delete"; + $tmp['cn'] = $part['old_cn']; + + $this->deletePartitions[] = $tmp; + } + $this->partitions[$key]['old_cn']=$part['cn']; + $this->partitions[$key]['status']="new"; + } + } + + $tmp = array(); + $tmp['cn'] = $this->DISK_cn; + + /* Attach partitions */ + foreach($this->partitions as $key=>$val) { + $this->partitions[$key]['FAIpartitionNr']=$key; + } + + /* Attach deleted */ + foreach($this->deletePartitions as $key=>$val) { + $this->partitions[$key."-delete"]=$val; + $this->partitions[$key."-delete"]['status']="delete"; + } + + $tmp['description'] = $this->DISK_description; + $tmp['partitions'] = $this->partitions; + $tmp['status'] = $this->status; + + /* If hdd name has changed, tell partitionTable to rename it */ + if(($this->is_edit)&&($this->old_cn != $this->DISK_cn)){ + $tmp['rename']['from'] = $this->old_cn; + $tmp['rename']['to'] = $this->DISK_cn; + } + + return($tmp); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc new file mode 100644 index 000000000..517b85240 --- /dev/null +++ b/plugins/admin/fai/class_faiProfile.inc @@ -0,0 +1,267 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description","FAIclass"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIprofile"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIscriptEntry"; + var $subClasses = array("top","FAIclass","FAIscriptEntry"); + + /* Specific attributes */ + var $old_cn = ""; + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $FAIclass = ""; // Classnames used for this profile + var $FAIclasses = array(); // Contains classname seperated in an array + var $FAIAllclasses = array(); // Contains all possible Classnames + + function faiProfile($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + $ldap=$this->config->get_ldap_link(); + + $tmp = split(" ",$this->FAIclass); + + foreach($tmp as $class){ + if(!empty($class)){ + $this->FAIclasses[trim($class)] = trim($class); + } + } + natcasesort($this->FAIclasses); + reset($this->FAIclasses) ; + + $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTAble","FAIpackage"); + + $sort = array(); + + $base = $_SESSION['faifilter']['base']; + $ldap->cd($base); + $ldap->search("(objectClass=*)",array("*")); + while($attrs = $ldap->fetch()){ + foreach($categories as $cat){ + if(in_array($cat,$attrs['objectClass'])){ + $this->FAIAllclasses[$attrs['cn'][0]][$cat]=$attrs; + $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; + } + } + } + ksort($sort); + foreach($sort as $name){ + $tmp[$name] =$this->FAIAllclasses[$name]; + } + $this->FAIAllclasses = array(); + $this->FAIAllclasses = $tmp; + + if($dn != "new"){ + $this->dn =$dn; + } + $this->old_cn = $this->cn; + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $s_entry = ""; + $s_action = ""; + + /* Remove class name From list */ + foreach($_POST as $name => $post){ + if(preg_match("/DEL_/i",$name)){ + $s_action = "delete"; + $s_entry = preg_replace("/DEL_/","",$name); + $s_entry = preg_replace("/_.*$/","",$s_entry); + }elseif(preg_match("/Add_class/i",$name)){ + $s_action = "add"; + } + } + + if($s_action == "delete"){ + unset($this->FAIclasses[$s_entry]); + } + + if($s_action == "add"){ + $this->dialog = new faiProfileEntry($this->config,$this->dn,$this->FAIclasses); + $this->is_dialog =true; + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + $this->dialog->save_object(); + $msgs= $this->dialog->check(); + if(count($msgs)){ + print_red($msgs); + }else{ + $ret = $this->dialog->save(); + foreach($ret as $class){ + $this->FAIclasses[$class] =$class; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + } + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + + if(isset($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + $divlist =new divlist("Profile"); + $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); + $divlist->SetEntriesPerPage(10); + + $divlist->SetHeader(array(array("string"=>"Class name"), + array("string"=>"Objects","attach"=>"style='width:120px;'"), + array("string"=>"Options","attach"=>"style='border-right:none;width:60px;'"))); + $listhead = + "
". + " ". + "
"; + + $objTypes['FAIhook'] = ""; + $objTypes['FAItemplate'] = ""; + $objTypes['FAIscript'] = ""; + $objTypes['FAIvariable'] = ""; + $objTypes['FAIpackages'] = ""; + $objTypes['FAIpartitionTable'] = ""; + + $actions = ""; + + foreach($this->FAIclasses as $usedClass){ + $str = ""; + if(isset($this->FAIAllclasses[$usedClass])){ + foreach($this->FAIAllclasses[$usedClass] as $class => $obj){ + $str.= $objTypes[$class]; + } + } + + $field1 = array("string"=> $usedClass,"attach"=>""); + $field2 = array("string"=> $str,"attach"=>""); + $field3 = array("string"=> preg_replace("/%KEY%/",$usedClass,$actions),"attach"=>"style='border-right:none;'"); + $divlist->AddEntry(array($field1,$field2,$field3)); + } + + $smarty->assign("divlisthead" ,$listhead); + $smarty->assign("divlist" ,$divlist->DrawList()); + + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + /* 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(); + $str = utf8_encode("üöä"); + if((empty($this->description))){ + $message[] =_("Please specify a description for this profile."); + } + + if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + + if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){ + $message[]=_("Please enter a valid name. Only 0-9 a-Z are allowed here."); + } + + if(count($this->FAIclasses) == 0){ + $message[]=_("Please assign at least one class to this profile."); + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($_SESSION['faifilter']['base']); + $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*")); + + if($ldap->count()){ + $message[]=_("There is already a profile with this class name defined."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $this->FAIclass = ""; + foreach($this->FAIclasses as $class){ + $this->FAIclass.=$class." "; + } + + $this->attrs['FAIclass']=trim($this->FAIclass); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiProfileEntry.inc b/plugins/admin/fai/class_faiProfileEntry.inc new file mode 100644 index 000000000..b38614e3b --- /dev/null +++ b/plugins/admin/fai/class_faiProfileEntry.inc @@ -0,0 +1,233 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array(); + var $objectclasses= array(); + + /* Array with available class names */ + var $FAIAllclasses = array(); + + function faiProfileEntry ($config, $dn= NULL,$used=array(),$objects=false) + { + plugin::plugin ($config, $dn); + + /* Search only in fai tree */ + $base = $_SESSION['faifilter']['base']; + + /* Create array with categories to be able to sort different types of objects */ + $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackage"); + + /* Read out all objects from fai tree */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($base); + $ldap->search("(| (objectClass=FAIscript)(objectClass=FAItemplate)(objectClass=FAIhook)(objectClass=FAIvariable) + (objectClass=FAIpartitionTable)(objectClass=FAIpackage))",array("*")); + while($attrs = $ldap->fetch()){ + + /* Only use objects which have cn set */ + if((isset($attrs['cn'][0]))&&(!in_array($attrs['cn'][0],$used))){ + foreach($categories as $cat){ + if(in_array($cat,$attrs['objectClass'])){ + + /* Append different types of objects */ + $this->FAIAllclasses[$attrs['cn'][0]]['objects'][$cat]=$cat; + + /* Set selected status to false */ + $this->FAIAllclasses[$attrs['cn'][0]]['status']=false; + + $sort[strtolower($attrs['cn'][0])] = $attrs['cn'][0]; + } + } + } + } + + ksort($sort); + foreach($sort as $name){ + $tmp[$name] =$this->FAIAllclasses[$name]; + } + $this->FAIAllclasses = array(); + $this->FAIAllclasses = $tmp; + + + /* If no search filter is set, create one */ + if (!is_global("SUBfaifilter")){ + $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$base, "Sregex" => "*"); + $SUBfaifilter['SShowTemplates'] = false; + $SUBfaifilter['SShowScripts'] = false; + $SUBfaifilter['SShowHooks'] = false; + $SUBfaifilter['SShowVariables'] = false; + $SUBfaifilter['SShowPackages'] = false; + $SUBfaifilter['SShowPartitions']= false; + register_global("SUBfaifilter", $SUBfaifilter); + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + $SUBfaifilter = $_SESSION['SUBfaifilter']; + + /* If someone used the apply button, update searchfilter */ + if(isset($_POST['Sregex'])){ + foreach($SUBfaifilter as $key => $val){ + if(!isset($_POST[$key])){ + $SUBfaifilter[$key] = false; + }else{ + $SUBfaifilter[$key] =$_POST[$key]; + } + } + $SUBfaifilter['Sregex']= $_POST['Sregex']; + if(!strstr($SUBfaifilter['Sregex'],"*")){ + $SUBfaifilter['Sregex'] = $SUBfaifilter['Sregex']."*"; + } + } + + /* Save current searchfilter in session*/ + $_SESSION['SUBfaifilter']= $SUBfaifilter; + + /* Check if we used a checkboxe from the list, to select dselect an entry */ + foreach($_POST as $name => $value){ + foreach($this->FAIAllclasses as $class => $obj){ + if(isset($_POST["ON_PAGE_".$class])){ + if(isset($_POST['USE_'.$class])){ + $this->FAIAllclasses[$class]['status']=true; + }else{ + $this->FAIAllclasses[$class]['status']=false; + } + } + } + } + + /* Create different picture for each object type */ + $objTypes['FAIhook'] = " "; + $objTypes['FAItemplate'] = " "; + $objTypes['FAIscript'] = " "; + $objTypes['FAIvariable'] = " "; + $objTypes['FAIpackages'] = " "; + $objTypes['FAIpartitionTable'] = " "; + + /* assign basic attributes */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + } + + /* Assign all filter attributes to smarty */ + foreach($SUBfaifilter as $key => $val){ + if(($key != "base")&&($key != "Sregex")){ + if($val){ + $smarty->assign($key."CHK", " checked "); + }else{ + $smarty->assign($key."CHK", ""); + } + }else{ + $smarty->assign($key,$val); + } + } + + /* Create a divlist to display all available class names with the depending object types */ + $divlist = new divlist("ProfileEntry"); + $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); + $divlist->SetEntriesPerPage(20); + $divlist->SetHeader(array(array("string"=>"Class name"), + array("string"=>"Objects"))); + + /* Action button allows us to delete an entry */ + $action = " + "; + + /* Check every single class name to match the current search filter */ + foreach($this->FAIAllclasses as $usedClass => $classes){ + + $fi = str_replace("*",".*",$SUBfaifilter['Sregex']); + + $abort = false; + if(!preg_match("/".$fi."/",$usedClass)){ + $abort = true; + } + if(($SUBfaifilter['SShowScripts'])&&(!in_array('FAIscript',$classes['objects']))){ + $abort = true; + } + if(($SUBfaifilter['SShowTemplates'])&&(!in_array('FAItemplate',$classes['objects']))){ + $abort = true; + } + if(($SUBfaifilter['SShowHooks'])&&(!in_array('FAIhook',$classes['objects']))){ + $abort = true; + } + if(($SUBfaifilter['SShowVariables'])&&(!in_array('FAIvariable',$classes['objects']))){ + $abort = true; + } + if(($SUBfaifilter['SShowPartitions'])&&(!in_array('FAIpartitionTable',$classes['objects']))){ + $abort = true; + } + if(($SUBfaifilter['SShowPackages'])&&(!in_array('FAIpackages',$classes['objects']))){ + $abort = true; + } + + if(!$abort){ + $str = ""; + foreach($classes['objects'] as $class => $obj){ + $str.= $objTypes[$obj]; + } + + /* Is this entry selected */ + if($classes['status']==true){ + $action_check = preg_replace("/%CHECK%/"," checked ",$action); + }else{ + $action_check = preg_replace("/%CHECK%/","",$action); + } + + /* Append to list */ + $field1 = array("string"=> preg_replace("/%KEY%/",$usedClass,$action_check).$usedClass,"attach"=>""); + $field2 = array("string"=> $str,"attach"=>""); + $divlist->AddEntry(array($field1,$field2)); + } + } + + $smarty->assign("faihead" , ""); + $smarty->assign("failist" , $divlist->DrawList()); + $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(TRUE)); + $smarty->assign("search_image" , get_template_path('images/search.png')); + + $display.= $smarty->fetch(get_template_path('faiProfileEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + } + + /* Check supplied data */ + function check() + { + $message= array(); + return ($message); + } + + function save() + { + $tmp = array(); + foreach($this->FAIAllclasses as $class => $obj){ + if($obj['status']==true){ + $tmp[$class]=$class; + } + } + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc new file mode 100644 index 000000000..3ee246aca --- /dev/null +++ b/plugins/admin/fai/class_faiScript.inc @@ -0,0 +1,281 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIscript"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIscriptEntry"; + var $subClasses = array("top","FAIclass","FAIscriptEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiScriptEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAIpriority","FAIscript"); + var $sub64coded = array("FAIscript"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $SubObjects = array(); // All leafobjects of this object + + function faiScript ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); + + while($object = $ldap->fetch()){ + /* Set status for save management */ + + foreach($this->subAttributes as $attrs){ + if(!isset($object[$attrs][0])){ + $this->SubObjects[$object['cn'][0]][$attrs]=""; + }else{ + $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; + } + } + + foreach($this->sub64coded as $codeIt){ + $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); + } + + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; + $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + } + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->is_dialog=true; + } + + /* Edit selected Sub Object */ + if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); + $this->is_dialog=true; + } + + /* Remove Sub object */ + if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ + if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ + $this->SubObjects[$_POST['SubObject']]['status']= "delete"; + }else{ + unset($this->SubObjects[$_POST['SubObject']]); + } + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + } + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + + /* Print dialog if $this->dialog is set */ + if($this->dialog){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + $smarty->assign("SubObjects",$this->getList()); + $smarty->assign("SubObjectKeys",array_flip($this->getList())); + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiScript.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + + /* 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(); + $str = utf8_encode("üöä"); + if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode($obj[$codeIt]); + } + + $tmp = array(); + foreach($this->subAttributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + $tmp[$attrs] = $obj[$attrs]; + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status'] == "delete"){ + $ldap->cd($sub_dn); + $ldap->rmdir_recursive($sub_dn); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + $ldap->cd($sub_dn); + $ldap->modify($tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + $ldap->cd($sub_dn); + $ldap->create_missing_trees($sub_dn); + $ldap->cd($sub_dn); + $ldap->add($tmp); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error()); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiScriptEntry.inc b/plugins/admin/fai/class_faiScriptEntry.inc new file mode 100644 index 000000000..903230055 --- /dev/null +++ b/plugins/admin/fai/class_faiScriptEntry.inc @@ -0,0 +1,135 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("Object_cn","Object_description","Object_FAIpriority","Object_FAIscript"); + var $objectclasses= array(); + + var $orig_cn = ""; + + var $Object_dn = ""; + var $Object_cn = ""; + var $Object_FAIpriority = ""; + var $Object_FAIscript = ""; + var $Object_description = ""; + var $Object_status = "new"; + + function faiScriptEntry ($config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if($dn != "new"){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = "Object_".$name; + $this->$oname=$value; + } + }else{ + $this->Object_status = "new"; + $this->orig_cn = false; + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + if(isset($_POST['ImportUpload'])){ + if(($_FILES['ImportFile']['error']!=0)){ + print_red(_("Please select a valid file.")); + }else + if(($_FILES['ImportFile']['size']==0)){ + print_red(_("Selected file is empty.")); + }else{ + $str = file_get_contents($_FILES['ImportFile']['tmp_name']); + $this->Object_FAIscript = $str; + } + } + + + + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + } + + for($i =1 ; $i <= 100 ; $i++){ + $Object_FAIprioritys[$i]=$i; + } + $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); + $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if(isset($_POST['SubObjectFormSubmitted'])){ + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + + /* Check supplied data */ + function check() + { + $message= array(); + + $str = utf8_encode("üöä"); + + if(empty($this->Object_FAIscript)){ + $message[]=_("Please specify a script."); + } + + if(empty($this->Object_description)){ + $message[] = _("Please enter a description."); + } + + if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ + $message[] = _("Invalid character in description. Please enter a valid description."); + } + + if(empty($this->Object_cn)){ + $message[] = _("Please enter a name."); + } + + if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ + $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $attr = preg_replace("/^Object_/","",$attrs); + $tmp[$attr] = $this->$attrs; + } + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->Object_status; + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc new file mode 100644 index 000000000..2c4377543 --- /dev/null +++ b/plugins/admin/fai/class_faiTemplate.inc @@ -0,0 +1,279 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAItemplate"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAItemplateEntry"; + var $subClasses = array("top","FAIclass","FAItemplateEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiTemplateEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAItemplateFile","FAItemplatePath"); + var $sub64coded = array("FAItemplateFile","FAItemplatePath"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $SubObjects = array(); // All leafobjects of this object + + function faiTemplate ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); + + while($object = $ldap->fetch()){ + /* Set status for save management */ + + foreach($this->subAttributes as $attrs){ + if(!isset($object[$attrs][0])){ + $this->SubObjects[$object['cn'][0]][$attrs]=""; + }else{ + $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; + } + } + + foreach($this->sub64coded as $codeIt){ + $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); + } + + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; + $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + } + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->is_dialog=true; + } + + /* Edit selected Sub Object */ + if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); + $this->is_dialog=true; + } + + /* Remove Sub object */ + if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ + if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ + $this->SubObjects[$_POST['SubObject']]['status']= "delete"; + }else{ + unset($this->SubObjects[$_POST['SubObject']]); + } + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + } + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + + /* Print dialog if $this->dialog is set */ + if($this->dialog){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + $smarty->assign("SubObjects",$this->getList()); + $smarty->assign("SubObjectKeys",array_flip($this->getList())); + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiTemplate.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + + /* 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(); + $str = utf8_encode("üöä"); + if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode($obj[$codeIt]); + } + $tmp = array(); + foreach($this->subAttributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + $tmp[$attrs] = $obj[$attrs]; + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status'] == "delete"){ + $ldap->cd($sub_dn); + $ldap->rmdir_recursive($sub_dn); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + $ldap->cd($sub_dn); + $ldap->modify($tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + $ldap->cd($sub_dn); + $ldap->create_missing_trees($sub_dn); + $ldap->cd($sub_dn); + $ldap->add($tmp); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error()); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiTemplateEntry.inc b/plugins/admin/fai/class_faiTemplateEntry.inc new file mode 100644 index 000000000..24d8d821b --- /dev/null +++ b/plugins/admin/fai/class_faiTemplateEntry.inc @@ -0,0 +1,124 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("Object_cn","Object_description","Object_FAItemplateFile","Object_FAItemplatePath"); + var $objectclasses= array(); + + var $orig_cn = ""; + + var $Object_dn = ""; + var $Object_cn = ""; + var $Object_FAItemplateFile = ""; + var $Object_FAItemplatePath = ""; + var $Object_description = ""; + var $Object_status = "new"; + + function faiTemplateEntry ($config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if($dn != "new"){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = "Object_".$name; + $this->$oname=$value; + } + }else{ + $this->Object_status = "new"; + $this->orig_cn = false; + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + } + + for($i =1 ; $i <= 100 ; $i++){ + $Object_FAIprioritys[$i]=$i; + } + $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); + $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if(isset($_POST['SubObjectFormSubmitted'])){ + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + + /* Check supplied data */ + function check() + { + $message= array(); + if(empty($this->Object_FAItemplateFile)){ + $message[]=_("Please specify a value for attribute 'file'."); + } + + if(empty($this->Object_FAItemplatePath)){ + $message[]=_("Please specify a value for attribute 'path'."); + } + + $str = utf8_encode("üöä"); + + if(empty($this->Object_description)){ + $message[] = _("Please enter a description."); + } + + if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ + $message[] = _("Invalid character in description. Please enter a valid description."); + } + + if(empty($this->Object_cn)){ + $message[] = _("Please enter a name."); + } + + if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ + $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); + } + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $attr = preg_replace("/^Object_/","",$attrs); + $tmp[$attr] = $this->$attrs; + } + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->Object_status; + + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiVariable.inc b/plugins/admin/fai/class_faiVariable.inc new file mode 100644 index 000000000..606f18c3e --- /dev/null +++ b/plugins/admin/fai/class_faiVariable.inc @@ -0,0 +1,281 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIvariable"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = "FAIvariableEntry"; + var $subClasses = array("top","FAIclass","FAIvariableEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = "faiVariableEntry"; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description","FAIvariableContent"); + var $sub64coded = array("FAIvariableContent"); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $SubObjects = array(); // All leafobjects of this object + + function faiVariable ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$this->subAttributes); + + while($object = $ldap->fetch()){ + /* Set status for save management */ + + foreach($this->subAttributes as $attrs){ + if(!isset($object[$attrs][0])){ + $this->SubObjects[$object['cn'][0]][$attrs]=""; + }else{ + $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; + } + } + + foreach($this->sub64coded as $codeIt){ + $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); + } + + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; + $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + } + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Add new sub object */ + if(isset($_POST['AddSubObject'])){ + $this->dialog= new $this->subClassName($this->config,"new"); + $this->is_dialog=true; + } + + /* Edit selected Sub Object */ + if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]); + $this->is_dialog=true; + } + + /* Remove Sub object */ + if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ + if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){ + $this->SubObjects[$_POST['SubObject']]['status']= "delete"; + }else{ + unset($this->SubObjects[$_POST['SubObject']]); + } + } + + /* Save Dialog */ + if(isset($_POST['SaveSubObject'])){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)>0){ + foreach($msgs as $msg){ + print_red($msg); + } + }else{ + $obj = $this->dialog->save(); + if(isset($obj['remove'])){ + if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ + $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; + }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + unset($this->SubObjects[$obj['remove']['from']]); + } + $obj['status'] = "new"; + $this->SubObjects[$obj['remove']['to']] = $obj; + unset($this->SubObjects[$obj['remove']['to']]['remove']); + }else{ + $this->SubObjects[$obj['cn']]=$obj; + } + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + } + + /* Cancel Dialog */ + if(isset($_POST['CancelSubObject'])){ + $this->is_dialog=false; + unset($this->dialog); + $this->dialog=NULL; + } + + /* Print dialog if $this->dialog is set */ + if($this->dialog){ + $this->dialog->save_object(); + $display = $this->dialog->execute(); + return($display); + } + + $smarty->assign("SubObjects",$this->getList()); + $smarty->assign("SubObjectKeys",array_flip($this->getList())); + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + + /* 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(); + $str = utf8_encode("üöä"); + if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + + /* Prepare FAIscriptEntry to write it to ldap + * First sort array. + * Because we must delete old entries first. + * After deletion, we perform add and modify + */ + $Objects = array(); + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] == "delete"){ + $Objects[$name] = $obj; + } + } + foreach($this->SubObjects as $name => $obj){ + if($obj['status'] != "delete"){ + $Objects[$name] = $obj; + } + } + + foreach($Objects as $name => $obj){ + + foreach($this->sub64coded as $codeIt){ + $obj[$codeIt]=base64_encode($obj[$codeIt]); + } + + $tmp = array(); + foreach($this->subAttributes as $attrs){ + if(empty($obj[$attrs])){ + $obj[$attrs] = array(); + } + $tmp[$attrs] = $obj[$attrs]; + } + + $tmp['objectClass'] = $this->subClasses; + + $sub_dn = "cn=".$obj['cn'].",".$this->dn; + + if($obj['status'] == "delete"){ + $ldap->cd($sub_dn); + $ldap->rmdir_recursive($sub_dn); + $this->handle_post_events("remove"); + }elseif($obj['status'] == "edited"){ + $ldap->cd($sub_dn); + $ldap->modify($tmp); + $this->handle_post_events("modify"); + }elseif($obj['status']=="new"){ + $ldap->cd($sub_dn); + $ldap->create_missing_trees($sub_dn); + $ldap->cd($sub_dn); + $ldap->add($tmp); + $this->handle_post_events("add"); + } + show_ldap_error($ldap->get_error()); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/class_faiVariableEntry.inc b/plugins/admin/fai/class_faiVariableEntry.inc new file mode 100644 index 000000000..3f993cb90 --- /dev/null +++ b/plugins/admin/fai/class_faiVariableEntry.inc @@ -0,0 +1,118 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes = array("Object_cn","Object_description","Object_FAIvariableContent"); + var $objectclasses= array(); + + var $orig_cn = ""; + var $Object_dn = ""; + var $Object_cn = ""; + var $Object_FAIvariableContent = ""; + var $Object_description = ""; + var $Object_status = "new"; + + function faiVariableEntry ($config, $dn= NULL,$object=false) + { + plugin::plugin ($config, $dn); + if($dn != "new"){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = "Object_".$name; + $this->$oname=$value; + } + }else{ + $this->Object_status = "new"; + $this->orig_cn = false; + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty = get_smarty(); + $display = ""; + + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,stripslashes($this->$attrs)); + } + + for($i =1 ; $i <= 100 ; $i++){ + $Object_FAIprioritys[$i]=$i; + } + $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); + $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + if(isset($_POST['SubObjectFormSubmitted'])){ + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + }else{ + $this->$attrs = ""; + } + } + } + } + + /* Check supplied data */ + function check() + { + $message= array(); + + $str = utf8_encode("üöä"); + if(empty($this->Object_FAIvariableContent)) { + $message[]=_("Please specify a value for the attribute 'content'."); + } + + if(empty($this->Object_description)){ + $message[] = _("Please enter a description."); + } + + if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){ + $message[] = _("Invalid character in description. Please enter a valid description."); + } + + if(empty($this->Object_cn)){ + $message[] = _("Please enter a name."); + } + + if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ + $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); + } + + return ($message); + } + + function save() + { + $tmp=array(); + foreach($this->attributes as $attrs){ + $attr = preg_replace("/^Object_/","",$attrs); + $tmp[$attr] = $this->$attrs; + } + + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ + $tmp['remove']['from'] = $this->orig_cn; + $tmp['remove']['to'] = $tmp['cn']; + } + + $tmp['dn'] = $this->dn; + $tmp['status'] = $this->Object_status; + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/fai/faiHook.tpl b/plugins/admin/fai/faiHook.tpl new file mode 100644 index 000000000..0a3d8e6aa --- /dev/null +++ b/plugins/admin/fai/faiHook.tpl @@ -0,0 +1,51 @@ + + + + + + +
+

 {t}Generic{/t}


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

  + +


+ + + + +
+
+ + + +
+
diff --git a/plugins/admin/fai/faiHookEntry.tpl b/plugins/admin/fai/faiHookEntry.tpl new file mode 100644 index 000000000..2dd86e4fc --- /dev/null +++ b/plugins/admin/fai/faiHookEntry.tpl @@ -0,0 +1,61 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t} {$must} + + +
+ {t}Description{/t} {$must} + + +
+
+   + +

 {t}Hook attributes{/t}

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

 

+
+
+   + +
+ diff --git a/plugins/admin/fai/faiPackage.tpl b/plugins/admin/fai/faiPackage.tpl new file mode 100644 index 000000000..d72310d6d --- /dev/null +++ b/plugins/admin/fai/faiPackage.tpl @@ -0,0 +1,29 @@ + + + + +
+

 {t}Generic{/t}


+ + + + + + + + + +
+ + + +
+ + + +
+
diff --git a/plugins/admin/fai/faiPartitionTable.tpl b/plugins/admin/fai/faiPartitionTable.tpl new file mode 100644 index 000000000..6d3f6229a --- /dev/null +++ b/plugins/admin/fai/faiPartitionTable.tpl @@ -0,0 +1,51 @@ + + + + + + +
+

 {t}Generic{/t}


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

  + +


+ + + + +
+
+ + + +
+
diff --git a/plugins/admin/fai/faiPartitionTableEntry.tpl b/plugins/admin/fai/faiPartitionTableEntry.tpl new file mode 100644 index 000000000..776905dae --- /dev/null +++ b/plugins/admin/fai/faiPartitionTableEntry.tpl @@ -0,0 +1,40 @@ + +
+

 {t}Generic{/t}

+ + + + + + + + + +
 {$must} + + +
 {$must} + + +
+
+

 

+
+

 {t}Partition entries{/t}

+{$setup} +
+ +
+
+

 

+
+
+ + +
diff --git a/plugins/admin/fai/faiProfile.tpl b/plugins/admin/fai/faiProfile.tpl new file mode 100644 index 000000000..11185d262 --- /dev/null +++ b/plugins/admin/fai/faiProfile.tpl @@ -0,0 +1,46 @@ +

 {t}Generic{/t}


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

+ +

+
+
+ + {$divlisthead} +
+
+
+
+ {$divlist} + +
+
diff --git a/plugins/admin/fai/faiProfileEntry.tpl b/plugins/admin/fai/faiProfileEntry.tpl new file mode 100644 index 000000000..b49352384 --- /dev/null +++ b/plugins/admin/fai/faiProfileEntry.tpl @@ -0,0 +1,69 @@ + + + + + +
+
+

+ {t}List of FAI objects (Fully Automatic Installation){/t} +

+
+
+ {$faihead} +
+
+
+ {$failist} + +
+
+
+

[i]{t}Information{/t}

+
+
+

+ {t}This menu allows you to select FAI class names and to add them to the currently edited profile.{/t} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + + + +
{t}Show only classes with templates{/t}
{t}Show only classes with scripts{/t}
{t}Show only classes with hooks{/t}
{t}Show only classes with variables{/t}
{t}Show only classes with packages{/t}
{t}Show only classes with partitions{/t}
+ + + + + +
+ + + +
+ {$apply} +
+
+
+ + +
+ diff --git a/plugins/admin/fai/faiScript.tpl b/plugins/admin/fai/faiScript.tpl new file mode 100644 index 000000000..0d405a102 --- /dev/null +++ b/plugins/admin/fai/faiScript.tpl @@ -0,0 +1,51 @@ + + + + + + +
+

 {t}Generic{/t}


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

  + +


+ + + + +
+
+ + + +
+
diff --git a/plugins/admin/fai/faiScriptEntry.tpl b/plugins/admin/fai/faiScriptEntry.tpl new file mode 100644 index 000000000..e5d7a7018 --- /dev/null +++ b/plugins/admin/fai/faiScriptEntry.tpl @@ -0,0 +1,72 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t} {$must} + + +
+ {t}Description{/t} {$must} + + +
+
+   + +

 {t}Script attributes{/t}

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

 

+

  + +

+
+ {t}Import script{/t}   +   + +
+
+ + + + +
+ +
+ +
+
+   + +
+ diff --git a/plugins/admin/fai/faiTemplate.tpl b/plugins/admin/fai/faiTemplate.tpl new file mode 100644 index 000000000..e310be27c --- /dev/null +++ b/plugins/admin/fai/faiTemplate.tpl @@ -0,0 +1,51 @@ + + + + + + +
+

 {t}Generic{/t}


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

  + +


+ + + + +
+
+ + + +
+
diff --git a/plugins/admin/fai/faiTemplateEntry.tpl b/plugins/admin/fai/faiTemplateEntry.tpl new file mode 100644 index 000000000..44c3bf8cd --- /dev/null +++ b/plugins/admin/fai/faiTemplateEntry.tpl @@ -0,0 +1,61 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t} {$must} + + +
+ {t}Description{/t} {$must} + + +
+
+   + +

 {t}Template attributes{/t}

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

 

+
+
+   + +
+ diff --git a/plugins/admin/fai/faiVariable.tpl b/plugins/admin/fai/faiVariable.tpl new file mode 100644 index 000000000..cc3871e7d --- /dev/null +++ b/plugins/admin/fai/faiVariable.tpl @@ -0,0 +1,51 @@ + + + + + + +
+

 {t}Generic{/t}


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

  + +


+ + + + +
+
+ + + +
+
diff --git a/plugins/admin/fai/faiVariableEntry.tpl b/plugins/admin/fai/faiVariableEntry.tpl new file mode 100644 index 000000000..131e7d1a3 --- /dev/null +++ b/plugins/admin/fai/faiVariableEntry.tpl @@ -0,0 +1,51 @@ + + + + + + + +
+

 {t}Generic{/t}

+ + + + + + + + + +
+ {t}Name{/t} {$must} + + +
+ {t}Description{/t} {$must} + + +
+
+   + +

 {t}Variable attributes{/t}

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

 

+
+
+   + +
+ diff --git a/plugins/admin/fai/headpage.tpl b/plugins/admin/fai/headpage.tpl new file mode 100644 index 000000000..2a4714c95 --- /dev/null +++ b/plugins/admin/fai/headpage.tpl @@ -0,0 +1,61 @@ + + + + + +
+
+

+ {t}List of FAI objects (Fully Automatic Installation){/t} +

+
+
+ {$faihead} +
+
+
+ {$failist} + +
+
+
+

[i]{t}Information{/t}

+
+
+

+ {t}This menu allows you to create, delete and edit FAI objects.{/t} +

+
+
+
+

[F]{t}Filters{/t}

+
+
+ + {$alphabet} +
+ + + + + + + + +
{t}Show profiles{/t}
{t}Show templates{/t}
{t}Show scripts{/t}
{t}Show hooks{/t}
{t}Show variables{/t}
{t}Show packages{/t}
{t}Show partitions{/t}
+ + + + + +
+ + + +
+ {$apply} +
+
+ + diff --git a/plugins/admin/fai/main.inc b/plugins/admin/fai/main.inc new file mode 100644 index 000000000..36d3c5021 --- /dev/null +++ b/plugins/admin/fai/main.inc @@ -0,0 +1,55 @@ +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/fai.png'), _("FAI management"), "\"\" ".$_SESSION['objectinfo']); + } else { + $display= print_header(get_template_path('images/fai.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/remove.tpl b/plugins/admin/fai/remove.tpl new file mode 100644 index 000000000..2d1deeec4 --- /dev/null +++ b/plugins/admin/fai/remove.tpl @@ -0,0 +1,18 @@ +
+ {t}Warning{/t} +
+ +

+ {$warning} + {t}This includes all object informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press Delete to continue or Cancel to abort.{/t} +

+ +

+ +   + +

diff --git a/plugins/admin/fai/tabsHook.inc b/plugins/admin/fai/tabsHook.inc new file mode 100644 index 000000000..f438f8236 --- /dev/null +++ b/plugins/admin/fai/tabsHook.inc @@ -0,0 +1,42 @@ +by_object['faiHook']; + + $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); + } + +} + +?> diff --git a/plugins/admin/fai/tabsPackage.inc b/plugins/admin/fai/tabsPackage.inc new file mode 100644 index 000000000..fdb1cb505 --- /dev/null +++ b/plugins/admin/fai/tabsPackage.inc @@ -0,0 +1,42 @@ +by_object['faiPackage']; + + $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); + } + +} + +?> diff --git a/plugins/admin/fai/tabsPartition.inc b/plugins/admin/fai/tabsPartition.inc new file mode 100644 index 000000000..d61396d67 --- /dev/null +++ b/plugins/admin/fai/tabsPartition.inc @@ -0,0 +1,45 @@ +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); + } + +} + +?> diff --git a/plugins/admin/fai/tabsProfile.inc b/plugins/admin/fai/tabsProfile.inc new file mode 100644 index 000000000..97dcdb073 --- /dev/null +++ b/plugins/admin/fai/tabsProfile.inc @@ -0,0 +1,42 @@ +by_object['faiProfile']; + + $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); + } + +} + +?> diff --git a/plugins/admin/fai/tabsScript.inc b/plugins/admin/fai/tabsScript.inc new file mode 100644 index 000000000..cb6dcf302 --- /dev/null +++ b/plugins/admin/fai/tabsScript.inc @@ -0,0 +1,42 @@ +by_object['faiScript']; + + $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); + } + +} + +?> diff --git a/plugins/admin/fai/tabsTemplate.inc b/plugins/admin/fai/tabsTemplate.inc new file mode 100644 index 000000000..ada68ce91 --- /dev/null +++ b/plugins/admin/fai/tabsTemplate.inc @@ -0,0 +1,42 @@ +by_object['faiTemplate']; + + $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); + } + +} + +?> diff --git a/plugins/admin/fai/tabsVariable.inc b/plugins/admin/fai/tabsVariable.inc new file mode 100644 index 000000000..86a8851f0 --- /dev/null +++ b/plugins/admin/fai/tabsVariable.inc @@ -0,0 +1,42 @@ +by_object['faiVariable']; + + $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['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); + } + +} + +?>