コード例 #1
0
ファイル: Reminder.php プロジェクト: Killerfun/galette
 /**
  * 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;
 }
コード例 #2
0
 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);
                 $warning_detected[] = $txt;
             }