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 $display = "";
88 $smarty = get_smarty();
89 $s_action = "";
90 $s_entry = "";
91 /* filter management
92 * Filter will be changed if POST['regex'] or $_GET['search'] isset
93 * New Filter will be stored in session and is used to generate list contents
94 */
95 $faifilter = $_SESSION['faifilter'];
97 /* Filter is posted by apply button
98 * Check every single chkbox
99 */
100 if(isset($_POST['regex'])){
101 $faifilter['regex'] = $_POST['regex']."*";
102 foreach(array("ShowPartitions","ShowProfiles","ShowTemplates","ShowScripts","ShowHooks","ShowVariables","ShowPackages") as $attrs){
103 if(isset($_POST[$attrs])){
104 $faifilter[$attrs] = true;
105 }else{
106 $faifilter[$attrs] = false;
107 }
108 }
109 }
111 /* Check ImageButton posts
112 * Create new tab ich new_xx is posted
113 */
114 foreach($_POST as $key => $val){
115 if(preg_match("/create_partition/i",$key)){
116 $s_action = "new_partition";
117 }elseif(preg_match("/create_script/i",$key)){
118 $s_action = "new_script";
119 }elseif(preg_match("/create_hook/i",$key)){
120 $s_action = "new_hook";
121 }elseif(preg_match("/create_variable/i",$key)){
122 $s_action = "new_variable";
123 }elseif(preg_match("/create_template/i",$key)){
124 $s_action = "new_template";
125 }elseif(preg_match("/create_package/i",$key)){
126 $s_action = "new_package";
127 }elseif(preg_match("/create_profile/i",$key)){
128 $s_action = "new_profile";
129 }elseif(preg_match("/edit_continue/",$key)){
130 $s_action = "select_class_name_finished";
131 }elseif(preg_match("/^entry_edit_.*/",$key)){
132 $s_entry = preg_replace("/^entry_edit_/","",$key);
133 $s_entry = preg_replace("/_.*$/","",$s_entry);
134 $s_action = "edit";
135 }elseif(preg_match("/^entry_delete_.*/",$key)){
136 $s_entry = preg_replace("/^entry_delete_/","",$key);
137 $s_entry = preg_replace("/_.*$/","",$s_entry);
138 $s_action = "delete";
139 }elseif(preg_match("/dep_back.*/i",$key)){
140 $s_action="back";
141 }elseif(preg_match("/dep_home.*/i",$key)){
142 $s_action="home";
143 }elseif(preg_match("/dep_root.*/i",$key)){
144 $s_action="root";
145 }
147 }
149 if($s_action=="root"){
150 $faifilter['base']=($this->config->current['BASE']);
151 }
153 if($s_action=="home"){
154 $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
155 $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
156 }
158 if($s_action=="back"){
159 $base_back = preg_replace("/^[^,]+,/","",$faifilter['base']);
160 $base_back = convert_department_dn($base_back);
162 if(isset($this->config->departments[trim($base_back)])){
163 $faifilter['base']= $this->config->departments[trim($base_back)];
164 }else{
165 $faifilter['base']= $this->config->departments["/"];
166 }
167 }
169 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
170 $s_action="open";
171 $s_entry = base64_decode($_GET['dep_id']);
172 $faifilter['base']= $this->config->departments[trim($s_entry)];
173 }
175 if(isset($_GET['edit_entry'])){
176 $s_entry = $_GET['edit_entry'];
177 $s_action = "edit";
178 }
180 /* Confirm dialog
181 * Delte object
182 */
183 if ($s_action=="delete"){
185 /* Get 'dn' from posted termlinst */
186 $this->dn= $this->objects[$s_entry]['dn'];
188 /* Load permissions for selected 'dn' and check if
189 we're allowed to remove this 'dn' */
190 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
191 $this->acl= get_module_permission($acl, "FAIclass", $this->dn);
192 if (chkacl($this->acl, "delete") == ""){
194 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
195 if (($user= get_lock($this->dn)) != ""){
196 return(gen_locked_message ($user, $this->dn));
197 }
199 /* Lock the current entry, so nobody will edit it during deletion */
200 add_lock ($this->dn, $this->ui->dn);
201 $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
202 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
203 } else {
205 /* Obviously the user isn't allowed to delete. Show message and
206 clean session. */
207 print_red (_("You are not allowed to delete this component!"));
208 }
209 }
211 /* Delete canceled? */
212 if (isset($_POST['delete_cancel'])){
213 del_lock ($this->dn);
214 }
217 /* Deltetion was confirmed, so delete this entry
218 */
219 if (isset($_POST['delete_terminal_confirm'])){
221 /* Some nice guy may send this as POST, so we've to check
222 for the permissions again. */
223 if (chkacl($this->acl, "delete") == ""){
225 /* Find out more about the object type */
226 $ldap = $this->config->get_ldap_link();
227 $ldap->cat($this->dn);
228 $attrs = $ldap->fetch();
230 $type = $this->get_type($attrs);
232 $this->dialog= new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn);
233 $this->dialog->set_acl(array($this->acl));
235 $this->dialog->by_object[$type[1]]->remove_from_parent ();
236 unset ($this->dialog);
237 gosa_log ("FAI class '".$this->dn."' has been removed");
238 $this->dialog= NULL;
240 /* Terminal list has changed, reload it. */
241 $this->reload ();
242 } else {
244 /* Normally this shouldn't be reached, send some extra
245 logs to notify the administrator */
246 print_red (_("You are not allowed to delete this component!"));
247 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
248 "deletion.");
249 }
251 /* Remove lock file after successfull deletion */
252 del_lock ($this->dn);
253 }
255 /* Edit Entry */
256 if($s_action == "edit"){
257 $entry = $this->objects[$s_entry];
259 $a_setup = ($this->get_type($entry));
261 $this->dn = $entry['dn'];
263 $this->dialog= new $a_setup[0]($this->config,
264 $this->config->data['TABS'][$a_setup[2]],$this->dn);
265 $this->is_dialog = true;
266 $_SESSION['objectinfo'] = $this->dn;
267 }
270 /* Dialog handling */
271 if($s_action == "new_partition"){
272 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
273 }
275 /* Dialog handling */
276 if($s_action == "new_script"){
277 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
278 }
280 /* Dialog handling */
281 if($s_action == "new_hook"){
282 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
283 }
285 /* Dialog handling */
286 if($s_action == "new_variable"){
287 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
288 }
290 /* Dialog handling */
291 if($s_action == "new_template"){
292 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
293 }
295 /* Dialog handling */
296 if($s_action == "new_package"){
297 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
298 }
300 /* New Profile */
301 if($s_action == "new_profile"){
302 $this->dn = "new" ;
303 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
305 $this->dialog = new $a_setup[0]($this->config,
306 $this->config->data['TABS'][$a_setup[2]],$this->dn);
307 $this->is_dialog = true;
309 }
311 if($s_action == "select_class_name_finished"){
312 $this->dialog->save_object();
313 if(count($this->dialog->check())!=0){
314 foreach($this->dialog->check() as $msg){
315 print_red($msg);
316 }
317 }else{
318 $this->dn = "new" ;
319 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
320 $name = $this->dialog->save();
322 $this->dialog = new $a_setup[0]($this->config,
323 $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
324 $this->dialog->by_object[$a_setup[1]]->cn = $name;
325 $this->is_dialog = true;
326 }
327 }
330 /* Search is set */
331 if(isset($_GET['search'])){
332 $faifilter['regex']=$_GET['search']."*";
333 }
335 /* remove double asterisks and save new filter */
336 $faifilter['regex'] = preg_replace("/\*\*/","*",$faifilter['regex']);
337 $_SESSION['faifilter']= $faifilter;
339 /* Edit dialog was canceled
340 * Remove dialog an show management dialog
341 */
342 if(isset($_POST['edit_cancel'])){
343 unset($this->dialog);
344 $this->dialog=NULL;
345 $this->is_dialog = false;
346 unset($_SESSION['objectinfo']);
347 }
349 /* This check if the given tab could be saved
350 * If it was possible to save it, remove dialog object.
351 * If it wasn't possible, show errors and keep dialog.
352 */
353 if(isset($_POST['edit_finish'])){
354 $this->dialog->save_object();
355 if(count($this->dialog->check())!=0){
356 foreach($this->dialog->check() as $msg){
357 print_red($msg);
358 }
359 }else{
360 $this->dialog->save();
361 unset($this->dialog);
362 $this->dialog=NULL;
363 $this->is_dialog=false;
364 unset($_SESSION['objectinfo']);
365 }
366 }
368 /* If dialog is set, but $this->is_dialog==false, then
369 * only the "abort" button is shown, this are dialogs that must not be saved.
370 * If is_dialog == true, we are currently editing tab objects.
371 * Here we need both, save and cancel
372 */
374 if($this->dialog != NULL){
375 $display .= $this->dialog->execute();
376 /* Don't show buttons if tab dialog requests this */
377 if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
379 }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
380 $display.= "<p style=\"text-align:right\">\n";
381 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
382 $display.= " \n";
383 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
384 $display.= "</p>";
385 }elseif(!isset($this->dialog->current)){
386 $display.= "<p style=\"text-align:right\">\n";
387 $display.= "<input type=submit name=\"edit_continue\" value=\""._("Continue")."\"> ";
388 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
389 $display.= "</p>";
390 }
391 return($display);
392 }
394 /* Show Management template
395 * The following code will only be reached if no dialog (tabs or dialogs)
396 * are currently opened.
397 * Assign all reguired vars to template engine
398 */
400 /* Prepare departments */
401 $options= "";
402 foreach ($this->config->idepartments as $key => $value){
403 if ($faifilter['base'] == $key){
404 $options.= "<option selected value='$key'>$value</option>";
405 } else {
406 $options.= "<option value='$key'>$value</option>";
407 }
408 }
410 /* Create listhead, it will be shown on top of the divlist.
411 * It provides general navigation and object creation
412 */
413 $faihead =
414 "<div style='background:#F0F0F9;padding:5px;'> ".
416 "<input type='image' src='images/list_up.png' align='middle'
417 title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'> ".
419 "<input type='image' src='images/list_root.png' align='middle'
420 title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
422 "<input type='image' src='images/list_home.png' align='middle'
423 title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'> ".
425 "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\"> ".
427 " <input type='image' src='images/fai_new_profile.png' align='middle'
428 title='"._("New profile")."' name='Create_profile' alt='"._("P")."'> ".
430 "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\"> ".
432 " <input type='image' src='images/fai_new_partitionTable.png' align='middle'
433 title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'> ".
435 " <input type='image' src='images/fai_new_script.png' align='middle'
436 title='"._("New scripts")."' name='Create_script' alt='"._("S")."'> ".
438 " <input type='image' src='images/fai_new_hook.png' align='middle'
439 title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'> ".
441 " <input type='image' src='images/fai_new_variable.png' align='middle'
442 title='"._("New variables")."' name='Create_variable' alt='"._("V")."'> ".
444 " <input type='image' src='images/fai_new_template.png' align='middle'
445 title='"._("New templates")."' name='Create_template' alt='"._("T")."'> ".
447 " <input type='image' src='images/fai_new_packages.png' align='middle'
448 title='"._("New package list")."' name='Create_package' alt='"._("PK")."'> ".
450 " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
452 _("Current base")." <select name='base' onChange='mainform.submit()'>$options</select>".
453 " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
455 "</div>";
457 $this->reload();
459 /* Create list with objects */
460 $divlist = new divlist("faiManagement");
461 $divlist->SetEntriesPerPage(20);
462 $divlist->SetSummary(_("This table displays all systems, in the selected tree."));
464 $divlist->SetHeader(array(
465 array("string" => " "),
466 array("string" => _("Name of FAI class")),
467 array("string" => _("Class type")),
468 array("string" => _("Actions"), "attach"=>"style='border-right:none;width:40px;'")));
471 $action = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='entry_edit_%KEY%' title='"._("Edit class")."'>";
472 $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
474 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";
475 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
477 foreach($this->departments as $key => $val) {
478 if(!isset($this->config->departments[trim($key)])){
479 $this->config->departments[trim($key)]="";
480 }
482 $non_empty="";
483 $keys= str_replace("/","\/",$key);
484 foreach($this->config->departments as $keyd=>$vald ){
485 if(preg_match("/".$keys."\/.*/",$keyd)){
486 $non_empty="full";
487 }
488 }
491 $title = $this->config->departments[$key];
492 $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach"=>"style='width:20px;'");
493 $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "title='".$title."'");
494 $field2 = array("string" => "");
495 $field3 = array("string" => "","attach"=>"style='text-align:right;border-right:none;'");
497 $divlist->AddEntry( array($field0,$field1,$field2,$field3));
499 }
502 /* Attach objects */
503 foreach($this->objects as $key => $value){
504 $info= "";
505 $img = "";
506 $type = $value['type'];
507 $abort=false;
509 switch($type) {
510 case "FAIpartitionTable" :
511 if(!$faifilter['ShowPartitions']){
512 $abort = true;
513 }
514 $img="<img src='images/fai_partitionTable.png' title='"._("Partition table")."' alt='PT'>";
515 $info = _("Partition table");
516 break;
517 case "FAIpackageList" :
518 if(!$faifilter['ShowPackages']){
519 $abort = true;
520 }
521 $img="<img src='images/fai_packages.png' title='"._("Package list")."' alt='PL'>";
522 $info = _("Package list");
523 break;
524 case "FAIscript" :
525 if(!$faifilter['ShowScripts']){
526 $abort = true;
527 }
528 $img="<img src='images/fai_script.png' title='"._("Scripts")."' alt='S'>";
529 $info = _("Scripts");
530 break;
531 case "FAIvariable" :
532 if(!$faifilter['ShowVariables']){
533 $abort = true;
534 }
535 $img="<img src='images/fai_variable.png' title='"._("Variables")."' alt='V'>";
536 $info = _("Variables");
537 break;
538 case "FAIhook" :
539 if(!$faifilter['ShowHooks']){
540 $abort = true;
541 }
542 $img="<img src='images/fai_hook.png' title='"._("Hooks")."' alt='H'>";
543 $info = _("Hooks");
544 break;
545 case "FAIprofile" :
546 if(!$faifilter['ShowProfiles']){
547 $abort = true;
548 }
549 $img="<img src='images/fai_profile.png' title='"._("Profile")."' alt='P'>";
550 $info = _("Profile");
551 break;
552 case "FAItemplate" :
553 if(!$faifilter['ShowTemplates']){
554 $abort = true;
555 }
556 $img="<img src='images/fai_template.png' title='"._("Templates")."' alt='T'>";
557 $info = _("Templates");
558 break;
559 default :
560 $img="<img src='images/empty.png' alt=''>";$info = "";break;
562 }
564 if(!$abort) {
565 if((isset($value['description']))&&(!empty($value['description']))){
566 $desc= " [".$value['description']."]";
567 }else{
568 $desc= "";
569 }
571 $field1 = array("string" => $img , "attach" => "style='height:26px;width=20px;'");
572 $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "");
573 $field3 = array("string" => $info, "attach" => "");
574 $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach"=>"style='text-align:right;border:none'");
575 $divlist->AddEntry(array($field1,$field2,$field3,$field4));
577 }
578 }
580 foreach($faifilter as $attrs => $value){
581 if($value){
582 $smarty->assign($attrs."CHK", " checked ");
583 }else{
584 $smarty->assign($attrs."CHK", " ");
585 }
586 }
588 /* Assign all reguired vars to template engine */
589 $smarty->assign("faihead" , $faihead);
590 $smarty->assign("failist" , $divlist->DrawList());
591 $smarty->assign("regex" , $faifilter['regex']);
592 $smarty->assign("infoimage" , get_template_path('images/info.png'));
593 $smarty->assign("launchimage" , get_template_path('images/launch.png'));
594 $smarty->assign("alphabet" , generate_alphabet());
595 $smarty->assign("apply" , apply_filter());
596 $smarty->assign("search_image" , get_template_path('images/search.png'));
598 $display = $smarty->fetch(get_template_path('headpage.tpl', TRUE, dirname(__FILE__)));
599 return ($display);
600 }
603 function reload()
604 {
605 /* Create a new list of FAI object
606 * Object list depends on faifilter['regex']
607 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
608 */
609 $faifilter= get_global('faifilter');
610 // Added for dirlist function...
612 /* Set base for all searches */
613 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
614 $regex = $faifilter['regex'];
616 /* Array to save objects */
617 $objects = array();
619 $this->objects=array();
621 /* NEW LIST MANAGMENT
622 * We also need to search for the departments
623 * So we are able to navigate like in konquerer
624 */
625 $base2 = $faifilter['base'];
627 $res3 = get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
628 TRUE, $base2, array("ou", "description"), TRUE);
630 $this->departments= array();
631 $tmp = array();
632 foreach ($res3 as $value){
633 $tmp[strtolower($value['dn']).$value['dn']]=$value;
634 }
635 ksort($tmp);
636 foreach($tmp as $value){
637 if($value["description"][0]!=".."){
638 $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
639 }else{
640 $this->departments[$value['dn']]=$value["description"][0];
641 }
642 }
644 /* END NEW LIST MANAGMENT
645 */
648 $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",
649 FALSE, $base, array("cn","description","objectClass"),TRUE);
651 foreach($res as $objecttypes){
652 $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))",
653 FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
654 foreach($res2 as $object){
655 $type= "";
656 unset($object['objectClass']['count']);
657 if(!isset($object['description'][0])){
658 $object['description'][0]="";
659 }
661 /* Clean up object informations */
662 $obj['cn'] = $object['cn'][0];
663 $obj['dn'] = $object['dn'];
664 $obj['description'] = $object['description'][0];
665 $obj['objectClass'] = $object['objectClass'];
667 if(in_array("FAIpartitionTable",$obj['objectClass'])){
668 $type = "FAIpartitionTable";
669 }elseif(in_array("FAIpackageList",$obj['objectClass'])){
670 $type = "FAIpackageList";
671 }elseif(in_array("FAIscript",$obj['objectClass'])){
672 $type = "FAIscript";
673 }elseif(in_array("FAIvariable",$obj['objectClass'])){
674 $type = "FAIvariable";
675 }elseif(in_array("FAIhook",$obj['objectClass'])){
676 $type = "FAIhook";
677 }elseif(in_array("FAIprofile",$obj['objectClass'])){
678 $obj['FAIclass'] = $object['FAIclass'][0];
679 $type = "FAIprofile";
680 }elseif(in_array("FAItemplate",$obj['objectClass'])){
681 $type = "FAItemplate";
682 }
683 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
684 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
686 }
687 }
688 ksort($this->objects);
689 reset ($this->objects);
691 /* use numeric index, thats a bit more secure */
692 $tmp0 = array();
693 foreach($this->objects as $obj){
694 $tmp0[]= $obj;
695 }
696 $this->objects = array();
697 $this->objects = $tmp0;
699 }
701 function remove_lock()
702 {
703 if (isset($this->dn)){
704 del_lock ($this->dn);
705 }
706 }
708 function get_type($array){
709 if(in_array("FAIpartitionTable",$array['objectClass'])){
710 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
711 }
712 if(in_array("FAIscript",$array['objectClass'])){
713 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
714 }
715 if(in_array("FAItemplate",$array['objectClass'])){
716 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
717 }
718 if(in_array("FAIhook",$array['objectClass'])){
719 return(array("tabsHook","faiHook","FAIHOOKTABS"));
720 }
721 if(in_array("FAIvariable",$array['objectClass'])){
722 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
723 }
724 if(in_array("FAIprofile",$array['objectClass'])){
725 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
726 }
728 if(in_array("FAIpackageList",$array['objectClass'])){
729 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
730 }
731 }
733 }
735 ?>