public function before_creer_compte()
 {
     $this->header_json();
     try {
         $preinscription = new bobs_utilisateur_preinscription();
         $preinscription->set_vars($_POST);
         $sujet_tpl = clicnat_textes::par_nom($this->db, "hirondelles/mail_inscription_sujet")->texte;
         $texte_tpl = clicnat_textes::par_nom($this->db, "hirondelles/mail_inscription")->texte;
         $vars = ["mail_support" => HIRONDELLES_MAIL_SUPPORT, "base_url" => 'http://hyla.picardie-nature.org/~nicolas/hirondelles/'];
         $preinscription->sauve_et_envoi_mail_tpl($sujet_tpl, $texte_tpl, $vars);
     } catch (Exception $e) {
         echo json_encode(["etat" => "err", "message" => $e->getMessage()]);
         exit(0);
     }
     echo json_encode(["etat" => "ok"]);
     exit(0);
 }
Esempio n. 2
0
 public function before_editer()
 {
     $u = $this->get_user_session();
     $sortie = new clicnat_sortie($this->db, (int) $_GET['sortie']);
     if ($this->is_admin($u->id_utilisateur)) {
         $this->assign('admin', true);
     } else {
         $this->assign('admin', false);
     }
     $editable = false;
     if ($sortie->id_utilisateur_propose == $u->id_utilisateur) {
         $editable = true;
     }
     if (!$editable) {
         if ($this->is_admin($u->id_utilisateur)) {
             $editable = true;
         }
     }
     if ($editable && isset($_GET['annuler_loc'])) {
         $sortie->annuler_localisation();
         $this->redirect("?t=editer&sortie={$sortie->id_sortie}");
     }
     $this->assign('edit', $editable);
     if (isset($_GET['update'])) {
         $champs = explode(',', 'nom,orga_nom,orga_prenom,adresse,tel,portable,mail,id_sortie_type,id_sortie_public,gestion_picnat,accessible_mobilite_reduite,accessible_deficient_auditif,accessible_deficient_visuel,id_sortie_cadre,description,description_lieu,duree_heure,structure,validation_externe,materiel_autre,id_sortie_pole,id_sortie_reseau');
         $bools_f = explode(',', 'gestion_picnat,accessible_mobilite_reduite,accessible_deficient_auditif,accessible_deficient_visuel,validation_externe');
         foreach ($bools_f as $k) {
             $_POST[$k] = isset($_POST[$k]) && $_POST[$k] == 1 ? 't' : 'f';
         }
         if (empty($_POST['duree_heure'])) {
             $_POST['duree_heure'] = 0;
         }
         if (empty($_POST['id_sortie_pole'])) {
             $_POST['id_sortie_pole'] = 1;
         }
         foreach (array_keys($_POST) as $k) {
             if (array_search($k, $champs) !== false) {
                 $sortie->update_field($k, $_POST[$k]);
             }
         }
         if (empty($sortie->id_espace_point)) {
             if (isset($_POST['x']) && isset($_POST['y'])) {
                 if (!empty($_POST['x']) && !empty($_POST['y'])) {
                     $pt = array('id_utilisateur' => $u->id_utilisateur, 'reference' => "sortie {$sortie->id_sortie}", 'nom' => "{$sortie->id_sortie}", 'x' => $_POST['x'], 'y' => $_POST['y']);
                     $id_espace = bobs_espace_point::insert($this->db, $pt);
                     $sortie->update_field('id_espace_point', $id_espace);
                 }
             }
         }
         // on enleve tout pour le remettre après
         $sortie->materiel_vide();
         foreach (array_keys($_POST) as $k) {
             if (preg_match('/^materiel_(\\d+)/', $k)) {
                 $sortie->materiel_ajoute($_POST[$k]);
             }
         }
         $this->redirect("?t=editer_suiv&id_sortie={$sortie->id_sortie}");
     } else {
         if (isset($_GET['ajouter_date'])) {
             $sortie = new clicnat_sortie($this->db, (int) $_GET['sortie']);
             $sortie->ajoute_date(bobs_element::date_fr2sql($_POST['date']));
             $message = new clicnat_mail();
             $message->from('*****@*****.**');
             $vars = ["titre" => $sortie->nom, "description" => $sortie->description, "date" => $_POST['date']];
             $sujet_tpl = clicnat_textes::par_nom(get_db(), 'calendrier/notification_nouvelle_sortie_titre')->texte;
             $texte_tpl = clicnat_textes::par_nom(get_db(), 'calendrier/notification_nouvelle_sortie')->texte;
             $message->sujet(self::mini_template($sujet_tpl, $vars));
             $message->message(self::mini_template($texte_tpl, $vars));
             foreach ($this->dests_notifications as $dest) {
                 $message->envoi($dest);
             }
             $this->redirect("?t=editer_suiv&id_sortie={$sortie->id_sortie}");
         }
     }
     $sortie = new clicnat_sortie($this->db, (int) $_GET['sortie']);
     $this->assign_by_ref('sortie', $sortie);
 }