/** * Send the reminder * * @param Texts $texts Text object * @param History $hist History * @param Db $zdb Database instance * * @return boolean */ public function send($texts, $hist, $zdb) { $type_name = 'late'; if ($this->_type === self::IMPENDING) { $type_name = 'impending'; } if ($this->hasMail()) { $texts->setReplaces($this->_replaces); $texts->getTexts($type_name . 'duedate', $this->_dest->language); $mail = new GaletteMail(); $mail->setSubject($texts->getSubject()); $mail->setRecipients(array($this->_dest->email => $this->_dest->sname)); $mail->setMessage($texts->getBody()); $sent = $mail->send(); $details = str_replace(array('%name', '%mail', '%days'), array($this->_dest->sname, $this->_dest->email, $this->_dest->days_remaining), _T("%name <%mail> (%days days)")); if ($sent == GaletteMail::MAIL_SENT) { $this->_success = true; $msg = ''; if ($type_name == 'late') { $msg = _T("Sent reminder mail for late membership"); } else { $msg = _T("Sent reminder mail for impending membership"); } $this->_msg = $details; $hist->add($msg, $details); } else { $this->_success = false; if ($type_name == 'late') { $msg = _T("A problem happened while sending late membership mail"); } else { $msg = _T("A problem happened while sending impending membership mail"); } $this->_msg = $details; $hist->add($str, $details); } } else { $this->_success = false; $this->_nomail = true; $str = str_replace('%membership', $type_name, _T("Unable to send %membership reminder (no mail address).")); $details = str_replace(array('%name', '%id', '%days'), array($this->_dest->sname, $this->_dest->id, $this->_dest->days_remaining), _T("%name (#%id - %days days)")); $hist->add($str, $details); $this->_msg = $this->_dest->sname; } //store reminder in database $this->_store($zdb); return $this->_success; }
} } if (count($error_detected) == 0) { $dyn_fields->setAllFields('contrib', $contrib->id, $contribution['dyn']); // Get member informations $adh = new Adherent(); $adh->load($contrib->member); if ($preferences->pref_mail_method > GaletteMail::METHOD_DISABLED) { $texts = new Texts($texts_fields, $preferences, array('name_adh' => custom_html_entity_decode($adh->sname), 'firstname_adh' => custom_html_entity_decode($adh->surname), 'lastname_adh' => custom_html_entity_decode($adh->name), 'mail_adh' => custom_html_entity_decode($adh->email), 'login_adh' => custom_html_entity_decode($adh->login), 'deadline' => custom_html_entity_decode($contrib->end_date), 'contrib_info' => custom_html_entity_decode($contrib->info), 'contrib_amount' => custom_html_entity_decode($contrib->amount), 'contrib_type' => custom_html_entity_decode($contrib->type->libelle))); if ($new && isset($_POST['mail_confirm']) && $_POST['mail_confirm'] == '1') { if (GaletteMail::isValidEmail($adh->email)) { $text = 'contrib'; if (!$contrib->isCotis()) { $text = 'donation'; } $mtxt = $texts->getTexts($text, $adh->language); $mail = new GaletteMail(); $mail->setSubject($texts->getSubject()); $mail->setRecipients(array($adh->email => $adh->sname)); $mail->setMessage($texts->getBody()); $sent = $mail->send(); if ($sent) { $hist->add(preg_replace(array('/%name/', '/%email/'), array($adh->sname, $adh->email), _T("Mail sent to user %name (%email)"))); } else { $txt = preg_replace(array('/%name/', '/%email/'), array($adh->sname, $adh->email), _T("A problem happened while sending contribution receipt to user %name (%email)")); $hist->add($txt); $error_detected[] = $txt; } } else { $txt = preg_replace(array('/%name/', '/%email/'), array($adh->sname, $adh->email), _T("Trying to send a mail to a member (%name) with an invalid address: %email")); $hist->add($txt);
$sent = $mail->send(); if ($sent == GaletteMail::MAIL_SENT) { $hist->add(str_replace('%s', $member->sname . ' (' . $member->email . ')', _T("New account mail sent to admin for '%s'."))); } else { $str = str_replace('%s', $member->sname . ' (' . $member->email . ')', _T("A problem happened while sending email to admin for account '%s'.")); $hist->add($str); $error_detected[] = $str; } unset($texts); } // send mail to member if ($preferences->pref_mail_method > GaletteMail::METHOD_DISABLED && $member->email != '') { //send mail to member // Get email text in database $texts = new Texts($texts_fields, $preferences, array('name_adh' => custom_html_entity_decode($member->sname), 'firstname_adh' => custom_html_entity_decode($member->surname), 'lastname_adh' => custom_html_entity_decode($member->name), 'mail_adh' => custom_html_entity_decode($member->email), 'login_adh' => custom_html_entity_decode($member->login), 'password_adh' => custom_html_entity_decode($_POST['mdp_adh']))); $mtxt = $texts->getTexts('sub', $member->language); $mail = new GaletteMail(); $mail->setSubject($texts->getSubject()); $mail->setRecipients(array($member->email => $member->sname)); $mail->setMessage($texts->getBody()); $sent = $mail->send(); if ($sent == GaletteMail::MAIL_SENT) { $hist->add(str_replace('%s', $member->sname . ' (' . $member->email . ')', _T("New account mail sent to '%s'."))); } else { $str = str_replace('%s', $member->sname . ' (' . $member->email . ')', _T("A problem happened while sending new account mail to '%s'")); $hist->add($str); $error_detected[] = $str; } } /** FIXME: query was previously passed as second argument, * but it not no longer available from here :/ */
$success_detected[] = _T("Member account has been modified."); } // send mail to member if (isset($_POST['mail_confirm']) && $_POST['mail_confirm'] == '1') { if ($preferences->pref_mail_method > GaletteMail::METHOD_DISABLED) { if ($member->email == '') { $error_detected[] = _T("- You can't send a confirmation by email if the member hasn't got an address!"); } else { //send mail to member // Get email text in database $texts = new Texts($texts_fields, $preferences, array('name_adh' => custom_html_entity_decode($member->sname), 'firstname_adh' => custom_html_entity_decode($member->surname), 'lastname_adh' => custom_html_entity_decode($member->name), 'mail_adh' => custom_html_entity_decode($member->email), 'login_adh' => custom_html_entity_decode($member->login), 'password_adh' => custom_html_entity_decode($_POST['mdp_adh']))); $mlang = $preferences->pref_lang; if (isset($_POST['pref_lang'])) { $mlang = $_POST['pref_lang']; } $mtxt = $texts->getTexts($new ? 'sub' : 'accountedited', $mlang); $mail = new GaletteMail(); $mail->setSubject($texts->getSubject()); $mail->setRecipients(array($member->email => $member->sname)); $mail->setMessage($texts->getBody()); $sent = $mail->send(); if ($sent == GaletteMail::MAIL_SENT) { $msg = str_replace('%s', $member->sname . ' (' . $member->email . ')', $new ? _T("New account mail sent to '%s'.") : _T("Account modification mail sent to '%s'.")); $hist->add($msg); $success_detected[] = $msg; } else { $str = str_replace('%s', $member->sname . ' (' . $member->email . ')', _T("A problem happened while sending account mail to '%s'")); $hist->add($str); $error_detected[] = $str; } }
} if ($adh->id != '') { //account has been found, proceed if (Core\GaletteMail::isValidEmail($adh->email)) { $password = new Core\Password(); $res = $password->generateNewPassword($adh->id); if ($res == true) { $link_validity = new DateTime(); $link_validity->add(new DateInterval('PT24H')); $df = _T("Y-m-d H:i:s"); $proto = 'http'; if (isset($_SERVER['HTTPS'])) { $proto = 'https'; } $texts = new Texts($texts_fields, $preferences, array('change_pass_uri' => $proto . '://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']) . '/change_passwd.php?hash=' . urlencode($password->getHash()), 'link_validity' => $link_validity->format(_T("Y-m-d H:i:s")), 'login_adh' => custom_html_entity_decode($adh->login, ENT_QUOTES))); $mtxt = $texts->getTexts('pwd', $adh->language); $mail = new Core\GaletteMail(); $mail->setSubject($texts->getSubject()); $mail->setRecipients(array($adh->email => $adh->sname)); $mail->setMessage($texts->getBody()); $sent = $mail->send(); if ($sent == Core\GaletteMail::MAIL_SENT) { $hist->add(str_replace('%s', $login_adh, _T("Mail sent to '%s' for password recovery."))); if ($from_admin === false) { $success_detected[] = _T("A mail has been sent to your address.<br/>Please check your inbox and follow the instructions."); $tpl->assign('success_detected', $success_detected); $done = true; } else { $success_detected[] = _T("An mail has been sent to the member."); } } else {
} $cur_lang = $preferences->pref_lang; $cur_ref = Texts::DEFAULT_REF; $texts = new Texts($texts_fields, $preferences); //set the language if (isset($_POST['sel_lang'])) { $cur_lang = $_POST['sel_lang']; } //set the text entry if (isset($_POST['sel_ref'])) { $cur_ref = $_POST['sel_ref']; } if (isset($_POST['valid']) && $_POST['valid'] == '1') { //form was send normally, we try to store new values //load actual text for further reference $mtxt = $texts->getTexts($cur_ref, $cur_lang); $res = $texts->setTexts($cur_ref, $cur_lang, $_POST['text_subject'], $_POST['text_body']); if (!$res) { $error_detected[] = preg_replace('(%s)', $mtxt->tcomment, _T("Email: '%s' has not been modified!")); } else { $success_detected[] = preg_replace('(%s)', $mtxt->tcomment, _T("Email: '%s' has been successfully modified.")); } } $tpl->assign('page_title', _T("Automatic emails texts edition")); $mtxt = $texts->getTexts($cur_ref, $cur_lang); $tpl->assign('reflist', $texts->getRefs($cur_lang)); $tpl->assign('langlist', $i18n->getList()); $tpl->assign('cur_lang', $cur_lang); $tpl->assign('cur_ref', $cur_ref); $tpl->assign('mtxt', $mtxt); $tpl->assign('require_dialog', true);