c03c089377109af6b4ecd6b18980996bec495736
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 }
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 }
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){
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);
438 /* If creation of a new user is allowed, append this template */
439 if (chkacl($acl, "create") == ""){
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 }
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.= " \n";
625 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
626 $display.= "</p>";
627 }
628 return ($display);
629 }
631 /* Return rendered main page */
632 /* Display dialog with system list */
633 $this->DivListUsers->parent = $this;
634 $this->DivListUsers->execute();
636 /* Add departments if subsearch is disabled */
637 if(!$this->DivListUsers->SubSearch){
638 $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4);
639 }
640 $this->reload();
641 $this->DivListUsers->setEntries($this->list);
642 return($this->DivListUsers->Draw());
643 }
646 function reload()
647 {
648 /* Set base for all searches */
649 $base= $this->DivListUsers->selectedBase;
650 $this->list =array();
652 /* Get filter configuration */
653 $Regex = $this->DivListUsers->Regex;
654 $SubSearch = $this->DivListUsers->SubSearch;
655 $ShowTemplates = $this->DivListUsers->ShowTemplates;
656 $ShowFunctionalUsers = $this->DivListUsers->ShowFunctionalUsers;
657 $ShowUnixUsers = $this->DivListUsers->ShowUnixUsers;
658 $ShowMailUsers = $this->DivListUsers->ShowMailUsers;
659 $ShowSambaUsers = $this->DivListUsers->ShowSambaUsers;
660 $ShowProxyUsers = $this->DivListUsers->ShowProxyUsers;
662 /* Setup filter depending on selection */
663 $filter="";
664 if ($this->config->current['SAMBAVERSION'] == 3){
665 $samba= "sambaSamAccount";
666 } else {
667 $samba= "sambaAccount";
668 }
670 if ($ShowFunctionalUsers){
671 $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)".
672 "(objectClass=gosaMailAccount)(objectClass=$samba)".
673 "(objectClass=gosaProxyAccount))))";
674 }
675 if ($ShowUnixUsers){
676 $filter.= "(objectClass=posixAccount)";
677 }
678 if ($ShowMailUsers){
679 $filter.= "(objectClass=gosaMailAccount)";
680 }
681 if ($ShowSambaUsers){
682 $filter.= "(objectClass=$samba)";
683 }
684 if ($ShowProxyUsers){
685 $filter.= "(objectClass=gosaProxyAccount)";
686 }
687 if ($ShowTemplates){
688 $filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))";
689 } else {
690 $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))";
691 }
692 $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)";
694 /* Generate userlist */
695 $ldap= $this->config->get_ldap_link(TRUE);
696 if ($SubSearch){
697 $ListTemp = get_list($filter, $this->ui->subtreeACL, $base,
698 array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT);
699 } else {
700 $base= get_people_ou().$base;
701 $ListTemp = get_list($filter, $this->ui->subtreeACL, $base,
702 array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT);
703 }
704 $SortTemp = array();
705 $List = array();
706 foreach($ListTemp as $Key => $Entry){
707 // Generate caption for rows
708 if (isset($Entry["sn"]) && isset($Entry["givenName"])){
709 $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
710 } else {
711 $display= "[".$Entry["uid"][0]."]";
712 }
714 $display = strtolower($display);
715 $List[$display] = $Entry;
716 $SortTemp[$display] = $display;
717 }
718 sort($SortTemp);
719 reset($SortTemp);
721 $this->list = array();
722 foreach($SortTemp as $Key){
723 $this->list[] = $List[$Key];
724 }
725 }
727 function remove_lock()
728 {
729 /* Remove user lock if a DN is marked as "currently edited" */
730 if (isset($this->usertab->dn)){
731 del_lock ($this->usertab->dn);
732 }
733 }
736 /* Perform copy & paste requests
737 If copy&paste is in progress this returns a dialog to fix required attributes
738 */
739 function copyPasteHandling($s_action,$s_entry)
740 {
741 /* Only perform copy/paste if it is enabled */
742 if($this->CopyPasteHandler){
744 /* Prepare current object to be pasted */
745 if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
747 $this->CopyPasteHandler->save_object();
748 $this->CopyPasteHandler->SetVar("base", $this->DivListUsers->selectedBase);
750 /* Execute copy & paste dialog and display returned data, normaly a dialog which allows
751 us to solve all attribute mismatches for this object.
752 If nothing is returned, copy & paste was succesfully or aborted */
753 if(($ret= $this->CopyPasteHandler->execute())){
754 return ($ret);
755 }
757 /* Use the last dn to search for it's ID in the newly generated list. */
758 $dn= $this->CopyPasteHandler->lastdn;
759 foreach($this->list as $id => $entry){
760 if($entry['dn'] == $dn){
761 $s_entry= $id;
762 break;
763 }
764 }
766 /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
767 if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
768 $this->CPPasswordChange = $s_entry;
769 }
770 }
772 /* Copy selected object
773 Create a new empty object and the current selected object.
774 Send both to copy&paste class*/
775 if($s_action == "copy"){
776 $this->CopyPasteHandler->Clear();
777 $dn= $this->list[trim($s_entry)]['dn'];
778 $acl= get_permissions ($dn, $this->ui->subtreeACL);
779 $obj = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
780 $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
781 $obj-> set_acl($acl);
782 $objNew-> set_acl($acl);
783 $this->CopyPasteHandler->Copy($obj,$objNew);
784 }
786 /* Cut selected object.
787 Open user object and send it to the copy & paste handler */
788 if($s_action == "cut"){
789 $this->CopyPasteHandler->Clear();
790 $dn= $this->list[trim($s_entry)]['dn'];
791 $acl= get_permissions ($dn, $this->ui->subtreeACL);
792 $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
793 $obj->set_acl($acl);
794 $this->CopyPasteHandler->Cut($obj);
795 }
796 }
797 }
799 function save_object()
800 {
801 /* Handle divlist filter && department selection*/
802 $this->DivListUsers->save_object();
803 }
805 /* A set of disabled and therefore overloaded functions. They are
806 not needed in this class. */
807 function remove_from_parent() { }
808 function check() { }
809 function save() { }
810 function adapt_from_template($dn) { }
811 function password_change_needed() { }
812 function show_header($button_text, $text, $disabled= FALSE) { }
814 } /* ... class userManagement */
815 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
816 ?>