public function send_mail() { if (!$this->sent_report) { $users = \System\User\Group::find(self::ID_GROUP_REPORT)->users->fetch(); $rcpt = array(); foreach ($users as $user) { $contacts = $user->contacts->where(array('type' => \System\User\Contact::STD_EMAIL, 'spam' => true))->fetch(); $mails = collect(array('attr', 'ident'), $contacts); $rcpt = array_merge($rcpt, $mails); } $data = $this->get_data(); $locales = new \System\Locales(); $subject = 'mail-subject-new-feedback'; $body = 'mail-body-new-feedback'; $from = $this->email; $mail = \Helper\Offcom\Mail::create($subject, $body); $locales->set_locale(); $subject = stprintf($locales->trans($subject), $data); $body = stprintf($locales->trans($body), $data); // Prepend tag to subject of all alerts $subject = '[Impro][Feedback ' . $this->id . '] ' . $subject; $body .= "\n\nTento e-mail byl automaticky vygenerován uživatelskou interakcí webu Improligy. Pokud tento e-mail neměl přijít vám, obraťte se na kontakty Improligy.\nhttp://www.improliga.cz"; $mail->rcpt = $rcpt; $this->sent_report = $mail->send(); if ($from) { $mail->from = \System\Settings::get('offcom', 'default', 'sender'); $mail->rcpt = array($from); $this->sent_copy = $mail->send(); } $this->save(); } return $this; }
/** * Write error into log file * * @param string $type * @param string $msg * @return void */ public static function report($type, $report) { $debug = \System\Settings::getSafe(array('dev', 'debug', 'backend'), false); \System\Directory::check(BASE_DIR . self::DIR_LOGS); $log_to = fopen(BASE_DIR . self::DIR_LOGS . '/' . $type . '.log', 'a+'); if (!$debug && $type == 'error') { $rcpt = \System\Settings::getSafe(array('dev', 'mailing', 'errors'), null); if ($rcpt) { \Helper\Offcom\Mail::create('[Fudjan] Server error', $report, $rcpt)->send(); } } if (is_resource($log_to)) { fwrite($log_to, $report); } }