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;
 }
Example #2
0
 public function cancel(\System\Template\Renderer $ren, $drop)
 {
     $this->canceled = true;
     $this->save();
     $current_user = $ren->response()->request()->user();
     if ($this->id_user != $current_user->id) {
         $notice = \Impro\User\Notice::for_user($this->user, array("generated_by" => 'team_attendance', "redirect" => $drop ? $ren->url('team_attendance', array($this->training->team)) : $ren->url('team_training', array($this->training->team, $this->training)), "author" => $current_user, "team" => $this->training->team, "text" => stprintf($ren->trans('training_cancel_mail'), array("link_user" => \Impro\User::link($ren), "link_team" => $this->training->team->to_html_link($ren, true), "tg_date" => $ren->format_date($this->training->start, 'human')))));
     }
     return $this;
 }
Example #3
0
 /** Redirect immediately page to another URL
  * @param string $url
  * @param int    $code
  * @return void
  */
 public static function redirect($url, $code = self::FOUND)
 {
     if (!\System\Status::on_cli()) {
         session_write_close();
         header(self::get_status($code));
         header("Location: " . $url);
     } else {
         throw new \System\Error\Format(stprintf('Cannot redirect to "%s" while on console.', $r['url']));
     }
     exit(0);
 }
Example #4
0
 /** Get URL to embed iframe
  * @return string
  */
 public function get_embed_url()
 {
     return 'http://' . self::URL_HOST . '/' . stprintf(self::URL_EMBED, $this->get_data());
 }
Example #5
0
 /** Translate string
  * @param string       $str
  * @param array|string $args Arguments to paste into the string. If not array, all arguments after str are written inside.
  * @return string
  */
 public function trans($str, $args = null, $lang = null)
 {
     $lang = is_null($lang) ? $this->get_lang() : $lang;
     if (!isset($this->messages[$lang])) {
         $this->messages[$lang] = array();
     }
     $msg = isset($this->messages[$lang][$str]) ? $this->messages[$lang][$str] : $str;
     if (is_array($args) || !is_null($args) && func_num_args() > 1) {
         if (!is_array($args)) {
             $args = func_get_args();
             array_shift($args);
         }
         return stprintf($msg, $args);
     } else {
         return $msg;
     }
 }
Example #6
0
 /** Object version of stprintf - handles System\Model\Attr models
  * @param string $str
  * @param System\Model\Attr $object
  * @param bool $strict
  * @param string $prefix
  */
 function soprintf($str, System\Model\Attr $object, $strict = true, $prefix = null)
 {
     $data = array_merge($object->get_opts(), $object->get_data());
     if ($object instanceof System\Model\Database) {
         $data[System\Model\Database::get_id_col(get_class($object))] = $object->id;
     }
     if (!$object->has_attr('seoname')) {
         $data['seoname'] = $object->get_seoname();
     }
     return stprintf($str, $data, $strict, $prefix);
 }
Example #7
0
 public function send_request(\System\User $user, \System\Template\Renderer $ren, \System\Http\Request $request)
 {
     return \Impro\User\Request::for_user($user, array("text" => stprintf($ren->locales()->trans('intra_team_member_add_text'), array("link_team" => $this->to_html_link($ren), "link_user" => \Impro\User::link($ren, $request->user()))), "id_author" => $request->user()->id, "id_team" => $this->id, "callback" => 'JoinTeam', "redirect_yes" => $ren->uri('team', array($this)), "allow_maybe" => false))->mail($ren);
 }