Пример #1
7
 public static function compose()
 {
     self::login_required();
     if ("POST" == Request::method()) {
         $from = Request::user()->id;
         $to = Request::POST()->to_account;
         $subject = isset(Request::POST()->subject) ? Request::POST()->subject : '';
         $text = Request::POST()->text;
         Messages::create($from, $to, $subject, $text);
         Response::redirect('mail/sent');
     } else {
         $inboxes_count = Messages::countMsg('to');
         $outboxes_count = Messages::countMsg('from');
         $users = Accounts::all();
         View::render('mails/compose', ['inboxes_count' => $inboxes_count, 'outboxes_count' => $outboxes_count, 'users' => $users]);
     }
 }