コード例 #1
0
 public function onListingSharing(Listing $newListing, User $sender, IResultObject $resultObject)
 {
     try {
         $message = $this->listingNotification->getNotificationMessage($newListing, $sender);
         $message->markAsSystemMessage();
         $this->messagesFacade->sendMessage($message, [$newListing->getUser()->getId()]);
     } catch (DBALException $e) {
         $resultObject->addError('Nepodařilo se odeslat zprávu o
              dopručení sdílené výčetky.', 'error');
     }
 }
コード例 #2
0
ファイル: MailBoxPresenter.php プロジェクト: blitzik/vycetky
 public function processNewMessageForm(Form $form)
 {
     $values = $form->getValues();
     $texy = new \Texy();
     $texy->setOutputMode(\Texy::HTML4_TRANSITIONAL);
     $texy->encoding = 'utf-8';
     $texy->allowedTags = \Texy::ALL;
     $text = $texy->process($values->message);
     // 0 == system account
     $author = $values['isSystemMessage'] == true ? 0 : $this->user->id;
     try {
         $this->messagesFacade->sendMessage($values->subject, $text, $author, $values->receivers);
     } catch (MessageLengthException $ml) {
         $form->addError('Zprávu nelze uložit, protože je příliš dlouhá.');
         return;
     } catch (\DibiException $e) {
         $this->flashMessage('Zpráva nemohla být odeslána. Zkuste akci opakovat později.', 'errror');
         $this->redirect('this');
     }
     $this->flashMessage('Zpráva byla úspěšně odeslána', 'success');
     $this->redirect('MailBox:sent');
 }
コード例 #3
0
 public function processNewMessageForm(Form $form)
 {
     $values = $form->getValues();
     $recipients = is_array($values->recipients) ? $values->recipients : [$values->recipients];
     if (!$this->authorizator->isAllowed($this->user, 'message', 'sent_to_restricted_recipients')) {
         $s = $this->messagesFacade->canMessageBeSentTo($values->recipients, $this->restrictedUsers, $this->users);
         if ($s === false) {
             $form->addError('Nelze odeslat zprávu vybranému příjemci.');
             return;
         }
     }
     if ($values['isSendAsAdmin'] == true and !$this->authorizator->isAllowed($this->user, 'message', 'send_as_admin')) {
         $form->addError('Nemáte dostatečná oprávnění k akci.');
         return;
     }
     $texy = new \Texy();
     $texy->setOutputMode(\Texy::HTML4_TRANSITIONAL);
     $texy->encoding = 'utf-8';
     $texy->allowedTags = \Texy::ALL;
     $text = $texy->process($values->text);
     $message = new SentMessage($values->subject, $text, $this->user);
     if ($values['isSendAsAdmin']) {
         $message->sendByAuthorRole();
     }
     try {
         $this->messagesFacade->sendMessage($message, $recipients);
     } catch (MessageLengthException $ml) {
         $form->addError('Zprávu nelze uložit, protože je příliš dlouhá.');
         return;
     } catch (DBALException $e) {
         $this->flashMessage('Zpráva nemohla být odeslána. Zkuste akci opakovat později.', 'errror');
         $this->redirect('this');
     }
     $this->presenter->flashMessage('Zpráva byla úspěšně odeslána', 'success');
     $this->presenter->redirect('MailBox:sent');
 }