1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id: class_sudo.inc 9975 2008-03-25 14:09:30Z hickert $$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
24 /*! \brief Sudo generic class. Allow setting User/Host/Command/Runas
25 for a sudo role object.
26 */
27 class sudo extends plugin
28 {
30 protected $cn= "";
31 protected $description= "";
33 protected $sudoUser = array("ALL");
34 protected $sudoCommand= array();
35 protected $sudoHost = array("ALL");
36 protected $sudoRunAs = array("ALL");
37 protected $accessTo = array();
38 protected $trustModel = "";
40 private $is_default = FALSE;
41 private $show_ws_dialog = FALSE;
42 private $was_trust_account= FALSE;
44 public $objectclasses = array("top","sudoRole");
45 public $attributes = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunAs","accessTo","trustModel");
47 public $ignore_account = TRUE;
49 public $orig_dn;
51 /*! \brief Returns to the base department for sudo roles.
52 This department is then used to store new roles.
53 @param Object GOsa configuration object.
54 @return String sudo store department
55 */
56 public static function get_sudoers_ou($config)
57 {
58 /***
59 GET sudo base
60 ***/
61 $base ="";
62 if(empty($base)){
63 /* Default is ou=sudoers,BASE */
64 $base = "ou=sudoers,".$config->current['BASE'];
65 }else{
67 /* Append base to given sudoers ou if missing */
68 if(!preg_match("/".normalizePreg($config->current['BASE'])."$/i",$base)){
69 if(!preg_match("/,$/",$base)){
70 $base = $base.",".$config->current['BASE'];
71 }else{
72 $base = $base.$config->current['BASE'];
73 }
74 }
75 }
76 return($base);
77 }
79 /*! \brief Initializes this sudo class, with all required attributes.
80 @param Object $config GOsa configuration object.
81 @param String $db "new" or the sudo role dn.
82 @return .
83 */
84 function sudo(&$config, $dn= NULL)
85 {
86 plugin::plugin ($config, $dn);
88 if($this->initially_was_account){
89 foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
90 $this->$attr = array();
91 if(isset($this->attrs[$attr])){
92 $tmp = array();
93 for($i = 0 ; $i < $this->attrs[$attr]['count']; $i++){
94 $tmp[] = $this->attrs[$attr][$i];
95 }
96 $this->$attr = $tmp;
97 }
98 }
100 /* Is this account a trustAccount? */
101 if (isset($this->attrs['trustModel'])){
102 $this->trustModel= $this->attrs['trustModel'][0];
103 $this->was_trust_account= TRUE;
104 } else {
105 $this->was_trust_account= FALSE;
106 $this->trustModel= "";
107 }
109 $this->accessTo = array();
110 if (isset($this->attrs['accessTo'])){
111 for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){
112 $tmp= $this->attrs['accessTo'][$i];
113 $this->accessTo[$tmp]= $tmp;
114 }
115 }
117 }
119 if(preg_match("/^defaults$/i",$this->cn)){
120 $this->is_default = TRUE;
121 }
123 /* Get global filter config */
124 if (!session::is_set("sysfilter")){
125 $ui= get_userinfo();
126 $base= get_base_from_people($ui->dn);
127 $sysfilter= array( "depselect" => $base,
128 "regex" => "*");
129 session::set("sysfilter", $sysfilter);
130 }
132 $this->orig_dn = $this->dn;
133 }
136 /*! \brief Creates the sudo generic ui.
137 @return String The generated HTML content for this plugin.
138 */
139 function execute()
140 {
141 /* Call parent execute */
142 plugin::execute();
144 /*********************
145 Access control list / trust mode
146 *********************/
148 /* Add user workstation? */
149 if (isset($_POST["add_ws"])){
150 $this->show_ws_dialog= TRUE;
151 $this->dialog= TRUE;
152 }
154 /* Add user workstation? */
155 if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
156 foreach($_POST['wslist'] as $ws){
157 $this->accessTo[$ws]= $ws;
158 }
159 ksort($this->accessTo);
160 $this->is_modified= TRUE;
161 }
163 /* Remove user workstations? */
164 if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
165 foreach($_POST['workstation_list'] as $name){
166 unset ($this->accessTo[$name]);
167 }
168 $this->is_modified= TRUE;
169 }
171 /* Add user workstation finished? */
172 if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
173 $this->show_ws_dialog= FALSE;
174 $this->dialog= FALSE;
175 }
177 /* Show ws dialog */
178 if ($this->show_ws_dialog){
179 return($this->display_trust_add_dialog());
180 }
183 /*********************
184 Add users
185 *********************/
187 if(isset($_POST['list_sudoUser']) && !is_object($this->dialog) && $this->acl_is_writeable("sudoUser")){
188 $used = array();
189 foreach($this->sudoUser as $name){
190 $used[] = preg_replace("/^!/","",$name);
191 }
192 $this->dialog =new target_list_users($this->config,$used);
193 }
195 /* Add selected hosts to the sudoUser list */
196 if(isset($_POST['SaveMultiSelectWindow']) && $this->dialog instanceof target_list_users){
197 if($this->acl_is_writeable("sudoUser")){
198 foreach($this->dialog->save() as $entry){
199 if(in_array("posixGroup",$entry['objectClass'])){
200 $name = trim("%".$entry['cn'][0]);
201 }else{
202 $name = trim($entry['uid'][0]);
203 }
204 if(!in_array($name,$this->sudoUser) && !in_array("!".$name,$this->sudoUser)){
205 $this->sudoUser[] = $name;
206 }
207 }
208 }
209 unset($this->dialog);
210 $this->dialog = NULL;
211 }
214 /*********************
215 Add systems
216 *********************/
218 if(isset($_POST['list_sudoHost']) && !is_object($this->dialog) && $this->acl_is_writeable("sudoHost")){
219 $used = array();
220 foreach($this->sudoHost as $name){
221 $used[] = preg_replace("/^!/","",$name);
222 }
223 $this->dialog =new target_list_systems($this->config,$used);
224 }
226 /* Add selected hosts to the sudoHost list */
227 if(isset($_POST['SaveMultiSelectWindow']) && $this->dialog instanceof target_list_systems){
228 if($this->acl_is_writeable("sudoHost")){
229 foreach($this->dialog->save() as $entry){
230 $cn = trim($entry['cn'][0]);
231 if(!in_array($cn,$this->sudoHost) && !in_array("!".$cn,$this->sudoHost)){
232 $this->sudoHost[] = $cn;
233 }
234 }
235 }
236 unset($this->dialog);
237 $this->dialog = NULL;
238 }
241 /*********************
242 Dialog handling / display / close
243 *********************/
245 if(isset($_POST['CloseMultiSelectWindow']) && is_object($this->dialog)){
246 unset($this->dialog);
247 $this->dialog = NULL;
248 }
250 if(is_object($this->dialog)){
251 return($this->dialog->execute());
252 }
255 /*********************
256 NEGATE values
257 *********************/
258 foreach($_POST as $name => $value){
259 if(preg_match("/^neg_/",$name)){
260 $attr = preg_replace("/^neg_([^_]*)_.*$/","\\1",$name);
261 $value= preg_replace("/^neg_[^_]*_([0-9]*)_.*$/","\\1",$name);
263 if($this->acl_is_writeable($attr)){
264 $attrs = $this->$attr;
265 if(isset( $attrs[$value])){
266 $v = $attrs[$value];
267 if(preg_match("/^!/",$v)){
268 $attrs[$value] = preg_replace("/^!/","",$v);
269 }else{
270 $attrs[$value] = "!".$v;
271 }
272 $this->$attr = $attrs;
273 }
274 }
275 break; // Do it once, image inputs will be posted twice
276 }
277 }
279 /*********************
280 Delete values
281 *********************/
282 foreach($_POST as $name => $value){
283 if(preg_match("/^del_/",$name)){
284 $attr = preg_replace("/^del_([^_]*)_.*$/","\\1",$name);
285 $value= preg_replace("/^del_[^_]*_([0-9]*)_.*$/","\\1",$name);
286 if($this->acl_is_writeable($attr)){
287 $attrs = $this->$attr;
288 if(isset( $attrs[$value])){
289 unset($attrs[$value]);
290 $this->$attr = $attrs;
291 }
292 }
293 break; // Do it once, image inputs will be posted twice
294 }
295 }
298 /*********************
299 ADD values
300 *********************/
302 /* User / Host / Runas */
303 foreach(array("sudoUser","sudoHost","sudoRunAs") as $attr){
304 if($this->acl_is_writeable($attr) &&
305 isset($_POST["add_".$attr]) &&
306 isset($_POST['new_'.$attr]) &&
307 !empty($_POST['new_'.$attr])){
308 if(preg_match("/^[a-z\.0-9]*$/i",$_POST['new_'.$attr])){
309 $attrs = $this->$attr;
310 $attrs[] = trim($_POST['new_'.$attr]);
311 $this->$attr = $attrs;
312 }else{
313 msg_dialog::display(_("Error"),msgPool::invalid($attr,$_POST['new_'.$attr],"/[a-z0-9]/"));
314 }
315 }
316 }
318 /* Command */
319 foreach(array("sudoCommand") as $attr){
320 if($this->acl_is_writeable($attr) && isset($_POST["add_".$attr]) && isset($_POST['new_'.$attr])){
321 $attrs = $this->$attr;
322 $attrs[] = trim($_POST['new_'.$attr]);
323 $this->$attr = $attrs;
324 }
325 }
328 /*********************
329 SMARTY assignments
330 *********************/
332 $smarty = get_smarty();
333 $smarty->assign("is_default",$this->is_default);
334 foreach($this->attributes as $attr){
335 if(is_string($this->$attr)){
336 $smarty->assign($attr,htmlentities($this->$attr));
337 }else{
338 $smarty->assign($attr,$this->$attr);
339 }
340 $smarty->assign($attr."ACL",$this->getacl($attr));
341 }
343 /* Work on trust modes */
344 $smarty->assign("trusthide", " disabled ");
345 if ($this->trustModel == "fullaccess"){
346 $trustmode= 1;
347 } elseif ($this->trustModel == "byhost"){
348 $trustmode= 2;
349 $smarty->assign("trusthide", "");
350 } else {
351 $trustmode= 0;
352 }
353 $smarty->assign("trustmode", $trustmode);
354 $smarty->assign("trustmodes", array(
355 0 => _("disabled"),
356 1 => _("full access"),
357 2 => _("allow access to these hosts")));
359 if((count($this->accessTo))==0){
360 $smarty->assign("emptyArrAccess",true);
361 }else{
362 $smarty->assign("emptyArrAccess",false);
363 }
364 $smarty->assign("workstations", $this->accessTo);
366 /* Create lists
367 */
368 $divlist_sudoUser = new divSelectBox("divlist_sudoUser");
369 $divlist_sudoUser->SetHeight("90");
370 $divlist_sudoHost = new divSelectBox("divlist_sudoHost");
371 $divlist_sudoHost->Setheight("90");
372 $divlist_sudoRunAs = new divSelectBox("divlist_sudoRunAs");
373 $divlist_sudoRunAs->Setheight("90");
374 $divlist_sudoCommand = new divSelectBox("divlist_sudoCommand");
375 $divlist_sudoCommand->Setheight("90");
377 /* Fill divlists
378 */
379 $neg_img= "<img src='plugins/sudo/images/negate.png' alt='!' class='center'>";
380 $option = "<input type='image' src='plugins/sudo/images/negate.png' name='neg_%ATTR%_%KEY%' class='center'>";
381 $option.= "<input type='image' src='images/lists/trash.png' name='del_%ATTR%_%KEY%' class='center'>";
382 foreach(array("sudoCommand","sudoHost","sudoRunAs") as $attr){
383 if($this->acl_is_readable($attr)){
384 foreach($this->$attr as $key => $entry){
385 $neg = "";
386 if(preg_match("/^!/",$entry)){
387 $neg = $neg_img;
388 }
389 $entry = preg_replace("/^!/","",$entry);
390 $list_name = "divlist_".$attr;
391 $$list_name->AddEntry(
392 array(
393 array("string" => $neg,"attach" => "style='width:18px;'"),
394 array("string" => $entry),
395 array("string" => preg_replace(array("/%KEY%/","/%ATTR%/"),array($key,$attr),$option),
396 "attach" => "style='width:40px; border-right: 0px;'")));
397 }
398 }
399 }
401 foreach(array("sudoUser") as $attr){
402 $img1 = "<img src='plugins/users/images/select_user.png' alt='"._("User")."' class='center'>";
403 $img2 = "<img src='plugins/groups/images/groups.png' alt='"._("Group")."' class='center'>";
404 if($this->acl_is_readable($attr)){
405 foreach($this->$attr as $key => $entry){
406 $neg = "";
407 if(preg_match("/^!/",$entry)){
408 $neg = $neg_img;
409 }
410 $entry = preg_replace("/^!/","",$entry);
412 $img = $img1;
413 if(preg_match("/^%/",$entry)){
414 $img = $img2;
415 }
416 $entry = preg_replace("/^%/","",$entry);
418 $list_name = "divlist_".$attr;
419 $$list_name->AddEntry(
420 array(
421 array("string" => $neg,"attach" => "style='width:18px;'"),
422 array("string" => $img,"attach" => "style='width:18px;'"),
423 array("string" => $entry),
424 array("string" => preg_replace(array("/%KEY%/","/%ATTR%/"),array($key,$attr),$option),
425 "attach" => "style='width:40px; border-right: 0px;'")));
426 }
427 }
428 }
433 /* Tell smarty about our divlists
434 */
435 $smarty->assign("divlist_sudoUser", $divlist_sudoUser->DrawList());
436 $smarty->assign("divlist_sudoHost", $divlist_sudoHost->DrawList());
437 $smarty->assign("divlist_sudoRunAs", $divlist_sudoRunAs->DrawList());
438 $smarty->assign("divlist_sudoCommand",$divlist_sudoCommand->DrawList());
439 return($smarty->fetch(get_template_path('generic.tpl', TRUE)));
440 }
443 /*! \brief Remove this sudo role from the ldap server
444 */
445 function remove_from_parent()
446 {
447 plugin::remove_from_parent();
449 $ldap = $this->config->get_ldap_link();
450 $ldap->cd($this->dn);
451 $ldap->rmdir($this->dn);
453 /* Send signal to the world that we've done */
454 $this->handle_post_events("remove");
455 }
458 /*! \brief Save all relevant HTML posts.
459 */
460 function save_object()
461 {
462 plugin::save_object();
464 if($this->is_default){
465 $this->cn = "defaults";
466 }
468 if(is_object($this->dialog)){
469 $this->dialog->save_object();
470 }
472 /* Trust mode - special handling */
473 if($this->acl_is_writeable("trustModel")){
474 if (isset($_POST['trustmode'])){
475 $saved= $this->trustModel;
476 if ($_POST['trustmode'] == "1"){
477 $this->trustModel= "fullaccess";
478 } elseif ($_POST['trustmode'] == "2"){
479 $this->trustModel= "byhost";
480 } else {
481 $this->trustModel= "";
482 }
483 if ($this->trustModel != $saved){
484 $this->is_modified= TRUE;
485 }
486 }
487 }
488 }
491 /*! \brief Save changes into the ldap database.
492 */
493 function save()
494 {
495 plugin::save();
496 /* Trust accounts */
497 $objectclasses= array();
498 foreach ($this->attrs['objectClass'] as $key => $class){
499 if (preg_match('/trustAccount/i', $class)){
500 continue;
501 }
502 $objectclasses[]= $this->attrs['objectClass'][$key];
503 }
505 $this->attrs['objectClass']= $objectclasses;
506 if ($this->trustModel != ""){
507 $this->attrs['objectClass'][]= "trustAccount";
508 $this->attrs['trustModel']= $this->trustModel;
509 $this->attrs['accessTo']= array();
510 if ($this->trustModel == "byhost"){
511 foreach ($this->accessTo as $host){
512 $this->attrs['accessTo'][]= $host;
513 }
514 }
515 } else {
516 if ($this->was_trust_account){
517 $this->attrs['accessTo']= array();
518 $this->attrs['trustModel']= array();
519 }
520 }
523 /* Ensure a correct array index
524 */
525 $this->attrs['sudoHost'] = array_values($this->attrs['sudoHost']);
526 $this->attrs['sudoRunAs'] = array_values($this->attrs['sudoRunAs']);
527 $this->attrs['sudoUser'] = array_values($this->attrs['sudoUser']);
528 $this->attrs['sudoCommand'] = array_values($this->attrs['sudoCommand']);
530 $this->cleanup();
532 $ldap = $this->config->get_ldap_link();
533 $ldap->cd($this->config->current['BASE']);
535 if($this->is_new){
536 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
537 $ldap->cd($this->dn);
538 $ldap->add($this->attrs);
540 /* Send signal to the world that we've done */
541 $this->handle_post_events("create");
542 }else{
543 $ldap->cd($this->dn);
544 $ldap->modify($this->attrs);;
546 /* Send signal to the world that we've done */
547 $this->handle_post_events("modify");
548 }
550 if (!$ldap->success()){
551 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
552 }
553 }
556 /*! \brief Check the given input.
557 @return Array All error messages in an array();
558 */
559 function check()
560 {
561 $message = plugin::check();
563 /* Is a name given? */
564 if($this->cn == ""){
565 $message[] = msgPool::required(_("Name"));
566 }
568 /* Check if name is reserved */
569 if(!$this->is_default && preg_match("/^defaults$/i",$this->cn)){
570 $message[] = msgPool::reserved(_("Name"));
571 }
573 /* Check name */
574 if(!preg_match("/^[0-9a-z\@]*$/i",$this->cn)){
575 $message[] = msgPool::invalid(_("Name"),$this->cn,"/[0-9a-z\@]/i");
576 }
578 /* Check if this entry will cause duplicated ldap entries */
579 $ldap = $this->config->get_ldap_link();
580 $ldap->cd($this->get_sudoers_ou($this->config));
581 $ldap->search("(&(objectClass=sudoRole)(cn=".$this->cn."))");
582 while($attrs = $ldap->fetch()){
583 if($attrs['dn'] != $this->dn){
584 $message[] = msgPool::duplicated(_("Name"));
585 }
586 }
588 /* Check if we are allowed to create or move this object
589 */
590 if($this->orig_dn == "new" && !$this->acl_is_createable($this->get_sudoers_ou($this->config))){
591 $message[] = msgPool::permCreate();
592 }
594 return ($message);
595 }
598 /*! \brief Display the System Trust Add Workstation dialog
599 @return String HTML dialog to add a system to the trust list.
601 */
602 private function display_trust_add_dialog()
603 {
604 $smarty = get_smarty();
606 /* Save data */
607 $sysfilter= session::get("sysfilter");
608 foreach( array("depselect", "regex") as $type){
609 if (isset($_POST[$type])){
610 $sysfilter[$type]= $_POST[$type];
611 }
612 }
613 if (isset($_GET['search'])){
614 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
615 if ($s == "**"){
616 $s= "*";
617 }
618 $sysfilter['regex']= $s;
619 }
620 session::set("sysfilter", $sysfilter);
622 /* Get workstation list */
623 $exclude= "";
624 foreach($this->accessTo as $ws){
625 $exclude.= "(cn=$ws)";
626 }
627 if ($exclude != ""){
628 $exclude= "(!(|$exclude))";
629 }
630 $regex= $sysfilter['regex'];
631 $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
633 $res = array();
634 $res= array_merge($res,get_sub_list($filter, array("terminal"), get_ou("terminalou"),
635 get_ou("systemsou").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT));
636 $res= array_merge($res,get_sub_list($filter, array("server"), get_ou("serverou"),
637 get_ou("systemsou").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT));
638 $res= array_merge($res,get_sub_list($filter, array("workstation"), get_ou("workstationou"),
639 get_ou("systemsou").$sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT));
641 $wslist= array();
642 foreach ($res as $attrs){
643 $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]);
644 }
645 asort($wslist);
646 foreach( array("depselect","regex") as $type){
647 $smarty->assign("$type", $sysfilter[$type]);
648 }
649 $smarty->assign("search_image", get_template_path('images/lists/search.png'));
650 $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
651 $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
652 $smarty->assign("deplist", $this->config->idepartments);
653 $smarty->assign("alphabet", generate_alphabet());
654 $smarty->assign("hint", print_sizelimit_warning());
655 $smarty->assign("wslist", $wslist);
656 $smarty->assign("apply", apply_filter());
657 $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__)));
658 return ($display);
659 }
662 /*! \brief Force this entry to be handled and saved as 'default'
663 @param BOOL TRUE -force defaults FALSE -normal
664 */
665 public function set_default($state)
666 {
667 $this->is_default = TRUE;
668 $this->cn = "defaults";
669 }
672 /*! \brief Add ACL object
673 @return Returns the ACL object.
674 */
675 static function plInfo()
676 {
677 return (array(
678 "plShortName" => _("Sudo"),
679 "plDescription" => _("Sudo role"),
680 "plSelfModify" => FALSE,
681 "plDepends" => array(),
682 "plPriority" => 0,
683 "plSection" => array("admin"),
684 "plCategory" => array("sudo" => array("objectClass" => "sudoRole", "description" => _("Sudo role"))),
686 "plProvidedAcls" => array(
687 "cn" => _("Name"),
688 "description" => _("Description"),
689 "sudoUser" => _("Users"),
690 "sudoHost" => _("Host"),
691 "sudoCommand" => _("Command"),
692 "sudoRunAs" => _("Run as user"),
693 "trustModel" => _("Access control list"))
694 ));
695 }
698 /*! \brief This function will be called if an object gets copied.
699 This function adapts attributes from the source object.
700 @param Array The source object.
701 */
702 function PrepareForCopyPaste($source)
703 {
704 plugin::PrepareForCopyPaste($source);
705 foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
706 $this->$attr = array();
707 if(isset($source[$attr])){
708 $tmp = array();
709 for($i = 0 ; $i < $source[$attr]['count']; $i++){
710 $tmp[] = $source[$attr][$i];
711 }
712 $this->$attr = $tmp;
713 }
714 }
716 /* Is this account a trustAccount? */
717 if (isset($source['trustModel'])){
718 $this->trustModel= $source['trustModel'][0];
719 $this->was_trust_account= TRUE;
720 } else {
721 $this->was_trust_account= FALSE;
722 $this->trustModel= "";
723 }
725 $this->accessTo = array();
726 if (isset($source['accessTo'])){
727 for ($i= 0; $i<$source['accessTo']['count']; $i++){
728 $tmp= $source['accessTo'][$i];
729 $this->accessTo[$tmp]= $tmp;
730 }
731 }
732 }
735 /*! \brief Used for copy & paste.
736 Returns a HTML input mask, which allows to change the cn of this entry.
737 @param Array Array containing current status && a HTML template.
738 */
739 function getCopyDialog()
740 {
741 $vars = array("cn");
742 $smarty = get_smarty();
743 $smarty->assign("cn", htmlentities($this->cn));
744 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
745 $ret = array();
746 $ret['string'] = $str;
747 $ret['status'] = "";
748 return($ret);
749 }
752 public function get_cn()
753 {
754 return($this->cn);
755 }
758 /*! \brief Used for copy & paste.
759 Some entries must be renamed to avaoid duplicate entries.
760 */
761 function saveCopyDialog()
762 {
763 if(isset($_POST['cn'])){
764 $this->cn = get_post('cn');
765 }
766 }
767 }
768 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
769 ?>