mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 11:19:55 +03:00
fixes #1902 ability to set a specific group to notify user registrations
This commit is contained in:
parent
87926235ca
commit
4b33001c15
10 changed files with 170 additions and 19 deletions
|
@ -43,7 +43,6 @@ $main_checkboxes = array(
|
|||
'obligatory_user_mail_address',
|
||||
'rate',
|
||||
'rate_anonymous',
|
||||
'email_admin_on_new_user',
|
||||
'allow_user_customization',
|
||||
'log',
|
||||
'history_admin',
|
||||
|
@ -199,6 +198,26 @@ if (isset($_POST['submit']))
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($_POST['email_admin_on_new_user']))
|
||||
{
|
||||
$_POST['email_admin_on_new_user'] = 'none';
|
||||
}
|
||||
elseif ('all' == $_POST['email_admin_on_new_user_filter'])
|
||||
{
|
||||
$_POST['email_admin_on_new_user'] = 'all';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($_POST['email_admin_on_new_user_filter_group']))
|
||||
{
|
||||
$_POST['email_admin_on_new_user'] = 'all';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_POST['email_admin_on_new_user'] = 'group:'.$_POST['email_admin_on_new_user_filter_group'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $main_checkboxes as $checkbox)
|
||||
{
|
||||
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
|
||||
|
@ -372,6 +391,25 @@ switch ($page['section'])
|
|||
'mail_theme_options' => $mail_themes,
|
||||
'order_by' => $order_by,
|
||||
'order_by_options' => $sort_fields,
|
||||
'email_admin_on_new_user' => 'none' != $conf['email_admin_on_new_user'],
|
||||
'email_admin_on_new_user_filter' => in_array($conf['email_admin_on_new_user'], array('none', 'all')) ? 'all' : 'group',
|
||||
'email_admin_on_new_user_filter_group' => preg_match('/^group:(\d+)$/', $conf['email_admin_on_new_user'], $matches) ? $matches[1] : -1,
|
||||
)
|
||||
);
|
||||
|
||||
// list of groups
|
||||
$query = '
|
||||
SELECT
|
||||
id,
|
||||
name
|
||||
FROM '.GROUPS_TABLE.'
|
||||
;';
|
||||
$groups = query2array($query, 'id', 'name');
|
||||
natcasesort($groups);
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'group_options' => $groups,
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -2592,6 +2592,17 @@ function delete_groups($group_ids)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (preg_match('/^group:(\d+)$/', conf_get_param('email_admin_on_new_user', 'undefined'), $matches))
|
||||
{
|
||||
foreach ($group_ids as $group_id)
|
||||
{
|
||||
if ($group_id == $matches[1])
|
||||
{
|
||||
conf_update_param('email_admin_on_new_user', 'all', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$group_id_string = implode(',', $group_ids);
|
||||
|
||||
// destruction of the access linked to the group
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
(function(){
|
||||
var targets = {
|
||||
'input[name="rate"]' : '#rate_anonymous',
|
||||
'input[name="allow_user_registration"]' : '#email_admin_on_new_user'
|
||||
'input[name="allow_user_registration"]' : '#email_admin_on_new_user',
|
||||
'input[name="email_admin_on_new_user"]' : '#email_admin_on_new_user_filter'
|
||||
};
|
||||
|
||||
for (selector in targets) {
|
||||
|
@ -67,6 +68,12 @@ jQuery("input[name='mail_theme']").change(function() {
|
|||
jQuery("input[name='mail_theme']").parents(".themeSelect").removeClass("themeDefault");
|
||||
jQuery(this).parents(".themeSelect").addClass("themeDefault");
|
||||
});
|
||||
|
||||
jQuery("input[name='email_admin_on_new_user_filter']").change(function() {
|
||||
var val = jQuery("input[name='email_admin_on_new_user_filter']:checked").val();
|
||||
|
||||
jQuery('#email_admin_on_new_user_filter_group_options').toggle('group' == val);
|
||||
});
|
||||
{/footer_script}
|
||||
|
||||
<form method="post" action="{$F_ACTION}" class="properties">
|
||||
|
@ -119,11 +126,13 @@ jQuery("input[name='mail_theme']").change(function() {
|
|||
{'Allow rating'|translate}
|
||||
</label>
|
||||
|
||||
<label id="rate_anonymous" class="font-checkbox no-bold">
|
||||
<div id="rate_anonymous" class="sub-setting">
|
||||
<label class="font-checkbox no-bold">
|
||||
<span class="icon-check"></span>
|
||||
<input type="checkbox" name="rate_anonymous" {if ($main.rate_anonymous)}checked="checked"{/if}>
|
||||
{'Rating by guests'|translate}
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
@ -133,11 +142,38 @@ jQuery("input[name='mail_theme']").change(function() {
|
|||
{'Allow user registration'|translate}
|
||||
</label>
|
||||
|
||||
<label id="email_admin_on_new_user" class="font-checkbox no-bold">
|
||||
<div id="email_admin_on_new_user" class="sub-setting">
|
||||
<label class="font-checkbox no-bold">
|
||||
<span class="icon-check"></span>
|
||||
<input type="checkbox" name="email_admin_on_new_user" {if ($main.email_admin_on_new_user)}checked="checked"{/if}>
|
||||
{'Email admins when a new user registers'|translate}
|
||||
</label>
|
||||
|
||||
<div id="email_admin_on_new_user_filter" class="sub-setting"{if (!$main.email_admin_on_new_user)} style="display:none"{/if}>
|
||||
<label class="font-checkbox no-bold">
|
||||
<span class="icon-dot-circled"></span>
|
||||
<input type="radio" name="email_admin_on_new_user_filter" value="all" {if ($main.email_admin_on_new_user_filter eq 'all')}checked{/if}>
|
||||
{'All admins'|translate}
|
||||
</label>
|
||||
<br>
|
||||
<label class="font-checkbox no-bold">
|
||||
<span class="icon-dot-circled"></span>
|
||||
<input type="radio" name="email_admin_on_new_user_filter" value="group" {if ($main.email_admin_on_new_user_filter eq 'group')}checked{/if}>
|
||||
{'Only admins in a specific group'|translate}
|
||||
</label>
|
||||
|
||||
<span id="email_admin_on_new_user_filter_group_options"{if ($main.email_admin_on_new_user_filter ne 'group')} style="display:none"{/if}>
|
||||
{if count($group_options) > 0}
|
||||
<select name="email_admin_on_new_user_filter_group">
|
||||
{html_options options=$group_options selected=$main.email_admin_on_new_user_filter_group}
|
||||
</select>
|
||||
{else}
|
||||
{'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list" class="externalLink">{'Group management'|@translate}</a>
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
|
|
@ -4525,6 +4525,10 @@ ul.jqtree-tree .jqtree-element {
|
|||
#ftpPage p {text-align:left;margin:1em;}
|
||||
#ftpPage fieldset p {margin:0;}
|
||||
|
||||
.sub-setting {
|
||||
margin: 10px 0 10px 20px;
|
||||
}
|
||||
|
||||
/* watermark configuration screen */
|
||||
#watermarkPositionBox {
|
||||
width:500px;
|
||||
|
|
|
@ -351,7 +351,7 @@ function switch_lang_back()
|
|||
* @param boolean $send_technical_details - send user IP and browser
|
||||
* @return boolean
|
||||
*/
|
||||
function pwg_mail_notification_admins($subject, $content, $send_technical_details=true)
|
||||
function pwg_mail_notification_admins($subject, $content, $send_technical_details=true, $group_id=null)
|
||||
{
|
||||
if (empty($subject) or empty($content))
|
||||
{
|
||||
|
@ -397,7 +397,10 @@ function pwg_mail_notification_admins($subject, $content, $send_technical_detail
|
|||
array(
|
||||
'filename' => 'notification_admin',
|
||||
'assign' => $tpl_vars,
|
||||
)
|
||||
),
|
||||
true, // exclude_current_user
|
||||
false, // only_webmasters
|
||||
$group_id
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -411,7 +414,7 @@ function pwg_mail_notification_admins($subject, $content, $send_technical_detail
|
|||
* @param array $tpl - as in pwg_mail()
|
||||
* @return boolean
|
||||
*/
|
||||
function pwg_mail_admins($args=array(), $tpl=array(), $exclude_current_user=true, $only_webmasters=false)
|
||||
function pwg_mail_admins($args=array(), $tpl=array(), $exclude_current_user=true, $only_webmasters=false, $group_id=null)
|
||||
{
|
||||
if (empty($args['content']) and empty($tpl))
|
||||
{
|
||||
|
@ -430,14 +433,30 @@ function pwg_mail_admins($args=array(), $tpl=array(), $exclude_current_user=true
|
|||
// get admins (except ourself)
|
||||
$query = '
|
||||
SELECT
|
||||
i.user_id,
|
||||
u.'.$conf['user_fields']['username'].' AS name,
|
||||
u.'.$conf['user_fields']['email'].' AS email
|
||||
FROM '.USERS_TABLE.' AS u
|
||||
JOIN '.USER_INFOS_TABLE.' AS i
|
||||
ON i.user_id = u.'.$conf['user_fields']['id'].'
|
||||
ON i.user_id = u.'.$conf['user_fields']['id'];
|
||||
|
||||
if (!is_null($group_id))
|
||||
{
|
||||
$query.= '
|
||||
JOIN '.USER_GROUP_TABLE.' AS ug
|
||||
ON ug.user_id = i.user_id';
|
||||
}
|
||||
|
||||
$query.= '
|
||||
WHERE i.status in (\''.implode("','", $user_statuses).'\')
|
||||
AND u.'.$conf['user_fields']['email'].' IS NOT NULL';
|
||||
|
||||
if (!is_null($group_id))
|
||||
{
|
||||
$query.= '
|
||||
AND group_id = '.intval($group_id);
|
||||
}
|
||||
|
||||
if ($exclude_current_user)
|
||||
{
|
||||
$query.= '
|
||||
|
|
|
@ -212,7 +212,7 @@ SELECT id
|
|||
|
||||
create_user_infos($user_id, $override);
|
||||
|
||||
if ($notify_admin and $conf['email_admin_on_new_user'])
|
||||
if ($notify_admin and 'none' != $conf['email_admin_on_new_user'])
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
$admin_url = get_absolute_root_url().'admin.php?page=user_list&username='.$login;
|
||||
|
@ -224,9 +224,17 @@ SELECT id
|
|||
get_l10n_args('Admin: %s', $admin_url),
|
||||
);
|
||||
|
||||
$group_id = null;
|
||||
if (preg_match('/^group:(\d+)$/', $conf['email_admin_on_new_user'], $matches))
|
||||
{
|
||||
$group_id = $matches[1];
|
||||
}
|
||||
|
||||
pwg_mail_notification_admins(
|
||||
get_l10n_args('Registration of %s', stripslashes($login) ),
|
||||
$keyargs_content
|
||||
$keyargs_content,
|
||||
true, // $send_technical_details
|
||||
$group_id
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','S
|
|||
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_complementary_mail_content','','Complementary mail content for notification by mail');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_recent_post_dates','true','Send recent post by dates for notification by mail');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_new_user','false','Send an email to theadministrators when a user registers');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_new_user','none','Send an email to theadministrators when a user registers');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment','false','Send an email to the administrators when a valid comment is entered');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment_validation','true','Send an email to the administrators when a comment requires validation');
|
||||
INSERT INTO piwigo_config (param,value,comment) VALUES ('obligatory_user_mail_address','false','Mail address is obligatory for users');
|
||||
|
|
31
install/db/165-database.php
Normal file
31
install/db/165-database.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This file is part of Piwigo. |
|
||||
// | |
|
||||
// | For copyright and license information, please view the COPYING.txt |
|
||||
// | file that was distributed with this source code. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (!defined('PHPWG_ROOT_PATH'))
|
||||
{
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
|
||||
$upgrade_description = 'Add more options to email_admin_on_new_user';
|
||||
|
||||
list($old_value) = pwg_db_fetch_row(pwg_query('SELECT value FROM '.PREFIX_TABLE.'config WHERE param = "email_admin_on_new_user"'));
|
||||
|
||||
$new_value = 'all';
|
||||
if ('false' == $old_value)
|
||||
{
|
||||
$new_value = 'none';
|
||||
}
|
||||
|
||||
conf_update_param('email_admin_on_new_user', $new_value);
|
||||
|
||||
echo
|
||||
"\n"
|
||||
. $upgrade_description
|
||||
."\n"
|
||||
;
|
||||
?>
|
|
@ -1345,4 +1345,6 @@ $lang['or'] = 'or';
|
|||
$lang['Locked album'] = 'Locked album';
|
||||
$lang['This album is currently locked, visible only to administrators.'] = 'This album is currently locked, visible only to administrators.';
|
||||
$lang['Unlock it'] = 'Unlock it';
|
||||
$lang['All admins'] = 'All admins';
|
||||
$lang['Only admins in a specific group'] = 'Only admins in a specific group';
|
||||
// Leave this line empty
|
||||
|
|
|
@ -1345,4 +1345,6 @@ $lang['or'] = 'ou';
|
|||
$lang['Locked album'] = 'Album verrouillé';
|
||||
$lang['This album is currently locked, visible only to administrators.'] = 'Cet album est actuellement verrouillé, visible uniquement par les administrateurs.';
|
||||
$lang['Unlock it'] = 'Le déverrouiller';
|
||||
$lang['All admins'] = 'Tous les administrateurs';
|
||||
$lang['Only admins in a specific group'] = 'Uniquement les administrations d\'un groupe spécifique';
|
||||
// Leave this line empty
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue