Resolved issue 0000784: Mail notification disabled on register user
Merge branch-1_7 2176:2177 into BSF git-svn-id: http://piwigo.org/svn/trunk@2178 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
24553207a9
commit
89623393d4
4 changed files with 44 additions and 42 deletions
|
|
@ -196,7 +196,7 @@ $page['direction_items'] = array(
|
||||||
if (isset($_POST['submit_add']))
|
if (isset($_POST['submit_add']))
|
||||||
{
|
{
|
||||||
$page['errors'] = register_user(
|
$page['errors'] = register_user(
|
||||||
$_POST['login'], $_POST['password'], $_POST['email']);
|
$_POST['login'], $_POST['password'], $_POST['email'], false);
|
||||||
|
|
||||||
if (count($page['errors']) == 0)
|
if (count($page['errors']) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,8 @@ where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function register_user($login, $password, $mail_address, $errors = array())
|
function register_user($login, $password, $mail_address,
|
||||||
|
$with_notification = true, $errors = array())
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
|
@ -113,28 +114,29 @@ SELECT MAX('.$conf['user_fields']['id'].') + 1
|
||||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
mass_inserts(USERS_TABLE, array_keys($insert), array($insert));
|
mass_inserts(USERS_TABLE, array_keys($insert), array($insert));
|
||||||
|
|
||||||
// Assign by default groups
|
// Assign by default groups
|
||||||
{
|
{
|
||||||
$query = '
|
$query = '
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM '.GROUPS_TABLE.'
|
FROM '.GROUPS_TABLE.'
|
||||||
WHERE is_default = \''.boolean_to_string(true).'\'
|
WHERE is_default = \''.boolean_to_string(true).'\'
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
;';
|
;';
|
||||||
$result = pwg_query($query);
|
$result = pwg_query($query);
|
||||||
|
|
||||||
$inserts = array();
|
$inserts = array();
|
||||||
while ($row = mysql_fetch_array($result))
|
while ($row = mysql_fetch_array($result))
|
||||||
{
|
{
|
||||||
array_push
|
array_push
|
||||||
(
|
|
||||||
$inserts,
|
|
||||||
array
|
|
||||||
(
|
(
|
||||||
'user_id' => $next_id,
|
$inserts,
|
||||||
'group_id' => $row['id']
|
array
|
||||||
)
|
(
|
||||||
);
|
'user_id' => $next_id,
|
||||||
|
'group_id' => $row['id']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($inserts) != 0)
|
if (count($inserts) != 0)
|
||||||
|
|
@ -142,10 +144,31 @@ SELECT id
|
||||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts);
|
mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
create_user_infos($next_id);
|
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',
|
trigger_action('register_user',
|
||||||
array(
|
array(
|
||||||
'id'=>$next_id,
|
'id'=>$next_id,
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
|
||||||
{
|
{
|
||||||
if (!($user['id'] = get_userid($_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']);
|
$user['id'] = get_userid($_SERVER['REMOTE_USER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
register.php
25
register.php
|
|
@ -52,34 +52,13 @@ if (isset($_POST['submit']))
|
||||||
register_user($_POST['login'],
|
register_user($_POST['login'],
|
||||||
$_POST['password'],
|
$_POST['password'],
|
||||||
$_POST['mail_address'],
|
$_POST['mail_address'],
|
||||||
|
true,
|
||||||
$errors);
|
$errors);
|
||||||
|
|
||||||
if (count($errors) == 0)
|
if (count($errors) == 0)
|
||||||
{
|
{
|
||||||
$user_id = get_userid($_POST['login']);
|
$user_id = get_userid($_POST['login']);
|
||||||
log_user( $user_id, false);
|
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
redirect(make_index_url());
|
redirect(make_index_url());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue