/** * 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; }
// 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 { $url = 'gestion_contributions.php?id_adh=' . $contrib->member;