e3a8e5675fc233ffbe83950fbbe4d47d67cd2f1d
1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 require "tabsPartition.inc";
21 require "tabsVariable.inc";
22 require "tabsHook.inc";
23 require "tabsTemplate.inc";
24 require "tabsScript.inc";
25 require "tabsProfile.inc";
26 require "tabsPackage.inc";
29 class faiManagement extends plugin
30 {
31 /* Definitions */
32 var $plHeadline = "FAI";
33 var $plDescription = "Fully Automatic Installation - management";
35 /* CLI vars */
36 var $cli_summary = "Handling of FAI entries";
37 var $cli_description = "This plugin represents a management tool\n
38 which allows us to manage all needed attributes for fully automatic installations (FAI)";
39 var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
41 /* Headpage attributes */
42 var $departments= array();
43 var $deptabs= NULL;
45 /* attribute list for save action */
46 var $attributes = array(); // Attributes Managed by this plugin, none,
47 // because this is only an overview over all objects already defined in FAI.
48 var $objectclasses = array(); // ObjectClasses which the attributes are related to
49 var $dialog = array(); // This object contains every dialog we have currently opened
51 var $objects = array(); // This array contains all available objects shown in divlist
52 var $is_dialog = false;
54 /* construction/reconstruction
55 * The Filter ($faifilter stored in $_SESSION['faifilter']) defines the last
56 * selected department and filter options
57 * If it is not defined already we create a new fresh faifilter.
58 */
59 function faiManagement ($config, $ui)
60 {
61 $this->ui = $ui;
63 /* Set current dn to "", */
64 $this->dn = "";
66 /* Assign config */
67 $this->config = $config;
69 /* Get global filter config */
70 if (!is_global("faifilter")){
71 $base = get_base_from_people($ui->dn);
72 $faifilter= array("base" => $base,
73 "regex" => "*");
74 $faifilter['ShowProfiles'] = true;
75 $faifilter['ShowTemplates'] = true;
76 $faifilter['ShowScripts'] = true;
77 $faifilter['ShowHooks'] = true;
78 $faifilter['ShowVariables'] = true;
79 $faifilter['ShowPackages'] = true;
80 $faifilter['ShowPartitions']=true;
81 register_global("faifilter", $faifilter);
82 }
83 }
85 function execute()
86 {
87 /* Call parent execute */
88 plugin::execute();
90 $display = "";
91 $smarty = get_smarty();
92 $s_action = "";
93 $s_entry = "";
94 /* filter management
95 * Filter will be changed if POST['regex'] or $_GET['search'] isset
96 * New Filter will be stored in session and is used to generate list contents
97 */
98 $faifilter = $_SESSION['faifilter'];
100 /* Filter is posted by apply button
101 * Check every single chkbox
102 */
103 if(isset($_POST['regex'])){
104 $faifilter['regex'] = $_POST['regex']."*";
105 foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
106 if(isset($_POST[$attrs])){
107 $faifilter[$attrs] = true;
108 }else{
109 $faifilter[$attrs] = false;
110 }
111 }
112 }
114 /* Check ImageButton posts
115 * Create new tab ich new_xx is posted
116 */
117 foreach($_POST as $key => $val){
118 if(preg_match("/create_partition/i",$key)){
119 $s_action = "new_partition";
120 }elseif(preg_match("/create_script/i",$key)){
121 $s_action = "new_script";
122 }elseif(preg_match("/create_hook/i",$key)){
123 $s_action = "new_hook";
124 }elseif(preg_match("/create_variable/i",$key)){
125 $s_action = "new_variable";
126 }elseif(preg_match("/create_template/i",$key)){
127 $s_action = "new_template";
128 }elseif(preg_match("/create_package/i",$key)){
129 $s_action = "new_package";
130 }elseif(preg_match("/create_profile/i",$key)){
131 $s_action = "new_profile";
132 }elseif(preg_match("/edit_continue/",$key)){
133 $s_action = "select_class_name_finished";
134 }elseif(preg_match("/^entry_edit_.*/",$key)){
135 $s_entry = preg_replace("/^entry_edit_/","",$key);
136 $s_entry = preg_replace("/_.*$/","",$s_entry);
137 $s_action = "edit";
138 }elseif(preg_match("/^entry_delete_.*/",$key)){
139 $s_entry = preg_replace("/^entry_delete_/","",$key);
140 $s_entry = preg_replace("/_.*$/","",$s_entry);
141 $s_action = "delete";
142 }elseif(preg_match("/dep_back.*/i",$key)){
143 $s_action="back";
144 }elseif(preg_match("/dep_home.*/i",$key)){
145 $s_action="home";
146 }elseif(preg_match("/dep_root.*/i",$key)){
147 $s_action="root";
148 }
150 }
152 if($s_action=="root"){
153 $faifilter['base']=($this->config->current['BASE']);
154 }
156 if($s_action=="home"){
157 $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
158 $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
159 }
161 if($s_action=="back"){
162 $base_back = preg_replace("/^[^,]+,/","",$faifilter['base']);
163 $base_back = convert_department_dn($base_back);
165 if(isset($this->config->departments[trim($base_back)])){
166 $faifilter['base']= $this->config->departments[trim($base_back)];
167 }else{
168 $faifilter['base']= $this->config->departments["/"];
169 }
170 }
172 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
173 $s_action="open";
174 $s_entry = base64_decode($_GET['dep_id']);
175 $faifilter['base']= $this->config->departments[trim($s_entry)];
176 }
178 if(isset($_GET['edit_entry'])){
179 $s_entry = $_GET['edit_entry'];
180 $s_action = "edit";
181 }
183 /* Confirm dialog
184 * Delte object
185 */
186 if ($s_action=="delete"){
188 /* Get 'dn' from posted termlinst */
189 $this->dn= $this->objects[$s_entry]['dn'];
191 /* Load permissions for selected 'dn' and check if
192 we're allowed to remove this 'dn' */
193 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
194 $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
195 if (chkacl($this->acl, "delete") == ""){
197 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
198 if (($user= get_lock($this->dn)) != ""){
199 return(gen_locked_message ($user, $this->dn));
200 }
202 /* Lock the current entry, so nobody will edit it during deletion */
203 add_lock ($this->dn, $this->ui->dn);
204 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
205 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
206 } else {
208 /* Obviously the user isn't allowed to delete. Show message and
209 clean session. */
210 print_red (_("You are not allowed to delete this component!"));
211 }
212 }
214 /* Delete canceled? */
215 if (isset($_POST['delete_cancel'])){
216 del_lock ($this->dn);
217 }
220 /* Deltetion was confirmed, so delete this entry
221 */
222 if (isset($_POST['delete_terminal_confirm'])){
224 /* Some nice guy may send this as POST, so we've to check
225 for the permissions again. */
226 if (chkacl($this->acl, "delete") == ""){
228 /* Find out more about the object type */
229 $ldap = $this->config->get_ldap_link();
230 $ldap->cat($this->dn);
231 $attrs = $ldap->fetch();
233 $type = $this->get_type($attrs);
235 $this->dialog= new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn);
236 $this->dialog->set_acl(array($this->acl));
238 $this->dialog->by_object[$type[1]]->remove_from_parent ();
239 unset ($this->dialog);
240 gosa_log ("FAI class '".$this->dn."' has been removed");
241 $this->dialog= NULL;
243 /* Terminal list has changed, reload it. */
244 $this->reload ();
245 } else {
247 /* Normally this shouldn't be reached, send some extra
248 logs to notify the administrator */
249 print_red (_("You are not allowed to delete this component!"));
250 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
251 "deletion.");
252 }
254 /* Remove lock file after successfull deletion */
255 del_lock ($this->dn);
256 }
258 /* Edit Entry */
259 if($s_action == "edit"){
260 $entry = $this->objects[$s_entry];
262 $a_setup = ($this->get_type($entry));
264 $this->dn = $entry['dn'];
266 $this->dialog= new $a_setup[0]($this->config,
267 $this->config->data['TABS'][$a_setup[2]],$this->dn);
268 $this->is_dialog = true;
269 $_SESSION['objectinfo'] = $this->dn;
270 }
273 /* Dialog handling */
274 if($s_action == "new_partition"){
275 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
276 }
278 /* Dialog handling */
279 if($s_action == "new_script"){
280 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
281 }
283 /* Dialog handling */
284 if($s_action == "new_hook"){
285 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
286 }
288 /* Dialog handling */
289 if($s_action == "new_variable"){
290 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
291 }
293 /* Dialog handling */
294 if($s_action == "new_template"){
295 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
296 }
298 /* Dialog handling */
299 if($s_action == "new_package"){
300 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
301 }
303 /* New Profile */
304 if($s_action == "new_profile"){
305 $this->dn = "new" ;
306 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
308 $this->dialog = new $a_setup[0]($this->config,
309 $this->config->data['TABS'][$a_setup[2]],$this->dn);
310 $this->is_dialog = true;
312 }
314 if($s_action == "select_class_name_finished"){
315 $this->dialog->save_object();
316 if(count($this->dialog->check())!=0){
317 foreach($this->dialog->check() as $msg){
318 print_red($msg);
319 }
320 }else{
321 $this->dn = "new" ;
322 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
323 $name = $this->dialog->save();
325 $this->dialog = new $a_setup[0]($this->config,
326 $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
327 $this->dialog->by_object[$a_setup[1]]->cn = $name;
328 $this->is_dialog = true;
329 }
330 }
333 /* Search is set */
334 if(isset($_GET['search'])){
335 $faifilter['regex']=$_GET['search']."*";
336 }
338 /* remove double asterisks and save new filter */
339 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
340 $_SESSION['faifilter']= $faifilter;
342 /* Edit dialog was canceled
343 * Remove dialog an show management dialog
344 */
345 if(isset($_POST['edit_cancel'])){
346 unset($this->dialog);
347 $this->dialog=NULL;
348 $this->is_dialog = false;
349 unset($_SESSION['objectinfo']);
350 }
352 /* This check if the given tab could be saved
353 * If it was possible to save it, remove dialog object.
354 * If it wasn't possible, show errors and keep dialog.
355 */
356 if(isset($_POST['edit_finish'])){
357 $this->dialog->save_object();
358 if(count($this->dialog->check())!=0){
359 foreach($this->dialog->check() as $msg){
360 print_red($msg);
361 }
362 }else{
363 $this->dialog->save();
364 unset($this->dialog);
365 $this->dialog=NULL;
366 $this->is_dialog=false;
367 unset($_SESSION['objectinfo']);
368 }
369 }
371 /* If dialog is set, but $this->is_dialog==false, then
372 * only the "abort" button is shown, this are dialogs that must not be saved.
373 * If is_dialog == true, we are currently editing tab objects.
374 * Here we need both, save and cancel
375 */
377 if($this->dialog != NULL){
378 $display .= $this->dialog->execute();
379 /* Don't show buttons if tab dialog requests this */
380 if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
382 }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
383 $display.= "<p style=\"text-align:right\">\n";
384 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
385 $display.= " \n";
386 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
387 $display.= "</p>";
388 }elseif(!isset($this->dialog->current)){
389 $display.= "<p style=\"text-align:right\">\n";
390 $display.= "<input type=submit name=\"edit_continue\" value=\""._("Continue")."\"> ";
391 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
392 $display.= "</p>";
393 }
394 return($display);
395 }
397 /* Show Management template
398 * The following code will only be reached if no dialog (tabs or dialogs)
399 * are currently opened.
400 * Assign all reguired vars to template engine
401 */
403 /* Prepare departments */
404 $options= "";
405 foreach ($this->config->idepartments as $key => $value){
406 if ($faifilter['base'] == $key){
407 $options.= "<option selected value='$key'>$value</option>";
408 } else {
409 $options.= "<option value='$key'>$value</option>";
410 }
411 }
413 /* Create listhead, it will be shown on top of the divlist.
414 * It provides general navigation and object creation
415 */
416 $faihead =
417 "<div style='background:#F0F0F9;padding:5px;'> ".
419 "<input type='image' src='images/list_up.png' align='middle'
420 title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'> ".
422 "<input type='image' src='images/list_root.png' align='middle'
423 title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
425 "<input type='image' src='images/list_home.png' align='middle'
426 title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'> ".
428 "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\"> ".
430 " <input type='image' src='images/fai_new_profile.png' align='middle'
431 title='"._("New profile")."' name='Create_profile' alt='"._("P")."'> ".
433 "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\"> ".
435 " <input type='image' src='images/fai_new_partitionTable.png' align='middle'
436 title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'> ".
438 " <input type='image' src='images/fai_new_script.png' align='middle'
439 title='"._("New scripts")."' name='Create_script' alt='"._("S")."'> ".
441 " <input type='image' src='images/fai_new_hook.png' align='middle'
442 title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'> ".
444 " <input type='image' src='images/fai_new_variable.png' align='middle'
445 title='"._("New variables")."' name='Create_variable' alt='"._("V")."'> ".
447 " <input type='image' src='images/fai_new_template.png' align='middle'
448 title='"._("New templates")."' name='Create_template' alt='"._("T")."'> ".
450 " <input type='image' src='images/fai_new_packages.png' align='middle'
451 title='"._("New package list")."' name='Create_package' alt='"._("PK")."'> ".
453 " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
455 _("Current base")." <select name='base' onChange='mainform.submit()'>$options</select>".
456 " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
458 "</div>";
460 $this->reload();
462 /* Create list with objects */
463 $divlist = new divlist("faiManagement");
464 $divlist->SetEntriesPerPage(0);
465 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
467 $divlist->SetHeader(array(
468 array("string" => " "),
469 array("string" => _("Name of FAI class")),
470 array("string" => _("Class type")),
471 array("string" => _("Actions"), "attach"=>"style='border-right:none;width:40px;'")));
474 $action = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='entry_edit_%KEY%' title='"._("Edit class")."'>";
475 $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
477 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";
478 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
480 foreach($this->departments as $key => $val) {
481 if(!isset($this->config->departments[trim($key)])){
482 $this->config->departments[trim($key)]="";
483 }
485 $non_empty="";
486 $keys= str_replace("/","\/",$key);
487 foreach($this->config->departments as $keyd=>$vald ){
488 if(preg_match("/".$keys."\/.*/",$keyd)){
489 $non_empty="full";
490 }
491 }
494 $title = $this->config->departments[$key];
495 $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach"=>"style='width:20px;'");
496 $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "title='".$title."'");
497 $field2 = array("string" => "");
498 $field3 = array("string" => "","attach"=>"style='text-align:right;border-right:none;'");
500 $divlist->AddEntry( array($field0,$field1,$field2,$field3));
502 }
505 /* Attach objects */
506 foreach($this->objects as $key => $value){
507 $info= "";
508 $img = "";
509 $type = $value['type'];
510 $abort=false;
512 switch($type) {
513 case "FAIpartitionTable" :
514 if(!$faifilter['ShowPartitions']){
515 $abort = true;
516 }
517 $img="<img src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
518 $info = _("Partition table");
519 break;
520 case "FAIpackageList" :
521 if(!$faifilter['ShowPackages']){
522 $abort = true;
523 }
524 $img="<img src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
525 $info = _("Package list");
526 break;
527 case "FAIscript" :
528 if(!$faifilter['ShowScripts']){
529 $abort = true;
530 }
531 $img="<img src='images/fai_script.png' title='"._("Scripts")."' alt='S'>";
532 $info = _("Scripts");
533 break;
534 case "FAIvariable" :
535 if(!$faifilter['ShowVariables']){
536 $abort = true;
537 }
538 $img="<img src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
539 $info = _("Variables");
540 break;
541 case "FAIhook" :
542 if(!$faifilter['ShowHooks']){
543 $abort = true;
544 }
545 $img="<img src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
546 $info = _("Hooks");
547 break;
548 case "FAIprofile" :
549 if(!$faifilter['ShowProfiles']){
550 $abort = true;
551 }
552 $img="<img src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
553 $info = _("Profile");
554 break;
555 case "FAItemplate" :
556 if(!$faifilter['ShowTemplates']){
557 $abort = true;
558 }
559 $img="<img src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
560 $info = _("Templates");
561 break;
562 default :
563 $img="<img src='images/empty.png' alt=''>";$info = "";break;
565 }
567 if(!$abort) {
568 if((isset($value['description']))&&(!empty($value['description']))){
569 $desc= " [".$value['description']."]";
570 }else{
571 $desc= "";
572 }
574 $field1 = array("string" => $img , "attach" => "style='height:26px;width=20px;'");
575 $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "");
576 $field3 = array("string" => $info, "attach" => "");
577 $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach"=>"style='text-align:right;border:none'");
578 $divlist->AddEntry(array($field1,$field2,$field3,$field4));
580 }
581 }
583 foreach($faifilter as $attrs => $value){
584 if($value){
585 $smarty->assign($attrs."CHK", " checked ");
586 }else{
587 $smarty->assign($attrs."CHK", " ");
588 }
589 }
591 /* Assign all reguired vars to template engine */
592 $smarty->assign("faihead" , $faihead);
593 $smarty->assign("failist" , $divlist->DrawList());
594 $smarty->assign("regex" , $faifilter['regex']);
595 $smarty->assign("infoimage" , get_template_path('images/info.png'));
596 $smarty->assign("launchimage" , get_template_path('images/launch.png'));
597 $smarty->assign("alphabet" , generate_alphabet());
598 $smarty->assign("apply" , apply_filter());
599 $smarty->assign("search_image" , get_template_path('images/search.png'));
601 $display = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
602 return ($display);
603 }
606 function reload()
607 {
608 /* Create a new list of FAI object
609 * Object list depends on faifilter['regex']
610 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
611 */
612 $faifilter= get_global('faifilter');
613 // Added for dirlist function...
615 /* Set base for all searches */
616 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
617 $regex = $faifilter['regex'];
619 /* Array to save objects */
620 $objects = array();
622 $this->objects=array();
624 /* NEW LIST MANAGMENT
625 * We also need to search for the departments
626 * So we are able to navigate like in konquerer
627 */
628 $base2 = $faifilter['base'];
630 $res3 = get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
631 TRUE, $base2, array("ou", "description"), TRUE);
633 $this->departments= array();
634 $tmp = array();
635 foreach ($res3 as $value){
636 $tmp[strtolower($value['dn']).$value['dn']]=$value;
637 }
638 ksort($tmp);
639 foreach($tmp as $value){
640 if($value["description"][0]!=".."){
641 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
642 }else{
643 $this->departments[$value['dn']]=$value["description"][0];
644 }
645 }
647 /* END NEW LIST MANAGMENT
648 */
651 $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",
652 FALSE, $base, array("cn","description","objectClass"),TRUE);
654 foreach($res as $objecttypes){
655 $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
656 FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
657 foreach($res2 as $object){
658 $type= "";
659 unset($object['objectClass']['count']);
660 if(!isset($object['description'][0])){
661 $object['description'][0]="";
662 }
664 /* Clean up object informations */
665 $obj['cn'] = $object['cn'][0];
666 $obj['dn'] = $object['dn'];
667 $obj['description'] = $object['description'][0];
668 $obj['objectClass'] = $object['objectClass'];
670 if(in_array("FAIpartitionTable",$obj['objectClass'])){
671 $type = "FAIpartitionTable";
672 }elseif(in_array("FAIpackageList",$obj['objectClass'])){
673 $type = "FAIpackageList";
674 }elseif(in_array("FAIscript",$obj['objectClass'])){
675 $type = "FAIscript";
676 }elseif(in_array("FAIvariable",$obj['objectClass'])){
677 $type = "FAIvariable";
678 }elseif(in_array("FAIhook",$obj['objectClass'])){
679 $type = "FAIhook";
680 }elseif(in_array("FAIprofile",$obj['objectClass'])){
681 $obj['FAIclass'] = $object['FAIclass'][0];
682 $type = "FAIprofile";
683 }elseif(in_array("FAItemplate",$obj['objectClass'])){
684 $type = "FAItemplate";
685 }
686 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
687 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
689 }
690 }
691 ksort($this->objects);
692 reset ($this->objects);
694 /* use numeric index, thats a bit more secure */
695 $tmp0 = array();
696 foreach($this->objects as $obj){
697 $tmp0[]= $obj;
698 }
699 $this->objects = array();
700 $this->objects = $tmp0;
702 }
704 function remove_lock()
705 {
706 if (isset($this->dn)){
707 del_lock ($this->dn);
708 }
709 }
711 function get_type($array){
712 if(in_array("FAIpartitionTable",$array['objectClass'])){
713 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
714 }
715 if(in_array("FAIscript",$array['objectClass'])){
716 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
717 }
718 if(in_array("FAItemplate",$array['objectClass'])){
719 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
720 }
721 if(in_array("FAIhook",$array['objectClass'])){
722 return(array("tabsHook","faiHook","FAIHOOKTABS"));
723 }
724 if(in_array("FAIvariable",$array['objectClass'])){
725 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
726 }
727 if(in_array("FAIprofile",$array['objectClass'])){
728 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
729 }
731 if(in_array("FAIpackageList",$array['objectClass'])){
732 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
733 }
734 }
736 }
738 ?>