/** * 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; }
/** * Set mailing recipients * * @param array $members Array of Adherent objects * * @return void */ public function setRecipients($members) { $m = array(); $this->_mrecipients = array(); $this->_unreachables = array(); foreach ($members as $member) { $email = $member->email; //if member mail is missing but there is a parent, //take the parent email. if (!$email && $member->hasParent()) { $email = $member->parent->email; } if (trim($email) != '' && self::isValidEmail($email)) { if (!in_array($member, $this->_mrecipients)) { $this->_mrecipients[] = $member; } $m[$email] = $member->sname; } else { if (!in_array($member, $this->_unreachables)) { $this->_unreachables[] = $member; } } } parent::setRecipients($m); }
} 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 :/ */ $hist->add(_T("Self_subscription as a member: ") . strtoupper($adherent['nom_adh']) . ' ' . $adherent['prenom_adh']); $head_redirect = array('timeout' => 10, 'url' => 'index.php'); $has_register = true;
} // Sent email to admin if pref checked if ($new && $preferences->pref_bool_mailadh) { // Get email text in database $text = 'newcont'; if (!$contrib->isCotis()) { $text = 'newdonation'; } $mtxt = $texts->getTexts($text, $preferences->pref_lang); $mail = new GaletteMail(); $mail->setSubject($texts->getSubject()); /** TODO: only super-admin is contacted here. We should send * a message to all admins, or propose them a chekbox if * they don't want to get bored */ $mail->setRecipients(array($preferences->pref_email_newadh => str_replace('%asso', $preferences->pref_name, _T("%asso Galette's admin")))); $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 admin for user %name (%email)"))); } else { $txt = preg_replace(array('/%name/', '/%email/'), array($adh->sname, $adh->email), _T("A problem happened while sending to admin notification for user %name (%email) contribution")); $hist->add($txt); $error_detected[] = $txt; } } } if (count($error_detected) == 0) { if ($contrib->isTransactionPart() && $contrib->transaction->getMissingAmount() > 0) { $url = 'ajouter_contribution.php?trans_id=' . $contrib->transaction->id . '&id_adh=' . $contrib->member; } else {
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 { $str = str_replace('%s', $login_adh, _T("A problem happened while sending password for account '%s'")); $hist->add($str); $error_detected[] = $str;