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 /* Register usertab to trigger edit dialog */
134 $this->usertab= new usertabs($this->config,
135 $this->config->data['TABS']['USERTABS'], $this->dn);
137 /* Switch tab, if it was requested by the user */
138 $this->usertab->current = $s_tab;
140 /* Set ACL and move DN to the headline */
141 # $this->usertab->set_acl_base();
142 $_SESSION['objectinfo']= $this->dn;
143 }
146 /********************
147 Edit canceled
148 ********************/
150 /* Reset all relevant data, if we get a _cancel request */
151 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
152 if (isset($this->usertab)){
153 del_lock ($this->usertab->dn);
154 unset ($this->usertab);
155 }
156 $this->usertab= NULL;
157 $this->lognames= array();;
158 $this->sn= "";
159 $this->givenName= "";
160 $this->uid= "";
161 unset ($_SESSION['objectinfo']);
162 }
165 /********************
166 Change password requested
167 ********************/
169 /* Password change requested */
170 if (($s_action == "change_pw") || (!empty($this->CPPasswordChange))){
172 if(!empty($this->CPPasswordChange)){
173 $s_entry = $this->CPPasswordChange;
174 $this->CPPasswordChange = "";
175 }
177 /* Get 'dn' from posted 'uid' */
178 $this->dn= $this->list[trim($s_entry)]['dn'];
180 /* Load permissions for selected 'dn' and check if
181 we're allowed to remove this 'dn' */
182 $ui = get_userinfo();
183 if (preg_match("/w/",$ui->get_permissions($this->dn,"users/password"))){
185 /* User is allowed to change passwords, save 'dn' and 'acl' for next
186 dialog. */
187 $_SESSION['objectinfo']= $this->dn;
188 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
190 } else {
191 /* User is not allowed. Show message and cancel. */
192 print_red (_("You are not allowed to set this users password!"));
193 }
194 }
197 /********************
198 Change password confirmed
199 ********************/
201 /* Perform password change */
202 if (isset($_POST['password_finish'])){
204 /* For security reasons, check if user is allowed to set password again */
205 if (chkacl($this->acl, "password") == "" || chkacl($this->acl, "create")){
207 /* Check input and feed errors into 'message' */
208 $message= array();
210 /* Sanity checks... */
211 if ($_POST['new_password'] != $_POST['repeated_password']){
213 /* Matching passwords in new and repeated? */
214 $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
215 } else {
217 /* Empty password is not permitted by default. */
218 if ($_POST['new_password'] == ""){
219 $message[]= _("The password you've entered as 'New password' is empty.");
220 }
221 }
223 /* Errors, or password change? */
224 if (count($message) != 0){
226 /* Show error message and continue editing */
227 show_errors ($message);
228 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
229 }
231 $config= $this->config;
232 $ldap_ui= $this->config->get_ldap_link();
233 if(isset($this->usertab->dn)){
234 $ldap_ui->cat($this->usertab->dn,array("uid"));
235 $user = $ldap_ui->fetch();
236 }else{
237 $ldap_ui->cat($this->dn,array("uid"));
238 $user = $ldap_ui->fetch();
239 }
240 if((is_array($user))&&(isset($user['uid']))){
241 $username= $user['uid'][0];
242 }
244 /* Set password, perform required steps */
245 if ($this->usertab){
246 if ($this->usertab->password_change_needed()){
247 $obj= $this->usertab->by_object['user'];
248 change_password ($this->usertab->dn, $_POST['new_password'],0, $obj->pw_storage);
249 if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
250 exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
251 }
253 gosa_log ("Password for '".$this->usertab->dn."' has been changed");
254 unset($this->usertab);
255 $this->usertab= NULL;
256 }
257 } else {
258 change_password ($this->dn, $_POST['new_password']);
259 if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
260 exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
261 }
263 gosa_log ("Password for '".$this->dn."' has been changed");
264 }
265 } else {
267 /* Missing permissions, show message */
268 print_red (_("You are not allowed to set this users password!"));
269 }
271 /* Clean session, delete lock */
272 del_lock ($this->dn);
273 unset ($this->usertab);
274 $this->usertab= NULL;
275 $this->lognames= array();;
276 $this->sn= "";
277 $this->givenName= "";
278 $this->uid= "";
279 unset ($_SESSION['objectinfo']);
280 }
283 /********************
284 Delete entry requested, display confirm dialog
285 ********************/
287 /* Remove user was requested */
288 if ($s_action=="del"){
290 /* Get 'dn' from posted 'uid' */
291 $this->dn= $this->list[trim($s_entry)]['dn'];
293 /* Load permissions for selected 'dn' and check if
294 we're allowed to remove this 'dn' */
296 /* Check locking, save current plugin in 'back_plugin', so
297 the dialog knows where to return. */
298 if (($user= get_lock($this->dn)) != ""){
299 return(gen_locked_message ($user, $this->dn));
300 }
302 /* Lock the current entry, so nobody will edit it during deletion */
303 add_lock ($this->dn, $this->ui->dn);
304 $smarty->assign("info", sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn)));
305 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
306 }
309 /********************
310 Delete entry confirmed
311 ********************/
313 /* Confirmation for deletion has been passed. User should be deleted. */
314 if (isset($_POST['delete_user_confirm'])){
316 /* Some nice guy may send this as POST, so we've to check
317 for the permissions again. */
318 if (chkacl($this->acl, "delete") == ""){
320 /* Delete request is permitted, perform LDAP action */
321 $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn);
322 $this->usertab->set_acl(array($this->acl));
323 $this->usertab->delete ();
324 gosa_log ("User object '".$this->dn."' has been removed");
325 unset ($this->usertab);
326 $this->usertab= NULL;
327 } else {
329 /* Normally this shouldn't be reached, send some extra
330 logs to notify the administrator */
331 print_red (_("You are not allowed to delete this user!"));
333 if(isset($this->ui->uid)){
334 gosa_log ("Warning: '".$this->ui->uid."' tried to trick user deletion.");
335 }
336 }
338 /* Remove lock file after successfull deletion */
339 del_lock ($this->dn);
340 }
343 /********************
344 Delete entry Canceled
345 ********************/
347 /* Delete user canceled? */
348 if (isset($_POST['delete_cancel'])){
349 del_lock ($this->dn);
350 }
353 /********************
354 Edit entry finished (Save)
355 ********************/
357 /* Finish user edit is triggered by the tabulator dialog, so
358 the user wants to save edited data. Check and save at this
359 point. */
360 if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->usertab->config))){
362 /* Check tabs, will feed message array */
363 $this->usertab->last= $this->usertab->current;
364 $this->usertab->save_object();
365 $message= $this->usertab->check();
367 /* Save, or display error message? */
368 if (count($message) == 0){
370 /* No errors. Go ahead and prepare to ask for a password
371 in case we're creating a new user. 'dn' will be 'new'
372 in this case. It is set to the correct value later. */
373 if ($this->dn == "new"){
374 $set_pass= 1;
375 } else {
376 $set_pass= 0;
377 }
379 /* Save user data to ldap */
380 if($this->usertab->save() == 1){
381 gosa_log ("User object '".$this->dn."' saving failed.");
382 return;
383 }
384 gosa_log ("User object '".$this->dn."' has been saved");
386 if (!isset($_POST['edit_apply'])){
387 /* User has been saved successfully, remove lock from LDAP. */
388 if ($this->dn != "new"){
389 del_lock ($this->dn);
390 }
392 /* In case of new users, ask for a password, skip this for templates */
393 if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){
394 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
395 }
397 unset ($this->usertab);
398 $this->usertab= NULL;
399 unset ($_SESSION['objectinfo']);
400 }
401 } else {
402 /* Ok. There seem to be errors regarding to the tab data,
403 show message and continue as usual. */
404 show_errors($message);
405 }
406 }
409 /********************
410 We want to create a new user, so fetch all available user templates
411 ********************/
413 /* Generate template list */
414 if (($s_action=="new")||($s_action=="create_user_from_tpl")){
416 $this->templates= array();
417 $ldap= $this->config->get_ldap_link();
419 /* Create list of templates */
420 foreach ($this->config->departments as $key => $value){
422 /* Get acls from different ou's */
423 $ui = get_userinfo();
424 $acl = $ui->get_permissions("cn=dummy,".$this->DivListUsers->selectedBase,"users/user") ;
426 /* If creation of a new user is allowed, append this template */
427 if (preg_match("/cw/",$acl)){
429 /* Search all templates from the current dn */
430 $ldap->cd (get_people_ou().$value);
431 $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
433 /* Append */
434 if ($ldap->count() != 0){
435 while ($attrs= $ldap->fetch()){
436 $this->templates[$ldap->getDN()]=
437 $attrs['uid'][0]." - ".@LDAP::fix($key);
438 }
439 $this->templates['none']= _("none");
440 }
441 }
442 }
444 /* Sort templates */
445 natcasesort ($this->templates);
446 reset ($this->templates);
447 }
450 /********************
451 Create a new user,template, user from template
452 ********************/
454 /* New user/template request */
455 if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){
456 /* By default we set 'dn' to 'new', all relevant plugins will
457 react on this. */
458 $this->dn= "new";
460 if (isset($this->config->current['IDGEN'])){
461 $this->got_uid= false;
462 } else {
463 $this->got_uid= true;
464 }
466 /* Create new usertab object */
467 $this->usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn);
468 $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
469 $this->usertab->set_acl_base('dummy,'.$this->DivListUsers->selectedBase);
471 /* Take care about templates */
472 if ($s_action=="new_tpl"){
473 $this->is_template= TRUE;
474 $this->usertab->set_template_mode ();
475 } else {
476 $this->is_template= FALSE;
477 }
479 /* Use template if there are any of them */
480 if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){
481 foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
482 $smarty->assign("$attr", $this->$attr);
483 }
484 if ($s_action=="create_user_from_tpl"){
485 $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']);
486 } else {
487 $smarty->assign("template", "none");
488 }
489 $smarty->assign("edit_uid", "");
490 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
491 }
492 }
494 /********************
495 Template selected continue edit
496 ********************/
498 /* Continue template editing */
499 if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){
500 $this->sn = $_POST['sn'];
501 $this->givenName = $_POST['givenName'];
503 /* Check for requred values */
504 $message= array();
505 if ($this->sn == "") {
506 $message[]= _("The required field 'Name' is not set.");
507 }
508 if ($this->givenName == "") {
509 $message[]= _("The required field 'Given name' is not set.");
510 }
512 /* Check if dn is used */
513 $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
514 $ldap= $this->config->get_ldap_link();
515 $ldap->cd ($dn);
516 $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
517 if ($ldap->count () != 0){
518 $message[]= _("A person with the choosen name is already used in this tree.");
519 }
521 /* Show error message / continue editing */
522 if (count($message) > 0){
523 show_errors ($message);
524 } else {
525 $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
526 if (isset($this->config->current['IDGEN']) &&
527 $this->config->current['IDGEN'] != ""){
528 $uids= gen_uids ($this->config->current['IDGEN'], $attributes);
529 if (count($uids)){
530 $smarty->assign("edit_uid", "false");
531 $smarty->assign("uids", $uids);
532 $this->uid= current($uids);
533 }
534 } else {
535 $smarty->assign("edit_uid", "");
536 $this->uid= "";
537 }
538 $this->got_uid= true;
539 }
541 foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
542 $smarty->assign("$attr", $this->$attr);
543 }
544 if (isset($_POST['template'])){
545 $smarty->assign("template", $_POST['template']);
546 }
547 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
548 }
551 /********************
552 No template selected continue edit
553 ********************/
555 /* No template. Ok. Lets fill data into the normal user dialog */
556 if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){
557 foreach(array("sn", "givenName", "uid") as $attr){
558 if (isset($_POST[$attr])){
559 $this->usertab->by_object['user']->$attr= $_POST[$attr];
560 }
561 }
562 }
565 /********************
566 Template selected continue edit
567 ********************/
569 /* Finish template preamble */
570 if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
572 /* Might not be filled if IDGEN is unset */
573 $this->sn = $_POST['sn'];
574 $this->givenName = $_POST['givenName'];
576 /* Move user supplied data to sub plugins */
577 $this->uid = $_POST['uid'];
578 $this->usertab->uid = $this->uid;
579 $this->usertab->sn = $this->sn;
580 $this->usertab->givenName = $this->givenName;
581 $template_dn = $_POST['template'];
582 $this->usertab->adapt_from_template($template_dn);
583 $template_base = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/", '', $template_dn);
584 $this->usertab->by_object['user']->base= $template_base;
585 }
588 /********************
589 If no template was selected set base
590 ********************/
592 if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){
593 $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
594 }
597 /********************
598 Display subdialog
599 ********************/
601 /* Show tab dialog if object is present */
602 if(isset($this->usertab->config)){
603 $display= $this->usertab->execute();
605 /* Don't show buttons if tab dialog requests this */
606 if(isset($this->usertab->by_object)){
607 if (!$this->usertab->by_object[$this->usertab->current]->dialog){
608 $display.= "<p style=\"text-align:right\">\n";
609 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
610 $display.= " \n";
611 if ($this->dn != "new"){
612 $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
613 $display.= " \n";
614 }
615 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
616 $display.= "</p>";
617 }
618 }
619 return ($display);
620 }
622 /* Check if there is a snapshot dialog open */
623 $base = $this->DivListUsers->selectedBase;
624 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
625 return($str);
626 }
628 /* Return rendered main page */
629 /* Display dialog with system list */
630 $this->DivListUsers->parent = $this;
631 $this->DivListUsers->execute();
633 /* Add departments if subsearch is disabled */
634 if(!$this->DivListUsers->SubSearch){
635 $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4);
636 }
637 $this->reload();
638 $this->DivListUsers->setEntries($this->list);
639 return($this->DivListUsers->Draw());
640 }
643 /* Return departments, that will be included within snapshot detection */
644 function get_used_snapshot_bases()
645 {
646 return(array(get_people_ou().$this->DivListUsers->selectedBase));
647 }
650 function reload()
651 {
652 /* Set base for all searches */
653 $base= $this->DivListUsers->selectedBase;
654 $this->list =array();
656 /* Get filter configuration */
657 $Regex = $this->DivListUsers->Regex;
658 $SubSearch = $this->DivListUsers->SubSearch;
659 $ShowTemplates = $this->DivListUsers->ShowTemplates;
660 $ShowFunctionalUsers = $this->DivListUsers->ShowFunctionalUsers;
661 $ShowUnixUsers = $this->DivListUsers->ShowUnixUsers;
662 $ShowMailUsers = $this->DivListUsers->ShowMailUsers;
663 $ShowSambaUsers = $this->DivListUsers->ShowSambaUsers;
664 $ShowProxyUsers = $this->DivListUsers->ShowProxyUsers;
666 /* Setup filter depending on selection */
667 $filter="";
668 if ($this->config->current['SAMBAVERSION'] == 3){
669 $samba= "sambaSamAccount";
670 } else {
671 $samba= "sambaAccount";
672 }
674 if ($ShowFunctionalUsers){
675 $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)".
676 "(objectClass=gosaMailAccount)(objectClass=$samba)".
677 "(objectClass=gosaProxyAccount))))";
678 }
679 if ($ShowUnixUsers){
680 $filter.= "(objectClass=posixAccount)";
681 }
682 if ($ShowMailUsers){
683 $filter.= "(objectClass=gosaMailAccount)";
684 }
685 if ($ShowSambaUsers){
686 $filter.= "(objectClass=$samba)";
687 }
688 if ($ShowProxyUsers){
689 $filter.= "(objectClass=gosaProxyAccount)";
690 }
691 if ($ShowTemplates){
692 $filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))";
693 } else {
694 $filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))";
695 }
696 $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)";
698 /* Generate userlist */
699 $ldap= $this->config->get_ldap_link(TRUE);
701 if ($SubSearch){
702 $ListTemp = get_list($filter, "users", $base,
703 array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT);
704 } else {
705 $base= get_people_ou().$base;
706 $ListTemp = get_list($filter, "users", $base,
707 array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT);
708 }
709 $SortTemp = array();
710 $List = array();
711 foreach($ListTemp as $Key => $Entry){
712 // Generate caption for rows
713 if (isset($Entry["sn"]) && isset($Entry["givenName"])){
714 $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
715 } else {
716 $display= "[".$Entry["uid"][0]."]";
717 }
719 $display = strtolower($display);
720 $List[$display] = $Entry;
721 $SortTemp[$display] = $display;
722 }
723 sort($SortTemp);
724 reset($SortTemp);
726 $this->list = array();
727 foreach($SortTemp as $Key){
728 $this->list[] = $List[$Key];
729 }
730 }
732 function remove_lock()
733 {
734 /* Remove user lock if a DN is marked as "currently edited" */
735 if (isset($this->usertab->dn)){
736 del_lock ($this->usertab->dn);
737 }
738 }
741 /* Perform copy & paste requests
742 If copy&paste is in progress this returns a dialog to fix required attributes
743 */
744 function copyPasteHandling($s_action,$s_entry)
745 {
746 /* Only perform copy/paste if it is enabled */
747 if($this->CopyPasteHandler){
749 /* Prepare current object to be pasted */
750 if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
752 $this->CopyPasteHandler->save_object();
753 $this->CopyPasteHandler->SetVar("base", $this->DivListUsers->selectedBase);
755 /* Execute copy & paste dialog and display returned data, normaly a dialog which allows
756 us to solve all attribute mismatches for this object.
757 If nothing is returned, copy & paste was succesfully or aborted */
758 if(($ret= $this->CopyPasteHandler->execute())){
759 return ($ret);
760 }
762 /* Use the last dn to search for it's ID in the newly generated list. */
763 $dn= $this->CopyPasteHandler->lastdn;
764 foreach($this->list as $id => $entry){
765 if($entry['dn'] == $dn){
766 $s_entry= $id;
767 break;
768 }
769 }
771 /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
772 if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
773 $this->CPPasswordChange = $s_entry;
774 }
775 }
777 /* Copy selected object
778 Create a new empty object and the current selected object.
779 Send both to copy&paste class*/
780 if($s_action == "copy"){
781 $this->CopyPasteHandler->Clear();
782 $dn= $this->list[trim($s_entry)]['dn'];
783 $obj = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
784 $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
785 $this->CopyPasteHandler->Copy($obj,$objNew);
786 }
788 /* Cut selected object.
789 Open user object and send it to the copy & paste handler */
790 if($s_action == "cut"){
791 $this->CopyPasteHandler->Clear();
792 $dn= $this->list[trim($s_entry)]['dn'];
793 $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
794 $this->CopyPasteHandler->Cut($obj);
795 }
796 }
797 }
799 function save_object()
800 {
801 /* Handle divlist filter && department selection*/
802 if(!is_object($this->usertab)){
803 $this->DivListUsers->save_object();
804 }
805 }
807 /* A set of disabled and therefore overloaded functions. They are
808 not needed in this class. */
809 function remove_from_parent() { }
810 function check() { }
811 function save() { }
812 function adapt_from_template($dn) { }
813 function password_change_needed() { }
815 } /* ... class userManagement */
816 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
817 ?>