Esempio n. 1
0
/** Fonction destinée à envoyer un mail suite à une proposition de correction d'appréciation
 *
 * @param string $corriger_app_login_eleve Login de l'élève
 * @param integer $corriger_app_id_groupe Identifiant du groupe
 * @param integer $corriger_app_num_periode Numéro de période
 * $texte_mail string l'explication à envoyer
 *
 * @return $string Chaine pour $msg
 */
function envoi_mail_proposition_correction($corriger_app_login_eleve, $corriger_app_id_groupe, $corriger_app_num_periode, $texte_mail)
{
    global $mysqli;
    global $prefixe_debug;
    if ($prefixe_debug == "") {
        $prefixe_debug = strftime("%Y%m%d %H%M%S") . " : " . $_SESSION['login'];
    }
    $msg = "";
    if ($texte_mail != "") {
        $envoi_mail_actif = getSettingValue('envoi_mail_actif');
        if ($envoi_mail_actif != 'n' && $envoi_mail_actif != 'y') {
            $envoi_mail_actif = 'y';
            // Passer à 'n' pour faire des tests hors ligne... la phase d'envoi de mail peut sinon ensabler.
        }
        if ($envoi_mail_actif == 'y') {
            $email_destinataires = "";
            $sql = "SELECT id_classe FROM j_eleves_classes WHERE (login='******' AND periode='{$corriger_app_num_periode}');";
            $req = mysqli_query($mysqli, $sql);
            if (mysqli_num_rows($req) > 0) {
                //$correction_id_classe=mysql_result($req,0,"id_classe");
                $obj_classe = $req->fetch_object();
                $correction_id_classe = $obj_classe->id_classe;
                $sql = "(SELECT DISTINCT email FROM utilisateurs WHERE statut='secours' AND email!='')\n\t\t\t\tUNION (SELECT DISTINCT email FROM utilisateurs u, j_scol_classes jsc WHERE u.login=jsc.login AND id_classe='{$correction_id_classe}');";
            } else {
                //$sql="select email from utilisateurs where statut='secours' AND email!='';";
                $sql = "select email from utilisateurs where (statut='secours' OR statut='scolarite') AND email!='';";
            }
            //echo "$sql<br />";
            fich_debug_proposition_correction_app($prefixe_debug . " : {$sql}\n");
            $req = mysqli_query($mysqli, $sql);
            if (mysqli_num_rows($req) > 0) {
                $lig_u = mysqli_fetch_object($req);
                $email_destinataires = $lig_u->email;
                while ($lig_u = mysqli_fetch_object($req)) {
                    $email_destinataires .= ", " . $lig_u->email;
                    $tab_param_mail['destinataire'][] = $lig_u->email;
                }
                $email_declarant = "";
                $nom_declarant = "";
                $sql = "select nom, prenom, civilite, email from utilisateurs where login = '******'login'] . "';";
                fich_debug_proposition_correction_app($prefixe_debug . " : {$sql}\n");
                $req = mysqli_query($mysqli, $sql);
                if (mysqli_num_rows($req) > 0) {
                    $lig_u = mysqli_fetch_object($req);
                    $nom_declarant = $lig_u->civilite . " " . casse_mot($lig_u->nom, 'maj') . " " . casse_mot($lig_u->prenom, 'majf');
                    $email_declarant = $lig_u->email;
                    $tab_param_mail['from'] = $lig_u->email;
                    $tab_param_mail['from_name'] = $nom_declarant;
                }
                $email_autres_profs_grp = "";
                // Recherche des autres profs du groupe
                $sql = "SELECT DISTINCT u.email FROM utilisateurs u, j_groupes_professeurs jgp WHERE jgp.id_groupe='{$corriger_app_id_groupe}' AND jgp.login=u.login AND u.login!='" . $_SESSION['login'] . "' AND u.email!='';";
                fich_debug_proposition_correction_app($prefixe_debug . " : {$sql}\n");
                //echo "$sql<br />";
                $req = mysqli_query($mysqli, $sql);
                if (mysqli_num_rows($req) > 0) {
                    $lig_u = mysqli_fetch_object($req);
                    $email_autres_profs_grp .= $lig_u->email;
                    $tab_param_mail['cc'][] = $lig_u->email;
                    while ($lig_u = mysqli_fetch_object($req)) {
                        $email_autres_profs_grp .= "," . $lig_u->email;
                        $tab_param_mail['cc'][] = $lig_u->email;
                    }
                }
                $sujet_mail = "Demande de validation de correction d'appréciation";
                $ajout_header = "";
                if ($email_declarant != "") {
                    $ajout_header .= "Cc: {$nom_declarant} <" . $email_declarant . ">";
                    $tab_param_mail['cc'][] = $email_declarant;
                    if ($email_autres_profs_grp != '') {
                        $ajout_header .= ", {$email_autres_profs_grp}";
                    }
                    $ajout_header .= "\r\n";
                    $ajout_header .= "Reply-to: {$nom_declarant} <" . $email_declarant . ">\r\n";
                    $tab_param_mail['replyto'] = $email_declarant;
                    $tab_param_mail['replyto_name'] = $nom_declarant;
                } elseif ($email_autres_profs_grp != '') {
                    $ajout_header .= "Cc: {$email_autres_profs_grp}\r\n";
                }
                $salutation = (date("H") >= 18 or date("H") <= 5) ? "Bonsoir" : "Bonjour";
                $texte_mail = $salutation . ",\n\n" . $texte_mail . "\nCordialement.\n-- \n" . $nom_declarant;
                fich_debug_proposition_correction_app($prefixe_debug . " : envoi_mail({$sujet_mail}, \n{$texte_mail}, \n{$email_destinataires}, \n{$ajout_header})\n");
                $envoi = envoi_mail($sujet_mail, $texte_mail, $email_destinataires, $ajout_header, "plain", $tab_param_mail);
                if (!$envoi) {
                    fich_debug_proposition_correction_app($prefixe_debug . " : Erreur lors de l envoi du mail.\n\n");
                }
            } else {
                $msg .= "Aucun compte scolarité avec adresse mail n'est associé à cet(te) élève.<br />Pas de compte secours avec adresse mail non plus.<br />La correction a été soumise, mais elle n'a pas fait l'objet d'un envoi de mail.<br />";
                fich_debug_proposition_correction_app($prefixe_debug . " : Aucun compte secours ni scol associé à la classe.\n");
            }
        }
    }
    return $msg;
}
Esempio n. 2
0
                if ($test != "0") {
                    $texte_mail = "Une correction a été proposée par " . casse_mot($_SESSION['prenom'], 'majf2') . " " . casse_mot($_SESSION['nom'], 'maj') . "\r\npour l'élève " . civ_nom_prenom($corriger_app_login_eleve) . " sur la période {$corriger_app_num_periode}\r\nen " . $current_group['name'] . " (" . $current_group["description"] . " en " . $current_group["classlist_string"] . ").\r\n\r\nVous pouvez valider ou rejeter la proposition en vous connectant avec un compte de statut scolarité ou secours.\r\nVous trouverez en page d'accueil, dans la rubrique Saisie, un message en rouge concernant la Correction de bulletins.\r\n";
                } else {
                    $texte_mail = "Suppression de la proposition de correction pour l'élève " . civ_nom_prenom($corriger_app_login_eleve) . "\r\nsur la période {$corriger_app_num_periode} en " . $current_group['name'] . " (" . $current_group["description"] . " en " . $current_group["classlist_string"] . ")\r\npar " . casse_mot($_SESSION['prenom'], 'majf2') . " " . casse_mot($_SESSION['nom'], 'maj') . ".\n";
                }
                fich_debug_proposition_correction_app($prefixe_debug . " : Texte du mail:\n{$texte_mail}\n");
                envoi_mail_proposition_correction($corriger_app_login_eleve, $corriger_app_id_groupe, $corriger_app_num_periode, $texte_mail);
                die;
            }
        } else {
            if ($app != "") {
                $sql = "INSERT INTO matieres_app_corrections SET login='******',id_groupe='" . $current_group["id"] . "',periode='{$corriger_app_num_periode}',appreciation='" . $app . "';";
                fich_debug_proposition_correction_app($prefixe_debug . " : {$sql}\n");
                $register = mysqli_query($mysqli, $sql);
                if (!$register) {
                    fich_debug_proposition_correction_app($prefixe_debug . " : Echec de l'enregistrement de la proposition de correction.\n");
                    echo "<span style='color:red' title=\"Echec de l'enregistrement de la proposition de correction\"> KO</span>";
                    return false;
                    die;
                } else {
                    echo "<div style='border:1px solid red; color: green' title=\"Proposition de correction soumise.\nElle doit encore être validée.\"><strong>Proposition de correction en attente&nbsp;:</strong><br />" . stripslashes(nl2br($app)) . "</div>";
                    fich_debug_proposition_correction_app($prefixe_debug . " : Proposition de correction soumise.\n");
                    $texte_mail = "Une correction proposée a été mise à jour par " . casse_mot($_SESSION['prenom'], 'majf2') . " " . casse_mot($_SESSION['nom'], 'maj') . "\r\npour l'élève " . civ_nom_prenom($corriger_app_login_eleve) . " sur la période {$corriger_app_num_periode}\r\nen " . $current_group['name'] . " (" . $current_group["description"] . " en " . $current_group["classlist_string"] . ").\r\n\r\nVous pouvez valider ou rejeter la proposition en vous connectant avec un compte de statut scolarité ou secours.\r\nVous trouverez en page d'accueil, dans la rubrique Saisie, un message en rouge concernant la Correction de bulletins.\r\n";
                    fich_debug_proposition_correction_app($prefixe_debug . " : Texte du mail:\n{$texte_mail}\n");
                    envoi_mail_proposition_correction($corriger_app_login_eleve, $corriger_app_id_groupe, $corriger_app_num_periode, $texte_mail);
                    die;
                }
            }
        }
    }
}
Esempio n. 3
0
                                        $texte_mail .= "Suppression de la proposition de correction pour l'élève {$correction_nom_prenom_eleve}\r\nsur la période {$correction_periode} en " . $current_group['name'] . " (" . $current_group["description"] . " en " . $current_group["classlist_string"] . ")\r\npar " . casse_mot($_SESSION['prenom'], 'majf2') . " " . casse_mot($_SESSION['nom'], 'maj') . ".\n";
                                        fich_debug_proposition_correction_app($prefixe_debug . " : Suppression de la proposition de correction.\nTexte du mail : \n" . $texte_mail . "\n");
                                    }
                                }
                            } else {
                                if ($app != "") {
                                    $sql = "INSERT INTO matieres_app_corrections SET login='******', id_groupe='{$id_groupe}', periode='{$correction_periode}', appreciation='" . $app . "';";
                                    fich_debug_proposition_correction_app($prefixe_debug . " : {$sql}\n");
                                    $register = mysqli_query($GLOBALS["mysqli"], $sql);
                                    if (!$register) {
                                        $msg = $msg . "Erreur lors de l'enregistrement de la proposition de correction pour <a href='" . $_SERVER['PHP_SELF'] . "#saisie_app_" . $correction_login_eleve . "' title=\"Aller à l'appréciation proposée pour élève.\">{$correction_nom_prenom_eleve}</a> sur la période {$correction_periode}.<br />";
                                        fich_debug_proposition_correction_app($prefixe_debug . " : Erreur lors de l'enregistrement de la proposition de correction pour {$correction_login_eleve}\n");
                                    } else {
                                        $msg .= "Enregistrement de la proposition de correction pour <a href='" . $_SERVER['PHP_SELF'] . "#saisie_app_" . $correction_login_eleve . "' title=\"Aller à l'appréciation proposée pour élève.\">{$correction_nom_prenom_eleve}</a> sur la période {$correction_periode} effectué.<br />";
                                        $texte_mail .= "Une correction a été proposée par " . casse_mot($_SESSION['prenom'], 'majf2') . " " . casse_mot($_SESSION['nom'], 'maj') . "\r\npour l'élève {$correction_nom_prenom_eleve} sur la période {$correction_periode}\r\nen " . $current_group['name'] . " (" . $current_group["description"] . " en " . $current_group["classlist_string"] . ").\r\n\r\nVous pouvez valider ou rejeter la proposition en vous connectant avec un compte de statut scolarité ou secours.\r\nVous trouverez en page d'accueil, dans la rubrique Saisie, un message en rouge concernant la Correction de bulletins.\r\n";
                                        fich_debug_proposition_correction_app($prefixe_debug . " : Proposition de correction soumise.\nTexte du mail : \n" . $texte_mail . "\n");
                                    }
                                }
                            }
                            if ($texte_mail != "") {
                                $msg .= envoi_mail_proposition_correction($correction_login_eleve, $id_groupe, $correction_periode, $texte_mail);
                            }
                        }
                    }
                }
            }
        }
    }
} elseif (isset($_POST['correction_periode']) && isset($_POST['no_anti_inject_correction_app_groupe'])) {
    check_token();
    // Dispositif pour proposer des corrections une fois la période close.