Esempio n. 1
0
 public function getNewsCount($user)
 {
     try {
         return $this->mailboxDao->createQueryBuilder()->select("COUNT(mb)")->from(MailBoxEntry::getClassName(), "mb")->where("mb.owner = :owner")->andWhere("mb.type = :type")->setParameter("owner", $user->getId())->setParameter("type", MailBoxEntryType::UNREAD)->getQuery()->getSingleScalarResult();
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
Esempio n. 2
0
 protected function createMessage(ArrayHash $values)
 {
     $pm = new PrivateMessage((array) $values);
     $mb = new MailBoxEntry((array) $values);
     $mb->setMessage($pm);
     $mb->setSender($this->getUser()->getIdentity());
     try {
         $this->privateMessageService->createEntry($mb);
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataSave(null, "this", $ex);
     }
     $this->redirect("default");
 }
 public function notifyNewMessage(MailBoxEntry $e)
 {
     $u = $e->getRecipient();
     $subjKey = "systemModule.notification.newMessage.subject";
     $bodyKey = "systemModule.notification.newMessage.body";
     $subject = $this->translator->translate($subjKey, null, ["host" => $this->getHostName()]);
     $body = $this->translator->translate($bodyKey, null, ["name" => $u->getName(), "surname" => $u->getSurname()]);
     $mail = new Message();
     $mail->setFrom($this->getSenderEmail())->setSubject($subject)->setBody($body)->addTo($u->getContact()->getEmail());
     $this->send($mail);
 }