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 ******/
172 if(!$this->is_account){
174 /* Assemble release name */
175 $release = $this->parent->parent->fai_release;
176 $tmp= preg_replace('/[,]*'.preg_quote(get_ou('faiBaseRDN'), '/').'.*$/', '', $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 }
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 ******/
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));
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){
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='plugins/fai/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='plugins/fai/images/removal_mark.png' alt='"._("Package marked for removal")."'
337 title='"._("Package marked for removal")."' class='center'>";
338 }
340 /* Get Version */
341 $version = " ";
342 if(isset($this->list[$usedName]['VERSION'])){
343 $version = $this->list[$usedName]['VERSION'];
344 }
346 /* Get description */
347 $description = " ";
348 if(isset($this->list[$usedName]['DESCRIPTION'])){
349 $description = base64_decode($this->list[$usedName]['DESCRIPTION']);
350 }
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='plugins/fai/images/removal_mark.png' name='removal_package_".base64_encode($usedName)."' >";
355 }
357 if(isset($this->list[$usedName]['TEMPLATE']) &&
358 !preg_match('/^freeze/', $this->FAIstate) && $this->acl_is_writeable("FAIdebconfInfo")){
359 $actions.= " <input type='image' class='center' title='"._("Configure this package")."'
360 src='plugins/fai/images/package_configure.png' name='configure_package_".base64_encode($usedName)."' >";
361 }
362 if(!preg_match('/^freeze/', $this->FAIstate) && $this->acl_is_writeable("FAIpackage")){
363 $actions.= " <input type='image' class='center' title='"._("Remove this package")."'
364 src='images/lists/trash.png' name='remove_package_".base64_encode($usedName)."' >";
365 }
367 $field1 = array("string" => $configured." ".$removal,"attach" => "style='width:40px;'");
368 $field2 = array("string" => $usedName ,"attach" => "style='width:200px;'");
369 $field3 = array("string" => $version);
370 $field4 = array("string" => $description);
371 $field5 = array("string" => $actions ,"attach" => "style='width:60px; border-right:0px;'");
372 $divlist->AddEntry(array($field1,$field2,$field3,$field4,$field5));
373 }
374 }
376 /* Assign variables */
377 foreach($this->attributes as $attrs){
378 $smarty->assign($attrs,$this->$attrs);
379 }
380 $smarty->assign( "FAIinstallMethods", $this->FAIinstallMethods );
382 /* Assign section to smarty */
383 $strsec = "";
384 foreach($this->FAIdebianSection as $sec){
385 $strsec .= $sec." ";
386 }
388 $tmp = $this->plInfo();
389 foreach($tmp['plProvidedAcls'] as $name => $translated){
390 $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/",$this->FAIstate)));
391 }
393 $smarty->assign("freeze", preg_match("/freeze/",$this->FAIstate));
394 $smarty->assign("divlist",$divlist->DrawList());
395 $smarty->assign("release" ,$this->FAIdebianRelease);
396 $smarty->assign("sections",$this->sections);
397 $smarty->assign("section" ,$strsec);
398 $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
399 return($display);
400 }
403 /*! \brief Removes this packageList from the ldap database
404 */
405 function remove_from_parent()
406 {
407 $ldap = $this->config->get_ldap_link();
408 $ldap->cd ($this->dn);
409 $release = $this->parent->parent->fai_release;
410 $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $this->dn);
411 FAI::prepare_to_save_FAI_object($use_dn,array(),true);
412 new log("remove","fai/".get_class($this),$use_dn,$this->attributes);
413 foreach($this->ConfiguredPackages as $pkgname => $attrs){
414 foreach($attrs as $name => $attr){
415 $pkgdn = "FAIvariable=".$name.",".$this->dn;
416 $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $pkgdn);
417 FAI::prepare_to_save_FAI_object($use_dn,array(),true);
418 }
419 }
420 $this->handle_post_events("remove");
421 }
424 /*! \brief Collect all relevant POST vars for this plugin
425 */
426 function save_object()
427 {
428 if(preg_match("/^freeze/", $this->FAIstate)) return;
429 plugin::save_object();
430 }
433 /*! \brief Check given inputs for this package list
434 @return Array Containing all error messages, or an empty array if no error occured
435 */
436 function check()
437 {
438 /* Call common method to give check the hook */
439 $message= plugin::check();
441 if(count($this->usedPackages)==0){
442 $message[]= _("Please select a least one package!");
443 }
445 if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))){
446 $message[]=_("Please choose a valid release/section combination for your repository setup!");
447 }
449 /* Ensure that we do not overwrite an allready existing entry
450 */
451 if($this->is_new){
452 $release = $this->parent->parent->fai_release;
453 $new_dn= 'cn='.$this->cn.",".get_ou('faiPackageRDN').get_ou('faiBaseRDN').$release;
454 $res = faiManagement::check_class_name("FAIpackageList",$this->cn,$new_dn);
455 if(isset($res[$this->cn])){
456 $message[] = msgPool::duplicated(_("Name"));
457 }
458 }
459 return ($message);
460 }
463 /*! \brief Reload the list of cached packages.
464 @return Returns the currently cached list of packages.
465 */
466 function genPkgs($force = false)
467 {
468 if(empty($this->FAIdebianRelease)) return;
470 if(!count($this->buffer) || $force){
471 $q = new gosaSupportDaemon();
472 $attrs = array("distribution", "package","version", "section", "description", "timestamp","template");
474 $packages = array_keys($this->usedPackages);
476 $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs,$packages);
477 if($q->is_error()){
478 msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
479 }else{
480 foreach($ret as $attr){
481 $this->buffer[$attr['PACKAGE']] = $attr;
482 }
483 }
484 }
485 return $this->buffer;
486 }
489 /*! \brief Save packages and their configuration to ldap
490 */
491 function save()
492 {
494 /* Assemble release name */
495 if($this->FAIdebianRelease == "ClearFromCopyPaste"){
497 $current_release = $this->parent->parent->fai_release;
498 $tmp= preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'.*$/', '', $current_release);
499 $tmp= preg_replace('/ou=/', '', $tmp);
500 $rev= array_reverse(split(',', $tmp));
501 $this->FAIdebianRelease= "";
502 foreach ($rev as $part){
503 $this->FAIdebianRelease.= "/$part";
504 }
505 $this->FAIdebianRelease= preg_replace('#^/#', '', $this->FAIdebianRelease);
506 }
508 plugin::save();
510 $ldap = $this->config->get_ldap_link();
512 $this->attrs['FAIpackage'] = array();
513 foreach($this->usedPackages as $pkg){
514 $this->attrs['FAIpackage'][] = $pkg;
515 }
517 $this->attrs['FAIdebianSection'] = array();
518 foreach($this->FAIdebianSection as $sec){
519 $this->attrs['FAIdebianSection'][] = $sec;
520 }
522 FAI::prepare_to_save_FAI_object($this->dn,$this->attrs);
524 if($this->initially_was_account){
525 new log("modify","fai/".get_class($this),$this->dn,$this->attributes);
526 }else{
527 new log("create","fai/".get_class($this),$this->dn,$this->attributes);
528 }
530 $ldap->cd($this->dn);
532 /* Save Package configurations */
533 foreach($this->ConfiguredPackages as $pkgname => $attrs){
534 foreach($attrs as $name => $attr){
536 $pkgattrs = array();
538 foreach($attr as $n=>$v){
539 if(empty($v)) $v = array();
540 }
542 /* Set attributes */
543 $pkgattrs['objectClass'][] = "FAIdebconfInfo";
545 $pkgattrs['FAIpackage'] = $pkgname;
546 $pkgattrs['FAIvariable'] = $name;
547 $pkgattrs['FAIvariableType'] = $attr['Type'];
548 $pkgattrs['FAIvariableContent'] = $attr['Value'];
549 $pkgdn = "FAIvariable=".$name.",".$this->dn;
551 /* Tag object */
552 $ui= get_userinfo();
553 $this->tag_attrs($pkgattrs, $pkgdn, $ui->gosaUnitTag);
555 if(in_array($pkgattrs['FAIvariableType'],array("boolean","multiselect","password","select","string","text"))){
557 if($pkgattrs['FAIvariableType'] == "text" && $pkgattrs['FAIvariableContent'] == ""){
558 gosa_log("Skipped saving FAIvariable '$name' empty string can't be saved.");
559 }else{
560 FAI::prepare_to_save_FAI_object($pkgdn,$pkgattrs);
561 }
562 }
563 }
564 }
565 }
568 /*! \brief Return plugin informations for acl handling
569 @return Array ACL infos of this plugin.
570 */
571 static function plInfo()
572 {
573 return (array(
574 "plShortName" => _("Package"),
575 "plDescription" => _("FAI Package list"),
576 "plSelfModify" => FALSE,
577 "plDepends" => array(),
578 "plPriority" => 28,
579 "plSection" => array("administration"),
580 "plCategory" => array("fai"),
581 "plProvidedAcls" => array(
582 "cn" => _("Name"),
583 "description" => _("Description"),
584 "FAIpackage" => _("Packages"),
585 "FAIdebianSection" => _("Section")." ("._("Readonly").")",
586 "FAIinstallMethod" => _("Install Method"),
587 "FAIdebconfInfo" => _("Package configuration"),
588 "FAIdebianRelease" => _("Release")." ("._("Readonly").")")
589 ));
590 }
593 /*! \brief prepares this plugin to be inserted after it was copied or cut.
594 @param Array All attributes from the source object.
595 */
596 function PrepareForCopyPaste($source)
597 {
598 plugin::PrepareForCopyPaste($source);
600 if(isset($source['FAIstate'][0])){
601 $this->FAIstate = $source['FAIstate'][0];
602 }
604 $this->FAIdebianRelease = "ClearFromCopyPaste";
606 if(isset($source['FAIpackage'])){
607 unset($source['FAIpackage']['count']);
608 foreach($source['FAIpackage'] as $pkg){
609 $this->usedPackages[$pkg] = $pkg;
610 }
611 ksort($this->usedPackages);
612 }else{
613 $this->usedPackages = array();
614 }
616 if((isset($source['FAIdebianSection']))&&(is_array($source['FAIdebianSection']))){
617 $this->FAIdebianSection = array();
618 for($i = 0 ; $i < $source['FAIdebianSection']['count'] ; $i ++){
619 $this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i];
620 }
621 }
623 /* Create one filter with all package names,
624 instead of calling $ldap->search for every single package
625 */
626 $PackageFilter = "";
627 foreach($this->usedPackages as $name){
628 $PackageFilter .= "(FAIpackage=".$name.")";
629 }
630 $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
632 /* Search for configuration objects */
633 $ldap = $this->config->get_ldap_link();
634 $ldap->cd($source['dn']);
635 $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
637 /* Walk through configurations and append them to our list of ConfiguredPackages */
638 while($attr = $ldap->fetch()){
640 /* Skip objects, that are tagged as removed */
641 if(isset($object['FAIstate'][0])){
642 if(preg_match("/removed$/",$attr['FAIstate'][0])){
643 continue;
644 }
645 }
647 $tmp =array();
648 $tmp['Name'] = $attr['FAIvariable'][0];
649 $tmp['Type'] = $attr['FAIvariableType'][0];
651 if (isset($attr['FAIvariableContent'][0])){
652 if(!in_array($attr['FAIvariableType'],array("multiselect"))){
653 $tmp['Value'] = $attr['FAIvariableContent'][0];
654 }else{
655 $content = array();
656 unset($attr['FAIvariableContent']['count']);
657 foreach($attr['FAIvariableContent'] as $attr){
658 $tmp['Value'][] = $attr;
659 }
660 }
661 $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
662 }
663 }
664 }
667 /*! \brief Returns a list of all configured servers with repositories.
668 @return Array All repository server
669 */
670 function getServerInfos()
671 {
672 $ret = array();
673 $ldap = $this->config->get_ldap_link();
674 $ldap->cd($this->config->current['BASE']);
675 $ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
676 while($attrs = $ldap->fetch()){
677 if(isset($attrs['FAIrepository'])){
678 for($i =0 ; $i < $attrs['FAIrepository']['count']; $i++){
679 $obj = $attrs['FAIrepository'][$i];
680 $tmp = split("\|",$obj);
681 if(count($tmp)==4){
682 foreach(split(",",$tmp[3]) as $sec){
683 if(!empty($sec)){
684 $ret[$tmp[2]][] = $sec;
685 }
686 }
687 }
688 }
689 }
690 }
691 return($ret);
692 }
695 /*! \brief Used for copy & paste.
696 Returns a HTML input mask, which allows to change the cn of this entry.
697 @param Array Array containing current status && a HTML template.
698 */
699 function getCopyDialog()
700 {
701 $vars = array("cn");
702 $smarty = get_smarty();
703 $smarty->assign("cn", htmlentities($this->cn));
704 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
705 $ret = array();
706 $ret['string'] = $str;
707 $ret['status'] = "";
708 return($ret);
709 }
712 /*! \brief Used for copy & paste.
713 Some entries must be renamed to avaoid duplicate entries.
714 */
715 function saveCopyDialog()
716 {
717 if(isset($_POST['cn'])){
718 $this->cn = get_post('cn');
719 }
720 }
721 }
723 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
724 ?>