Code

Updated FAI package
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiPackage.inc
1 <?php
3 class faiPackage extends plugin
4 {
5   /* attribute list for save action */
6   var $ignore_account   = TRUE;
8   /* Attributes for this Object */
9   var $attributes       = array("cn","description","FAIpackage","FAIdebianRelease","FAIdebianSection", "FAIinstallMethod");
11   /* ObjectClasses for this Object*/
12   var $objectclasses    = array("top","FAIclass","FAIpackageList","FAIrepository");
14   /* Class name of the Ldap ObjectClass for the Sub Object */
15   var $subClass         = "";
16   var $subClasses       = array("top","FAIclass","FAIscriptEntry");
18   /* Class name of the php class which allows us to edit a Sub Object */
19   var $subClassName     = "";      
21   /* Attributes to initialise for each subObject */
22   var $subAttributes    = array("cn","description"); 
23   var $sub64coded       = array();
25   var $ConfiguredPackages = array();
27   /* Specific attributes */
28   var $cn               = "";       // The class name for this object
29   var $description      = "";       // The description for this set of partitions
30   var $is_dialog        = false;    // specifies which buttons will be shown to save or abort
31   var $SubObjects       = array();  // All leafobjects of this object
33   var $FAIdebianRelease          = ""; // The selected release
34   var $FAIdebianSection          = array(); // selected section
35   var $FAIinstallMethod          = "aptitude"; // hard coded
37   var $sections         = array();  // All section types
39   var $list             = NULL;
41   var $usedPackages     = array();
42   var $buffer           = NULL; 
43   var $newDialogShown   =false;
45   var $FAIstate         = "";
46   var $view_logged      = FALSE;
47   var $base;
48   var $FAIpackage ;
50   var $FAIinstallMethods  = array( "install", "ninstall", "remove", 
51       "dselect-upgrade", "taskinst", "taskrm",
52       "hold", "clean", "aptitude", "aptitude-r",
53       "pending", "dpkgc" );
56   function faiPackage (&$config, $dn= NULL)
57   {
58     /* Load Attributes */
59     plugin::plugin ($config, $dn);
61     /* If "dn==new" we try to create a new entry
62      * Else we must read all objects from ldap which belong to this entry.
63      * First read SubObjects from ldap ... and then the partition definitions for the SubObjects.
64      */
65     if($dn != "new"){
66       $this->dn =$dn;
68       /* Check if there are already some packages in this list 
69        */
70       $this->usedPackages = array();
71       if(isset($this->attrs['FAIpackage'])){
72         unset($this->attrs['FAIpackage']['count']);
73         foreach($this->attrs['FAIpackage'] as $pkg){
74           $name = preg_replace("/\-$/","",$pkg);
75           $this->usedPackages[$name] = $pkg;
76         }
77         ksort($this->usedPackages);
78       }  
80       /* Fetch all package configurations from ldap 
81        */
82       $PackageFilter = "";
83       foreach($this->usedPackages as $name => $value){
84         $PackageFilter .= "(FAIpackage=".$name.")";
85       }
86       $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
88       /* Search for configuration objects */ 
89       $ldap = $this->config->get_ldap_link();
90       $ldap->cd($this->dn);
91       $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType",
92             "FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
94       /* Walk through configurations and append them to our list of ConfiguredPackages 
95        */
96       while($attr = $ldap->fetch()){
98         /* Skip objects, that are tagged as removed */
99         if(isset($object['FAIstate'][0])){
100           if(preg_match("/removed$/",$attr['FAIstate'][0])){
101             continue;
102           }
103         }
105         $tmp =array(); 
106         $tmp['Name']  = $attr['FAIvariable'][0];
107         $tmp['Type']  = $attr['FAIvariableType'][0];
109         if (isset($attr['FAIvariableContent'][0])){
110           if(!in_array($attr['FAIvariableType'],array("multiselect"))){
111             $tmp['Value'] = $attr['FAIvariableContent'][0];
112           }else{
113             $content = array();        
114             unset($attr['FAIvariableContent']['count']);
115             foreach($attr['FAIvariableContent'] as $attr){
116               $tmp['Value'][] = $attr;
117             }
118           }
119           $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
120         }
121       }
123       $this->FAIdebianSection = array();
124       if(isset($this->attrs['FAIdebianSection'])){
125         for($i = 0 ; $i < $this->attrs['FAIdebianSection']['count'] ; $i++ ){ 
126           $sec = $this->attrs['FAIdebianSection'][$i];
127           $this->FAIdebianSection[$sec]=$sec;
128         }
129       }
130       $this->FAIpackage = array();
132     } // ENDE  dn != new  
134     $methods = array();
135     foreach($this->FAIinstallMethods as $method){
136       $methods[$method] = $method;
137     }
138     $this->FAIinstallMethods = $methods;
140     /* Check if we exist already - no need to ask for revisions, etc. then */
141     if ($this->dn != "new"){
142       $this->newDialogShown= true;
143     }
144     $this->is_new = FALSE;
145     if($this->dn == "new"){
146       $this->is_new =TRUE;
147     }
149     /* Generate package list */
150     $this->list= $this->genPkgs(TRUE);
151   }
154   function execute()
155   {
156     /* Call parent execute */
157     plugin::execute();
159     if($this->is_account && !$this->view_logged){
160       $this->view_logged = TRUE;
161       new log("view","fai/".get_class($this),$this->dn);
162     }
164     /* Fill templating stuff */
165     $smarty= get_smarty();
166     $display= "";
168     /******
169      * Initialize a new Package List with release and section name
170      ******/
171     
172     if(!$this->is_account){
174       /* Assemble release name */
175       $release = $this->parent->parent->fai_release;
176       $tmp= preg_replace('/[,]*'.normalizePreg(get_ou('faiou')).'.*$/', '', $release);
177       $tmp= preg_replace('/ou=/', '', $tmp);
178       $rev= array_reverse(split(',', $tmp));
179       $this->FAIdebianRelease= "/";
180       foreach ($rev as $part){
181         $this->FAIdebianRelease.= "/$part";
182       }
183       $this->FAIdebianRelease= preg_replace('#^[/]*#', '', $this->FAIdebianRelease);
185       /* Assemble sections */
186       $repos= $this->getServerInfos();
187       if(isset($repos[$this->FAIdebianRelease])){
188         $this->FAIdebianSection= $repos[$this->FAIdebianRelease];
189         $this->FAIdebianSection= array_unique($this->FAIdebianSection);
190       }
192       /* Assign Repository settings*/ 
193       $this->is_account     = true;
194     }
195   
197     /******
198      * Add 
199      ******/
201     /* + was pressed to open the package dialog */
202     if(isset($_POST['Addpkg']) && $this->acl_is_writeable("FAIpackage") && !preg_match("/freeze/",$this->FAIstate)){
203       $this->dialog = new faiPackageEntry($this->config, $this->FAIdebianRelease,$this->usedPackages);
204       $this->is_dialog =true;
205     }
207     /* Check image Posts 
208      */
209     foreach($_POST as $name => $value){
211       /******
212        * Mark as removed  
213        ******/
214       
215       if(!preg_match('/freeze/i', $this->FAIstate) && preg_match("/^removal_package_/",$name)){
216         $id = @base64_decode(preg_replace("/^removal_package_(.*)_[xy]*$/","\\1",$name));
217         if(isset($this->usedPackages[$id])){
218           $pkg = $this->usedPackages[$id]; 
219           if (preg_match('/\-$/', $pkg)){
220             $pkg= preg_replace('/\-$/', '', $pkg);
221           } else {
222             $pkg= preg_replace('/$/', '-', $pkg);
223           }
224           $this->usedPackages[$id] = $pkg;
225         }
226         break;
227       }
229       /******
230        * Delete Pkgs   
231        ******/
232       if(!preg_match('/freeze/i', $this->FAIstate) && preg_match("/^remove_package_/",$name)){
233         $id = @base64_decode(preg_replace("/^remove_package_(.*)_[xy]*$/","\\1",$name));
234         if(isset($this->usedPackages[$id])){
235           unset($this->usedPackages[$id]);
236         }
237         break;
238       }
240       /******
241        * Configure Pkgs   
242        ******/
243       if(!preg_match('/freeze/i', $this->FAIstate) && preg_match("/^configure_package_/",$name)){
244         $pkg = @base64_decode(preg_replace("/^configure_package_(.*)_[xy]*$/","\\1",$name));
245          
246         if(isset($this->usedPackages[$pkg])){
248           /* Configuration dialog open*/
249           $pkg_config = array();
250           if(isset($this->ConfiguredPackages[$pkg])){
251             $pkg_config = $this->ConfiguredPackages[$pkg];
252           }
253           $this->dialog = new faiPackageConfiguration($this->config, $this->dn,$pkg, $this->FAIdebianRelease , $pkg_config);
254           $this->is_dialog =true;
255         }
256         break;
257       }
258     }
260     /* Abort package selection dialog */ 
261     if(isset($_POST['CancelSubObject'])){
262       $this->dialog = false;
263       $this->is_dialog=false;
264     }
266     /* attach new packages */
267     if(isset($_POST['SaveSubObject'])) {
268       if(!preg_match("/freeze/i", $this->FAIstate)){
269         $this->dialog->save_object();
270         if(count($this->dialog->check())){
271           foreach($this->dialog->check() as $msgs){
272             msg_dialog::display(_("Error"), $msgs, ERROR_DIALOG);
273           }
274         }else{
275           $use = $this->dialog->save();
276           $this->usedPackages = $use;
277           $this->dialog = false;
278           $this->is_dialog=false;
279           ksort($this->usedPackages);
281           /* Generate package list */
282           $this->list= $this->genPkgs(TRUE);
283         }
284       }else{
285         $this->dialog = false;
286         $this->is_dialog=false;
287       }
288     }
290     /* Save Configuration */
291     if(isset($_POST['SaveObjectConfig'])){
292       if(!preg_match("/^freeze/", $this->FAIstate)){
293         $this->ConfiguredPackages= array_merge($this->ConfiguredPackages,$this->dialog->save());
294       }
295       $this->dialog = false;
296       $this->is_dialog=false;
297     }
299     /* cancel configuration */     
300     if(isset($_POST['CancelObjectConfig'])){
301       $this->dialog = false;
302       $this->is_dialog=false;
303     }
305     /* Display dialog */ 
306     if($this->is_dialog){
307       $this->dialog->save_object();
308       return $this->dialog->execute();
309     }
312     /******
313      * Display UI / HTML / smarty 
314      ******/
316     /* Create divlist to display a list of all currently used packages
317      */
318     $divlist = new divSelectBox("faiPackages");
320     ksort($this->usedPackages);
321     if(is_array($this->usedPackages)){
322       foreach($this->usedPackages as $usedName => $name){
323     
324         $actions = "";
326         /* Append message if package is configured */
327         $configured = "<img src='images/empty.png' alt=' '  class='center'>";
328         if(isset($this->ConfiguredPackages[$usedName])){
329           $configured = "<img src='images/package_configure.png' alt='"._("Configured")."'
330                       title='"._("Configured")."' class='center'>";
331         }
333         /* Adapt used name if we're marked for removal */
334         $removal = "<img src='images/empty.png' alt=' '  class='center'>";
335         if (preg_match('/\-$/', $name)){
336           $removal = "<img src='images/negate.png' alt='"._("Package marked for removal")."'
337                       title='"._("Package marked for removal")."' class='center'>";
338         }
340         /* Get Version */
341         $version = "&nbsp;";
342         if(isset($this->list[$usedName]['VERSION'])){
343           $version = $this->list[$usedName]['VERSION'];
344         }
345     
346         /* Get description */
347         $description = "&nbsp;";
348         if(isset($this->list[$usedName]['DESCRIPTION'])){
349           $description = base64_decode($this->list[$usedName]['DESCRIPTION']);
350         }
351  
352         if(!preg_match('/^freeze/', $this->FAIstate) && $this->acl_is_writeable("FAIpackage")){
353           $actions = "<input type='image' class='center' title='"._("Mark package for removal")."' 
354             src='images/negate.png' name='removal_package_".base64_encode($usedName)."' >";
355         }
356         if(!preg_match('/^freeze/', $this->FAIstate) && $this->acl_is_writeable("FAIdebconfInfo")){
357           $actions.= "&nbsp;<input type='image' class='center' title='"._("Configure this package")."' 
358             src='images/package_configure.png' name='configure_package_".base64_encode($usedName)."' >";
359         }
360         if(!preg_match('/^freeze/', $this->FAIstate) && $this->acl_is_writeable("FAIpackage")){
361           $actions.= "&nbsp;<input type='image' class='center' title='"._("Remove this package")."' 
362             src='images/lists/trash.png' name='remove_package_".base64_encode($usedName)."' >";
363         }
365         $field1 = array("string" => $configured."&nbsp;".$removal,"attach" => "style='width:40px;'");
366         $field2 = array("string" => $usedName ,"attach" => "style='width:200px;'");
367         $field3 = array("string" => $version);
368         $field4 = array("string" => $description);
369         $field5 = array("string" => $actions ,"attach" => "style='width:60px; border-right:0px;'");
370         $divlist->AddEntry(array($field1,$field2,$field3,$field4,$field5));
371       }
372     }
374     /* Assign variables */
375     foreach($this->attributes as $attrs){
376       $smarty->assign($attrs,$this->$attrs);
377     }
378     $smarty->assign( "FAIinstallMethods", $this->FAIinstallMethods );
380     /* Assign section to smarty */
381     $strsec = "";
382     foreach($this->FAIdebianSection as $sec){
383       $strsec .= $sec." ";
384     }
386     $tmp = $this->plInfo();
387     foreach($tmp['plProvidedAcls'] as $name => $translated){
388       $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/",$this->FAIstate)));
389     }
390  
391     $smarty->assign("freeze", preg_match("/freeze/",$this->FAIstate));
392     $smarty->assign("divlist",$divlist->DrawList());
393     $smarty->assign("release" ,$this->FAIdebianRelease);
394     $smarty->assign("sections",$this->sections);
395     $smarty->assign("section" ,$strsec);
396     $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
397     return($display);
398   }
401   /*! \brief  Removes this packageList from the ldap database 
402    */
403   function remove_from_parent()
404   {
405     $ldap = $this->config->get_ldap_link();
406     $ldap->cd ($this->dn);
407     $release = $this->parent->parent->fai_release;
408     $use_dn = preg_replace("/".normalizePreg(FAI::get_release_dn($this->dn))."/i", $release, $this->dn);
409     FAI::prepare_to_save_FAI_object($use_dn,array(),true);
410     new log("remove","fai/".get_class($this),$use_dn,$this->attributes);
411     foreach($this->ConfiguredPackages as $pkgname => $attrs){
412       foreach($attrs as $name => $attr){
413         $pkgdn =  "FAIvariable=".$name.",".$this->dn;
414         $use_dn = preg_replace("/".normalizePreg(FAI::get_release_dn($this->dn))."/i", $release, $pkgdn);
415         FAI::prepare_to_save_FAI_object($use_dn,array(),true);
416       }
417     }
418     $this->handle_post_events("remove");
419   }
422   /*! \brief  Collect all relevant POST vars for this plugin 
423    */
424   function save_object()
425   {
426     if(preg_match("/^freeze/", $this->FAIstate)) return;
427     plugin::save_object();
428   }
431   /*! \brief  Check given inputs for this package list
432       @return Array Containing all error messages, or an empty array if no error occured
433    */
434   function check()
435   {
436     /* Call common method to give check the hook */
437     $message= plugin::check();
439     if(count($this->usedPackages)==0){
440       $message[]= _("Please select a least one package!");
441     }
443     if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))){
444       $message[]=_("Please choose a valid release/section combination for your repository setup!");
445     }
447     /* Ensure that we do not overwrite an allready existing entry 
448      */
449     if($this->is_new){
450       $release = $this->parent->parent->fai_release;
451       $new_dn= 'cn='.$this->cn.",".get_ou('faipackageou').get_ou('faiou').$release;
452       $res = faiManagement::check_class_name("FAIpackageList",$this->cn,$new_dn);
453       if(isset($res[$this->cn])){
454         $message[] = msgPool::duplicated(_("Name"));
455       }
456     }
457     return ($message);
458   }
461   /*! \brief  Reload the list of cached packages.
462       @return Returns the currently cached list of packages. 
463    */
464   function genPkgs($force = false)
465   {
466     if(!count($this->buffer) || $force){
467       $q = new gosaSupportDaemon();
468       $attrs = array("distribution", "package","version", "section", "description", "timestamp");
470       $packages = array_keys($this->usedPackages);
472       $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs,$packages);
473       if($q->is_error()){
474         msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
475       }else{
476         foreach($ret as $attr){
477           $this->buffer[$attr['PACKAGE']] = $attr;
478         }
479       }
480     }
481     return $this->buffer;
482   }
485   /*! \brief Save packages and their configuration to ldap 
486    */
487   function save()
488   {
490     /* Assemble release name */
491     if($this->FAIdebianRelease == "ClearFromCopyPaste"){
493       $current_release  = $this->parent->parent->fai_release;
494       $tmp= preg_replace('/,'.normalizePreg(get_ou('faiou')).'.*$/', '', $current_release);
495       $tmp= preg_replace('/ou=/', '', $tmp);
496       $rev= array_reverse(split(',', $tmp));
497       $this->FAIdebianRelease= "";
498       foreach ($rev as $part){
499         $this->FAIdebianRelease.= "/$part";
500       }
501       $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease);
502     }
504     plugin::save();
506     $ldap = $this->config->get_ldap_link();
508     $this->attrs['FAIpackage'] = array();
509     foreach($this->usedPackages as $pkg){
510       $this->attrs['FAIpackage'][] = $pkg;
511     } 
513     $this->attrs['FAIdebianSection'] = array();
514     foreach($this->FAIdebianSection as $sec){
515       $this->attrs['FAIdebianSection'][] = $sec;
516     }
518     FAI::prepare_to_save_FAI_object($this->dn,$this->attrs);
519     
520     if($this->initially_was_account){
521       new log("modify","fai/".get_class($this),$this->dn,$this->attributes);
522     }else{
523       new log("create","fai/".get_class($this),$this->dn,$this->attributes);
524     }
526     $ldap->cd($this->dn);
528     /* Save Package configurations */
529     foreach($this->ConfiguredPackages as $pkgname => $attrs){
530       foreach($attrs as $name => $attr){
531       
532         $pkgattrs = array();
534         foreach($attr as $n=>$v){
535           if(empty($v)) $v = array();
536         }
538         /* Set attributes */
539         $pkgattrs['objectClass'][]        = "FAIdebconfInfo";
541         $pkgattrs['FAIpackage']           = $pkgname;
542         $pkgattrs['FAIvariable']          = $name;
543         $pkgattrs['FAIvariableType']      = $attr['Type'];
544         $pkgattrs['FAIvariableContent']   = $attr['Value'];
545         $pkgdn =  "FAIvariable=".$name.",".$this->dn;
547         /* Tag object */
548         $this->tag_attrs($pkgattrs, $pkgdn, $this->gosaUnitTag);
550         if(in_array($pkgattrs['FAIvariableType'],array("boolean","multiselect","password","select","string","text"))){
552           if($pkgattrs['FAIvariableType'] == "text" && $pkgattrs['FAIvariableContent'] == ""){
553             gosa_log("Skipped saving FAIvariable '$name' empty string can't be saved.");
554           }else{
555             FAI::prepare_to_save_FAI_object($pkgdn,$pkgattrs);
556           }
557         }
558       }
559     }
560   }
563   /*! \brief  Return plugin informations for acl handling 
564       @return Array ACL infos of this plugin.
565    */ 
566   static function plInfo()
567   {
568     return (array( 
569           "plShortName" => _("Package"),
570           "plDescription" => _("FAI Package list"),
571           "plSelfModify"  => FALSE,
572           "plDepends"     => array(),
573           "plPriority"    => 28,
574           "plSection"     => array("administration"),
575           "plCategory"    => array("fai"),
576           "plProvidedAcls" => array(
577             "cn"                => _("Name"),
578             "description"       => _("Description"),
579             "FAIpackage"        => _("Packages"),
580             "FAIdebianSection"  => _("Section")."&nbsp;("._("Readonly").")",
581             "FAIinstallMethod"  => _("Install Method"),
582             "FAIdebconfInfo"    => _("Package configuration"),
583             "FAIdebianRelease"  => _("Release")."&nbsp;("._("Readonly").")")
584           ));
585   }
588   /*! \brief prepares this plugin to be inserted after it was copied or cut.
589       @param Array  All attributes from the source object. 
590    */
591   function PrepareForCopyPaste($source)
592   {
593     plugin::PrepareForCopyPaste($source);
595     if(isset($source['FAIstate'][0])){
596       $this->FAIstate = $source['FAIstate'][0];
597     }
599     $this->FAIdebianRelease = "ClearFromCopyPaste";
601     if(isset($source['FAIpackage'])){
602       unset($source['FAIpackage']['count']);
603       foreach($source['FAIpackage'] as $pkg){
604         $this->usedPackages[$pkg] = $pkg;
605       }
606       ksort($this->usedPackages);
607     }else{
608       $this->usedPackages = array();
609     }
611     if((isset($source['FAIdebianSection']))&&(is_array($source['FAIdebianSection']))){
612       $this->FAIdebianSection = array();
613       for($i = 0 ; $i < $source['FAIdebianSection']['count'] ; $i ++){
614         $this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i];
615       }
616     }
618     /* Create one filter with all package names, 
619        instead of calling $ldap->search for every single package 
620      */
621     $PackageFilter = "";
622     foreach($this->usedPackages as $name){
623       $PackageFilter .= "(FAIpackage=".$name.")";
624     }
625     $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
627     /* Search for configuration objects */ 
628     $ldap = $this->config->get_ldap_link();
629     $ldap->cd($source['dn']);
630     $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
632     /* Walk through configurations and append them to our list of ConfiguredPackages */
633     while($attr = $ldap->fetch()){
635       /* Skip objects, that are tagged as removed */
636       if(isset($object['FAIstate'][0])){
637         if(preg_match("/removed$/",$attr['FAIstate'][0])){
638           continue;
639         }
640       }
642       $tmp =array(); 
643       $tmp['Name']  = $attr['FAIvariable'][0];
644       $tmp['Type']  = $attr['FAIvariableType'][0];
646       if (isset($attr['FAIvariableContent'][0])){
647         if(!in_array($attr['FAIvariableType'],array("multiselect"))){
648           $tmp['Value'] = $attr['FAIvariableContent'][0];
649         }else{
650           $content = array();        
651           unset($attr['FAIvariableContent']['count']);
652           foreach($attr['FAIvariableContent'] as $attr){
653             $tmp['Value'][] = $attr;
654           }
655         }
656         $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
657       }
658     }
659   }
662   /*! \brief  Returns a list of all configured servers with repositories.
663       @return Array  All repository server 
664    */
665   function getServerInfos()
666   {
667     $ret = array();
668     $ldap = $this->config->get_ldap_link();
669     $ldap->cd($this->config->current['BASE']);
670     $ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
671     while($attrs = $ldap->fetch()){
672       if(isset($attrs['FAIrepository'])){
673         for($i =0 ; $i < $attrs['FAIrepository']['count']; $i++){
674           $obj = $attrs['FAIrepository'][$i];
675           $tmp = split("\|",$obj);
676           if(count($tmp)==4){
677             foreach(split(",",$tmp[3]) as $sec){
678               if(!empty($sec)){
679                 $ret[$tmp[2]][] =  $sec;
680               }
681             }
682           }
683         }
684       }
685     }
686     return($ret);
687   }
690   /*! \brief  Used for copy & paste.
691     Returns a HTML input mask, which allows to change the cn of this entry.
692     @param  Array   Array containing current status && a HTML template.
693    */
694   function getCopyDialog()
695   {
696     $vars = array("cn");
697     $smarty = get_smarty();
698     $smarty->assign("cn", htmlentities($this->cn));
699     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
700     $ret = array();
701     $ret['string'] = $str;
702     $ret['status'] = "";
703     return($ret);
704   }
707   /*! \brief  Used for copy & paste.
708     Some entries must be renamed to avaoid duplicate entries.
709    */
710   function saveCopyDialog()
711   {
712     if(isset($_POST['cn'])){
713       $this->cn = get_post('cn');
714     }
715   }
718 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
719 ?>