Code

866ff64a2d7fec240e9d645ab4edc7294ed21df8
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiPartitionTable.inc
1 <?php
3 class faiPartitionTable extends plugin
4 {
5   /* attribute list for save action */
6   var $ignore_account   = TRUE;
7   var $attributes       = array("cn","description", "FAIpartitionMethod");
8   var $objectclasses    = array("top","FAIclass","FAIpartitionTable");
10   var $subAttributes      = array("cn","description");
11   var $subPartAttributes  = array("cn","FAIpartitionNr","FAIpartitionSize","FAImountPoint","FAIfsType","FAIpartitionType","FAImountOptions","FAIfsOptions","FAIpartitionFlags","description");
13   var $sub64coded = array();
14   var $subBinary = array();
16   /* Specific attributes */
17   var $cn                 = "";       // The class name for this object
18   var $description        = "";       // The description for this set of partitions
19   var $FAIpartitionMethod = "";       // "setup-storage" or not assigned
20   var $disks              = array();  // All defined Disks 
21   var $is_dialog          = false;    // specifies which buttons will be shown to save or abort
23   var $FAIstate           = "";
24   var $ui;
26   var $view_logged      = FALSE;
28   function faiPartitionTable (&$config, $dn= NULL)
29   {
30     /* Load Attributes */
31     plugin::plugin ($config, $dn);
33     /* If "dn==new" we try to create a new entry
34      * Else we must read all objects from ldap which belong to this entry.
35      */
36     $this->ui = get_userinfo();
37     if($dn != "new"){
38       $this->dn =$dn;
40       /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
41        */
42       $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))");
43       foreach($res as $obj){
45         /* Skip not relevant objects */
46         if(!preg_match("/".preg_quote($this->dn, '/')."$/i",$obj['dn'])) continue;
47         $objects = array();
48         $objects['description']  = "";
49         $objects['status']      = "edited";
51         // Transform disk type into image later...
52         if (!isset($obj['FAIdiskType'])){
53           $objects['FAIdiskType']        = "old";
54         } else {
55           $objects['FAIdiskType']        = $obj['FAIdiskType'];
56         }
57         $objects['FAIdiskOption']        = $obj['FAIdiskOption'];
59         // Transform potential lvm information
60         if (isset($obj['FAIlvmDevice'])){
61           $objects['FAIlvmDevice'] = $obj['FAIlvmDevice'];
62         }
64         $objects['dn']          = $obj['dn'];
65         $objects                = $this->get_object_attributes($objects,$this->subAttributes);
66         $this->disks[$objects['cn']] = $objects;
67         $this->disks[$objects['cn']]['partitions'] = array();
68       }
70       /* read all partitions for each disk 
71        */
72       foreach($this->disks as $name => $disk){
73         $res = FAI::get_all_objects_for_given_base($disk['dn'],"(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))");
74         foreach($res as $obj){
76           /* Skip not relevant objects */
77           if(!preg_match("/".preg_quote($disk['dn'], '/')."$/i",$obj['dn'])) continue;
79           $objects = array();
80           $objects['status']      = "edited";
81           $objects['dn']          = $obj['dn'];
82           $objects                = $this->get_object_attributes($objects,$this->subPartAttributes);
83           unset($objects['dn']);;
84           $this->disks[$name]['partitions'][$objects['FAIpartitionNr']] = $objects;
85         }
86       }
87     }
89     $this->is_new = FALSE;
90     if($this->dn == "new"){
91       $this->is_new =TRUE;
92     }
93     ksort($this->disks);
94   }
97   function acl_base_for_current_object($dn)
98   {
99     if($dn == "new" || $dn == ""){
100       if($this->dn == "new"){
101         $dn= $this->parent->parent->acl_base;
102       }else{
103         $dn = $this->dn;
104       }
105     }
106     return($dn);
107   }
110   function execute()
111   {
112     /* Call parent execute */
113     plugin::execute();
115     if($this->is_account && !$this->view_logged){
116       $this->view_logged = TRUE;
117       new log("view","fai/".get_class($this),$this->dn);
118     }
120     /* Fill templating stuff */
121     $smarty= get_smarty();
122     $display= "";
123  
124     /* Add Disk to this Partitionset
125      * This code adds a new HDD to the disks 
126      * A new Dialog will be opened 
127      */
128     if(isset($_POST['AddDisk']) && !preg_match("/freeze/i",$this->FAIstate)){
129       $usedDiskNames =array();
130       foreach($this->disks as $key=>$disk){
131         $usedDiskNames[]= $key;
132       }
133       if ($this->FAIpartitionMethod == "setup-storage") {
134         $this->dialog = new faiDiskEntry($this->config,$this->dn,$usedDiskNames); 
135       } else {
136         $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); 
137       }
138       $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn));
139       $this->dialog->set_acl_category("fai");
140       $this->dialog->FAIstate = $this->FAIstate;
141       $this->is_dialog = true;
142     }
144     /* Add Disk to this Partitionset
145      * This code adds a new HDD to the disks 
146      * A new Dialog will be opened 
147      */
148     if(isset($_POST['AddRaid']) && !preg_match("/freeze/i",$this->FAIstate)){
149       $usedDiskNames =array();
150       foreach($this->disks as $key=>$disk){
151         $usedDiskNames[]= $key;
152       }
153       $this->dialog = new faiRaidEntry($this->config,$this->dn,$usedDiskNames); 
154       $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn));
155       $this->dialog->set_acl_category("fai");
156       $this->dialog->FAIstate = $this->FAIstate;
157       $this->is_dialog = true;
158     }
160     /* Add Disk to this Partitionset
161      * This code adds a new HDD to the disks 
162      * A new Dialog will be opened 
163      */
164     if(isset($_POST['AddVolgroup']) && !preg_match("/freeze/i",$this->FAIstate)){
165       $usedDiskNames =array();
166       foreach($this->disks as $key=>$disk){
167         $usedDiskNames[]= $key;
168       }
169       $this->dialog = new faiLvmEntry($this->config,$this->dn,$usedDiskNames); 
170       $this->dialog->set_acl_base($this->acl_base_for_current_object($this->dn));
171       $this->dialog->set_acl_category("fai");
172       $this->dialog->FAIstate = $this->FAIstate;
173       $this->is_dialog = true;
174     }
176     /* Edit disk.
177      * Open dialog which allows us to edit the selected entry 
178      */    
180     if($this->dn != "new"){
181       set_object_info($this->dn);
182     }
184     /* Edit entries via GET */
185     $Udisk = null;
186     if(isset($_GET['act']) && isset($_GET['id'])){
187       if($_GET['act'] == "edit" && isset($this->disks[$_GET['id']])){
188         $Udisk= $_GET['id'];
189       }
190     }
192     /* New Listhandling */
193     foreach($_POST as $name => $value){
194       if(preg_match("/^edit_/",$name)){
195         $entry = preg_replace("/^edit_/","",$name);
196         $Udisk = base64_decode(preg_replace("/_.*/","",$entry));
197         break;
198       }
199       if(preg_match("/^delete_/",$name)){
200         $entry = preg_replace("/^delete_/","",$name);
201         $disk = base64_decode(preg_replace("/_.*/","",$entry));
203         if (!preg_match("/freeze/i", $this->FAIstate)){
204           if(isset($this->disks[$disk])){
206             /* Check for references */
207             $ignore = false;
208             $name = "";
209             foreach($this->disks as $dtest) {
210               // Is raid?
211               $device= null;
212               $name = $dtest['cn'];
214               if ($disk == "raid"){
215                 $device = "md";
216               } else {
217                 $device = $disk;
219                 // Used by raid?
220                 if (isset($this->disks[$name]['partitions'])){
221                   foreach ($this->disks[$name]['partitions'] as $partition) {
222                     if (preg_match("/${disk}\.?[0-9]+/", $partition['FAIpartitionSize'])){
223                       $ignore = true;
224                       break 2;
225                     }
226                   }
227                 }
228               }
230               // Used by volgroup?
231               if (isset($this->disks[$name]["FAIlvmDevice"])){
232                 foreach ($this->disks[$name]["FAIlvmDevice"] as $vg_element) {
233                   if (preg_match("/^${device}\.?[0-9]+$/", $vg_element)){
234                     $ignore = true;
235                     break 2;
236                   }
237                 }
238               }
239             }
241             if ($ignore) {
242               msg_dialog::display(_("Error"), sprintf(_("The disk cannot be deleted while it is used in the '%s' disk definition!"), $name), ERROR_DIALOG);
243             } else {
244               if($this->disks[$disk]['status']=="edited"){
245                 $this->disks[$disk."-delete"]=$this->disks[$disk];
246                 unset($this->disks[$disk]);
247                 $disk = $disk."-delete";        
248                 $this->disks[$disk]['status']="delete";
249                 foreach($this->disks[$disk]['partitions'] as $name => $value ){
250                   if($value['status']=="edited"){
251                     $this->disks[$disk]['partitions'][$name]['status']="delete"; 
252                   }else{
253                     unset($this->disks[$disk]['partitions'][$name]);
254                   }
255                 }
256               }else{
257                 unset($this->disks[$disk]);
258               }
259             }
261           }
262         }
263         break;
264       }
265     }
267     if($Udisk){
268       $usedDiskNames =array();
269       if(isset($this->disks[$Udisk])){
271         foreach($this->disks  as $key=>$disk){
272           if($key != $Udisk){
273             $usedDiskNames[]= $key;
274           }
275         }
277         /* Set object info string, which will be displayed in plugin info line */ 
278         if(isset($this->disks[$Udisk]['dn'])){
279           set_object_info($this->disks[$Udisk]['dn']);
280           $dn = $this->disks[$Udisk]['dn'];
281         }else{
282           set_object_info("");
283           $dn = "new";
284         }
286         if ($this->FAIpartitionMethod == "setup-storage") {
287           $this->dialog = new faiDiskEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); 
288         } else {
289           $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); 
290         }
291         $this->dialog->set_acl_base($this->acl_base_for_current_object($dn));
292         $this->dialog->set_acl_category("fai");
293         $this->dialog->FAIstate = $this->FAIstate;
295         $this->is_dialog = true;
296       }
297     }
299     /* Edit aborted, close dialog, without saving anything
300      */
301     if(isset($_POST['CancelDisk'])){
302       unset($this->dialog);
303       $this->dialog = FALSE;
304       $this->is_dialog=false;
305     }
307     /* Dialog saved
308      * Save given data from Dialog, if no error is occurred
309      */
310     if(isset($_POST['SaveDisk'])){
312       if (!preg_match("/freeze/i", $this->FAIstate)){
313         $this->dialog->save_object();
314         if(count($this->dialog->check())){
315           foreach($this->dialog->check() as $msg){
316             msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
317           }
318         }else{
319           $disk = $this->dialog->save();
320           if(isset($disk['rename'])){
321             if($this->disks[$disk['rename']['from']]['status']=="edited"){
322               $this->disks[$disk['rename']['from']]['status']="delete";
323             }else{
324               unset($this->disks[$disk['rename']['from']]);
325             }
327             foreach($disk['partitions'] as $key => $val){
328               if($disk['partitions'][$key]['status']!="delete"){
329                 $disk['partitions'][$key]['status']= "new";
330               }
331             }
333             $disk['status']="new";
334             $disk['cn']= $disk['rename']['to'];
335           }
337           $this->disks[$disk['cn']]=$disk; 
338           unset($this->dialog);
339           $this->dialog = FALSE;
340           $this->is_dialog=false;
341           ksort($this->disks);
342         }
343       }else{
344         $this->dialog = FALSE;
345         $this->is_dialog=false;
346       }
347     }
349     /* Display dialog if one is defined
350      */
351     if(is_object($this->dialog)){
352       $this->dialog->save_object();
353       return($this->dialog->execute());
354     }
356     /* Assign all attributes to smarty engine
357      */
358     foreach($this->attributes as $attrs){
359       $smarty->assign($attrs,$this->$attrs);
360       if($this->$attrs){
361         $smarty->assign($attrs."CHK"," ");
362       }else{
363         $smarty->assign($attrs."CHK"," disabled ");
364       }
365     }
366    
367     $dn = $this->acl_base_for_current_object($this->dn);
368     $smarty->assign("sub_object_is_addable",
369         preg_match("/c/",$this->ui->get_permissions($dn,"fai/faiPartitionTableEntry")) &&
370         !preg_match("/freeze/",$this->FAIstate));
371     $smarty->assign("sub_object_is_removeable",
372         preg_match("/d/",$this->ui->get_permissions($dn,"fai/faiPartitionTableEntry")) &&
373         !preg_match("/freeze/",$this->FAIstate));
375     $tmp = $this->plInfo();
376     foreach($tmp['plProvidedAcls'] as $name => $translated){
377       $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/i",$this->FAIstate)));
378     }
380     /* Assign mode */
381     if ($this->FAIpartitionMethod == ""){
382       $smarty->assign("mode", "");
383       $smarty->assign("storage_mode", "disabled");
384     } else {
385       $smarty->assign("mode", "checked");
386       $smarty->assign("storage_mode", "");
387     }
388     if (!count($this->disks)) {
389       $smarty->assign("lockmode", "");
390     } else {
391       $smarty->assign("lockmode", "disabled");
392     }
393     if (isset($this->disks['raid'])){
394       $smarty->assign("addraid", "disabled");
395     } else {
396       $smarty->assign("addraid", "");
397     }
399     /* Divlist containing disks */
400     $divlist = new divSelectBox("FAItemplates");
401     $divlist->setHeight(400);
402     foreach($this->disks as $key => $disk){
403       $act = "";
405       $dn = "new";
406       if(isset($obj['dn'])){
407         $dn = $obj['dn'];
408       }
409       $dn = $this->acl_base_for_current_object($dn);
410       $acl = $this->ui->get_permissions($dn,"fai/faiPartitionTableEntry");
411       if(preg_match("/(r|w)/",$acl)) {
412         if($disk['status'] != "delete"){
414           $act .= "<input type='image' src='images/lists/edit.png'   name='edit_%s'    title='"._("edit")."' alt='"._("edit")."'>";
415           if(preg_match("/d/",$acl)){
416             $act .="<input type='image' src='images/lists/trash.png' name='delete_%s'  title='"._("delete")."' alt='"._("delete")."'>";
417           }
419           $cnt=0;
420           foreach($disk['partitions'] as $val){
421             if($val['status']!="delete"){
422               $cnt ++;
423             }
424           }
426           $edit_link = "<a href='?plug=".$_GET['plug']."&amp;act=edit&amp;id=".$key."'>".$key."</a>";
427           $types= array("old" => "plugins/fai/images/fai_partitionTable.png", "disk" => "plugins/fai/images/fai_partitionTable.png",
428                         "raid" => "plugins/fai/images/raid.png", "lvm" => "plugins/ogroups/images/list_ogroup.png");
429           $type = isset($disk['FAIdiskType'])?$types[$disk['FAIdiskType']]:$types['old'];
430           $divlist->AddEntry(array( 
431               array("string"=> "<img border='0' src='".$type."'>", "attach"=>"style='width:16px'"),
432               array("string"=> $edit_link, "attach"=>"style='width:100px'"),
433               array("string"=> $disk['description']),
434               array("string"=> $cnt,  "attach"=>"style='width:16px'"),
435               array("string"=>str_replace("%s",base64_encode($key),$act),
436                 "attach"=>"style='border-right: 0px;width:50px;text-align:right;'")));
437         }
438       }
439     }
440     $smarty->assign("Entry_divlist",$divlist->DrawList());
442     $display.= $smarty->fetch(get_template_path('faiPartitionTable.tpl', TRUE));
443     return($display);
444   }
448   /* Delete me, and all my subtrees
449    */
450   function remove_from_parent()
451   {
452     $ldap = $this->config->get_ldap_link();
453     $ldap->cd ($this->dn);
455     $release = $this->parent->parent->fai_release;
456     $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $this->dn);
458     FAI::prepare_to_save_FAI_object($use_dn,array(),true);
459     new log("remove","fai/".get_class($this),$use_dn,$this->attributes);   
460     foreach($this->disks as $disk){
461       $disk_dn = "cn=".$disk['cn'].",".$this->dn;
462       $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i",$release, $disk_dn);
463       FAI::prepare_to_save_FAI_object($use_dn,array(),true);
464       foreach($disk['partitions'] as $key => $partition){    
465         $partition_dn= "FAIpartitionNr=".$partition['FAIpartitionNr'].",".$disk_dn;      
466         $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $partition_dn);
467         FAI::prepare_to_save_FAI_object($use_dn,array(),true);
468       }
469     }
470   }
473   /* Save data to object 
474    */
475   function save_object()
476   {
477     if (preg_match("/freeze/", $this->FAIstate)) return;
478     plugin::save_object();
479     foreach($this->attributes as $attrs){
480       if(isset($_POST[$attrs])){
481         $this->$attrs = $_POST[$attrs];
482       }
483     }
484     if(isset($_POST['faiPartitionTable'])){
485       if(!count($this->disks)){
486         if(isset($_POST['mode'])){
487           $this->FAIpartitionMethod = "setup-storage";
488         }else{
489           $this->FAIpartitionMethod = "";
490         }
491       }
492     }
493   }
496   /* Check supplied data */
497   function check()
498   {
499     /* Call common method to give check the hook */
500     $message= plugin::check();
502     /* Ensure that we do not overwrite an allready existing entry 
503      */
504     if($this->is_new){
505       $release = $this->parent->parent->fai_release;
506       $new_dn= 'cn='.$this->cn.",".get_ou('faiPartitionRDN').get_ou('faiBaseRDN').$release;
507       $res = faiManagement::check_class_name("FAIpartitionTable",$this->cn,$new_dn);
508       if(isset($res[$this->cn])){
509         $message[] = msgPool::duplicated(_("Name"));
510       }
511     }
512     return ($message);
513   }
516   /* Save to LDAP */
517   function save()
518   {
520     plugin::save();
521     /* Save current settings.
522      * 1 : We must save the partition table, with its description and cn 
523      * 2 : Append Disk with cn and  description.
524      * 3 : Save partitions for each disk
525      */  
527     $ldap = $this->config->get_ldap_link();
529     FAI::prepare_to_save_FAI_object($this->dn,$this->attrs);
531     if($this->initially_was_account){
532       new log("modify","fai/".get_class($this),$this->dn,$this->attributes);
533     }else{
534       new log("create","fai/".get_class($this),$this->dn,$this->attributes);
535     }
536  
537     /* Sort entries, because we must delete entries with status="delete" first */
538     $order = array();
539     foreach($this->disks as $key => $disk){
540       if($disk['status'] == "delete"){
541         $order[$key] = $disk;
542       }
543     }
544     foreach($this->disks as $key => $disk){
545       if($disk['status'] != "delete"){
546         $order[$key] = $disk;
547       }
548     }
550     /* Append all disks to ldap */
551     foreach($order as $cn=>$disk){
552       $disk_dn                    = "cn=".$disk['cn'].",".$this->dn;
553       $disk_attrs['cn']           =  $disk['cn'];
554       $disk_attrs['description']  =  $disk['description'];
555   
556       if(isset($disk['FAIdiskType'])){
557         $disk_attrs['FAIdiskType']  =  $disk['FAIdiskType']; 
558       }
560       if(empty($disk_attrs['description']) && $disk['status'] == "edited"){
561         $disk_attrs['description'] = array();
562       }
564       $disk_attrs['objectClass']  =  array("top","FAIclass","FAIpartitionDisk");
566       if($disk['status']=="new"){
567         $ldap->cat($disk_dn,array("objectClass"));
568         if($ldap->count()){
569           $disk['status']="edited";
570         }
571       }
573       /* Tag object */
574       $this->tag_attrs($disk_attrs, $disk_dn, $this->gosaUnitTag);
576       if($disk['status'] == "delete"){
577         FAI::prepare_to_save_FAI_object($disk_dn,array(),true);
578         $this->handle_post_events("remove");
579       }elseif($disk['status'] == "edited"){
580         FAI::prepare_to_save_FAI_object($disk_dn,$disk_attrs);
581         $this->handle_post_events("modify");
582       }elseif($disk['status']=="new"){
583         FAI::prepare_to_save_FAI_object($disk_dn,$disk_attrs);
584         $this->handle_post_events("add");
585       }
587       if($disk['status']!="delete")
588       /* Add all partitions */
589       foreach($disk['partitions'] as $key => $partition){
590         $partition_attrs = array();
592         foreach($partition as $key => $value){
593           if(!empty($value)){
594             $partition_attrs[$key]=$value;        
595           }else{
596             unset($partition_attrs[$key]);        
597           }
598         }
600         $partition_dn= "FAIpartitionNr=".$partition_attrs['FAIpartitionNr'].",".$disk_dn;      
601         $partition_attrs['objectClass']= array("top","FAIclass","FAIpartitionEntry");
602         $partition_attrs['cn']= $partition_attrs['FAIpartitionNr'];
603         
604         unset($partition_attrs['status']);
605         unset($partition_attrs['old_cn']);
607         if($partition['status']=="new"){
608           $ldap->cat($partition_dn,array("objectClass"));
609           if($ldap->count()){
610             $partition['status']="edited";
611           }
612         }
614         if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){
615           $partition_attrs['FAImountPoint']="swap";
616         }
618         /* Tag object */
619         $this->tag_attrs($partition_attrs, $partition_dn, $this->gosaUnitTag);
621         if($partition['status'] == "delete"){
622           FAI::prepare_to_save_FAI_object($partition_dn,array(),true);
623           $this->handle_post_events("remove");
624         }elseif($partition['status'] == "edited"){
625           FAI::prepare_to_save_FAI_object($partition_dn,$partition_attrs);
626           $this->handle_post_events("modify");
627         }elseif($partition['status']=="new"){
628           FAI::prepare_to_save_FAI_object($partition_dn,$partition_attrs);
629           $this->handle_post_events("add");
630         }
631       }
632     }
633     $this->handle_post_events("add");
634   }
637   function PrepareForCopyPaste($source)
638   {
639     plugin::PrepareForCopyPaste($source);
641     /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
642      */
643     $res = FAI::get_all_objects_for_given_base($source['dn'],"(&(objectClass=FAIclass)(objectClass=FAIpartitionDisk))");
644     foreach($res as $obj){
646       /* Skip not relevant objects */
647       if(!preg_match("/".preg_quote($source['dn'], '/')."$/i",$obj['dn'])) continue;
649       $objects = array();
650       $objects['description']  = "";
651       $objects['status']      = "edited";
652       $objects['dn']          = $obj['dn'];
653       $objects                = $this->get_object_attributes($objects,$this->subAttributes);
654       $this->disks[$objects['cn']] = $objects;
655       $this->disks[$objects['cn']]['partitions'] = array();
656     }
658     /* read all partitions for each disk
659      */
660     foreach($this->disks as $name => $disk){
661       $res = FAI::get_all_objects_for_given_base($disk['dn'],"(&(objectClass=FAIclass)(objectClass=FAIpartitionEntry))");
662       foreach($res as $obj){
664         /* Skip not relevant objects */
665         if(!preg_match("/".preg_quote($disk['dn'], '/')."$/i",$obj['dn'])) continue;
667         $objects = array();
668         $objects['status']      = "edited";
669         $objects['dn']          = $obj['dn'];
670         $objects                = $this->get_object_attributes($objects,$this->subPartAttributes);
671         unset($objects['dn']);;
672         $this->disks[$name]['partitions'][$objects['FAIpartitionNr']] = $objects;
673       }
674     }
675     ksort($this->disks);
676   }
679   /* Return plugin informations for acl handling */ 
680   static function plInfo()
681   {
682     return (array( 
683           "plShortName" => _("Partition table"),
684           "plDescription" => _("FAI partition table"),
685           "plSelfModify"  => FALSE,
686           "plDepends"     => array(),
687           "plPriority"    => 26,
688           "plSection"     => array("administration"),
689           "plCategory"    => array("fai"),
690           "plProvidedAcls" => array(
691             "cn"                => _("Name")."&nbsp;("._("Read only").")",
692             "description"       => _("Description"))
693           ));
694   }
697   /*! \brief  Used for copy & paste.
698     Returns a HTML input mask, which allows to change the cn of this entry.
699     @param  Array   Array containing current status && a HTML template.
700    */
701   function getCopyDialog()
702   {
703     $vars = array("cn");
704     $smarty = get_smarty();
705     $smarty->assign("cn", htmlentities($this->cn));
706     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
707     $ret = array();
708     $ret['string'] = $str;
709     $ret['status'] = "";
710     return($ret);
711   }
714   /*! \brief  Used for copy & paste.
715     Some entries must be renamed to avaoid duplicate entries.
716    */
717   function saveCopyDialog()
718   {
719     if(isset($_POST['cn'])){
720       $this->cn = get_post('cn');
721     }
722   }
724   /* Reload some attributes */
725   function get_object_attributes($object,$attributes)
726   {
727     $ldap = $this->config->get_ldap_link();
728     $ldap->cd($this->config->current['BASE']);
729     $ldap->cat($object['dn'],$attributes);
730     $tmp  = $ldap->fetch();
732     foreach($attributes as $attrs){
733       if(isset($tmp[$attrs][0])){
734         $var = $tmp[$attrs][0];
736         /* Check if we must decode some attributes */
737         if(in_array_ics($attrs,$this->sub64coded)){
738           $var = base64_decode($var);
739         }
741         /*  check if this is a binary entry */
742         if(in_array_ics($attrs,$this->subBinary)){
743           $var = $ldap->get_attribute($object['dn'], $attrs,$r_array=0);
744         }
746         /* Fix slashes */
747         $var = addslashes($var);
748         $object[$attrs] = $var;
749       }
750     }
751     return($object);
752   }
756 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
757 ?>