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; }
public static function build_locales() { $cfg = \System\Settings::get('locales', 'allowed'); $loc = new \System\Locales(); foreach ($cfg as $lang) { $loc->load_messages($lang); \System\File::put(BASE_DIR . \System\Locales::DIR_CACHE . '/' . $lang . '.json', json_encode($loc->get_messages($lang))); } }