Code

list base image migration for gosa-plugins
[gosa.git] / gosa-plugins / sudo / admin / sudo / class_sudoGeneric.inc
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   /*! \brief  Returns to the base department for sudo roles.
50               This department is then used to store new roles.
51       @param  Object  GOsa configuration object.
52       @return String sudo store department
53    */
54   public static function get_sudoers_ou($config)
55   {
56     /***
57       GET sudo base
58      ***/
59     $base ="";
60     if(empty($base)){
61       /* Default is ou=sudoers,BASE */
62       $base = "ou=sudoers,".$config->current['BASE'];
63     }else{
65       /* Append base to given sudoers ou if missing */
66       if(!preg_match("/".normalizePreg($config->current['BASE'])."$/i",$base)){
67         if(!preg_match("/,$/",$base)){
68           $base = $base.",".$config->current['BASE'];
69         }else{
70           $base = $base.$config->current['BASE'];
71         }
72       }
73     }
74     return($base);
75   }
77   /*! \brief  Initializes this sudo class, with all required attributes.
78       @param  Object $config  GOsa configuration object.
79       @param  String $db      "new" or the sudo role dn.
80       @return .
81    */
82   function sudo(&$config, $dn= NULL)
83   {
84     plugin::plugin ($config, $dn);
86     if($this->initially_was_account){
87       foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
88         $this->$attr = array();
89         if(isset($this->attrs[$attr])){
90           $tmp = array();
91           for($i = 0 ; $i < $this->attrs[$attr]['count']; $i++){
92             $tmp[] = $this->attrs[$attr][$i];
93           }
94           $this->$attr = $tmp;
95         }
96       }
98       /* Is this account a trustAccount? */
99       if (isset($this->attrs['trustModel'])){
100         $this->trustModel= $this->attrs['trustModel'][0];
101         $this->was_trust_account= TRUE;
102       } else {
103         $this->was_trust_account= FALSE;
104         $this->trustModel= "";
105       }
107       $this->accessTo = array();
108       if (isset($this->attrs['accessTo'])){
109         for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){
110           $tmp= $this->attrs['accessTo'][$i];
111           $this->accessTo[$tmp]= $tmp;
112         }
113       }
115     }
117     if(preg_match("/^defaults$/i",$this->cn)){
118       $this->is_default = TRUE;
119     }
121     /* Get global filter config */
122     if (!session::is_set("sysfilter")){
123       $ui= get_userinfo();
124       $base= get_base_from_people($ui->dn);
125       $sysfilter= array( "depselect"       => $base,
126           "regex"           => "*");
127       session::set("sysfilter", $sysfilter);
128     }
129   }
132   /*! \brief  Creates the sudo generic ui. 
133       @return String  The generated HTML content for this plugin. 
134    */
135   function execute()
136   {
137     /* Call parent execute */
138     plugin::execute();
140     /*********************
141        Access control list / trust mode 
142      *********************/ 
144     /* Add user workstation? */
145     if (isset($_POST["add_ws"])){
146       $this->show_ws_dialog= TRUE;
147       $this->dialog= TRUE;
148     }
150     /* Add user workstation? */
151     if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
152       foreach($_POST['wslist'] as $ws){
153         $this->accessTo[$ws]= $ws;
154       }
155       ksort($this->accessTo);
156       $this->is_modified= TRUE;
157     }
159     /* Remove user workstations? */
160     if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
161       foreach($_POST['workstation_list'] as $name){
162         unset ($this->accessTo[$name]);
163       }
164       $this->is_modified= TRUE;
165     }
167     /* Add user workstation finished? */
168     if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
169       $this->show_ws_dialog= FALSE;
170       $this->dialog= FALSE;
171     }
173     /* Show ws dialog */
174     if ($this->show_ws_dialog){
175       return($this->display_trust_add_dialog());
176     }
179     /*********************
180        Add users 
181      *********************/ 
182   
183     if(isset($_POST['list_sudoUser']) && !is_object($this->dialog) && $this->acl_is_writeable("sudoUser")){
184       $used = array();
185       foreach($this->sudoUser as $name){
186         $used[] = preg_replace("/^!/","",$name);
187       }
188       $this->dialog =new target_list_users($this->config,$used);
189     }
190    
191     /* Add selected hosts  to the sudoUser list */ 
192     if(isset($_POST['SaveMultiSelectWindow']) && $this->dialog instanceof target_list_users){
193       if($this->acl_is_writeable("sudoUser")){
194         foreach($this->dialog->save() as $entry){
195           if(in_array("posixGroup",$entry['objectClass'])){
196             $name = trim("%".$entry['cn'][0]);
197           }else{
198             $name = trim($entry['uid'][0]);
199           }
200           if(!in_array($name,$this->sudoUser) && !in_array("!".$name,$this->sudoUser)){
201             $this->sudoUser[] = $name;
202           }
203         }   
204       }
205       unset($this->dialog);
206       $this->dialog = NULL;
207     }    
210     /*********************
211        Add systems 
212      *********************/ 
213   
214     if(isset($_POST['list_sudoHost']) && !is_object($this->dialog) && $this->acl_is_writeable("sudoHost")){
215       $used = array();
216       foreach($this->sudoHost as $name){
217         $used[] = preg_replace("/^!/","",$name);
218       }
219       $this->dialog =new target_list_systems($this->config,$used);
220     }
221    
222     /* Add selected hosts  to the sudoHost list */ 
223     if(isset($_POST['SaveMultiSelectWindow']) && $this->dialog instanceof target_list_systems){
224       if($this->acl_is_writeable("sudoHost")){
225         foreach($this->dialog->save() as $entry){
226           $cn = trim($entry['cn'][0]);
227           if(!in_array($cn,$this->sudoHost) && !in_array("!".$cn,$this->sudoHost)){
228             $this->sudoHost[] = $cn;
229           }
230         }   
231       }   
232       unset($this->dialog);
233       $this->dialog = NULL;
234     }    
237     /*********************
238        Dialog handling / display / close  
239      *********************/ 
240   
241     if(isset($_POST['CloseMultiSelectWindow']) && is_object($this->dialog)){
242       unset($this->dialog);
243       $this->dialog = NULL;
244     }    
246     if(is_object($this->dialog)){
247       return($this->dialog->execute());
248     }
250  
251     /*********************
252        NEGATE values 
253      *********************/ 
254     foreach($_POST as $name => $value){
255       if(preg_match("/^neg_/",$name)){
256         $attr = preg_replace("/^neg_([^_]*)_.*$/","\\1",$name);
257         $value= preg_replace("/^neg_[^_]*_([0-9]*)_.*$/","\\1",$name);
258  
259         if($this->acl_is_writeable($attr)){
260           $attrs = $this->$attr;
261           if(isset( $attrs[$value])){
262             $v =  $attrs[$value];
263             if(preg_match("/^!/",$v)){
264               $attrs[$value] = preg_replace("/^!/","",$v);
265             }else{
266               $attrs[$value] = "!".$v;
267             }
268             $this->$attr = $attrs;  
269           }
270         }
271         break; // Do it once, image inputs will be posted twice
272       }
273     }
274   
275     /*********************
276        Delete values 
277      *********************/ 
278     foreach($_POST as $name => $value){
279       if(preg_match("/^del_/",$name)){
280         $attr = preg_replace("/^del_([^_]*)_.*$/","\\1",$name);
281         $value= preg_replace("/^del_[^_]*_([0-9]*)_.*$/","\\1",$name);
282         if($this->acl_is_writeable($attr)){
283           $attrs = $this->$attr;
284           if(isset( $attrs[$value])){
285             unset($attrs[$value]);
286             $this->$attr = $attrs;  
287           }
288         }
289         break; // Do it once, image inputs will be posted twice
290       }
291     }
294     /*********************
295        ADD values 
296      *********************/
298     /* User / Host / Runas */ 
299     foreach(array("sudoUser","sudoHost","sudoRunAs") as $attr){
300       if($this->acl_is_writeable($attr) && 
301           isset($_POST["add_".$attr]) && 
302           isset($_POST['new_'.$attr]) && 
303           !empty($_POST['new_'.$attr])){
304         if(preg_match("/^[a-z\.0-9]*$/i",$_POST['new_'.$attr])){
305           $attrs = $this->$attr;
306           $attrs[] =  trim($_POST['new_'.$attr]); 
307           $this->$attr = $attrs;
308         }else{
309           msg_dialog::display(_("Error"),msgPool::invalid($attr,$_POST['new_'.$attr],"/[a-z0-9]/"));
310         }
311       }
312     }
314     /* Command */
315     foreach(array("sudoCommand") as $attr){
316       if($this->acl_is_writeable($attr) && isset($_POST["add_".$attr]) && isset($_POST['new_'.$attr])){
317         $attrs = $this->$attr;
318         $attrs[] =  trim($_POST['new_'.$attr]); 
319         $this->$attr = $attrs;
320       }
321     }
323     
324     /*********************
325        SMARTY assignments 
326      *********************/
328     $smarty = get_smarty();
329     $smarty->assign("is_default",$this->is_default);
330     foreach($this->attributes as $attr){
331       if(is_string($this->$attr)){
332         $smarty->assign($attr,htmlentities($this->$attr));
333       }else{
334         $smarty->assign($attr,$this->$attr);
335       }
336       $smarty->assign($attr."ACL",$this->getacl($attr));
337     }
339     /* Work on trust modes */
340     $smarty->assign("trusthide", " disabled ");
341     if ($this->trustModel == "fullaccess"){
342       $trustmode= 1;
343     } elseif ($this->trustModel == "byhost"){
344       $trustmode= 2;
345       $smarty->assign("trusthide", "");
346     } else {
347       $trustmode= 0;
348     }
349     $smarty->assign("trustmode", $trustmode);
350     $smarty->assign("trustmodes", array( 
351           0 => _("disabled"), 
352           1 => _("full access"),
353           2 => _("allow access to these hosts")));
355     if((count($this->accessTo))==0){
356       $smarty->assign("emptyArrAccess",true);
357     }else{
358       $smarty->assign("emptyArrAccess",false);
359     }
360     $smarty->assign("workstations", $this->accessTo);
361     
362     /* Create lists 
363      */
364     $divlist_sudoUser = new divSelectBox("divlist_sudoUser");
365     $divlist_sudoUser->SetHeight("90");
366     $divlist_sudoHost = new divSelectBox("divlist_sudoHost");
367     $divlist_sudoHost->Setheight("90");
368     $divlist_sudoRunAs = new divSelectBox("divlist_sudoRunAs");
369     $divlist_sudoRunAs->Setheight("90");
370     $divlist_sudoCommand = new divSelectBox("divlist_sudoCommand");
371     $divlist_sudoCommand->Setheight("90");
373     /* Fill divlists
374      */
375     $neg_img= "<img src='images/negate.png' alt='!' class='center'>"; 
376     $option = "<input type='image' src='images/negate.png'     name='neg_%ATTR%_%KEY%' class='center'>"; 
377     $option.= "<input type='image' src='images/lists/trash.png'  name='del_%ATTR%_%KEY%' class='center'>"; 
378     foreach(array("sudoCommand","sudoHost","sudoRunAs") as $attr){
379       if($this->acl_is_readable($attr)){
380         foreach($this->$attr as $key => $entry){
381           $neg = "";
382           if(preg_match("/^!/",$entry)){
383             $neg = $neg_img;
384           }
385           $entry = preg_replace("/^!/","",$entry);
386           $list_name = "divlist_".$attr;
387           $$list_name->AddEntry(
388               array(
389                 array("string" => $neg,"attach" => "style='width:18px;'"),
390                 array("string" => $entry),
391                 array("string" => preg_replace(array("/%KEY%/","/%ATTR%/"),array($key,$attr),$option),
392                   "attach" => "style='width:40px; border-right: 0px;'")));
393         }
394       }
395     }
397     foreach(array("sudoUser") as $attr){
398       $img1 = "<img src='images/select_user.png'   alt='"._("User")."' class='center'>";
399       $img2 = "<img src='images/select_groups.png' alt='"._("Group")."' class='center'>";
400       if($this->acl_is_readable($attr)){
401         foreach($this->$attr as $key => $entry){
402           $neg = "";
403           if(preg_match("/^!/",$entry)){
404             $neg = $neg_img;
405           }
406           $entry = preg_replace("/^!/","",$entry);
408           $img = $img1;
409           if(preg_match("/^%/",$entry)){
410             $img = $img2;
411           }
412           $entry = preg_replace("/^%/","",$entry);
413   
414           $list_name = "divlist_".$attr;
415           $$list_name->AddEntry(
416               array(
417                 array("string" => $neg,"attach" => "style='width:18px;'"),
418                 array("string" => $img,"attach" => "style='width:18px;'"),
419                 array("string" => $entry),
420                 array("string" => preg_replace(array("/%KEY%/","/%ATTR%/"),array($key,$attr),$option),
421                   "attach" => "style='width:40px; border-right: 0px;'")));
422         }
423       }
424     }
429     /* Tell smarty about our divlists 
430      */
431     $smarty->assign("divlist_sudoUser",   $divlist_sudoUser->DrawList());
432     $smarty->assign("divlist_sudoHost",   $divlist_sudoHost->DrawList());
433     $smarty->assign("divlist_sudoRunAs",  $divlist_sudoRunAs->DrawList());
434     $smarty->assign("divlist_sudoCommand",$divlist_sudoCommand->DrawList());
435     return($smarty->fetch(get_template_path('generic.tpl', TRUE)));
436   }
439   /*! \brief  Remove this sudo role from the ldap server 
440    */
441   function remove_from_parent()
442   {
443     plugin::remove_from_parent();
445     $ldap = $this->config->get_ldap_link();
446     $ldap->cd($this->dn);
447     $ldap->rmdir($this->dn);
449     /* Send signal to the world that we've done */
450     $this->handle_post_events("remove");
451   }
454   /*! \brief  Save all relevant HTML posts. 
455    */
456   function save_object()
457   {
458     plugin::save_object();
459     
460     if($this->is_default){
461       $this->cn = "defaults";
462     }  
464     if(is_object($this->dialog)){
465       $this->dialog->save_object();
466     }
468     /* Trust mode - special handling */
469     if($this->acl_is_writeable("trustModel")){
470       if (isset($_POST['trustmode'])){
471         $saved= $this->trustModel;
472         if ($_POST['trustmode'] == "1"){
473           $this->trustModel= "fullaccess";
474         } elseif ($_POST['trustmode'] == "2"){
475           $this->trustModel= "byhost";
476         } else {
477           $this->trustModel= "";
478         }
479         if ($this->trustModel != $saved){
480           $this->is_modified= TRUE;
481         }
482       }
483     }
484   }
487   /*! \brief  Save changes into the ldap database.
488    */
489   function save()
490   {
491     plugin::save();
492    /* Trust accounts */
493     $objectclasses= array();
494     foreach ($this->attrs['objectClass'] as $key => $class){
495       if (preg_match('/trustAccount/i', $class)){
496         continue;
497       }
498       $objectclasses[]= $this->attrs['objectClass'][$key];
499     }
501     $this->attrs['objectClass']= $objectclasses;
502     if ($this->trustModel != ""){
503       $this->attrs['objectClass'][]= "trustAccount";
504       $this->attrs['trustModel']= $this->trustModel;
505       $this->attrs['accessTo']= array();
506       if ($this->trustModel == "byhost"){
507         foreach ($this->accessTo as $host){
508           $this->attrs['accessTo'][]= $host;
509         }
510       }
511     } else {
512       if ($this->was_trust_account){
513         $this->attrs['accessTo']= array();
514         $this->attrs['trustModel']= array();
515       }
516     }
519     /* Ensure a correct array index 
520      */ 
521     $this->attrs['sudoHost']    = array_values($this->attrs['sudoHost']);
522     $this->attrs['sudoRunAs']   = array_values($this->attrs['sudoRunAs']);
523     $this->attrs['sudoUser']    = array_values($this->attrs['sudoUser']);
524     $this->attrs['sudoCommand'] = array_values($this->attrs['sudoCommand']);
526     $this->cleanup();
528     $ldap = $this->config->get_ldap_link();
529     $ldap->cd($this->config->current['BASE']);
531     if($this->is_new){
532       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
533       $ldap->cd($this->dn);
534       $ldap->add($this->attrs);
536       /* Send signal to the world that we've done */
537       $this->handle_post_events("create");
538     }else{
539       $ldap->cd($this->dn);
540       $ldap->modify($this->attrs);;
542       /* Send signal to the world that we've done */
543       $this->handle_post_events("modify");
544     }
546     if (!$ldap->success()){
547       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
548     }
549   }
552   /*! \brief  Check the given input.
553       @return Array   All error messages in an array();
554    */
555   function check()
556   {
557     $message = plugin::check();
559     /* Is a name given? */
560     if(empty($this->cn)){
561       $message[] = msgPool::required(_("Name"));
562     }
564     /* Check if name is reserved */
565     if(!$this->is_default && preg_match("/^defaults$/i",$this->cn)){
566       $message[] = msgPool::reserved(_("Name"));
567     }
569     /* Check name */
570     if(!preg_match("/^[0-9a-z\@]*$/i",$this->cn)){
571       $message[] = msgPool::invalid(_("Name"),$this->cn,"/[0-9a-z\@]/i");
572     }
574     /* Check if this entry will cause duplicated ldap entries */
575     $ldap = $this->config->get_ldap_link();
576     $ldap->cd($this->get_sudoers_ou($this->config));
577     $ldap->search("(&(objectClass=sudoRole)(cn=".$this->cn."))");
578     while($attrs = $ldap->fetch()){
579       if($attrs['dn'] != $this->dn){
580         $message[] = msgPool::duplicated(_("Name"));
581       }
582     }
584     return ($message);
585   }
588   /*! \brief  Display the System Trust Add Workstation dialog 
589     @return String  HTML dialog to add a system to the trust list.
591    */
592   private function display_trust_add_dialog()
593   {
594     $smarty = get_smarty();
596     /* Save data */
597     $sysfilter= session::get("sysfilter");
598     foreach( array("depselect", "regex") as $type){
599       if (isset($_POST[$type])){
600         $sysfilter[$type]= $_POST[$type];
601       }
602     }
603     if (isset($_GET['search'])){
604       $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
605       if ($s == "**"){
606         $s= "*";
607       }
608       $sysfilter['regex']= $s;
609     }
610     session::set("sysfilter", $sysfilter);
612     /* Get workstation list */
613     $exclude= "";
614     foreach($this->accessTo as $ws){
615       $exclude.= "(cn=$ws)";
616     }
617     if ($exclude != ""){
618       $exclude= "(!(|$exclude))";
619     }
620     $regex= $sysfilter['regex'];
621     $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
623     $res = array();
624     $res= array_merge($res,get_sub_list($filter, array("terminal"), get_ou("terminalou"),
625         get_ou("systemsou").$sysfilter['depselect'],          array("cn"), GL_SUBSEARCH | GL_SIZELIMIT));
626     $res= array_merge($res,get_sub_list($filter, array("server"), get_ou("serverou"), 
627         get_ou("systemsou").$sysfilter['depselect'],          array("cn"), GL_SUBSEARCH | GL_SIZELIMIT));
628     $res= array_merge($res,get_sub_list($filter, array("workstation"), get_ou("workstationou"),
629         get_ou("systemsou").$sysfilter['depselect'],          array("cn"), GL_SUBSEARCH | GL_SIZELIMIT));
631     $wslist= array();
632     foreach ($res as $attrs){
633       $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]);
634     }
635     asort($wslist);
636     foreach( array("depselect","regex") as $type){
637       $smarty->assign("$type", $sysfilter[$type]);
638     }
639     $smarty->assign("search_image", get_template_path('images/search.png'));
640     $smarty->assign("launchimage",  get_template_path('images/lists/action.png'));
641     $smarty->assign("tree_image",   get_template_path('images/tree.png'));
642     $smarty->assign("deplist",      $this->config->idepartments);
643     $smarty->assign("alphabet",     generate_alphabet());
644     $smarty->assign("hint",         print_sizelimit_warning());
645     $smarty->assign("wslist",       $wslist);
646     $smarty->assign("apply",        apply_filter());
647     $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__)));
648     return ($display);
649   }
652   /*! \brief Force this entry to be handled and saved as 'default'
653       @param  BOOL  TRUE -force defaults   FALSE -normal
654    */
655   public function set_default($state)
656   {
657     $this->is_default = TRUE;
658     $this->cn = "defaults";
659   }
662   /*! \brief  Add ACL object
663       @return Returns the ACL object.
664    */
665   static function plInfo()
666   {
667     return (array(  
668           "plShortName" => _("Sudo"),
669           "plDescription" => _("Sudo role"),
670           "plSelfModify"  => FALSE,
671           "plDepends"     => array(),
672           "plPriority"    => 0,
673           "plSection"     => array("admin"),
674           "plCategory"    => array("sudo" => array("objectClass" => "sudoRole", "description" => _("Sudo role"))),
676           "plProvidedAcls"    => array(
677             "cn"                => _("Name"),
678             "description"       => _("Description"),
679             "sudoUser"          => _("Users"),
680             "sudoHost"          => _("Host"),
681             "sudoCommand"       => _("Command"),
682             "sudoRunAs"         => _("Run as user"),
683             "trustModel"        => _("Access control list"))
684         ));
685   }
688   /*! \brief  This function will be called if an object gets copied.
689               This function adapts attributes from the source object.
690       @param  Array The source object.
691    */
692   function PrepareForCopyPaste($source)
693   {
694     plugin::PrepareForCopyPaste($source);
695     foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
696       $this->$attr = array();
697       if(isset($source[$attr])){
698         $tmp = array();
699         for($i = 0 ; $i < $source[$attr]['count']; $i++){
700           $tmp[] = $source[$attr][$i];
701         }
702         $this->$attr = $tmp;
703       }
704     }
706     /* Is this account a trustAccount? */
707     if (isset($source['trustModel'])){
708       $this->trustModel= $source['trustModel'][0];
709       $this->was_trust_account= TRUE;
710     } else {
711       $this->was_trust_account= FALSE;
712       $this->trustModel= "";
713     }
715     $this->accessTo = array();
716     if (isset($source['accessTo'])){
717       for ($i= 0; $i<$source['accessTo']['count']; $i++){
718         $tmp= $source['accessTo'][$i];
719         $this->accessTo[$tmp]= $tmp;
720       }
721     }
722   }
725   /*! \brief  Used for copy & paste.
726               Returns a HTML input mask, which allows to change the cn of this entry.
727       @param  Array   Array containing current status && a HTML template.              
728    */
729   function getCopyDialog()
730   {
731     $vars = array("cn");
732     $smarty = get_smarty();
733     $smarty->assign("cn", htmlentities($this->cn));
734     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
735     $ret = array();
736     $ret['string'] = $str;
737     $ret['status'] = "";
738     return($ret);
739   }
742   public function get_cn()
743   {
744     return($this->cn);
745   }
748   /*! \brief  Used for copy & paste.
749               Some entries must be renamed to avaoid duplicate entries.
750    */
751   function saveCopyDialog()
752   {
753     if(isset($_POST['cn'])){
754       $this->cn = get_post('cn');
755     }
756   }
758 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
759 ?>