Code

Added Autoscroll for department rename
[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   }
58   function execute()
59   {
60     /* Call parent execute */
61     plugin::execute();
63     /* LOCK MESSAGE Vars */
64     $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
66     $smarty       = get_smarty();                 // Smarty instance
67     $s_action     = "";                           // Contains the action to be taken
68     $s_entry      = "";                           // The value for s_action
70     /* Edit entry button pressed? */
71     if( isset($_GET['act']) && $_GET['act'] == "edit_entry" ){
72       $s_action= "edit";
73       $s_entry= validate($_GET['id']);
74     }
76     /* Test relevant POST values */  
77     foreach($_POST as $key => $val){
79       /* Get every possible POST combination and set s_action/s_entry accordingly */
80       foreach(array("del"       => "user_del",    "edit"      => "user_edit",
81                     "new"       => "user_new",
82                     "new_tpl"   => "user_tplnew",
83                     "create_user_from_tpl"          => "userfrom_tpl",
84                     "change_pw" => "user_chgpw", 
85                     "editPaste" => "editPaste",   "copy"      => "copy",
86                     "cut"       => "cut") as $act => $name){
88         if (preg_match("/".$name.".*/", $key)){
89           $s_action= $act;
90           $s_entry= preg_replace("/".$name."_/i", "", $key);
91           break;
92         }
93       }
94       
95     } /* ...Test POST */
97     /* Remove coordinate prefix from POST, required by some browsers */
98     $s_entry= preg_replace("/_.$/", "", $s_entry);
100     /* Seperate possibly encoded tab and entry, default to tab "user" */
101     if(preg_match("/.*-.*/", $s_entry)){
102       $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry);
103       $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry);
104     }else{
105       $s_tab= "user";
106     }
108     /* Some may be active but diabled in gosa.conf. */
109     if(!search_config($this->config->data['TABS'], $s_tab , "CLASS")){
110       $s_tab = "user";
111     }
113     /* Display the copy & paste dialog, if it is currently open */
114     $ret = $this->copyPasteHandling($s_action,$s_entry);
115     if($ret){
116       return($ret);
117     }
120     /********************
121       Edit existing entry 
122      ********************/
124     /* User wants to edit data? */
125     if (($s_action=="edit") && (!isset($this->usertab->config))){
127       /* Get 'dn' from posted 'uid', must be unique */
128       $this->dn= $this->list[trim($s_entry)]['dn'];
130       /* Check locking, save current plugin in 'back_plugin', so
131          the dialog knows where to return. */
132       if (($user= get_lock($this->dn)) != ""){
133         return(gen_locked_message ($user, $this->dn));
134       }
136       /* Lock the current entry, so everyone will get the
137          above dialog */
138       add_lock ($this->dn, $this->ui->dn);
140       /* Set up the users ACL's for this 'dn' */
141       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
143       /* Register usertab to trigger edit dialog */
144       $this->usertab= new usertabs($this->config, 
145           $this->config->data['TABS']['USERTABS'], $this->dn);
147       /* Switch tab, if it was requested by the user */
148       $this->usertab->current = $s_tab;
150       /* Set ACL and move DN to the headline */
151       $this->usertab->set_acl($acl);
152       $_SESSION['objectinfo']= $this->dn;
153     }
156     /********************
157       Edit canceled 
158      ********************/
160     /* Reset all relevant data, if we get a _cancel request */
161     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
162       if (isset($this->usertab)){
163         del_lock ($this->usertab->dn);
164         unset ($this->usertab);
165       }
166       $this->usertab= NULL;
167       $this->lognames= array();;
168       $this->sn= "";
169       $this->givenName= "";
170       $this->uid= "";
171       unset ($_SESSION['objectinfo']);
172     }
175     /********************
176       Change password requested  
177      ********************/
179     /* Password change requested */
180     if (($s_action == "change_pw") || (!empty($this->CPPasswordChange))){
182       if(!empty($this->CPPasswordChange)){
183         $s_entry = $this->CPPasswordChange;
184         $this->CPPasswordChange = "";
185       }
187       /* Get 'dn' from posted 'uid' */
188       $this->dn= $this->list[trim($s_entry)]['dn'];
190       /* Load permissions for selected 'dn' and check if
191          we're allowed to remove this 'dn' */
192       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
193       $acl= get_module_permission($acl, "user", $this->dn);
194       if (chkacl($acl, "password") == ""){
196         /* User is allowed to change passwords, save 'dn' and 'acl' for next
197            dialog. */
198         $this->acl= $acl;
199         $_SESSION['objectinfo']= $this->dn;
200         return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
202       } else {
203         /* User is not allowed. Show message and cancel. */
204         print_red (_("You are not allowed to set this users password!"));
205       }
206     }
209     /********************
210       Change password confirmed
211      ********************/
213     /* Perform password change */
214     if (isset($_POST['password_finish'])){
216       /* For security reasons, check if user is allowed to set password again */
217       if (chkacl($this->acl, "password") == "" || chkacl($this->acl, "create")){
219         /* Check input and feed errors into 'message' */
220         $message= array();
222         /* Sanity checks... */
223         if ($_POST['new_password'] != $_POST['repeated_password']){
225           /* Matching passwords in new and repeated? */
226           $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
227         } else {
229           /* Empty password is not permitted by default. */
230           if ($_POST['new_password'] == ""){
231             $message[]= _("The password you've entered as 'New password' is empty.");
232           }
233         }
235         /* Errors, or password change? */
236         if (count($message) != 0){
238           /* Show error message and continue editing */
239           show_errors ($message);
240           return($smarty->fetch(get_template_path('password.tpl', TRUE)));
241         }
243         $config= $this->config;
244         $ldap_ui= $this->config->get_ldap_link();
245         if(isset($this->usertab->dn)){
246           $ldap_ui->cat($this->usertab->dn,array("uid"));
247           $user = $ldap_ui->fetch();
248         }else{
249           $ldap_ui->cat($this->dn,array("uid"));
250           $user = $ldap_ui->fetch();
251         }
252         if((is_array($user))&&(isset($user['uid']))){
253           $username= $user['uid'][0];
254         }
256         /* Set password, perform required steps */
257         if ($this->usertab){
258           if ($this->usertab->password_change_needed()){
259             $obj= $this->usertab->by_object['user'];
260             change_password ($this->usertab->dn, $_POST['new_password'],0, $obj->pw_storage);
261             if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
262               exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
263             }
265             gosa_log ("Password for '".$this->usertab->dn."' has been changed");
266             unset($this->usertab);
267             $this->usertab= NULL;
268           }
269         } else {
270           change_password ($this->dn, $_POST['new_password']);
271           if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
272             exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
273           }
275           gosa_log ("Password for '".$this->dn."' has been changed");
276         }
277       } else {
279         /* Missing permissions, show message */
280         print_red (_("You are not allowed to set this users password!"));
281       }
283       /* Clean session, delete lock */
284       del_lock ($this->dn);
285       unset ($this->usertab);
286       $this->usertab= NULL;
287       $this->lognames= array();;
288       $this->sn= "";
289       $this->givenName= "";
290       $this->uid= "";
291       unset ($_SESSION['objectinfo']);
292     }
295     /********************
296       Delete entry requested, display confirm dialog
297      ********************/
299     /* Remove user was requested */
300     if ($s_action=="del"){
302       /* Get 'dn' from posted 'uid' */
303       $this->dn= $this->list[trim($s_entry)]['dn'];
305       /* Load permissions for selected 'dn' and check if
306          we're allowed to remove this 'dn' */
307       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
308       $this->acl= get_module_permission($acl, "user", $this->dn);
309       if (chkacl($this->acl, "delete") == ""){
311         /* Check locking, save current plugin in 'back_plugin', so
312            the dialog knows where to return. */
313         if (($user= get_lock($this->dn)) != ""){
314           return(gen_locked_message ($user, $this->dn));
315         }
317         /* Lock the current entry, so nobody will edit it during deletion */
318         add_lock ($this->dn, $this->ui->dn);
319         $smarty->assign("info", sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn)));
320         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
321       } else {
323         /* Obviously the user isn't allowed to delete. Show message and
324            clean session. */
325         print_red (_("You are not allowed to delete this user!"));
326       }
327     }
330     /********************
331       Delete entry confirmed 
332      ********************/
334     /* Confirmation for deletion has been passed. User should be deleted. */
335     if (isset($_POST['delete_user_confirm'])){
337       /* Some nice guy may send this as POST, so we've to check
338          for the permissions again. */
339       if (chkacl($this->acl, "delete") == ""){
341         /* Delete request is permitted, perform LDAP action */
342         $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn);
343         $this->usertab->set_acl(array($this->acl));
344         $this->usertab->delete ();
345         gosa_log ("User object '".$this->dn."' has been removed");
346         unset ($this->usertab);
347         $this->usertab= NULL;
348       } else {
350         /* Normally this shouldn't be reached, send some extra
351            logs to notify the administrator */
352         print_red (_("You are not allowed to delete this user!"));
354         if(isset($this->ui->uid)){
355           gosa_log ("Warning: '".$this->ui->uid."' tried to trick user deletion.");
356         }
357       }
359       /* Remove lock file after successfull deletion */
360       del_lock ($this->dn);
361     }
363     
364     /********************
365       Delete entry Canceled 
366      ********************/
368     /* Delete user canceled? */
369     if (isset($_POST['delete_cancel'])){
370       del_lock ($this->dn);
371     }
374     /********************
375       Edit entry finished (Save) 
376      ********************/
378     /* Finish user edit is triggered by the tabulator dialog, so
379        the user wants to save edited data. Check and save at this
380        point. */
381     if ((isset($_POST['edit_finish'])) && (isset($this->usertab->config))){
383       /* Check tabs, will feed message array */
384       $this->usertab->last= $this->usertab->current;
385       $this->usertab->save_object();
386       $message= $this->usertab->check();
388       /* Save, or display error message? */
389       if (count($message) == 0){
391         /* No errors. Go ahead and prepare to ask for a password
392            in case we're creating a new user. 'dn' will be 'new'
393            in this case. It is set to the correct value later. */
394         if ($this->dn == "new"){
395           $set_pass= 1;
396         } else {
397           $set_pass= 0;
398         }
400         /* Save user data to ldap */
401         if($this->usertab->save() == 1){
402           gosa_log ("User object '".$this->dn."' saving failed.");
403           return;
404         }
405         gosa_log ("User object '".$this->dn."' has been saved");
407         /* User has been saved successfully, remove lock from LDAP. */
408         if ($this->dn != "new"){
409           del_lock ($this->dn);
410         }
412         /* In case of new users, ask for a password, skip this for templates */
413         if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){
414           return($smarty->fetch(get_template_path('password.tpl', TRUE)));
415         }
417         unset ($this->usertab);
418         $this->usertab= NULL;
419         unset ($_SESSION['objectinfo']);
420       } else {
421         /* Ok. There seem to be errors regarding to the tab data,
422            show message and continue as usual. */
423         show_errors($message);
424       }
425     }
428     /********************
429       We want to create a new user, so fetch all available user templates 
430      ********************/
432     /* Generate template list */
433     if (($s_action=="new")||($s_action=="create_user_from_tpl")){
435       $this->templates= array();
436       $ldap= $this->config->get_ldap_link();
438       /* Create list of templates */
439       foreach ($this->config->departments as $key => $value){
440     
441         /* Get acls from different ou's */
442         $acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL);
443         $acl= get_module_permission($acl, "user", get_people_ou().$value);
444   
445         /* If creation of a new user is allowed, append this template */
446         if (chkacl($acl, "create") == ""){
447           
448           /* Search all templates from the current dn */
449           $ldap->cd (get_people_ou().$value);
450           $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
452           /* Append */
453           if ($ldap->count() != 0){
454             while ($attrs= $ldap->fetch()){
455               $this->templates[$ldap->getDN()]=
456                 $attrs['uid'][0]." - ".@LDAP::fix($key);
457             }
458             $this->templates['none']= _("none");
459           }
460         }
461       }
463       /* Sort templates */
464       natcasesort ($this->templates);
465       reset ($this->templates);
466     }
469     /********************
470       Create a new user,template, user from template 
471      ********************/
473     /* New user/template request */
474     if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){
475       /* By default we set 'dn' to 'new', all relevant plugins will
476          react on this. */
477       $this->dn= "new";
478       if (isset($this->config->current['IDGEN'])){
479         $this->got_uid= false;
480       } else {
481         $this->got_uid= true;
482       }
484       /* Create new usertab object */
485       $this->usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn);
486       $this->usertab->set_acl(array(':all'));
487       $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
489       /* Take care about templates */
490       if ($s_action=="new_tpl"){
491         $this->is_template= TRUE;
492         $this->usertab->set_template_mode ();
493       } else {
494         $this->is_template= FALSE;
495       }
497       /* Use template if there are any of them */
498       if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){
499         foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
500           $smarty->assign("$attr", $this->$attr);
501         }
502         if ($s_action=="create_user_from_tpl"){
503           $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']);
504         } else {
505           $smarty->assign("template", "none");
506         }
507         $smarty->assign("edit_uid", "");
508         return($smarty->fetch(get_template_path('template.tpl', TRUE)));
509       }
510     }
512     /********************
513       Template selected continue edit
514      ********************/
516     /* Continue template editing */
517     if ((isset($_POST['template_continue'])) && ($_POST['template'] != 'none') && (!isset($_POST['uid']))){
518       $this->sn             = $_POST['sn'];
519       $this->givenName      = $_POST['givenName'];
521       /* Check for requred values */
522       $message= array();
523       if ($this->sn == "") {
524         $message[]= _("The required field 'Name' is not set.");
525       }
526       if ($this->givenName == "") {
527         $message[]= _("The required field 'Given name' is not set.");
528       }
530       /* Check if dn is used */
531       $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
532       $ldap= $this->config->get_ldap_link();
533       $ldap->cd ($dn);
534       $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
535       if ($ldap->count () != 0){
536         $message[]= _("A person with the choosen name is already used in this tree.");
537       }
539       /* Show error message / continue editing */
540       if (count($message) > 0){
541         show_errors ($message);
542       } else {
543         $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
544         if (isset($this->config->current['IDGEN']) &&
545             $this->config->current['IDGEN'] != ""){
546           $uids= gen_uids ($this->config->current['IDGEN'], $attributes);
547           if (count($uids)){
548             $smarty->assign("edit_uid", "false");
549             $smarty->assign("uids", $uids);
550             $this->uid= current($uids);
551           }
552         } else {
553           $smarty->assign("edit_uid", "");
554           $this->uid= "";
555         }
556         $this->got_uid= true;
557       }
559       foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
560         $smarty->assign("$attr", $this->$attr);
561       }
562       if (isset($_POST['template'])){
563         $smarty->assign("template", $_POST['template']);
564       }
565       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
566     }
569     /********************
570       No template selected continue edit
571      ********************/
573     /* No template. Ok. Lets fill data into the normal user dialog */
574     if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){
575       foreach(array("sn", "givenName", "uid") as $attr){
576         if (isset($_POST[$attr])){
577           $this->usertab->by_object['user']->$attr= $_POST[$attr];
578         }
579       }
580     }
583     /********************
584       Template selected continue edit
585      ********************/
587     /* Finish template preamble */
588     if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
590       /* Might not be filled if IDGEN is unset */
591       $this->sn                 = $_POST['sn'];
592       $this->givenName          = $_POST['givenName'];
594       /* Move user supplied data to sub plugins */
595       $this->uid                = $_POST['uid'];
596       $this->usertab->uid       = $this->uid;
597       $this->usertab->sn        = $this->sn;
598       $this->usertab->givenName = $this->givenName;
599       $template_dn              = $_POST['template'];
600       $this->usertab->adapt_from_template($template_dn);
601       $template_base            = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/", '', $template_dn);
602       $this->usertab->by_object['user']->base= $template_base;
604       /* Set up the users ACL's for this 'dn' */
605       $acl= get_permissions ($template_base, $this->ui->subtreeACL);
606       $this->usertab->set_acl($acl);
607     }
608    
609  
610     /********************
611       If no template was selected set base
612      ********************/
614     if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){
615       $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
616     }
619     /********************
620       Display subdialog 
621      ********************/
623     /* Show tab dialog if object is present */
624     if(isset($this->usertab->config)){
625       $display= $this->usertab->execute();
627       /* Don't show buttons if tab dialog requests this */
628       if (!$this->usertab->by_object[$this->usertab->current]->dialog){
629         $display.= "<p style=\"text-align:right\">\n";
630         $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
631         $display.= "&nbsp;\n";
632         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
633         $display.= "</p>";
634       }
635       return ($display);
636     }
637       
638     /* Return rendered main page */
639         /* Display dialog with system list */
640     $this->DivListUsers->parent = $this;
641     $this->DivListUsers->execute();
643     /* Add departments if subsearch is disabled */
644     if(!$this->DivListUsers->SubSearch){
645       $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4);
646     }
647     $this->reload();
648     $this->DivListUsers->setEntries($this->list);
649     return($this->DivListUsers->Draw());
650   }
653   function reload()
654   {
655     /* Set base for all searches */
656     $base= $this->DivListUsers->selectedBase;
657     $this->list =array();
659     /* Get filter configuration */
660     $Regex                = $this->DivListUsers->Regex;
661     $SubSearch            = $this->DivListUsers->SubSearch;
662     $ShowTemplates        = $this->DivListUsers->ShowTemplates;
663     $ShowFunctionalUsers  = $this->DivListUsers->ShowFunctionalUsers;
664     $ShowUnixUsers        = $this->DivListUsers->ShowUnixUsers;
665     $ShowMailUsers        = $this->DivListUsers->ShowMailUsers;
666     $ShowSambaUsers       = $this->DivListUsers->ShowSambaUsers;
667     $ShowProxyUsers       = $this->DivListUsers->ShowProxyUsers;
669     /* Setup filter depending on selection */
670     $filter="";
671     if ($this->config->current['SAMBAVERSION'] == 3){
672       $samba= "sambaSamAccount";
673     } else {
674       $samba= "sambaAccount";
675     }
677     if ($ShowFunctionalUsers){
678       $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)".
679                 "(objectClass=gosaMailAccount)(objectClass=$samba)".
680                 "(objectClass=gosaProxyAccount))))";
681     }
682     if ($ShowUnixUsers){
683       $filter.= "(objectClass=posixAccount)";
684     }
685     if ($ShowMailUsers){
686       $filter.= "(objectClass=gosaMailAccount)";
687     }
688     if ($ShowSambaUsers){
689       $filter.= "(objectClass=$samba)";
690     }
691     if ($ShowProxyUsers){
692       $filter.= "(objectClass=gosaProxyAccount)";
693     }
694     if ($ShowTemplates){
695       $filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))";
696     } else {
697       $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))";
698     }
699     $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)";
701     /* Generate userlist */
702     $ldap= $this->config->get_ldap_link(TRUE);
703     if ($SubSearch){
704       $ListTemp =  get_list($filter, $this->ui->subtreeACL, $base,
705                             array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT);
706     } else {
707       $base= get_people_ou().$base;
708       $ListTemp = get_list($filter, $this->ui->subtreeACL, $base, 
709                             array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT);
710     }
711     $SortTemp = array();
712     $List = array();
713     foreach($ListTemp as $Key => $Entry){
714        // Generate caption for rows
715       if (isset($Entry["sn"]) && isset($Entry["givenName"])){
716         $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
717       } else {
718         $display= "[".$Entry["uid"][0]."]";
719       }
721       $display = strtolower($display);
722       $List[$display] = $Entry;
723       $SortTemp[$display] = $display;
724     }
725     sort($SortTemp);
726     reset($SortTemp);
728     $this->list = array();
729     foreach($SortTemp as $Key){
730       $this->list[] = $List[$Key];
731     }
732   }
734   function remove_lock()
735   {
736     /* Remove user lock if a DN is marked as "currently edited" */
737     if (isset($this->usertab->dn)){
738       del_lock ($this->usertab->dn);
739     }
740   }
742  
743   /* Perform copy & paste requests
744       If copy&paste is in progress this returns a dialog to fix required attributes 
745    */ 
746   function copyPasteHandling($s_action,$s_entry)
747   {
748     /* Only perform copy/paste if it is enabled */
749     if($this->CopyPasteHandler){
751       /* Prepare current object to be pasted */
752       if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
754         $this->CopyPasteHandler->save_object();
755         $this->CopyPasteHandler->SetVar("base", $this->DivListUsers->selectedBase);
757         /* Execute copy & paste dialog and display returned data, normaly a dialog which allows 
758             us to solve all attribute mismatches for this object.
759             If nothing is returned, copy & paste was succesfully or aborted */
760         if(($ret= $this->CopyPasteHandler->execute())){
761           return ($ret);
762         }
764         /* Use the last dn to search for it's ID in the newly generated list. */
765         $dn= $this->CopyPasteHandler->lastdn;
767         /* Get new user list */
768         $this->reload();
769         foreach($this->list as $id => $entry){
770           if($entry['dn'] == $dn){
771             $s_entry= $id;
772             break;
773           }
774         }
775        
776         /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
777         if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
778           $this->CPPasswordChange = $s_entry;
779         }
780       }
782       /* Copy selected object 
783           Create a new empty object and the current selected object. 
784           Send both to copy&paste class*/
785       if($s_action == "copy"){
786         $this->CopyPasteHandler->Clear();
787         $dn= $this->list[trim($s_entry)]['dn'];
788         $acl= get_permissions ($dn, $this->ui->subtreeACL);
789         $obj    = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
790         $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
791         $obj->    set_acl($acl);
792         $objNew-> set_acl($acl);
793         $this->CopyPasteHandler->Copy($obj,$objNew);
794       }
796       /* Cut selected object. 
797           Open user object and send it to the copy & paste handler */
798       if($s_action == "cut"){
799         $this->CopyPasteHandler->Clear();
800         $dn= $this->list[trim($s_entry)]['dn'];
801         $acl= get_permissions ($dn, $this->ui->subtreeACL);
802         $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
803         $obj->set_acl($acl);
804         $this->CopyPasteHandler->Cut($obj);
805       }
806     }
807   }
809   function save_object()
810   {
811     /* Handle divlist filter && department selection*/
812     if(!is_object($this->usertab)){
813       $this->DivListUsers->save_object();
814     }
815   }
817   /* A set of disabled and therefore overloaded functions. They are
818      not needed in this class. */
819   function remove_from_parent() { } 
820   function check() { } 
821   function save() { } 
822   function adapt_from_template($dn) { } 
823   function password_change_needed() { } 
824   function show_header($button_text, $text, $disabled= FALSE) { }
826 } /* ... class userManagement */
827 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
828 ?>