feature 440: send mail to admin when comment is entered

git-svn-id: http://piwigo.org/svn/trunk@1617 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2006-11-22 04:41:25 +00:00
parent f3db3ef388
commit 5de8aeafad
9 changed files with 190 additions and 46 deletions
+46 -23
View File
@@ -46,6 +46,22 @@ else
{
$page['section'] = $_GET['section'];
}
$general_checkboxes = array(
'log',
'history_admin',
'history_guest',
'login_history',
'email_admin_on_new_user'
);
$comments_checkboxes = array(
'comments_forall',
'comments_validation',
'email_admin_on_comment',
'email_admin_on_comment_validation',
);
//------------------------------ verification and registration of modifications
if (isset($_POST['submit']) and !is_adviser())
{
@@ -58,10 +74,10 @@ if (isset($_POST['submit']) and !is_adviser())
{
array_push($page['errors'], $lang['conf_gallery_url_error']);
}
$_POST['log'] = empty($_POST['log'])?'false':'true';
$_POST['history_admin'] = empty($_POST['history_admin'])?'false':'true';
$_POST['history_guest'] = empty($_POST['history_guest'])?'false':'true';
$_POST['login_history'] = empty($_POST['login_history'])?'false':'true';
foreach( $general_checkboxes as $checkbox)
{
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
}
break;
}
case 'comments' :
@@ -74,6 +90,10 @@ if (isset($_POST['submit']) and !is_adviser())
{
array_push($page['errors'], $lang['conf_nb_comment_page_error']);
}
foreach( $comments_checkboxes as $checkbox)
{
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
}
break;
}
case 'default' :
@@ -160,26 +180,18 @@ $template->assign_vars(
'F_ACTION'=>$action
));
$html_check='checked="checked"';
switch ($page['section'])
{
case 'general' :
{
$html_check='checked="checked"';
$lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
$lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':'';
$history_users = ($conf['log']=='true')?$html_check:'';
$history_admin = ($conf['history_admin']=='true')?$html_check:'';
$history_guest = ($conf['history_guest']=='true')?$html_check:'';
$login_history = ($conf['login_history']=='true')?$html_check:'';
$template->assign_block_vars(
'general',
array(
'HISTORY_USERS'=>$history_users,
'HISTORY_ADMIN'=>$history_admin,
'HISTORY_GUEST'=>$history_guest,
'LOGIN_HISTORY'=>$login_history,
'GALLERY_LOCKED_YES'=>$lock_yes,
'GALLERY_LOCKED_NO'=>$lock_no,
($conf['rate']=='true'?'RATE_YES':'RATE_NO')=>$html_check,
@@ -189,24 +201,35 @@ switch ($page['section'])
'CONF_PAGE_BANNER' => $conf['page_banner'],
'CONF_GALLERY_URL' => $conf['gallery_url'],
));
foreach( $general_checkboxes as $checkbox)
{
$template->merge_block_vars(
'general',
array(
strtoupper($checkbox) => ($conf[$checkbox]=='true')?$html_check:''
)
);
}
break;
}
case 'comments' :
{
$all_yes = ($conf['comments_forall']=='true')?'checked="checked"':'';
$all_no = ($conf['comments_forall']=='false')?'checked="checked"':'';
$validate_yes = ($conf['comments_validation']=='true')?'checked="checked"':'';
$validate_no = ($conf['comments_validation']=='false')?'checked="checked"':'';
$template->assign_block_vars(
'comments',
array(
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
'COMMENTS_ALL_YES'=>$all_yes,
'COMMENTS_ALL_NO'=>$all_no,
'VALIDATE_YES'=>$validate_yes,
'VALIDATE_NO'=>$validate_no
));
foreach( $comments_checkboxes as $checkbox)
{
$template->merge_block_vars(
'comments',
array(
strtoupper($checkbox) => ($conf[$checkbox]=='true')?$html_check:''
)
);
}
break;
}
case 'default' :
+15 -13
View File
@@ -155,28 +155,30 @@ else
// +-----------------------------------------------------------------------+
// | comments management |
// +-----------------------------------------------------------------------+
if (is_admin() and !is_adviser() )
{
if (isset($_GET['delete']) and is_numeric($_GET['delete']) )
{// comments deletion
$query = '
if (isset($_GET['delete']) and is_numeric($_GET['delete'])
and !is_adviser() )
{// comments deletion
check_status(ACCESS_ADMINISTRATOR);
$query = '
DELETE FROM '.COMMENTS_TABLE.'
WHERE id='.$_GET['delete'].'
;';
pwg_query($query);
}
pwg_query($query);
}
if (isset($_GET['validate']) and is_numeric($_GET['validate']) )
{ // comments validation
$query = '
if (isset($_GET['validate']) and is_numeric($_GET['validate'])
and !is_adviser() )
{ // comments validation
check_status(ACCESS_ADMINISTRATOR);
$query = '
UPDATE '.COMMENTS_TABLE.'
SET validated = \'true\'
, validation_date = NOW()
, validation_date = NOW()
WHERE id='.$_GET['validate'].'
;';
pwg_query($query);
}
pwg_query($query);
}
// +-----------------------------------------------------------------------+
// | page header and options |
// +-----------------------------------------------------------------------+
-3
View File
@@ -515,9 +515,6 @@ $conf['nbm_max_treatment_timeout_percent'] = 0.8;
// nbm_treatment_timeout_default is used by default
$conf['nbm_treatment_timeout_default'] = 20;
// Send an email to the webmaster when a new user registers
$conf['email_admin_on_new_user']=false;
// +-----------------------------------------------------------------------+
// | Set default admin layout |
// +-----------------------------------------------------------------------+
+25
View File
@@ -193,6 +193,31 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
}
$template->assign_block_vars('information',
array('INFORMATION'=>$message));
if ( ($comment_action=='validate' and $conf['email_admin_on_comment'])
or $conf['email_admin_on_comment_validation'] )
{
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
$del_url = get_host_url().cookie_path()
.'comments.php?delete='.$comm['id'];
$content =
'Author: '.$comm['author']."\n"
.'Comment: '.$comm['content']."\n"
.'IP: '.$comm['ip']."\n"
.'Browser: '.$comm['agent']."\n\n"
.'Delete: '.$del_url."\n";
if ($comment_action!='validate')
{
$content .=
'Validate: '.get_host_url().cookie_path()
.'comments.php?validate='.$comm['id'];
}
pwg_mail( get_webmaster_mail_address(), '',
'PWG comment by '.$comm['author'],
$content
);
}
}
else
{
+3
View File
@@ -26,3 +26,6 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('login_history','
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_complementary_mail_content','','Complementary mail content for notification by mail');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_new_user','false','Send an email to the admin when a user registers');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_comment','false','Send an email to the admin when a valid comment is entered');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_comment_validation','false','Send an email to the admin when a comment requires validation');
+62
View File
@@ -0,0 +1,62 @@
<?php
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $
// | last modifier : $Author: plg $
// | revision : $Revision: 870 $
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add email_admin_on_new_user, email_admin_on_comment, email_admin_on_comment_validation';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('email_admin_on_new_user','false','Send an email to the admin when a user registers');
";
pwg_query($query);
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('email_admin_on_comment','false','Send an email to the admin when a valid comment is entered');
";
pwg_query($query);
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('email_admin_on_comment_validation','false','Send an email to the admin when a comment requires validation');
";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
+3
View File
@@ -81,6 +81,9 @@ $lang['Edit all picture informations'] = 'Edit all picture informations';
$lang['Edit selected tags'] = 'Edit selected tags';
$lang['Edit tags'] = 'Edit tags';
$lang['Elements'] = 'Elements';
$lang['Email admin when a new user registers'] = 'Email admin when a new user registers';
$lang['Email admin when a valid comment is entered'] = 'Email admin when a valid comment is entered';
$lang['Email admin when a comment requires validation'] = 'Email admin when a comment requires validation';
$lang['Empty caddie'] = 'Empty caddie';
$lang['Environment'] = 'Environment';
$lang['Expand all categories'] = 'Expand all categories';
+3
View File
@@ -81,6 +81,9 @@ $lang['Edit all picture informations'] = 'Modifier toutes les informations li
$lang['Edit selected tags'] = 'Editer les tags sélectionnés';
$lang['Edit tags'] = 'Editer les tags';
$lang['Elements'] = 'Éléments';
$lang['Email admin when a new user registers'] = 'Notifier le webmestre lors de l\'inscription d\'un utilisateur';
$lang['Email admin when a valid comment is entered'] = 'Notifier le webmestre quand un commentaire est enregistré';
$lang['Email admin when a comment requires validation'] = 'Notifier le webmestre quand un commentaire requiert sa validation';
$lang['Empty caddie'] = 'Vider le panier';
$lang['Environment'] = 'Environnement';
$lang['Expand all categories'] = 'Développer toutes les catégories';
+33 -7
View File
@@ -52,12 +52,20 @@
<label><input type="radio" class="radio" name="rate_anonymous" value="false" {general.RATE_ANONYMOUS_NO} />{lang:No}</label>
</li>
<li>
<label>
<span class="property">{lang:Email admin when a new user registers}</span>
<input type="checkbox" name="email_admin_on_new_user" {general.EMAIL_ADMIN_ON_NEW_USER} />
</label>
</li>
<br/>
<li>
<fieldset>
<legend>{lang:History}</legend>
<ul>
<li>
<label><span class="property">{lang:Users}</span><input type="checkbox" name="log" {general.HISTORY_USERS} /></label>
<label><span class="property">{lang:Users}</span><input type="checkbox" name="log" {general.LOG} /></label>
</li>
<li>
@@ -84,9 +92,10 @@
<ul>
<li>
<span class="property">{lang:Comments for all}</span>
<label><input type="radio" class="radio" name="comments_forall" value="true" {comments.COMMENTS_ALL_YES} />{lang:Yes}</label>
<label><input type="radio" class="radio" name="comments_forall" value="false" {comments.COMMENTS_ALL_NO} />{lang:No}</label>
<label>
<span class="property">{lang:Comments for all}</span>
<input type="checkbox" name="comments_forall" {comments.COMMENTS_FORALL} />
</label>
</li>
<li>
@@ -97,10 +106,27 @@
</li>
<li>
<span class="property">{lang:Validation}</span>
<label><input type="radio" class="radio" name="comments_validation" value="true" {comments.VALIDATE_YES} />{lang:Yes}</label>
<label><input type="radio" class="radio" name="comments_validation" value="false" {comments.VALIDATE_NO} />{lang:No}</label>
<label>
<span class="property">{lang:Validation}</span>
<input type="checkbox" name="comments_validation" {comments.COMMENTS_VALIDATION} />
</label>
</li>
<li>
<label>
<span class="property">{lang:Email admin when a valid comment is entered}</span>
<input type="checkbox" name="email_admin_on_comment" {comments.EMAIL_ADMIN_ON_COMMENT} />
</label>
</li>
<li>
<label>
<span class="property">{lang:Email admin when a comment requires validation}</span>
<input type="checkbox" name="email_admin_on_comment_validation" {comments.EMAIL_ADMIN_ON_COMMENT_VALIDATION} />
</label>
</li>
</ul>
</fieldset>
<!-- END comments -->