From 6d85089c9aaa43b67c0379e85ff7b6815a90a438 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 29 Sep 2009 10:59:12 +0000 Subject: [Bug 1041] Merged form trunk to branch : Switchable double/single password input with text or password type in admin using new $conf git-svn-id: http://piwigo.org/svn/branches/2.0@3945 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/template/goto/user_list.tpl | 9 ++++- admin/user_list.php | 81 +++++++++++++++++++++++++++++++-------- include/config_default.inc.php | 3 ++ 3 files changed, 75 insertions(+), 18 deletions(-) diff --git a/admin/template/goto/user_list.tpl b/admin/template/goto/user_list.tpl index aa4e369dc..76bbdbf3c 100644 --- a/admin/template/goto/user_list.tpl +++ b/admin/template/goto/user_list.tpl @@ -6,8 +6,13 @@
{'Add a user'|@translate} - - + + {if $Double_Password} + + + {else} + + {/if}
diff --git a/admin/user_list.php b/admin/user_list.php index 5011a2aea..daac95a8e 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -183,20 +183,63 @@ $page['direction_items'] = array( // | add a user | // +-----------------------------------------------------------------------+ -if (isset($_POST['submit_add'])) +// Check for config_default var - If True : Using double password type else single password type +// This feature is discussed on Piwigo's english forum +if ($conf['double_password_type_in_admin'] == true) { - $page['errors'] = register_user( - $_POST['login'], $_POST['password'], $_POST['email'], false); - - if (count($page['errors']) == 0) - { - array_push( - $page['infos'], - sprintf( - l10n('user "%s" added'), - $_POST['login'] - ) - ); + if (isset($_POST['submit_add'])) + { + if(empty($_POST['password'])) + { + array_push($page['errors'], l10n('Password is missing')); + } + else if(empty($_POST['password_conf'])) + { + array_push($page['errors'], l10n('Password confirmation is missing')); + } + else if(empty($_POST['email'])) + { + array_push($page['errors'], l10n('Email address is missing')); + } + else if ($_POST['password'] != $_POST['password_conf']) + { + array_push($page['errors'], l10n('Password confirmation error')); + } + else + { + $page['errors'] = register_user( + $_POST['login'], $_POST['password'], $_POST['email'], false); + + if (count($page['errors']) == 0) + { + array_push( + $page['infos'], + sprintf( + l10n('user "%s" added'), + $_POST['login'] + ) + ); + } + } + } +} +else if ($conf['double_password_type_in_admin'] == false) +{ + if (isset($_POST['submit_add'])) + { + $page['errors'] = register_user( + $_POST['login'], $_POST['password'], $_POST['email'], false); + + if (count($page['errors']) == 0) + { + array_push( + $page['infos'], + sprintf( + l10n('user "%s" added'), + $_POST['login'] + ) + ); + } } } @@ -486,6 +529,12 @@ if ($conf['allow_adviser']) $template->assign('adviser', true); } +// Display or Hide double password type +if ($conf['double_password_type_in_admin']) +{ + $template->assign('Double_Password', true); +} + // Filter status options $status_options[-1] = '------------'; foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) @@ -658,12 +707,12 @@ foreach ($visible_user_list as $local_user) 'U_PERM' => $perm_url.$local_user['id'], 'USERNAME' => $local_user['username'] .($local_user['id'] == $conf['guest_id'] - ? '
['.l10n('is_the_guest').']' : '') + ? '
['.l10n('is_the_guest').']' : '') .($local_user['id'] == $conf['default_user_id'] - ? '
['.l10n('is_the_default').']' : ''), + ? '
['.l10n('is_the_default').']' : ''), 'STATUS' => l10n('user_status_'. $local_user['status']).(($local_user['adviser'] == 'true') - ? '
['.l10n('adviser').']' : ''), + ? '
['.l10n('adviser').']' : ''), 'EMAIL' => get_email_address_as_display_text($local_user['email']), 'GROUPS' => $groups_string, 'PROPERTIES' => implode( ', ', $properties), diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 8d5c295ce..5983c392c 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -319,6 +319,9 @@ $conf['rate_items'] = array(0,1,2,3,4,5); // Define default method to use ('http' or 'html' in order to do redirect) $conf['default_redirect_method'] = 'http'; +// Define using double password type in admin's users management panel +$conf['double_password_type_in_admin'] = false; + // +-----------------------------------------------------------------------+ // | metadata | // +-----------------------------------------------------------------------+ -- cgit v1.2.3