/** * Envoie un minimail * * @author Christophe Beyer <*****@*****.**> * @since 2005/10/18 * @param string title Titre du minimail * @param string message Corps du minimail * @param integer from_id Id utilisateur de l'exp�diteur * @param array destin Id tableau avec les destinataires (cl� = id user) * @return mixed Id du message cr�� ou NULL si erreur */ public function sendMinimail($title, $message, $from_id, $destin, $format) { $res = NULL; $DAOminimail_from = _dao("minimail|minimail_from"); $DAOminimail_to = _dao("minimail|minimail_to"); $newMp = _record("minimail|minimail_from"); $newMp->title = $title; $newMp->message = $message; $newMp->format = $format; $newMp->date_send = date("Y-m-d H:i:s"); $newMp->from_id = $from_id; $newMp->is_deleted = 0; $DAOminimail_from->insert($newMp); if ($newMp->id !== NULL) { //print_r($newMp); // On parcourt chaque destinataire while (list($to_id, ) = each($destin)) { // print_r("to_id=$to_id / to_login=$to_login"); $newDest = _record("minimail|minimail_to"); $newDest->id_message = $newMp->id; $newDest->to_id = $to_id; $newDest->date_read = 0; $newDest->is_read = 0; $newDest->is_replied = 0; $newDest->is_deleted = 0; $DAOminimail_to->insert($newDest); // ======= Alerte mail =============== // On vérifie que l'envoi de mails est activé, qu'un serveur SMTP est configuré, que le destinataire a coché l'option "etre prêvenu par mail" et qu'il a renseigné un mail if ($newDest->id2 && CopixConfig::get('|mailEnabled') == 1 && CopixConfig::get('|mailSmtpHost')) { $prefs = Prefs::getPrefs($to_id); if (isset($prefs['prefs']['alerte_mail_email']) && isset($prefs['minimail']['alerte_minimail']) && $prefs['prefs']['alerte_mail_email'] && $prefs['minimail']['alerte_minimail'] == 1) { $userInfoFrom = Kernel::getUserInfo("ID", $from_id); //print_r($userInfoFrom); $to = $prefs['prefs']['alerte_mail_email']; $auteur = utf8_decode($userInfoFrom['prenom'] . ' ' . $userInfoFrom['nom'] . ' (' . $userInfoFrom['login'] . ')'); $subject = CopixI18N::get('minimail|minimail.mail.alert.subject', array($auteur)); $message = str_replace('<br />', "\n", CopixI18N::get('minimail|minimail.mail.alert.body', array($auteur, CopixUrl::get('minimail||getMessage', array('id' => $newMp->id)), CopixUrl::get()))); $from = CopixConfig::get('default|mailFrom'); $fromName = CopixConfig::get('default|mailFromName'); $cc = $cci = ''; $monMail = new CopixTextEMail($to, $cc, $cci, $subject, $message); $send = $monMail->send($from, $fromName); } } // ======= Fin alerte mail =============== } $res = $newMp->id; if ($res) { $plugStats = CopixPluginRegistry::get("stats|stats"); $plugStats->setParams(array('module' => 'minimail', 'action' => 'sendMinimail', 'objet_a' => $res)); } } return $res; }
/** * Entree dans le module * * @author Christophe Beyer <*****@*****.**> * @since 2010/08/26 * @param integer $id Id du module */ public function processGo() { $ppo = new CopixPPO(); $iId = CopixRequest::getInt('id'); $iSubmit = CopixRequest::getInt('submit'); $this->addCss('styles/module_contact.css'); $this->js->button('.button'); $getLevel = Kernel::getLevel('MOD_CONTACT', $iId); //echo "getLevel=$getLevel"; $rContact = _dao('contact|contacts')->get($iId); //print_r($rContact); if (!$rContact) { return $this->error('contact|contact.errors.param', true, CopixUrl::get('||')); } $ppo->types = _dao('contact|contacts_types')->findByContact($iId); $user = _currentUser(); $possible = CopixConfig::get('|mailEnabled') == 1 && CopixConfig::get('|mailSmtpHost'); if ($iSubmit) { // Submit du formulaire $record = _record('contact|contacts_messages'); $record->contact = $iId; $record->to_email = $rContact->email; $record->date = date("Y-m-d H:i:s"); $record->from_nom = _request('from_nom'); $record->from_email = _request('from_email'); $record->from_login = $user->getLogin(); $record->from_user_id = $user->getId(); $record->type = _request('type'); $record->message = _request('message'); $record->ip = $_SERVER["REMOTE_ADDR"]; $check = _dao('contact|contacts_messages')->check($record); $ok = false; if (!is_array($check)) { // OK, pas d'erreurs _dao('contact|contacts_messages')->insert($record); if ($record->id) { // Enregistrement bien passe $type_nom = ''; foreach ($ppo->types as $type) { if ($type->id == $record->type) { $type_nom = $type->nom; } } if ($possible) { $to = $record->to_email; $subject = $type_nom; $message = CopixI18N::get('contact.mail.date') . " : " . date("d/m/Y H:i"); $message .= "\n" . CopixI18N::get('contact.mail.ip') . " : " . $record->ip; $message .= "\n"; $message .= "\n" . CopixI18N::get('contact.mail.nom') . " : " . $record->from_nom; if ($record->from_login) { $message .= ' (' . $record->from_login . ')'; } $message .= "\n" . CopixI18N::get('contact.mail.email') . " : " . $record->from_email; $message .= "\n"; $message .= "\n" . CopixI18N::get('contact.mail.type') . " : " . $type_nom; $message .= "\n" . CopixI18N::get('contact.mail.message') . " : " . $record->message; $message .= "\n\n-- \n" . CopixUrl::get(); $from = $record->from_email; $fromName = $record->from_nom; if ($record->from_login) { $fromName .= ' (' . $record->from_login . ')'; } $cc = $cci = ''; $monMail = new CopixTextEMail($to, $cc, $cci, utf8_decode($subject), utf8_decode($message)); $send = $monMail->send(utf8_decode($from), utf8_decode($fromName)); if ($send) { $ok = true; } else { $check = array(CopixI18N::get('contact|contact.errors.mailSend')); } } else { $check = array(CopixI18N::get('contact|contact.errors.mailDisabledAfter')); } } else { $check = array(CopixI18N::get('contact|contact.errors.save')); } } $ppo->rForm = $record; $ppo->errors = $check; $ppo->ok = $ok; } else { $ppo->rForm = _record('contact|contacts_messages'); foreach ($ppo->types as $type) { if ($type->is_default) { $ppo->rForm->type = $type->id; } } $ppo->rForm->from_nom = trim($user->getExtra('prenom') . ' ' . $user->getExtra('nom')); $prefs = Prefs::getPrefs($user->getId()); if (isset($prefs['prefs']['alerte_mail_email'])) { $ppo->rForm->from_email = $prefs['prefs']['alerte_mail_email']; } if (!$possible) { $ppo->errors = array(CopixI18N::get('contact|contact.errors.mailDisabled')); } } $ppo->TITLE_PAGE = $rContact->titre; return _arPPO($ppo, 'contact.tpl'); }
public function processGetreqereg() { //check parent informations : $sub = 'parent'; //array of required values : $required = array('nom', 'prenom', 'adresse', 'postal', 'city', 'teldom', 'mail'); //errors array $errors = array(); foreach ($required as $require) { $value = $this->request($sub . $require); if (empty($value)) { $errors[$sub . $require] = $this->i18n('public.getreq.required'); } } //check childrens infos $sub = 'child'; $required = array('nom', 'prenom', 'ecole', 'classe'); $children = array(); for ($i = 1; $i <= 4; $i++) { $valuei = $this->request($sub . $i . 'nom'); $valueii = $this->request($sub . $i . 'prenom'); if (empty($valuei) && empty($valueii) && $i != 1) { continue; } foreach ($required as $require) { $valueiii = $this->request($sub . $i . $require); if (empty($valueiii)) { $errors[$sub . $i . $require] = $this->i18n('public.getreq.required'); } else { $children[$i][$require] = $this->request($sub . $i . $require); } } } //if errors : go back if (!empty($errors)) { $this->flash->errors = $errors; $this->flash->content = $_POST; return $this->go('public|default|getreq'); } //compose informations //children Infos : $childText = ''; foreach ($children as $child) { $childText .= 'Nom : ' . $child['nom'] . PHP_EOL; $childText .= 'Prenom : ' . $child['prenom'] . PHP_EOL; $childText .= 'Ecole : ' . $this->db->query('SELECT nom FROM kernel_bu_ecole WHERE numero = ' . (int) $child['ecole'])->toString() . PHP_EOL; $childText .= 'Classe : ' . $this->db->query('SELECT nom FROM kernel_bu_ecole_classe WHERE id = ' . (int) $child['classe'])->toString() . PHP_EOL . ' ---------------- ' . PHP_EOL; } //adult infos : $adult = array('nom' => $this->request('parentnom'), 'prenom' => $this->request('parentprenom'), 'adresse' => $this->request('parentadresse'), 'postal' => $this->request('parentpostal'), 'city' => $this->request('parentcity'), 'teldom' => $this->request('parentteldom'), 'telpro' => $this->request('parenttelpro'), 'mail' => $this->request('parentmail')); // $mailContent = <<<EOT Une nouvelle demande d'inscription à été réalisée information : Informations lié à l'adulte : ============================= Nom-----------------: {$adult['nom']} Prenom--------------: {$adult['prenom']} Adresse-------------: {$adult['adresse']} Code Postal---------: {$adult['postal']} Ville---------------: {$adult['city']} Tel du domicile-----: {$adult['teldom']} Tel professionel----: {$adult['telpro']} Adresse Mail--------: {$adult['mail']} Information sur l(es) enfant(s) : ================================= {$childText} ~~~~~~~~~~~~~~~~~~~~~~ ce message à été généré et envoyé automatiquement par l'application ICONITO Ecole Numérique EOT; //send Mail $mail = new CopixTextEMail('*****@*****.**', '', '', utf8_decode('Nouvelle demande d\'inscription à iconito'), utf8_decode($mailContent)); $mail->send(); //ereg data in DB $dbEreg = array('parent' => $this->db->quote(serialize($adult)), 'enfants' => $this->db->quote(serialize($children)), 'date' => time()); $this->db->create('module_getreq', $dbEreg); $ppo = new CopixPPO(); return _arPPO($ppo, 'getreq.success.tpl'); }
public function sendmail($mail) { $arrErrors = array(); if ($mail['dest'] == null || $mail['dest'] == "") { $arrErrors[] = _i18n('email.error.nodest'); } else { $arrTmp = explode(",", $mail['dest']); try { foreach ($arrTmp as $key => $tmpMail) { if ($tmpMail != "") { CopixFormatter::getMail($tmpMail); } } } catch (CopixException $e) { $arrErrors[] = _i18n('email.error.baddest'); } } if ($mail['cc'] != "") { $arrTmp = explode(",", $mail['cc']); try { foreach ($arrTmp as $key => $tmpMail) { if ($tmpMail != "") { CopixFormatter::getMail($tmpMail); } } } catch (CopixException $e) { $arrErrors[] = _i18n('email.error.badcc'); } } else { $mail['cc'] = ""; } if ($mail['cci'] != "") { $arrTmp = explode(",", $mail['cci']); try { foreach ($arrTmp as $key => $tmpMail) { if ($tmpMail != "") { CopixFormatter::getMail($tmpMail); } } } catch (CopixException $e) { $arrErrors[] = _i18n('email.error.badcci'); } } else { $mail['cci'] = ""; } if ($mail['subject'] == null || $mail['subject'] == "") { $arrErrors[] = _i18n('email.error.nosubject'); } if ($mail['msg'] == null || $mail['msg'] == "") { $arrErrors[] = _i18n('email.error.nomsg'); } if ($mail['from'] == null || $mail['from'] == "") { $arrErrors[] = _i18n('email.error.nofrom'); } else { $arrTmp = explode(",", $mail['from']); try { foreach ($arrTmp as $tmpMail) { if ($tmpMail != "") { CopixFormatter::getMail($tmpMail); } } } catch (CopixException $e) { $arrErrors[] = _i18n('email.error.badfrom'); } } if ($mail['fromname'] == null || $mail['fromname'] == "") { $arrErrors[] = _i18n('email.error.nofromname'); } if (count($arrErrors) == 0) { $monMail = new CopixTextEMail($mail['dest'], $mail['cc'], $mail['cci'], utf8_decode($mail['subject']), utf8_decode($mail['msg'])); $monMail->send($mail['from'], $mail['fromname']); CopixSession::set('admin|email|donnees', $this->newMail()); } return $arrErrors; }