diff options
Diffstat (limited to '')
-rw-r--r-- | admin/user_list.php | 2 | ||||
-rw-r--r-- | include/functions_user.inc.php | 57 | ||||
-rw-r--r-- | include/user.inc.php | 2 | ||||
-rw-r--r-- | register.php | 25 |
4 files changed, 44 insertions, 42 deletions
diff --git a/admin/user_list.php b/admin/user_list.php index 6bd8c4046..57149c295 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -193,7 +193,7 @@ $page['direction_items'] = array( if (isset($_POST['submit_add'])) { $page['errors'] = register_user( - $_POST['login'], $_POST['password'], $_POST['email']); + $_POST['login'], $_POST['password'], $_POST['email'], false); if (count($page['errors']) == 0) { diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 40a8e7280..6d8c8b666 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -44,7 +44,8 @@ function validate_mail_address( $mail_address ) } } -function register_user($login, $password, $mail_address, $errors = array()) +function register_user($login, $password, $mail_address, + $with_notification = true, $errors = array()) { global $lang, $conf; @@ -91,28 +92,29 @@ SELECT MAX('.$conf['user_fields']['id'].') + 1 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); mass_inserts(USERS_TABLE, array_keys($insert), array($insert)); - // Assign by default groups - { - $query = ' + // Assign by default groups + { + $query = ' SELECT id FROM '.GROUPS_TABLE.' WHERE is_default = \''.boolean_to_string(true).'\' ORDER BY id ASC ;'; - $result = pwg_query($query); + $result = pwg_query($query); - $inserts = array(); - while ($row = mysql_fetch_array($result)) - { - array_push - ( - $inserts, - array + $inserts = array(); + while ($row = mysql_fetch_array($result)) + { + array_push ( - 'user_id' => $next_id, - 'group_id' => $row['id'] - ) - ); + $inserts, + array + ( + 'user_id' => $next_id, + 'group_id' => $row['id'] + ) + ); + } } if (count($inserts) != 0) @@ -120,10 +122,31 @@ SELECT id include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts); } - } create_user_infos($next_id); + if ($with_notification and $conf['email_admin_on_new_user']) + { + include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); + $username = $_POST['login']; + $admin_url = get_absolute_root_url() + .'admin.php?page=user_list&username='.$username; + + $keyargs_content = array + ( + get_l10n_args('User: %s', $username), + get_l10n_args('Email: %s', $_POST['mail_address']), + get_l10n_args('', ''), + get_l10n_args('Admin: %s', $admin_url) + ); + + pwg_mail_notification_admins + ( + get_l10n_args('Registration of %s', $username), + $keyargs_content + ); + } + trigger_action('register_user', array( 'id'=>$next_id, diff --git a/include/user.inc.php b/include/user.inc.php index 047e68723..965cfa262 100644 --- a/include/user.inc.php +++ b/include/user.inc.php @@ -65,7 +65,7 @@ if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER'])) { if (!($user['id'] = get_userid($_SERVER['REMOTE_USER']))) { - register_user($_SERVER['REMOTE_USER'], '', ''); + register_user($_SERVER['REMOTE_USER'], '', '', false); $user['id'] = get_userid($_SERVER['REMOTE_USER']); } } diff --git a/register.php b/register.php index eed28b847..5eb1d5b5d 100644 --- a/register.php +++ b/register.php @@ -52,34 +52,13 @@ if (isset($_POST['submit'])) register_user($_POST['login'], $_POST['password'], $_POST['mail_address'], + true, $errors); if (count($errors) == 0) { $user_id = get_userid($_POST['login']); - log_user( $user_id, false); - - if ($conf['email_admin_on_new_user']) - { - include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); - $username = $_POST['login']; - $admin_url = get_absolute_root_url() - .'admin.php?page=user_list&username='.$username; - - $keyargs_content = array - ( - get_l10n_args('User: %s', $username), - get_l10n_args('Email: %s', $_POST['mail_address']), - get_l10n_args('', ''), - get_l10n_args('Admin: %s', $admin_url) - ); - - pwg_mail_notification_admins - ( - get_l10n_args('Registration of %s', $username), - $keyargs_content - ); - } + log_user($user_id, false); redirect(make_index_url()); } } |