new parameter '$use_smtp' to disable email notification if needed
bug correction on email notification (using '$dsondage->titre' in adminstuds.php)
This commit is contained in:
parent
e53043b232
commit
eb5677e451
|
@ -76,21 +76,25 @@ if (!$sondage || $sondage->RecordCount() != 1){
|
||||||
$dsujet=$sujets->FetchObject(false);
|
$dsujet=$sujets->FetchObject(false);
|
||||||
$dsondage=$sondage->FetchObject(false);
|
$dsondage=$sondage->FetchObject(false);
|
||||||
|
|
||||||
// Send email (only once during the session) to alert admin of the change he made
|
// Send email (only once during the session) to alert admin of the change he made. ==> two modifications (comment, title, description, ...) on differents polls in the same session will generate only one mail.
|
||||||
$email_admin = $dsondage->mail_admin;
|
$email_admin = $dsondage->mail_admin;
|
||||||
|
$poll_title = $dsondage->titre;
|
||||||
function send_mail_admin() {
|
function send_mail_admin() {
|
||||||
global $email_admin;
|
global $email_admin;
|
||||||
|
global $poll_title;
|
||||||
global $numsondageadmin;
|
global $numsondageadmin;
|
||||||
|
if(config_get('use_smtp')==true){
|
||||||
|
if(!isset($_SESSION["mail_admin_sent"])) {
|
||||||
|
Utils::sendEmail( $email_admin,
|
||||||
|
_("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $poll_title ),
|
||||||
|
_("You have changed the settings of your poll. \nYou can modify this poll with this link") .
|
||||||
|
" :\n\n" . Utils::getUrlSondage($numsondageadmin, true) . "\n\n" .
|
||||||
|
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION
|
||||||
|
);
|
||||||
|
$_SESSION["mail_admin_sent"]=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!isset($_SESSION["mail_admin_sent"])) {
|
|
||||||
Utils::sendEmail( $email_admin,
|
|
||||||
_("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $dsondage->titre ),
|
|
||||||
_("You have changed the settings of your poll. \nYou can modify this poll with this link") .
|
|
||||||
" :\n\n" . Utils::getUrlSondage($numsondageadmin, true) . "\n\n" .
|
|
||||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION
|
|
||||||
);
|
|
||||||
$_SESSION["mail_admin_sent"]=true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//si la valeur du nouveau titre est valide et que le bouton est activé
|
//si la valeur du nouveau titre est valide et que le bouton est activé
|
||||||
|
@ -105,8 +109,10 @@ if (isset($_POST["boutonnouveautitre"])) {
|
||||||
|
|
||||||
//Email sent to the admin
|
//Email sent to the admin
|
||||||
if ($connect->Execute($sql, array($nouveautitre, $numsondage))) {
|
if ($connect->Execute($sql, array($nouveautitre, $numsondage))) {
|
||||||
send_mail_admin();
|
//if(config_get('use_smtp')==true){
|
||||||
}
|
send_mail_admin();
|
||||||
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
* general configuration
|
* general configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//is a smtp server is configured to send e-mail ?
|
//use email for polls creation/modification/responses notification
|
||||||
//$use_smtp = true;
|
$use_smtp = true;
|
||||||
|
|
||||||
//if only one language is allowed in constants.php, $ALLOWED_LANGUAGES, the language selection bar is useless
|
//if only one language is allowed in constants.php, $ALLOWED_LANGUAGES, the language selection bar is useless
|
||||||
$show_language_bar_selection = true;
|
$show_language_bar_selection = true;
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
* choix_autre.php
|
* choix_autre.php
|
||||||
*/
|
*/
|
||||||
//default values for the new poll duration (number of days).
|
//default values for the new poll duration (number of days).
|
||||||
$default_poll_duration = 10;
|
$default_poll_duration = 30;
|
||||||
|
|
||||||
//user can add link or URL when creating his poll.
|
//user can add link or URL when creating his poll.
|
||||||
$user_can_add_link_or_url = false;
|
$user_can_add_link_or_url = false;
|
||||||
|
|
|
@ -28,7 +28,7 @@ if (file_exists('bandeaux_local.php')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1/3 : error if $_SESSION from info_sondage are not valid
|
// Step 1/3 : error if $_SESSION from info_sondage are not valid
|
||||||
if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || Utils::issetAndNoEmpty('adresse', $_SESSION) === false) {
|
if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || ((config_get('use_smtp')) ? Utils::issetAndNoEmpty('adresse', $_SESSION) === false : false)) {
|
||||||
|
|
||||||
Utils::print_header ( _("Error!") );
|
Utils::print_header ( _("Error!") );
|
||||||
bandeau_titre(_("Error!"));
|
bandeau_titre(_("Error!"));
|
||||||
|
|
|
@ -68,22 +68,23 @@ function ajouter_sondage()
|
||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
$connect->Execute($sql, array($sondage, $_SESSION['toutchoix']));
|
$connect->Execute($sql, array($sondage, $_SESSION['toutchoix']));
|
||||||
|
|
||||||
$message = _("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.");
|
if(config_get('use_smtp')==true){
|
||||||
$message .= "\n\n";
|
$message = _("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.");
|
||||||
$message .= stripslashes(html_entity_decode($_SESSION["nom"],ENT_QUOTES,"UTF-8"))." " . _("hast just created a poll called") . " : \"".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES))."\".\n";
|
$message .= "\n\n";
|
||||||
$message .= _("Thanks for filling the poll at the link above") . " :\n\n%s\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION;
|
$message .= stripslashes(html_entity_decode($_SESSION["nom"],ENT_QUOTES,"UTF-8"))." " . _("hast just created a poll called") . " : \"".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES))."\".\n";
|
||||||
|
$message .= _("Thanks for filling the poll at the link above") . " :\n\n%s\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION;
|
||||||
|
|
||||||
$message_admin = _("This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above");
|
$message_admin = _("This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above");
|
||||||
$message_admin .= " :\n\n"."%s \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION;
|
$message_admin .= " :\n\n"."%s \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION;
|
||||||
|
|
||||||
$message = sprintf($message, Utils::getUrlSondage($sondage));
|
$message = sprintf($message, Utils::getUrlSondage($sondage));
|
||||||
$message_admin = sprintf($message_admin, Utils::getUrlSondage($sondage_admin, true));
|
$message_admin = sprintf($message_admin, Utils::getUrlSondage($sondage_admin, true));
|
||||||
|
|
||||||
if (Utils::isValidEmail($_SESSION['adresse'])) {
|
|
||||||
Utils::sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $_SESSION['adresse'] );
|
|
||||||
Utils::sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $_SESSION['adresse'] );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (Utils::isValidEmail($_SESSION['adresse'])) {
|
||||||
|
Utils::sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $_SESSION['adresse'] );
|
||||||
|
Utils::sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $_SESSION['adresse'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
error_log(date('H:i:s d/m/Y:') . ' CREATION: '.$sondage."\t".$_SESSION[formatsondage]."\t".$_SESSION[nom]."\t".$_SESSION[adresse]."\t \t".$_SESSION[toutchoix]."\n", 3, 'admin/logs_studs.txt');
|
error_log(date('H:i:s d/m/Y:') . ' CREATION: '.$sondage."\t".$_SESSION[formatsondage]."\t".$_SESSION[nom]."\t".$_SESSION[adresse]."\t \t".$_SESSION[toutchoix]."\n", 3, 'admin/logs_studs.txt');
|
||||||
Utils::cleaning_polls($connect, 'admin/logs_studs.txt');
|
Utils::cleaning_polls($connect, 'admin/logs_studs.txt');
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,11 @@ if (Utils::issetAndNoEmpty("poursuivre")){
|
||||||
unset($_SESSION["mailsonde"]);
|
unset($_SESSION["mailsonde"]);
|
||||||
$_SESSION["mailsonde"] = ($mailsonde !== null) ? true : false;
|
$_SESSION["mailsonde"] = ($mailsonde !== null) ? true : false;
|
||||||
|
|
||||||
if (Utils::isValidEmail($adresse) === false) {
|
if (config_get('use_smtp')==true){
|
||||||
$erreur_adresse = true;
|
if (Utils::isValidEmail($adresse) === false) {
|
||||||
}
|
$erreur_adresse = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match(';<|>|";',$titre)) {
|
if (preg_match(';<|>|";',$titre)) {
|
||||||
$erreur_injection_titre = true;
|
$erreur_injection_titre = true;
|
||||||
|
@ -94,7 +96,14 @@ if (Utils::issetAndNoEmpty("poursuivre")){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si pas d'erreur dans l'adresse alors on change de page vers date ou autre
|
// Si pas d'erreur dans l'adresse alors on change de page vers date ou autre
|
||||||
if ($titre && $nom && $adresse && !$erreur_adresse && ! $erreur_injection_titre && ! $erreur_injection_commentaires && ! $erreur_injection_nom) {
|
if(config_get('use_smtp')==true){
|
||||||
|
$email_OK = $adresse && !$erreur_adresse;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$email_OK = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($titre && $nom && $email_OK && ! $erreur_injection_titre && ! $erreur_injection_commentaires && ! $erreur_injection_nom) {
|
||||||
|
|
||||||
if ( $poursuivre == "creation_sondage_date" ) {
|
if ( $poursuivre == "creation_sondage_date" ) {
|
||||||
header("Location:choix_date.php");
|
header("Location:choix_date.php");
|
||||||
|
@ -242,16 +251,19 @@ echo '
|
||||||
'.$input_name.'
|
'.$input_name.'
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
'.$errors['name']['msg'].'
|
'.$errors['name']['msg'];
|
||||||
<div class="form-group'.$errors['email']['class'].'">
|
if(config_get('use_smtp')==true){
|
||||||
<label for="email" class="col-sm-4 control-label">'. _("Your email address") .' *</label>
|
echo '
|
||||||
<div class="col-sm-8">
|
<div class="form-group'.$errors['email']['class'].'">
|
||||||
'.$input_email.'
|
<label for="email" class="col-sm-4 control-label">'. _("Your email address") .' *</label>
|
||||||
</div>
|
<div class="col-sm-8">
|
||||||
</div>
|
'.$input_email.'
|
||||||
'.$errors['email']['msg'].'
|
</div>
|
||||||
|
</div>
|
||||||
|
'.$errors['email']['msg'];
|
||||||
|
}
|
||||||
|
|
||||||
<div class="form-group">
|
echo '<div class="form-group">
|
||||||
<div class="col-sm-offset-1 col-sm-11">
|
<div class="col-sm-offset-1 col-sm-11">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
|
@ -259,18 +271,20 @@ echo '
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>';
|
||||||
<div class="form-group">
|
if(config_get('use_smtp')==true){
|
||||||
<div class="col-sm-offset-1 col-sm-11">
|
echo '<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="col-sm-offset-1 col-sm-11">
|
||||||
<label>
|
<div class="checkbox">
|
||||||
<input type=checkbox name=mailsonde '.$cochemail.' id="mailsonde">'. _("To receive an email for each new vote.") .'
|
<label>
|
||||||
</label>
|
<input type=checkbox name=mailsonde '.$cochemail.' id="mailsonde">'. _("To receive an email for each new vote.") .'
|
||||||
</div>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
|
||||||
<p class="text-right">
|
echo '<p class="text-right">
|
||||||
<input type="hidden" name="choix_sondage" value="'. $choix_sondage .'"/>
|
<input type="hidden" name="choix_sondage" value="'. $choix_sondage .'"/>
|
||||||
<button name="poursuivre" value="'. $choix_sondage .'" type="submit" class="btn btn-success" title="'. _('Go to step 2') . '">'. _('Next') . '</button>
|
<button name="poursuivre" value="'. $choix_sondage .'" type="submit" class="btn btn-success" title="'. _('Go to step 2') . '">'. _('Next') . '</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
16
studs.php
16
studs.php
|
@ -173,13 +173,15 @@ if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) {
|
||||||
$connect->Execute($sql, array($nom, $numsondage, $nouveauchoix));
|
$connect->Execute($sql, array($nom, $numsondage, $nouveauchoix));
|
||||||
|
|
||||||
if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") {
|
if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") {
|
||||||
Utils::sendEmail( "$dsondage->mail_admin",
|
if(config_get('use_smtp')==true){
|
||||||
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."",
|
Utils::sendEmail( "$dsondage->mail_admin",
|
||||||
html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8').
|
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."",
|
||||||
_("has filled a line.\nYou can find your poll at the link") . " :\n\n".
|
html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8').
|
||||||
Utils::getUrlSondage($numsondage) . " \n\n" .
|
_("has filled a line.\nYou can find your poll at the link") . " :\n\n".
|
||||||
_("Thanks for your confidence.") . "\n". NOMAPPLICATION );
|
Utils::getUrlSondage($numsondage) . " \n\n" .
|
||||||
}
|
_("Thanks for your confidence.") . "\n". NOMAPPLICATION );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$err |= NAME_EMPTY;
|
$err |= NAME_EMPTY;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user