diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index 50009650714d8e5935f91e27039fe4f8669e1bb3..7d2fd5cda6cd0ad5aa561c4c2d9f4ce0d2251b3f 100644 (file)
<?php
/*
This code is part of GOsa (https://gosa.gonicus.de)
<?php
/*
This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
+ Copyright (C) 2003-2006 - Cajus Pollmeier <pollmeier@gonicus.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/* Include user tab class */
require "tabs_user.inc";
require "tabs_user.inc";
+
class userManagement extends plugin
{
class userManagement extends plugin
{
- /* Definitions */
+ /* Plugin definitions */
var $plHeadline= "Users";
var $plDescription= "This does something";
/* Dialog attributes */
var $plHeadline= "Users";
var $plDescription= "This does something";
/* Dialog attributes */
- var $usertab= NULL;
- var $userlist= array();
- var $ui= NULL;
- var $acl= "";
- var $templates= array();
- var $got_uid= false;
-
- function userManagement ($config, $ui)
+ var $usertab = NULL;
+ var $ui = NULL;
+ var $acl = "";
+ var $templates = array();
+ var $got_uid = false;
+ var $CopyPasteHandler = NULL;
+ var $CPPasswordChange = ""; // Contains the entry id which should get a new password
+ var $DivListUsers;
+
+ function userManagement($config, $ui)
{
/* Save configuration for internal use */
$this->config= $config;
$this->ui= $ui;
{
/* Save configuration for internal use */
$this->config= $config;
$this->ui= $ui;
- /* Get global filter config */
- if (!is_global("userfilter")){
- $base= get_base_from_people($ui->dn);
- $userfilter= array( "mailusers" => "checked",
- "unixusers" => "checked",
- "templates" => "",
- "subsearch" => "",
- "proxyusers" => "checked",
- "sambausers" => "checked",
- "ftpusers" => "checked",
- "faxusers" => "checked",
- "functionalusers" => "checked",
- "depselect" => $base,
- "regex" => "*");
- register_global("userfilter", $userfilter);
+ /* Copy & Paste handler */
+ if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
+ $this->CopyPasteHandler= new CopyPasteHandler($this->config);
}
}
+
+ /* Creat dialog object */
+ $this->DivListUsers = new divListUsers($this->config,$this);
+
+ /* LOCK MESSAGE Vars */
+ $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
}
}
+
function execute()
{
function execute()
{
- $smarty= get_smarty();
- $userfilter= get_global("userfilter");
-
- /* Save filter data if we are in the headpage */
- if (!isset($this->usertab)){
- foreach( array("depselect", "regex") as $type){
- if (isset($_POST[$type])){
- $userfilter[$type]= $_POST[$type];
- }
- }
- if (isset($_POST['depselect'])){
- foreach( array("functionalusers", "unixusers", "mailusers",
- "sambausers", "proxyusers", "ftpusers",
- "faxusers", "templates", "subsearch") as $type){
-
- if (isset($_POST[$type])) {
- $userfilter[$type]= "checked";
- } else {
- $userfilter[$type]= "";
- }
+ /* Call parent execute */
+ plugin::execute();
+
+ $smarty = get_smarty(); // Smarty instance
+ $s_action = ""; // Contains the action to be taken
+ $s_entry = ""; // The value for s_action
+
+ /* Edit entry button pressed? */
+ if( isset($_GET['act']) && $_GET['act'] == "edit_entry" ){
+ $s_action= "edit";
+ $s_entry= validate($_GET['id']);
+ }
+
+ /* Test relevant POST values */
+ foreach($_POST as $key => $val){
+
+ /* Get every possible POST combination and set s_action/s_entry accordingly */
+ foreach(array("del" => "user_del", "edit" => "user_edit",
+ "new" => "user_new",
+ "new_tpl" => "user_tplnew",
+ "change_pw" => "user_chgpw",
+ "editPaste" => "editPaste", "copy" => "copy",
+ "cut" => "cut") as $act => $name){
+
+ if (preg_match("/".$name.".*/", $key)){
+ $s_action= $act;
+ $s_entry= preg_replace("/".$name."_/i", "", $key);
+ break;
}
}
}
}
- if (isset($_GET['search'])){
- $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
- if ($s == "**"){
- $s= "*";
- }
- $userfilter['regex']= $s;
- }
- register_global("userfilter", $userfilter);
- }
+
+ } /* ...Test POST */
- /* React on user interaction here */
- if ($_SERVER["REQUEST_METHOD"] == "POST"){
+ /* Remove coordinate prefix from POST, required by some browsers */
+ $s_entry= preg_replace("/_.$/", "", $s_entry);
- /* User wants to edit data? */
- if ( (isset($_POST['select_user']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['userlist']) && $_POST['userlist'] != ""){
+ /* Seperate possibly encoded tab and entry, default to tab "user" */
+ if(preg_match("/.*-.*/", $s_entry)){
+ $s_tab= preg_replace("/^[^-]*-/i", "" ,$s_entry);
+ $s_entry= preg_replace("/-[^-]*$/i", "", $s_entry);
+ }else{
+ $s_tab= "user";
+ }
- /* Get 'dn' from posted 'uid', must be unique */
- $this->dn= trim($_POST['userlist']);
+ /* Display the copy & paste dialog, if it is currently open */
+ $ret = $this->copyPasteHandling($s_action,$s_entry);
+ if($ret){
+ return($ret);
+ }
- /* Check locking, save current plugin in 'back_plugin', so
- the dialog knows where to return. */
- if (($user= get_lock($this->dn)) != ""){
- return(gen_locked_message ($user, $this->dn));
- }
- /* Lock the current entry, so everyone will get the
- above dialog */
- add_lock ($this->dn, $this->ui->dn);
+ /********************
+ Edit existing entry
+ ********************/
- /* Set up the users ACL's for this 'dn' */
- $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+ /* User wants to edit data? */
+ if (($s_action=="edit") && (!isset($this->usertab->config))){
- /* Register usertab to trigger edit dialog */
- $this->usertab= new usertabs($this->config,
- $this->config->data['TABS']['USERTABS'], $this->dn);
- $this->usertab->set_acl($acl);
+ /* Get 'dn' from posted 'uid', must be unique */
+ $this->dn= $this->list[trim($s_entry)]['dn'];
- $_SESSION['objectinfo']= $this->dn;
+ /* Check locking, save current plugin in 'back_plugin', so
+ the dialog knows where to return. */
+ if (($user= get_lock($this->dn)) != ""){
+ return(gen_locked_message ($user, $this->dn));
}
}
+
+ /* Lock the current entry, so everyone will get the
+ above dialog */
+ add_lock ($this->dn, $this->ui->dn);
+
+ /* Set up the users ACL's for this 'dn' */
+ $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+
+ /* Register usertab to trigger edit dialog */
+ $this->usertab= new usertabs($this->config,
+ $this->config->data['TABS']['USERTABS'], $this->dn);
+
+ /* Switch tab, if it was requested by the user */
+ $this->usertab->current = $s_tab;
+
+ /* Set ACL and move DN to the headline */
+ $this->usertab->set_acl($acl);
+ $_SESSION['objectinfo']= $this->dn;
}
}
- /* Reset requested? */
+
+ /********************
+ Edit canceled
+ ********************/
+
+ /* Reset all relevant data, if we get a _cancel request */
if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
if (isset($this->usertab)){
del_lock ($this->usertab->dn);
if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
if (isset($this->usertab)){
del_lock ($this->usertab->dn);
unset ($_SESSION['objectinfo']);
}
unset ($_SESSION['objectinfo']);
}
+
+ /********************
+ Change password requested
+ ********************/
+
/* Password change requested */
/* Password change requested */
- if (isset($_POST['setpass_user']) && isset($_POST['userlist'])){
+ if (($s_action == "change_pw") || (!empty($this->CPPasswordChange))){
+
+ if(!empty($this->CPPasswordChange)){
+ $s_entry = $this->CPPasswordChange;
+ $this->CPPasswordChange = "";
+ }
/* Get 'dn' from posted 'uid' */
/* Get 'dn' from posted 'uid' */
- $this->dn= trim($_POST['userlist']);
+ $this->dn= $this->list[trim($s_entry)]['dn'];
/* Load permissions for selected 'dn' and check if
we're allowed to remove this 'dn' */
/* Load permissions for selected 'dn' and check if
we're allowed to remove this 'dn' */
}
}
}
}
+
+ /********************
+ Change password confirmed
+ ********************/
+
/* Perform password change */
if (isset($_POST['password_finish'])){
/* Perform password change */
if (isset($_POST['password_finish'])){
}
}
}
}
- /* Errors, or change password? */
+ /* Errors, or password change? */
if (count($message) != 0){
/* Show error message and continue editing */
if (count($message) != 0){
/* Show error message and continue editing */
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
+ $config= $this->config;
+ $ldap_ui= $this->config->get_ldap_link();
+ if(isset($this->usertab->dn)){
+ $ldap_ui->cat($this->usertab->dn,array("uid"));
+ $user = $ldap_ui->fetch();
+ }else{
+ $ldap_ui->cat($this->dn,array("uid"));
+ $user = $ldap_ui->fetch();
+ }
+ if((is_array($user))&&(isset($user['uid']))){
+ $username= $user['uid'][0];
+ }
+
/* Set password, perform required steps */
if ($this->usertab){
if ($this->usertab->password_change_needed()){
$obj= $this->usertab->by_object['user'];
/* Set password, perform required steps */
if ($this->usertab){
if ($this->usertab->password_change_needed()){
$obj= $this->usertab->by_object['user'];
- change_password ($this->usertab->dn, $_POST['new_password'],
- 0, $obj->pw_storage);
+ change_password ($this->usertab->dn, $_POST['new_password'],0, $obj->pw_storage);
+ if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
+ exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
+ }
+
gosa_log ("Password for '".$this->usertab->dn."' has been changed");
unset($this->usertab);
$this->usertab= NULL;
}
} else {
change_password ($this->dn, $_POST['new_password']);
gosa_log ("Password for '".$this->usertab->dn."' has been changed");
unset($this->usertab);
$this->usertab= NULL;
}
} else {
change_password ($this->dn, $_POST['new_password']);
+ if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
+ exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$username." ".$_POST['new_password'], $resarr);
+ }
+
gosa_log ("Password for '".$this->dn."' has been changed");
}
} else {
gosa_log ("Password for '".$this->dn."' has been changed");
}
} else {
/* Clean session, delete lock */
del_lock ($this->dn);
/* Clean session, delete lock */
del_lock ($this->dn);
- $this->reload();
unset ($this->usertab);
$this->usertab= NULL;
$this->lognames= array();;
unset ($this->usertab);
$this->usertab= NULL;
$this->lognames= array();;
}
}
+ /********************
+ Delete entry requested, display confirm dialog
+ ********************/
+
/* Remove user was requested */
/* Remove user was requested */
- if (isset($_POST['delete_user']) && isset($_POST['userlist'])){
+ if ($s_action=="del"){
/* Get 'dn' from posted 'uid' */
/* Get 'dn' from posted 'uid' */
- $this->dn= trim($_POST['userlist']);
+ $this->dn= $this->list[trim($s_entry)]['dn'];
/* Load permissions for selected 'dn' and check if
we're allowed to remove this 'dn' */
/* Load permissions for selected 'dn' and check if
we're allowed to remove this 'dn' */
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("info", sprintf(_("You're about to delete the user %s."), $this->dn));
+ $smarty->assign("info", sprintf(_("You're about to delete the user %s."), @LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
}
}
+ /********************
+ Delete entry confirmed
+ ********************/
/* Confirmation for deletion has been passed. User should be deleted. */
if (isset($_POST['delete_user_confirm'])){
/* Confirmation for deletion has been passed. User should be deleted. */
if (isset($_POST['delete_user_confirm'])){
if (chkacl($this->acl, "delete") == ""){
/* Delete request is permitted, perform LDAP action */
if (chkacl($this->acl, "delete") == ""){
/* Delete request is permitted, perform LDAP action */
- $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],
- $this->dn);
+ $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$this->dn);
$this->usertab->set_acl(array($this->acl));
$this->usertab->delete ();
gosa_log ("User object '".$this->dn."' has been removed");
unset ($this->usertab);
$this->usertab= NULL;
$this->usertab->set_acl(array($this->acl));
$this->usertab->delete ();
gosa_log ("User object '".$this->dn."' has been removed");
unset ($this->usertab);
$this->usertab= NULL;
-
- /* User list has changed, reload it. */
- $this->reload ();
} else {
/* Normally this shouldn't be reached, send some extra
} else {
/* Normally this shouldn't be reached, send some extra
del_lock ($this->dn);
}
del_lock ($this->dn);
}
+
+ /********************
+ Delete entry Canceled
+ ********************/
/* Delete user canceled? */
if (isset($_POST['delete_cancel'])){
/* Delete user canceled? */
if (isset($_POST['delete_cancel'])){
}
}
+ /********************
+ Edit entry finished (Save)
+ ********************/
+
/* Finish user edit is triggered by the tabulator dialog, so
the user wants to save edited data. Check and save at this
point. */
/* Finish user edit is triggered by the tabulator dialog, so
the user wants to save edited data. Check and save at this
point. */
- if (isset($_POST['edit_finish'])){
+ if ((isset($_POST['edit_finish'])) && (isset($this->usertab->config))){
/* Check tabs, will feed message array */
$this->usertab->last= $this->usertab->current;
/* Check tabs, will feed message array */
$this->usertab->last= $this->usertab->current;
}
gosa_log ("User object '".$this->dn."' has been saved");
}
gosa_log ("User object '".$this->dn."' has been saved");
- /* User has been saved successfully, remove lock from
- LDAP. */
+ /* User has been saved successfully, remove lock from LDAP. */
if ($this->dn != "new"){
del_lock ($this->dn);
}
if ($this->dn != "new"){
del_lock ($this->dn);
}
- /* In case of new users, ask for a password */
- if (($set_pass || $this->usertab->password_change_needed()) &&
- !$this->is_template){
-
+ /* In case of new users, ask for a password, skip this for templates */
+ if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
return($smarty->fetch(get_template_path('password.tpl', TRUE)));
}
- /* There's no page reload so we have to read new users at
- this point. */
- $this->reload ();
unset ($this->usertab);
$this->usertab= NULL;
unset ($_SESSION['objectinfo']);
unset ($this->usertab);
$this->usertab= NULL;
unset ($_SESSION['objectinfo']);
-
} else {
/* Ok. There seem to be errors regarding to the tab data,
show message and continue as usual. */
} else {
/* Ok. There seem to be errors regarding to the tab data,
show message and continue as usual. */
}
}
}
}
+
+ /********************
+ We want to create a new user, so fetch all available user templates
+ ********************/
+
/* Generate template list */
/* Generate template list */
- if (isset($_POST['new_user'])){
+ if (($s_action=="new")||($s_action=="create_user_from_tpl")){
+
$this->templates= array();
$ldap= $this->config->get_ldap_link();
$this->templates= array();
$ldap= $this->config->get_ldap_link();
+
+ /* Create list of templates */
foreach ($this->config->departments as $key => $value){
foreach ($this->config->departments as $key => $value){
+
+ /* Get acls from different ou's */
$acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL);
$acl= get_module_permission($acl, "user", get_people_ou().$value);
$acl= get_permissions (get_people_ou().$value, $this->ui->subtreeACL);
$acl= get_module_permission($acl, "user", get_people_ou().$value);
+
+ /* If creation of a new user is allowed, append this template */
if (chkacl($acl, "create") == ""){
if (chkacl($acl, "create") == ""){
+
+ /* Search all templates from the current dn */
$ldap->cd (get_people_ou().$value);
$ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
$ldap->cd (get_people_ou().$value);
$ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
+ /* Append */
if ($ldap->count() != 0){
while ($attrs= $ldap->fetch()){
$this->templates[$ldap->getDN()]=
if ($ldap->count() != 0){
while ($attrs= $ldap->fetch()){
$this->templates[$ldap->getDN()]=
- $attrs['uid'][0]." - $key";
+ $attrs['uid'][0]." - ".@LDAP::fix($key);
}
$this->templates['none']= _("none");
}
}
}
}
$this->templates['none']= _("none");
}
}
}
+
+ /* Sort templates */
natcasesort ($this->templates);
reset ($this->templates);
}
natcasesort ($this->templates);
reset ($this->templates);
}
- /* New user/template request */
- if (isset($_POST['new_user']) || isset($_POST['new_template'])){
+ /********************
+ Create a new user,template, user from template
+ ********************/
+
+ /* New user/template request */
+ if (($s_action=="create_user_from_tpl")||($s_action=="new") || ($s_action=="new_tpl")){
/* By default we set 'dn' to 'new', all relevant plugins will
react on this. */
$this->dn= "new";
/* By default we set 'dn' to 'new', all relevant plugins will
react on this. */
$this->dn= "new";
}
/* Create new usertab object */
}
/* Create new usertab object */
- $this->usertab= new usertabs($this->config,
- $this->config->data['TABS']['USERTABS'], $this->dn);
+ $this->usertab= new usertabs($this->config,$this->config->data['TABS']['USERTABS'], $this->dn);
$this->usertab->set_acl(array(':all'));
$this->usertab->set_acl(array(':all'));
+ $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
/* Take care about templates */
/* Take care about templates */
- if (isset($_POST['new_template'])){
+ if ($s_action=="new_tpl"){
$this->is_template= TRUE;
$this->usertab->set_template_mode ();
} else {
$this->is_template= TRUE;
$this->usertab->set_template_mode ();
} else {
}
/* Use template if there are any of them */
}
/* Use template if there are any of them */
- if (count($this->templates) && !isset($_POST['new_template'])){
+ if ((count($this->templates) && ($s_action!='new_tpl'))||($s_action=="create_user_from_tpl")){
foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
$smarty->assign("$attr", $this->$attr);
}
foreach(array("sn", "givenName", "uid", "got_uid", "templates") as $attr){
$smarty->assign("$attr", $this->$attr);
}
- if (isset($_POST['template'])){
- $smarty->assign("template", $_POST['template']);
+ if ($s_action=="create_user_from_tpl"){
+ $smarty->assign("template", $this->dn= $this->list[trim($s_entry)]['dn']);
+ } else {
+ $smarty->assign("template", "none");
}
}
+ $smarty->assign("edit_uid", "");
return($smarty->fetch(get_template_path('template.tpl', TRUE)));
}
return($smarty->fetch(get_template_path('template.tpl', TRUE)));
}
-
}
}
+ /********************
+ Template selected continue edit
+ ********************/
+
/* Continue template editing */
/* Continue template editing */
- if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid'])){
- $this->sn= $_POST['sn'];
- $this->givenName= $_POST['givenName'];
+ if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){
+ $this->sn = $_POST['sn'];
+ $this->givenName = $_POST['givenName'];
/* Check for requred values */
$message= array();
/* Check for requred values */
$message= array();
$dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
$ldap= $this->config->get_ldap_link();
$ldap->cd ($dn);
$dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
$ldap= $this->config->get_ldap_link();
$ldap->cd ($dn);
- $ldap->search ("(&(sn=".$this->sn.")(givenName=".$this->givenName."))", array("givenName"));
+ $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
if ($ldap->count () != 0){
$message[]= _("A person with the choosen name is already used in this tree.");
}
if ($ldap->count () != 0){
$message[]= _("A person with the choosen name is already used in this tree.");
}
$this->uid= current($uids);
}
} else {
$this->uid= current($uids);
}
} else {
+ $smarty->assign("edit_uid", "");
$this->uid= "";
}
$this->got_uid= true;
$this->uid= "";
}
$this->got_uid= true;
return($smarty->fetch(get_template_path('template.tpl', TRUE)));
}
return($smarty->fetch(get_template_path('template.tpl', TRUE)));
}
+
+ /********************
+ No template selected continue edit
+ ********************/
+
/* No template. Ok. Lets fill data into the normal user dialog */
if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){
foreach(array("sn", "givenName", "uid") as $attr){
/* No template. Ok. Lets fill data into the normal user dialog */
if (isset($_POST['template_continue']) && $_POST['template'] == 'none'){
foreach(array("sn", "givenName", "uid") as $attr){
}
}
}
}
+
+ /********************
+ Template selected continue edit
+ ********************/
+
/* Finish template preamble */
if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
/* Might not be filled if IDGEN is unset */
/* Finish template preamble */
if (isset($_POST['template_continue']) && $_POST['template'] != 'none' && (isset($_POST['uid']))){
/* Might not be filled if IDGEN is unset */
- $this->sn= $_POST['sn'];
- $this->givenName= $_POST['givenName'];
+ $this->sn = $_POST['sn'];
+ $this->givenName = $_POST['givenName'];
/* Move user supplied data to sub plugins */
/* Move user supplied data to sub plugins */
- $this->uid= $_POST['uid'];
- $this->usertab->uid= $this->uid;
- $this->usertab->sn= $this->sn;
- $this->usertab->givenName= $this->givenName;
- $template_dn= $_POST['template'];
+ $this->uid = $_POST['uid'];
+ $this->usertab->uid = $this->uid;
+ $this->usertab->sn = $this->sn;
+ $this->usertab->givenName = $this->givenName;
+ $template_dn = $_POST['template'];
$this->usertab->adapt_from_template($template_dn);
$this->usertab->adapt_from_template($template_dn);
- $template_base= preg_replace("/^[^,]+,".get_people_ou()."/", '', $template_dn);
+ $template_base = preg_replace("/^[^,]+,".normalizePreg(get_people_ou())."/", '', $template_dn);
$this->usertab->by_object['user']->base= $template_base;
/* Set up the users ACL's for this 'dn' */
$acl= get_permissions ($template_base, $this->ui->subtreeACL);
$this->usertab->set_acl($acl);
}
$this->usertab->by_object['user']->base= $template_base;
/* Set up the users ACL's for this 'dn' */
$acl= get_permissions ($template_base, $this->ui->subtreeACL);
$this->usertab->set_acl($acl);
}
+
+
+ /********************
+ If no template was selected set base
+ ********************/
+
+ if (isset($_POST['template_continue']) && ($_POST['template'] == 'none')){
+ $this->usertab->by_object['user']->base= $this->DivListUsers->selectedBase;
+ }
+
+
+ /********************
+ Display subdialog
+ ********************/
/* Show tab dialog if object is present */
/* Show tab dialog if object is present */
- if ($this->usertab){
+ if(isset($this->usertab->config)){
$display= $this->usertab->execute();
/* Don't show buttons if tab dialog requests this */
if (!$this->usertab->by_object[$this->usertab->current]->dialog){
$display.= "<p style=\"text-align:right\">\n";
$display= $this->usertab->execute();
/* Don't show buttons if tab dialog requests this */
if (!$this->usertab->by_object[$this->usertab->current]->dialog){
$display.= "<p style=\"text-align:right\">\n";
- $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
+ $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
$display.= " \n";
$display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
$display.= "</p>";
}
return ($display);
}
$display.= " \n";
$display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
$display.= "</p>";
}
return ($display);
}
+
+ /* Return rendered main page */
+ /* Display dialog with system list */
+ $this->DivListUsers->parent = $this;
+ $this->DivListUsers->execute();
- $smarty= get_smarty();
-
- /* Check sorting variable */
- if (!isset($this->usertab) &&
- !isset($_POST['new_user']) &&
- !isset($_POST['new_template']) &&
- !isset($_POST['delete_user']) &&
- !isset($_POST['setpass_user']) &&
- !isset($_POST['select_user'])){
- $this->reload();
- }
-
- /* Check for exeeded sizelimit */
- if (($message= check_sizelimit()) != ""){
- return($message);
- }
-
- /* Show main page */
- $smarty->assign("userlist", $this->userlist);
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info.png'));
- $smarty->assign("launchimage", get_template_path('images/launch.png'));
- $smarty->assign("deplist", $this->config->idepartments);
- foreach( array("depselect", "regex", "functionalusers", "unixusers",
- "mailusers", "sambausers", "proxyusers", "ftpusers",
- "faxusers", "templates", "subsearch") as $type){
-
- $smarty->assign("$type", $userfilter[$type]);
+ /* Add departments if subsearch is disabled */
+ if(!$this->DivListUsers->SubSearch){
+ $this->DivListUsers->AddDepartments($this->DivListUsers->selectedBase,4);
}
}
-
- /* Extend if we are not using javascript */
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("hint", print_sizelimit_warning());
-
- return ($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
+ $this->reload();
+ $this->DivListUsers->setEntries($this->list);
+ return($this->DivListUsers->Draw());
}
function reload()
{
}
function reload()
{
- /* Get config */
- $userfilter= get_global('userfilter');
-
/* Set base for all searches */
/* Set base for all searches */
- $base= $userfilter['depselect'];
-
- /* Regex filter? */
- if ($userfilter['regex'] != ""){
- $regex= $userfilter['regex'];
- } else {
- $regex= "*";
- }
-
- /* Set filter depending on selection */
+ $base= $this->DivListUsers->selectedBase;
+ $this->list =array();
+
+ /* Get filter configuration */
+ $Regex = $this->DivListUsers->Regex;
+ $SubSearch = $this->DivListUsers->SubSearch;
+ $ShowTemplates = $this->DivListUsers->ShowTemplates;
+ $ShowFunctionalUsers = $this->DivListUsers->ShowFunctionalUsers;
+ $ShowUnixUsers = $this->DivListUsers->ShowUnixUsers;
+ $ShowMailUsers = $this->DivListUsers->ShowMailUsers;
+ $ShowSambaUsers = $this->DivListUsers->ShowSambaUsers;
+ $ShowProxyUsers = $this->DivListUsers->ShowProxyUsers;
+
+ /* Setup filter depending on selection */
+ $filter="";
if ($this->config->current['SAMBAVERSION'] == 3){
$samba= "sambaSamAccount";
} else {
$samba= "sambaAccount";
}
if ($this->config->current['SAMBAVERSION'] == 3){
$samba= "sambaSamAccount";
} else {
$samba= "sambaAccount";
}
- $filter="";
- if ($userfilter['functionalusers'] == "checked"){
- $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)(objectClass=gosaMailAccount)(objectClass=PureFTPdUser)(objectClass=$samba)(objectClass=goFaxAccount)(objectClass=gosaProxyAccount))))";
+ if ($ShowFunctionalUsers){
+ $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)".
+ "(objectClass=gosaMailAccount)(objectClass=$samba)".
+ "(objectClass=gosaProxyAccount))))";
}
}
- if ($userfilter['unixusers'] == "checked"){
+ if ($ShowUnixUsers){
$filter.= "(objectClass=posixAccount)";
}
$filter.= "(objectClass=posixAccount)";
}
- if ($userfilter['mailusers'] == "checked"){
+ if ($ShowMailUsers){
$filter.= "(objectClass=gosaMailAccount)";
}
$filter.= "(objectClass=gosaMailAccount)";
}
- if ($userfilter['sambausers'] == "checked"){
+ if ($ShowSambaUsers){
$filter.= "(objectClass=$samba)";
}
$filter.= "(objectClass=$samba)";
}
- if ($userfilter['proxyusers'] == "checked"){
+ if ($ShowProxyUsers){
$filter.= "(objectClass=gosaProxyAccount)";
}
$filter.= "(objectClass=gosaProxyAccount)";
}
- if ($userfilter['ftpusers'] == "checked"){
- $filter.= "(objectClass=PureFTPdUser)";
- }
- if ($userfilter['faxusers'] == "checked"){
- $filter.= "(objectClass=goFaxAccount)";
- }
-
- if ($userfilter['templates'] == "checked"){
+ if ($ShowTemplates){
$filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))";
} else {
$filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))";
}
$filter= "(|(objectClass=gosaUserTemplate)(&(objectClass=gosaAccount)(|$filter)))";
} else {
$filter= "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(|$filter))";
}
- $filter= "(&(|(uid=$regex)(sn=$regex)(givenName=$regex))$filter)";
+ $filter= "(&(|(uid=".normalizeLdap($Regex).")(sn=".normalizeLdap($Regex).")(givenName=".normalizeLdap($Regex)."))$filter)";
/* Generate userlist */
$ldap= $this->config->get_ldap_link(TRUE);
/* Generate userlist */
$ldap= $this->config->get_ldap_link(TRUE);
- if ($userfilter['subsearch'] == "checked"){
- $this->list= get_list($this->ui->subtreeACL, "$filter", TRUE, $base, array("uid", "givenName", "sn", "objectClass"), TRUE);
+ if ($SubSearch){
+ $ListTemp = get_list($filter, $this->ui->subtreeACL, $base,
+ array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT);
} else {
$base= get_people_ou().$base;
} else {
$base= get_people_ou().$base;
- $this->list= get_list($this->ui->subtreeACL, "$filter", FALSE, $base, array("uid", "givenName", "sn", "objectClass"), TRUE);
- }
-
- $this->userlist= array();
-
- foreach ($this->list as $value){
- if (isset($value["uid"][0]) && !preg_match('/\$$/', $value["uid"][0])){
- if (in_array_ics('gosaUserTemplate', $value['objectClass'])){
- $this->userlist[$value["dn"]]= "* ".$value["uid"][0]." ("._("Template").")";
- continue;
- }
- if (isset($value["givenName"][0]) && isset($value["sn"][0])){
- $this->userlist[$value["dn"]]= $value["sn"][0].", ".
- $value["givenName"][0].
- " [".$value["uid"][0]."]";
- } else {
- $this->userlist[$value["dn"]]= "[".$value["uid"][0]."]";
- }
+ $ListTemp = get_list($filter, $this->ui->subtreeACL, $base,
+ array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT);
+ }
+ $SortTemp = array();
+ foreach($ListTemp as $Key => $Entry){
+ // Generate caption for rows
+ if (isset($Entry["sn"]) && isset($Entry["givenName"])){
+ $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
+ } else {
+ $display= "[".$Entry["uid"][0]."]";
}
}
+
+ $SortTemp[$Key] = $display;
+ }
+ natcasesort($SortTemp);
+ reset($SortTemp);
+ foreach($SortTemp as $Key => $Value){
+ $this->list[] = $ListTemp[$Key];
}
}
- natcasesort ($this->userlist);
- reset ($this->userlist);
}
}
- function remove_from_parent()
+ function remove_lock()
{
{
+ /* Remove user lock if a DN is marked as "currently edited" */
+ if (isset($this->usertab->dn)){
+ del_lock ($this->usertab->dn);
+ }
}
}
-
- /* Check values */
- function check()
+
+ /* Perform copy & paste requests
+ If copy&paste is in progress this returns a dialog to fix required attributes
+ */
+ function copyPasteHandling($s_action,$s_entry)
{
{
- }
+ /* Only perform copy/paste if it is enabled */
+ if($this->CopyPasteHandler){
+ /* Prepare current object to be pasted */
+ if( $s_action == "editPaste" || $this->CopyPasteHandler->stillOpen()){
- /* Save to LDAP */
- function save()
- {
- }
+ $this->CopyPasteHandler->save_object();
+ $this->CopyPasteHandler->SetVar("base", $this->DivListUsers->selectedBase);
- function adapt_from_template($dn)
- {
- }
+ /* Execute copy & paste dialog and display returned data, normaly a dialog which allows
+ us to solve all attribute mismatches for this object.
+ If nothing is returned, copy & paste was succesfully or aborted */
+ if(($ret= $this->CopyPasteHandler->execute())){
+ return ($ret);
+ }
- function password_change_needed()
- {
- }
+ /* Use the last dn to search for it's ID in the newly generated list. */
+ $dn= $this->CopyPasteHandler->lastdn;
+ foreach($this->list as $id => $entry){
+ if($entry['dn'] == $dn){
+ $s_entry= $id;
+ break;
+ }
+ }
+
+ /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
+ if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
+ $this->CPPasswordChange = $s_entry;
+ }
+ }
- function show_header($button_text, $text, $disabled= FALSE)
- {
+ /* Copy selected object
+ Create a new empty object and the current selected object.
+ Send both to copy&paste class*/
+ if($s_action == "copy"){
+ $this->CopyPasteHandler->Clear();
+ $dn= $this->list[trim($s_entry)]['dn'];
+ $acl= get_permissions ($dn, $this->ui->subtreeACL);
+ $obj = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
+ $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
+ $obj-> set_acl($acl);
+ $objNew-> set_acl($acl);
+ $this->CopyPasteHandler->Copy($obj,$objNew);
+ }
+
+ /* Cut selected object.
+ Open user object and send it to the copy & paste handler */
+ if($s_action == "cut"){
+ $this->CopyPasteHandler->Clear();
+ $dn= $this->list[trim($s_entry)]['dn'];
+ $acl= get_permissions ($dn, $this->ui->subtreeACL);
+ $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
+ $obj->set_acl($acl);
+ $this->CopyPasteHandler->Cut($obj);
+ }
+ }
}
}
- function remove_lock()
+ function save_object()
{
{
- if (isset($this->usertab->dn)){
- del_lock ($this->usertab->dn);
- }
+ /* Handle divlist filter && department selection*/
+ $this->DivListUsers->save_object();
}
}
-}
+ /* A set of disabled and therefore overloaded functions. They are
+ not needed in this class. */
+ function remove_from_parent() { }
+ function check() { }
+ function save() { }
+ function adapt_from_template($dn) { }
+ function password_change_needed() { }
+ function show_header($button_text, $text, $disabled= FALSE) { }
+} /* ... class userManagement */
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>