Code

Added new (but currently not 100% working) Management dialog
[gosa.git] / plugins / admin / users / class_userManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003-2006 - Cajus Pollmeier <pollmeier@gonicus.de>
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
21 /* Include user tab class */
22 require "tabs_user.inc";
25 class userManagement extends plugin
26 {
27   /* Plugin definitions */
28   var $plHeadline= "Users";
29   var $plDescription= "This does something";
31   /* Dialog attributes */
32   var $usertab              = NULL;
33   var $ui                   = NULL;
34   var $acl                  = "";
35   var $templates            = array();
36   var $got_uid              = false;
37   var $CopyPasteHandler     = NULL;
38   var $CPPasswordChange     = ""; // Contains the entry id which should get a new password
39   var $DivListUsers;
41   function userManagement($config, $ui)
42   {
43     /* Save configuration for internal use */
44     $this->config= $config;
45     $this->ui= $ui;
47     /* Copy & Paste handler */
48     if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
49       $this->CopyPasteHandler= new CopyPasteHandler($this->config);
50     }
52     /* Creat dialog object */
53     $this->DivListUsers = new divListUsers($this->config,$this);
55     /* LOCK MESSAGE Vars */
56     $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
57   }
60   function execute()
61   {
62     /* Call parent execute */
63     plugin::execute();
65     $smarty       = get_smarty();                 // Smarty instance
66     $s_action     = "";                           // Contains the action to be taken
67     $s_entry      = "";                           // The value for s_action
69     /* Edit entry button pressed? */
70     if( isset($_GET['act']) && $_GET['act'] == "edit_entry" ){
71       $s_action= "edit";
72       $s_entry= validate($_GET['id']);
73     }
75     /* Test relevant POST values */  
76     foreach($_POST as $key => $val){
78       /* Get every possible POST combination and set s_action/s_entry accordingly */
79       foreach(array("del"       => "user_del",    "edit"      => "user_edit",
80                     "new"       => "user_new",
81                     "new_tpl"   => "user_tplnew",
82                     "change_pw" => "user_chgpw", 
83                     "editPaste" => "editPaste",   "copy"      => "copy",
84                     "cut"       => "cut") as $act => $name){
86         if (preg_match("/".$name.".*/", $key)){
87           $s_action= $act;
88           $s_entry= preg_replace("/".$name."_/i", "", $key);
89           break;
90         }
91       }
92       
93     } /* ...Test POST */
95     /* Remove coordinate prefix from POST, required by some browsers */
96     $s_entry= preg_replace("/_.$/", "", $s_entry);
98     /* Seperate possibly encoded tab and entry, default to tab "user" */
99     if(preg_match("/.*-.*/", $s_entry)){
100       $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry);
101       $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry);
102     }else{
103       $s_tab= "user";
104     }
106     /* Display the copy & paste dialog, if it is currently open */
107     $ret = $this->copyPasteHandling($s_action,$s_entry);
108     if($ret){
109       return($ret);
110     }
113     /********************
114       Edit existing entry 
115      ********************/
117     /* User wants to edit data? */
118     if (($s_action=="edit") && (!isset($this->usertab->config))){
120       /* Get 'dn' from posted 'uid', must be unique */
121       $this->dn= $this->list[trim($s_entry)]['dn'];
123       /* Check locking, save current plugin in 'back_plugin', so
124          the dialog knows where to return. */
125       if (($user= get_lock($this->dn)) != ""){
126         return(gen_locked_message ($user, $this->dn));
127       }
129       /* Lock the current entry, so everyone will get the
130          above dialog */
131       add_lock ($this->dn, $this->ui->dn);
133       /* Set up the users ACL's for this 'dn' */
134       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
136       /* Register usertab to trigger edit dialog */
137       $this->usertab= new usertabs($this->config, 
138           $this->config->data['TABS']['USERTABS'], $this->dn);
140       /* Switch tab, if it was requested by the user */
141       $this->usertab->current = $s_tab;
143       /* Set ACL and move DN to the headline */
144       $this->usertab->set_acl($acl);
145       $_SESSION['objectinfo']= $this->dn;
146     }
149     /********************
150       Edit canceled 
151      ********************/
153     /* Reset all relevant data, if we get a _cancel request */
154     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
155       if (isset($this->usertab)){
156         del_lock ($this->usertab->dn);
157         unset ($this->usertab);
158       }
159       $this->usertab= NULL;
160       $this->lognames= array();;
161       $this->sn= "";
162       $this->givenName= "";
163       $this->uid= "";
164       unset ($_SESSION['objectinfo']);
165     }
168     /********************
169       Change password requested  
170      ********************/
172     /* Password change requested */
173     if (($s_action == "change_pw") || (!empty($this->CPPasswordChange))){
175       if(!empty($this->CPPasswordChange)){
176         $s_entry = $this->CPPasswordChange;
177         $this->CPPasswordChange = "";
178       }
180       /* Get 'dn' from posted 'uid' */
181       $this->dn= $this->list[trim($s_entry)]['dn'];
183       /* Load permissions for selected 'dn' and check if
184          we're allowed to remove this 'dn' */
185       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
186       $acl= get_module_permission($acl, "user", $this->dn);
187       if (chkacl($acl, "password") == ""){
189         /* User is allowed to change passwords, save 'dn' and 'acl' for next
190            dialog. */
191         $this->acl= $acl;
192         $_SESSION['objectinfo']= $this->dn;
193         return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
195       } else {
196         /* User is not allowed. Show message and cancel. */
197         print_red (_("You are not allowed to set this users password!"));
198       }
199     }
202     /********************
203       Change password confirmed
204      ********************/
206     /* Perform password change */
207     if (isset($_POST['password_finish'])){
209       /* For security reasons, check if user is allowed to set password again */
210       if (chkacl($this->acl, "password") == "" || chkacl($this->acl, "create")){
212         /* Check input and feed errors into 'message' */
213         $message= array();
215         /* Sanity checks... */
216         if ($_POST['new_password'] != $_POST['repeated_password']){
218           /* Matching passwords in new and repeated? */
219           $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
220         } else {
222           /* Empty password is not permitted by default. */
223           if ($_POST['new_password'] == ""){
224             $message[]= _("The password you've entered as 'New password' is empty.");
225           }
226         }
228         /* Errors, or password change? */
229         if (count($message) != 0){
231           /* Show error message and continue editing */
232           show_errors ($message);
233           return($smarty->fetch(get_template_path('password.tpl', TRUE)));
234         }
236         $config= $this->config;
237         $ldap_ui= $this->config->get_ldap_link();
238         if(isset($this->usertab->dn)){
239           $ldap_ui->cat($this->usertab->dn,array("uid"));
240           $user = $ldap_ui->fetch();
241         }else{
242           $ldap_ui->cat($this->dn,array("uid"));
243           $user = $ldap_ui->fetch();
244         }
245         if((is_array($user))&&(isset($user['uid']))){
246           $username= $user['uid'][0];
247         }
249         /* Set password, perform required steps */
250         if ($this->usertab){
251           if ($this->usertab->password_change_needed()){
252             $obj= $this->usertab->by_object['user'];
253             change_password ($this->usertab->dn, $_POST['new_password'],0, $obj->pw_storage);
254             if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
255               exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
256             }
258             gosa_log ("Password for '".$this->usertab->dn."' has been changed");
259             unset($this->usertab);
260             $this->usertab= NULL;
261           }
262         } else {
263           change_password ($this->dn, $_POST['new_password']);
264           if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
265             exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
266           }
268           gosa_log ("Password for '".$this->dn."' has been changed");
269         }
270       } else {
272         /* Missing permissions, show message */
273         print_red (_("You are not allowed to set this users password!"));
274       }
276       /* Clean session, delete lock */
277       del_lock ($this->dn);
278       unset ($this->usertab);
279       $this->usertab= NULL;
280       $this->lognames= array();;
281       $this->sn= "";
282       $this->givenName= "";
283       $this->uid= "";
284       unset ($_SESSION['objectinfo']);
285     }
288     /********************
289       Delete entry requested, display confirm dialog
290      ********************/
292     /* Remove user was requested */
293     if ($s_action=="del"){
295       /* Get 'dn' from posted 'uid' */
296       $this->dn= $this->list[trim($s_entry)]['dn'];
298       /* Load permissions for selected 'dn' and check if
299          we're allowed to remove this 'dn' */
300       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
301       $this->acl= get_module_permission($acl, "user", $this->dn);
302       if (chkacl($this->acl, "delete") == ""){
304         /* Check locking, save current plugin in 'back_plugin', so
305            the dialog knows where to return. */
306         if (($user= get_lock($this->dn)) != ""){
307           return(gen_locked_message ($user, $this->dn));
308         }
310         /* Lock the current entry, so nobody will edit it during deletion */
311         add_lock ($this->dn, $this->ui->dn);
312         $smarty->assign("info", sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn)));
313         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
314       } else {
316         /* Obviously the user isn't allowed to delete. Show message and
317            clean session. */
318         print_red (_("You are not allowed to delete this user!"));
319       }
320     }
323     /********************
324       Delete entry confirmed 
325      ********************/
327     /* Confirmation for deletion has been passed. User should be deleted. */
328     if (isset($_POST['delete_user_confirm'])){
330       /* Some nice guy may send this as POST, so we've to check
331          for the permissions again. */
332       if (chkacl($this->acl, "delete") == ""){
334         /* Delete request is permitted, perform LDAP action */
335         $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn);
336         $this->usertab->set_acl(array($this->acl));
337         $this->usertab->delete ();
338         gosa_log ("User object '".$this->dn."' has been removed");
339         unset ($this->usertab);
340         $this->usertab= NULL;
341       } else {
343         /* Normally this shouldn't be reached, send some extra
344            logs to notify the administrator */
345         print_red (_("You are not allowed to delete this user!"));
347         if(isset($this->ui->uid)){
348           gosa_log ("Warning: '".$this->ui->uid."' tried to trick user deletion.");
349         }
350       }
352       /* Remove lock file after successfull deletion */
353       del_lock ($this->dn);
354     }
356     
357     /********************
358       Delete entry Canceled 
359      ********************/
361     /* Delete user canceled? */
362     if (isset($_POST['delete_cancel'])){
363       del_lock ($this->dn);
364     }
367     /********************
368       Edit entry finished (Save) 
369      ********************/
371     /* Finish user edit is triggered by the tabulator dialog, so
372        the user wants to save edited data. Check and save at this
373        point. */
374     if ((isset($_POST['edit_finish'])) && (isset($this->usertab->config))){
376       /* Check tabs, will feed message array */
377       $this->usertab->last= $this->usertab->current;
378       $this->usertab->save_object();
379       $message= $this->usertab->check();
381       /* Save, or display error message? */
382       if (count($message) == 0){
384         /* No errors. Go ahead and prepare to ask for a password
385            in case we're creating a new user. 'dn' will be 'new'
386            in this case. It is set to the correct value later. */
387         if ($this->dn == "new"){
388           $set_pass= 1;
389         } else {
390           $set_pass= 0;
391         }
393         /* Save user data to ldap */
394         if($this->usertab->save() == 1){
395           gosa_log ("User object '".$this->dn."' saving failed.");
396           return;
397         }
398         gosa_log ("User object '".$this->dn."' has been saved");
400         /* User has been saved successfully, remove lock from LDAP. */
401         if ($this->dn != "new"){
402           del_lock ($this->dn);
403         }
405         /* In case of new users, ask for a password, skip this for templates */
406         if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){
407           return($smarty->fetch(get_template_path('password.tpl', TRUE)));
408         }
410         unset ($this->usertab);
411         $this->usertab= NULL;
412         unset ($_SESSION['objectinfo']);
413       } else {
414         /* Ok. There seem to be errors regarding to the tab data,
415            show message and continue as usual. */
416         show_errors($message);
417       }
418     }
421     /********************
422       We want to create a new user, so fetch all available user templates 
423      ********************/
425     /* Generate template list */
426     if (($s_action=="new")||($s_action=="create_user_from_tpl")){
428       $this->templates= array();
429       $ldap= $this->config->get_ldap_link();
431       /* Create list of templates */
432       foreach ($this->config->departments as $key => $value){
433     
434         /* Get acls from different ou's */
435         $acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL);
436         $acl= get_module_permission($acl, "user", get_people_ou().$value);
437   
438         /* If creation of a new user is allowed, append this template */
439         if (chkacl($acl, "create") == ""){
440           
441           /* Search all templates from the current dn */
442           $ldap->cd (get_people_ou().$value);
443           $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
445           /* Append */
446           if ($ldap->count() != 0){
447             while ($attrs= $ldap->fetch()){
448               $this->templates[$ldap->getDN()]=
449                 $attrs['uid'][0]." - ".@LDAP::fix($key);
450             }
451             $this->templates['none']= _("none");
452           }
453         }
454       }
456       /* Sort templates */
457       natcasesort ($this->templates);
458       reset ($this->templates);
459     }
462     /********************
463       Create a new user,template, user from template 
464      ********************/
466     /* New user/template request */
467     if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){
468       /* By default we set 'dn' to 'new', all relevant plugins will
469          react on this. */
470       $this->dn= "new";
471       if (isset($this->config->current['IDGEN'])){
472         $this->got_uid= false;
473       } else {
474         $this->got_uid= true;
475       }
477       /* Create new usertab object */
478       $this->usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn);
479       $this->usertab->set_acl(array(':all'));
480       $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
482       /* Take care about templates */
483       if ($s_action=="new_tpl"){
484         $this->is_template= TRUE;
485         $this->usertab->set_template_mode ();
486       } else {
487         $this->is_template= FALSE;
488       }
490       /* Use template if there are any of them */
491       if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){
492         foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
493           $smarty->assign("$attr", $this->$attr);
494         }
495         if ($s_action=="create_user_from_tpl"){
496           $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']);
497         } else {
498           $smarty->assign("template", "none");
499         }
500         $smarty->assign("edit_uid", "");
501         return($smarty->fetch(get_template_path('template.tpl', TRUE)));
502       }
503     }
505     /********************
506       Template selected continue edit
507      ********************/
509     /* Continue template editing */
510     if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){
511       $this->sn             = $_POST['sn'];
512       $this->givenName      = $_POST['givenName'];
514       /* Check for requred values */
515       $message= array();
516       if ($this->sn == "") {
517         $message[]= _("The required field 'Name' is not set.");
518       }
519       if ($this->givenName == "") {
520         $message[]= _("The required field 'Given name' is not set.");
521       }
523       /* Check if dn is used */
524       $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
525       $ldap= $this->config->get_ldap_link();
526       $ldap->cd ($dn);
527       $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
528       if ($ldap->count () != 0){
529         $message[]= _("A person with the choosen name is already used in this tree.");
530       }
532       /* Show error message / continue editing */
533       if (count($message) > 0){
534         show_errors ($message);
535       } else {
536         $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
537         if (isset($this->config->current['IDGEN']) &&
538             $this->config->current['IDGEN'] != ""){
539           $uids= gen_uids ($this->config->current['IDGEN'], $attributes);
540           if (count($uids)){
541             $smarty->assign("edit_uid", "false");
542             $smarty->assign("uids", $uids);
543             $this->uid= current($uids);
544           }
545         } else {
546           $smarty->assign("edit_uid", "");
547           $this->uid= "";
548         }
549         $this->got_uid= true;
550       }
552       foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
553         $smarty->assign("$attr", $this->$attr);
554       }
555       if (isset($_POST['template'])){
556         $smarty->assign("template", $_POST['template']);
557       }
558       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
559     }
562     /********************
563       No template selected continue edit
564      ********************/
566     /* No template. Ok. Lets fill data into the normal user dialog */
567     if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){
568       foreach(array("sn", "givenName", "uid") as $attr){
569         if (isset($_POST[$attr])){
570           $this->usertab->by_object['user']->$attr= $_POST[$attr];
571         }
572       }
573     }
576     /********************
577       Template selected continue edit
578      ********************/
580     /* Finish template preamble */
581     if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
583       /* Might not be filled if IDGEN is unset */
584       $this->sn                 = $_POST['sn'];
585       $this->givenName          = $_POST['givenName'];
587       /* Move user supplied data to sub plugins */
588       $this->uid                = $_POST['uid'];
589       $this->usertab->uid       = $this->uid;
590       $this->usertab->sn        = $this->sn;
591       $this->usertab->givenName = $this->givenName;
592       $template_dn              = $_POST['template'];
593       $this->usertab->adapt_from_template($template_dn);
594       $template_base            = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/", '', $template_dn);
595       $this->usertab->by_object['user']->base= $template_base;
597       /* Set up the users ACL's for this 'dn' */
598       $acl= get_permissions ($template_base, $this->ui->subtreeACL);
599       $this->usertab->set_acl($acl);
600     }
601    
602  
603     /********************
604       If no template was selected set base
605      ********************/
607     if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){
608       $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
609     }
612     /********************
613       Display subdialog 
614      ********************/
616     /* Show tab dialog if object is present */
617     if(isset($this->usertab->config)){
618       $display= $this->usertab->execute();
620       /* Don't show buttons if tab dialog requests this */
621       if (!$this->usertab->by_object[$this->usertab->current]->dialog){
622         $display.= "<p style=\"text-align:right\">\n";
623         $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
624         $display.= "&nbsp;\n";
625         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
626         $display.= "</p>";
627       }
628       return ($display);
629     }
630       
631     /* Return rendered main page */
632         /* Display dialog with system list */
633     $this->DivListUsers->execute();
635     /* Add departments if subsearch is disabled */
636     if(!$this->DivListUsers->SubSearch){
637       $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4);
638     }
639     $this->reload();
640     $this->DivListUsers->setEntries($this->list);
641     return($this->DivListUsers->Draw());
642   }
645   function reload()
646   {
647     /* Set base for all searches */
648     $base= $this->DivListUsers->selectedBase;
649     $this->list =array();
651     /* Get filter configuration */
652     $Regex                = $this->DivListUsers->Regex;
653     $SubSearch            = $this->DivListUsers->SubSearch;
654     $ShowTemplates        = $this->DivListUsers->ShowTemplates;
655     $ShowFunctionalUsers  = $this->DivListUsers->ShowFunctionalUsers;
656     $ShowUnixUsers        = $this->DivListUsers->ShowUnixUsers;
657     $ShowMailUsers        = $this->DivListUsers->ShowMailUsers;
658     $ShowSambaUsers       = $this->DivListUsers->ShowSambaUsers;
659     $ShowProxyUsers       = $this->DivListUsers->ShowProxyUsers;
661     /* Setup filter depending on selection */
662     $filter="";
663     if ($this->config->current['SAMBAVERSION'] == 3){
664       $samba= "sambaSamAccount";
665     } else {
666       $samba= "sambaAccount";
667     }
669     if ($ShowFunctionalUsers){
670       $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)".
671                 "(objectClass=gosaMailAccount)(objectClass=$samba)".
672                 "(objectClass=gosaProxyAccount))))";
673     }
674     if ($ShowUnixUsers){
675       $filter.= "(objectClass=posixAccount)";
676     }
677     if ($ShowMailUsers){
678       $filter.= "(objectClass=gosaMailAccount)";
679     }
680     if ($ShowSambaUsers){
681       $filter.= "(objectClass=$samba)";
682     }
683     if ($ShowProxyUsers){
684       $filter.= "(objectClass=gosaProxyAccount)";
685     }
686     if ($ShowTemplates){
687       $filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))";
688     } else {
689       $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))";
690     }
691     $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)";
693     /* Generate userlist */
694     $ldap= $this->config->get_ldap_link(TRUE);
695     if ($SubSearch){
696       $ListTemp =  get_list($filter, $this->ui->subtreeACL, $base,
697                             array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT);
698     } else {
699       $base= get_people_ou().$base;
700       $ListTemp = get_list($filter, $this->ui->subtreeACL, $base, 
701                             array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT);
702     }
703     $SortTemp = array();
704     foreach($ListTemp as $Key => $Entry){
705        // Generate caption for rows
706       if (isset($Entry["sn"]) && isset($Entry["givenName"])){
707         $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
708       } else {
709         $display= "[".$Entry["uid"][0]."]";
710       }
712       $SortTemp[$Key] = $display;
713     }
714     natcasesort($SortTemp);
715     reset($SortTemp);
716     foreach($SortTemp as $Key => $Value){
717       $this->list[] = $ListTemp[$Key];
718     }
719   }
721   function remove_lock()
722   {
723     /* Remove user lock if a DN is marked as "currently edited" */
724     if (isset($this->usertab->dn)){
725       del_lock ($this->usertab->dn);
726     }
727   }
729  
730   /* Perform copy & paste requests
731       If copy&paste is in progress this returns a dialog to fix required attributes 
732    */ 
733   function copyPasteHandling($s_action,$s_entry)
734   {
735     /* Only perform copy/paste if it is enabled */
736     if($this->CopyPasteHandler){
738       /* Prepare current object to be pasted */
739       if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
741         $this->CopyPasteHandler->save_object();
742         $this->CopyPasteHandler->SetVar("base", $this->DivListUsers->selectedBase);
744         /* Execute copy & paste dialog and display returned data, normaly a dialog which allows 
745             us to solve all attribute mismatches for this object.
746             If nothing is returned, copy & paste was succesfully or aborted */
747         if(($ret= $this->CopyPasteHandler->execute())){
748           return ($ret);
749         }
751         /* Use the last dn to search for it's ID in the newly generated list. */
752         $dn= $this->CopyPasteHandler->lastdn;
753         foreach($this->list as $id => $entry){
754           if($entry['dn'] == $dn){
755             $s_entry= $id;
756             break;
757           }
758         }
759        
760         /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
761         if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
762           $this->CPPasswordChange = $s_entry;
763         }
764       }
766       /* Copy selected object 
767           Create a new empty object and the current selected object. 
768           Send both to copy&paste class*/
769       if($s_action == "copy"){
770         $this->CopyPasteHandler->Clear();
771         $dn= $this->list[trim($s_entry)]['dn'];
772         $acl= get_permissions ($dn, $this->ui->subtreeACL);
773         $obj    = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
774         $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
775         $obj->    set_acl($acl);
776         $objNew-> set_acl($acl);
777         $this->CopyPasteHandler->Copy($obj,$objNew);
778       }
780       /* Cut selected object. 
781           Open user object and send it to the copy & paste handler */
782       if($s_action == "cut"){
783         $this->CopyPasteHandler->Clear();
784         $dn= $this->list[trim($s_entry)]['dn'];
785         $acl= get_permissions ($dn, $this->ui->subtreeACL);
786         $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
787         $obj->set_acl($acl);
788         $this->CopyPasteHandler->Cut($obj);
789       }
790     }
791   }
793   function save_object()
794   {
795     /* Handle divlist filter && department selection*/
796     $this->DivListUsers->save_object();
797   }
799   /* A set of disabled and therefore overloaded functions. They are
800      not needed in this class. */
801   function remove_from_parent() { } 
802   function check() { } 
803   function save() { } 
804   function adapt_from_template($dn) { } 
805   function password_change_needed() { } 
806   function show_header($button_text, $text, $disabled= FALSE) { }
808 } /* ... class userManagement */
809 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
810 ?>