From 703f049b09ea8c0e0f891887e48f3490813fea9f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 16 Apr 2006 12:31:00 +0000 Subject: [PATCH] function to create email addresses after a configurable policy --- admin/inc/class.boaccounts.inc.php | 12 +++++++-- admin/inc/class.uiaccounts.inc.php | 32 +++++++++++++++++----- admin/setup/phpgw_de.lang | 4 ++- admin/setup/phpgw_en.lang | 4 ++- admin/templates/default/account_form.tpl | 34 +++++++++++++++++++++--- admin/templates/default/config.tpl | 19 +++++++++++++ 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/admin/inc/class.boaccounts.inc.php b/admin/inc/class.boaccounts.inc.php index 9da037b5e9..621025701c 100755 --- a/admin/inc/class.boaccounts.inc.php +++ b/admin/inc/class.boaccounts.inc.php @@ -307,6 +307,10 @@ if ($_POST['submit']) { + if (!($email = $_POST['account_email'])) + { + $email = $GLOBALS['egw']->common->email_address($_POST['account_firstname'],$_POST['account_lastname'],$_POST['account_lid']); + } $userData = array( 'account_type' => 'u', 'account_lid' => $accountPrefix.$_POST['account_lid'], @@ -326,7 +330,7 @@ 'homedirectory' => $_POST['homedirectory'], 'loginshell' => $_POST['loginshell'], 'account_expires_never' => $_POST['never_expires'], - 'account_email' => $_POST['account_email'], + 'account_email' => $email, /* 'file_space' => $_POST['account_file_space_number'] . "-" . $_POST['account_file_space_type'] */ ); @@ -517,6 +521,10 @@ if ($_POST['submit']) { + if (!($email = $_POST['account_email'])) + { + $email = $GLOBALS['egw']->common->email_address($_POST['account_firstname'],$_POST['account_lastname'],$_POST['account_lid']); + } $userData = array( 'account_lid' => $accountPrefix.$_POST['account_lid'], 'firstname' => $_POST['account_firstname'], @@ -535,7 +543,7 @@ 'homedirectory' => $_POST['homedirectory'], 'loginshell' => $_POST['loginshell'], 'account_expires_never' => $_POST['never_expires'], - 'email' => $_POST['account_email'], + 'email' => $email, /* 'file_space' => $_POST['account_file_space_number'] . "-" . $_POST['account_file_space_type'] */ ); if ($userData['account_primary_group'] && (!isset($userData['account_groups']) || !in_array($userData['account_primary_group'],$userData['account_groups']))) diff --git a/admin/inc/class.uiaccounts.inc.php b/admin/inc/class.uiaccounts.inc.php index 3434a5cdf3..eb24fde717 100755 --- a/admin/inc/class.uiaccounts.inc.php +++ b/admin/inc/class.uiaccounts.inc.php @@ -1029,6 +1029,8 @@ function create_edit_user($_account_id,$_userData='',$_errors='') { + $GLOBALS['egw_info']['flags']['include_xajax'] = true; + $sbox =& CreateObject('phpgwapi.sbox'); $jscal =& CreateObject('phpgwapi.jscalendar'); @@ -1127,7 +1129,8 @@ 'lang_firstname' => lang('First Name'), 'lang_anonymous' => lang('Anonymous User (not shown in list sessions)'), 'lang_changepassword' => lang('Can change password'), - 'lang_button' => ($_account_id?lang('Save'):lang('Add')) + 'lang_button' => ($_account_id?lang('Save'):lang('Add')), + 'lang_passwds_unequal' => lang('The two passwords are not the same'), /* 'lang_file_space' => lang('File Space') */ ); $t->set_var($var); @@ -1187,7 +1190,7 @@ $var = Array( 'input_expires' => $jscal->input('expires',$userData['expires']<0?'':($userData['expires']?$userData['expires']:time()+(60*60*24*7))), 'lang_never' => lang('Never'), - 'account_lid' => $accountPrefix.'', + 'account_lid' => $accountPrefix.'', 'lang_homedir' => $lang_homedir, 'lang_shell' => $lang_shell, 'homedirectory' => $homedirectory, @@ -1195,12 +1198,13 @@ 'anonymous' => '', 'changepassword' => '', 'account_status' => '', - 'account_firstname' => '', - 'account_lastname' => '', - 'account_email' => '', + 'account_firstname' => '', + 'account_lastname' => '', + 'account_email' => '', 'account_passwd' => $userData['account_passwd'], 'account_passwd_2' => $userData['account_passwd_2'], - 'account_file_space' => $account_file_space + 'account_file_space' => $account_file_space, + 'account_id' => (int) $userData['account_id'], ); if($userData['expires'] == -1) @@ -1325,6 +1329,22 @@ echo $t->fp('out','form'); } + function ajax_check_account_email($first,$last,$account_lid,$account_id,$email,$id) + { + $response =& new xajaxResponse(); + if (!$email) + { + $response->addAssign('email','value',$GLOBALS['egw']->common->email_address($first,$last,$account_lid)); + } + $id_account_lid = (int) $GLOBALS['egw']->accounts->name2id($account_lid); + if ($id == 'account' && $id_account_lid && $id_account_lid != (int) $account_id) + { + $response->addScript("alert('".addslashes(lang('That loginid has already been taken').': '.$account_lid)."'); document.getElementById('account').value='". + ($account_id ? $GLOBALS['egw']->accounts->id2name($account_id) : '')."'; document.getElementById('account').focus();"); + } + return $response->getXML(); + } + function edit_group_managers($group_info,$_errors='') { if ($GLOBALS['egw']->acl->check('group_access',16,'admin')) diff --git a/admin/setup/phpgw_de.lang b/admin/setup/phpgw_de.lang index 86c12e8856..324e8ff269 100644 --- a/admin/setup/phpgw_de.lang +++ b/admin/setup/phpgw_de.lang @@ -221,12 +221,14 @@ host information admin de Host-Information hour
(0-23) admin de Stunde
(0-23) how many days should entries stay in the access log, before they get deleted (default 90) ? admin de Wie viele Tage sollen Einträge im Zugangsprotokoll bleiben, bevor sie gelöscht werden (Vorgabe 90)? how many minutes should an account or ip be blocked (default 30) ? admin de Wie viele Minuten soll ein Benutzerkonto oder eine IP gesperrt werden (Vorgabe 30)? +how should email addresses for new users be constructed? admin de In welchem Format sollen EMail Adressen von neuen Benutzern erzeugt werden? icon admin de Icon idle admin de im Leerlauf if no acl records for user or any group the user is a member of admin de Wenn es keinen ACL-Eintrag für einen Benutzer oder oder eine Gruppe der er angehört gibt if using ldap, do you want to manage homedirectory and loginshell attributes? admin de Wenn Sie LDAP verwenden, wollen Sie Benutzerverzeichnisse und Komandointerpreter verwalten ? in mbyte admin de in MByte inbound admin de eingehend +initial admin de Anfangsbuchstabe install crontab admin de Crontab installieren installed applications common de Installierte Anwendungen installed crontab admin de Installierte Crontab @@ -406,7 +408,7 @@ use cookies to pass sessionid admin de SitzungsId in einem Cookie speichern use pure html compliant code (not fully working yet) admin de Vollständig HTML kompatiblen Code verwenden (nicht vollständig implementiert) use theme admin de Benutztes Farbschema user accounts admin de Benutzerkonten -user data admin de Benutzerdaten +user data common de Benutzerdaten user for smtp-authentication (leave it empty if no auth required) admin de Benutzer für SMTP Authentifizierung (leer lassen falls keine Authentifizierung nötig) user groups admin de Benutzergruppen userdata admin de Benutzerkonto diff --git a/admin/setup/phpgw_en.lang b/admin/setup/phpgw_en.lang index d5578201be..d4dcd2c996 100644 --- a/admin/setup/phpgw_en.lang +++ b/admin/setup/phpgw_en.lang @@ -221,12 +221,14 @@ host information admin en Host information hour
(0-23) admin en Hour
(0-23) how many days should entries stay in the access log, before they get deleted (default 90) ? admin en How many days should entries stay in the access log, before they get deleted (default 90) ? how many minutes should an account or ip be blocked (default 30) ? admin en How many minutes should an account or IP be blocked (default 30) ? +how should email addresses for new users be constructed? admin en How should EMail addresses for new users be constructed? icon admin en Icon idle admin en idle if no acl records for user or any group the user is a member of admin en If no ACL records for user or any group the user is a member of if using ldap, do you want to manage homedirectory and loginshell attributes? admin en If using LDAP, do you want to manage homedirectory and loginshell attributes? in mbyte admin en in MByte inbound admin en inbound +initial admin en Initial install crontab admin en Install crontab installed applications common en Installed applications installed crontab admin en Installed crontab @@ -406,7 +408,7 @@ use cookies to pass sessionid admin en Use cookies to pass sessionid use pure html compliant code (not fully working yet) admin en Use pure HTML compliant code (not fully working yet) use theme admin en Use theme user accounts admin en User accounts -user data admin en User Data +user data common en User Data user for smtp-authentication (leave it empty if no auth required) admin en User for SMTP-authentication (leave it empty if no auth required) user groups admin en User groups userdata admin en userdata diff --git a/admin/templates/default/account_form.tpl b/admin/templates/default/account_form.tpl index b6f762df0d..01ec0dc189 100644 --- a/admin/templates/default/account_form.tpl +++ b/admin/templates/default/account_form.tpl @@ -1,6 +1,34 @@ {error_messages} - +
@@ -75,9 +103,9 @@ - + - + diff --git a/admin/templates/default/config.tpl b/admin/templates/default/config.tpl index 1a34bf9c19..b0b77ae52b 100644 --- a/admin/templates/default/config.tpl +++ b/admin/templates/default/config.tpl @@ -71,6 +71,25 @@ + + + + +
{lang_password} {lang_reenter_password}
{lang_How_should_EMail_addresses_for_new_users_be_constructed?}: + +
 {lang_appearance}