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);
|
||||
$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;
|
||||
$poll_title = $dsondage->titre;
|
||||
function send_mail_admin() {
|
||||
global $email_admin;
|
||||
global $poll_title;
|
||||
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( $dsondage->titre ),
|
||||
_("[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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//si la valeur du nouveau titre est valide et que le bouton est activé
|
||||
@ -105,7 +109,9 @@ if (isset($_POST["boutonnouveautitre"])) {
|
||||
|
||||
//Email sent to the admin
|
||||
if ($connect->Execute($sql, array($nouveautitre, $numsondage))) {
|
||||
//if(config_get('use_smtp')==true){
|
||||
send_mail_admin();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
* general configuration
|
||||
*/
|
||||
|
||||
//is a smtp server is configured to send e-mail ?
|
||||
//$use_smtp = true;
|
||||
//use email for polls creation/modification/responses notification
|
||||
$use_smtp = true;
|
||||
|
||||
//if only one language is allowed in constants.php, $ALLOWED_LANGUAGES, the language selection bar is useless
|
||||
$show_language_bar_selection = true;
|
||||
@ -44,7 +44,7 @@
|
||||
* choix_autre.php
|
||||
*/
|
||||
//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 = false;
|
||||
|
@ -28,7 +28,7 @@ if (file_exists('bandeaux_local.php')) {
|
||||
}
|
||||
|
||||
// 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!") );
|
||||
bandeau_titre(_("Error!"));
|
||||
|
@ -68,6 +68,7 @@ function ajouter_sondage()
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($sondage, $_SESSION['toutchoix']));
|
||||
|
||||
if(config_get('use_smtp')==true){
|
||||
$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 .= "\n\n";
|
||||
$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";
|
||||
@ -83,7 +84,7 @@ function ajouter_sondage()
|
||||
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');
|
||||
Utils::cleaning_polls($connect, 'admin/logs_studs.txt');
|
||||
|
||||
|
@ -77,9 +77,11 @@ if (Utils::issetAndNoEmpty("poursuivre")){
|
||||
unset($_SESSION["mailsonde"]);
|
||||
$_SESSION["mailsonde"] = ($mailsonde !== null) ? true : false;
|
||||
|
||||
if (config_get('use_smtp')==true){
|
||||
if (Utils::isValidEmail($adresse) === false) {
|
||||
$erreur_adresse = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match(';<|>|";',$titre)) {
|
||||
$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
|
||||
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" ) {
|
||||
header("Location:choix_date.php");
|
||||
@ -242,16 +251,19 @@ echo '
|
||||
'.$input_name.'
|
||||
</div>
|
||||
</div>
|
||||
'.$errors['name']['msg'].'
|
||||
'.$errors['name']['msg'];
|
||||
if(config_get('use_smtp')==true){
|
||||
echo '
|
||||
<div class="form-group'.$errors['email']['class'].'">
|
||||
<label for="email" class="col-sm-4 control-label">'. _("Your email address") .' *</label>
|
||||
<div class="col-sm-8">
|
||||
'.$input_email.'
|
||||
</div>
|
||||
</div>
|
||||
'.$errors['email']['msg'].'
|
||||
'.$errors['email']['msg'];
|
||||
}
|
||||
|
||||
<div class="form-group">
|
||||
echo '<div class="form-group">
|
||||
<div class="col-sm-offset-1 col-sm-11">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
@ -259,8 +271,9 @@ echo '
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
</div>';
|
||||
if(config_get('use_smtp')==true){
|
||||
echo '<div class="form-group">
|
||||
<div class="col-sm-offset-1 col-sm-11">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
@ -268,9 +281,10 @@ echo '
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
<p class="text-right">
|
||||
echo '<p class="text-right">
|
||||
<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>
|
||||
</p>
|
||||
|
@ -173,6 +173,7 @@ if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) {
|
||||
$connect->Execute($sql, array($nom, $numsondage, $nouveauchoix));
|
||||
|
||||
if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") {
|
||||
if(config_get('use_smtp')==true){
|
||||
Utils::sendEmail( "$dsondage->mail_admin",
|
||||
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."",
|
||||
html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8').
|
||||
@ -181,6 +182,7 @@ if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) {
|
||||
_("Thanks for your confidence.") . "\n". NOMAPPLICATION );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$err |= NAME_EMPTY;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user