summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 41eb376)
raw | patch | inline | side by side (parent: 41eb376)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 8 Sep 2005 11:44:18 +0000 (11:44 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 8 Sep 2005 11:44:18 +0000 (11:44 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1328 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/FAI/class_faiManagement.inc | patch | blob | history | |
plugins/admin/FAI/class_faiProfile.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/class_faiProfileEntry.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/faiProfile.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/FAI/faiProfileEntry.tpl | [new file with mode: 0644] | patch | blob |
index 76bf88bf22da4584eb37700a5946d5cff5cbddad..463deda538ccd40f2d9ddb464a3b3d3486bdfd26 100644 (file)
require "tabsHook.inc";
require "tabsTemplate.inc";
require "tabsScript.inc";
+require "tabsProfile.inc";
class faiManagement extends plugin
{
if(in_array("FAIvariable",$array['objectClass'])){
return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
}
+ if(in_array("FAIprofile",$array['objectClass'])){
+ return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
+ }
}
}
diff --git a/plugins/admin/FAI/class_faiProfile.inc b/plugins/admin/FAI/class_faiProfile.inc
--- /dev/null
@@ -0,0 +1,231 @@
+<?php
+
+class faiProfile extends plugin
+{
+ /* CLI vars */
+ var $cli_summary = "Manage server basic objects";
+ var $cli_description = "Some longer text\nfor help";
+ var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+
+ /* 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 $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){
+ $this->FAIclasses[trim($class)] = trim($class);
+ }
+
+ $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTAble","FAIpackage");
+
+ $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;
+ }
+ }
+ }
+
+ if($dn != "new"){
+ $this->dn =$dn;
+ }
+ }
+
+ 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"),
+ array("string"=>"Options")));
+ $listhead =
+ "<div style='background:#F0F0F9;padding:5px;'>".
+ "<input type='image' align='middle' src='images/editpaste.png' title='"._("Append new class names")."' alt='"._("Add")."' name='Add_class'> ".
+ "</div>";
+
+ $objTypes['FAIhook'] = "<image src='images/fai_hook.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAItemplate'] = "<image src='images/fai_template.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIscript'] = "<image src='images/fai_script.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIvariable'] = "<image src='images/fai_variable.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIpackages'] = "<image src='images/fai_packages.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIpartitionTable'] = "<image src='images/fai_partitionTable.png' title='"._("Hook bundle")."' alt=''>";
+
+ $actions = "<input type='image' src='images/editdelete.png' title='"._("Remove class from profile")."' name='DEL_%KEY%'>";
+
+ 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))||(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();
+
+ $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
--- /dev/null
@@ -0,0 +1,201 @@
+<?php
+
+class faiProfileEntry extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes = array();
+ var $objectclasses= array();
+
+ var $FAIAllclasses = array();
+
+ function faiProfileEntry ($config, $dn= NULL,$used=array(),$objects=false)
+ {
+ plugin::plugin ($config, $dn);
+
+ $base = $_SESSION['faifilter']['base'];
+
+ $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTAble","FAIpackage");
+
+ $base = $_SESSION['faifilter']['base'];
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd($base);
+ $ldap->search("(objectClass=*)",array("*"));
+ while($attrs = $ldap->fetch()){
+ if((isset($attrs['cn'][0]))&&(!in_array($attrs['cn'][0],$used))){
+ foreach($categories as $cat){
+ if(in_array($cat,$attrs['objectClass'])){
+ $this->FAIAllclasses[$attrs['cn'][0]]['objects'][$cat]=$cat;
+ $this->FAIAllclasses[$attrs['cn'][0]]['status']=false;
+ }
+ }
+ }
+ }
+
+ if (1==1||!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(isset($_POST['apply'])){
+ foreach($SUBfaifilter as $key => $val){
+ if(!isset($_POST[$key])){
+ $SUBfaifilter[$key] = false;
+ }else{
+ $SUBfaifilter[$key] =$_POST[$key];
+ }
+ }
+ }
+
+ $_SESSION['SUBfaifilter']= $SUBfaifilter;
+
+ 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;
+ }
+ }
+ }
+ }
+
+ $objTypes['FAIhook'] = "<image src='images/fai_hook.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAItemplate'] = "<image src='images/fai_template.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIscript'] = "<image src='images/fai_script.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIvariable'] = "<image src='images/fai_variable.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIpackages'] = "<image src='images/fai_packages.png' title='"._("Hook bundle")."' alt=''>";
+ $objTypes['FAIpartitionTable'] = "<image src='images/fai_partitionTable.png' title='"._("Hook bundle")."' alt=''>";
+
+ foreach($this->attributes as $attrs){
+ $smarty->assign($attrs,stripslashes($this->$attrs));
+ }
+
+ 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);
+ }
+ }
+ $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 = "<input type='hidden' name='ON_PAGE_%KEY%' value='1'>
+ <input type='checkbox' name='USE_%KEY%' value='%KEY%' onChange='document.mainform.submit();' %CHECK%>";
+
+ foreach($this->FAIAllclasses as $usedClass => $classes){
+
+ $abort = false;
+
+ 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];
+ }
+
+ if($classes['status']==true){
+ $action_check = preg_replace("/%CHECK%/"," checked ",$action);
+ }else{
+ $action_check = preg_replace("/%CHECK%/","",$action);
+ }
+
+ $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()
+ {
+ 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();
+ 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/faiProfile.tpl b/plugins/admin/FAI/faiProfile.tpl
--- /dev/null
@@ -0,0 +1,46 @@
+<h2><img alt="" src="images/house.png" align="middle" title="{t}Generic{/t}"> {t}Generic{/t}</h2><br>
+<table summary="" cellspacing="4">
+ <tr>
+ <td>
+ <LABEL for="cn">
+ {t}Name{/t}
+ </LABEL>
+ </td>
+ <td>
+ <input value="{$cn}" disabled id="cn">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <LABEL for="description">
+ {t}Description{/t}{$must}
+ </LABEL>
+ </td>
+ <td>
+ <input value="{$description}" {$description} name="description" id="description">
+ </td>
+ </tr>
+</table>
+<br>
+
+<table summary="" style="vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;">
+ <div class="contentboxh">
+ <p class="contentboxh">
+ <LABEL for="userlist">{t}List of used class names{/t}</LABEL>
+ </p>
+ </div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+
+ {$divlisthead}
+ </div>
+ <div style='height:4px;'>
+ </div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$divlist}
+ <input type="hidden" name="edit_helper">
+ </div>
+ </td>
+ </tr>
+</table>
diff --git a/plugins/admin/FAI/faiProfileEntry.tpl b/plugins/admin/FAI/faiProfileEntry.tpl
--- /dev/null
@@ -0,0 +1,63 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:600px">
+ <div class="contentboxh">
+ <p class="contentboxh">
+ {t}List of FAI objects (Fully Automatic Installation){/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$faihead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$failist}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh">
+ <p class="contentboxh"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <p class="contentboxb">
+ {t}This menu allows you to create, delete and edit selected FAI obejcts. Having a large size of objects, you might prefer the range selectors on top of this list.{/t}
+ </p>
+ </div>
+ <br>
+ <div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ <tr><td><input type="checkbox" name="SShowTemplates" {$SShowTemplatesCHK}>{t}Show only classes with templates{/t}</td></tr>
+ <tr><td><input type="checkbox" name="SShowScripts" {$SShowScriptsCHK}>{t}Show only classes with scripts{/t}</td></tr>
+ <tr><td><input type="checkbox" name="SShowHooks" {$SShowHooksCHK}>{t}Show only classes with hooks{/t}</td></tr>
+ <tr><td><input type="checkbox" name="SShowVariables" {$SShowVariablesCHK}>{t}Show only classes with variables{/t}</td></tr>
+ <tr><td><input type="checkbox" name="SShowPackages" {$SShowPackagesCHK}>{t}Show only classes with packages{/t}</td></tr>
+ <tr><td><input type="checkbox" name="SShowPartitions" {$SShowPartitionsCHK}>{t}Show only classes with partitions{/t}</td></tr>
+ </table>
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ <tr>
+ <td>
+ <LABEL for "regex"><img alt="{t}Display objects matching{/t}" src="{$search_image}" align=middle title='{t}Display objects matching{/t}'></LABEL>
+ </td>
+ <td width="99%">
+ <input type='text' name='Sregex' maxlength='20' style='width:99%' value='{$Sregex}' id='filter'
+ title='{t}Regular expression for matching object names{/t}' onChange="mainform.submit()">
+ </td>
+ </tr>
+ </table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table summary="">
+<div align="right" style="align:right;">
+ <input name="SaveSubObject" value="Use" type="submit">
+ <input name="CancelSubObject" value="Cancel" type="submit">
+</div>
+<input type="hidden" name="ignore">