/**
  * Returns the ancestors of a message (the message itself is also returned).
  *
  * @param Message $message
  *
  * @return array[Message]
  */
 public function findAncestors(Message $message, User $user)
 {
     $dql = "\n            SELECT m\n            FROM Claroline\\MessageBundle\\Entity\\Message m\n            JOIN m.userMessages um\n            JOIN um.user u\n            WHERE m.lft BETWEEN m.lft AND m.rgt\n            AND m.root = {$message->getRoot()}\n            AND m.lvl <= {$message->getLvl()}\n            AND (\n                u.id = :userid\n                OR m.user = :userid\n            )\n        ";
     $query = $this->_em->createQuery($dql);
     $query->setParameter('userid', $user->getId());
     return $query->getResult();
 }
Esempio n. 2
0
 /**
  * Returns the ancestors of a message (the message itself is also returned).
  *
  * @param Message $message
  *
  * @return array[Message]
  */
 public function findAncestors(Message $message)
 {
     $dql = "\n            SELECT m\n            FROM Claroline\\MessageBundle\\Entity\\Message m\n            WHERE m.lft BETWEEN m.lft AND m.rgt\n            AND m.root = {$message->getRoot()}\n            AND m.lvl <= {$message->getLvl()}\n        ";
     $query = $this->_em->createQuery($dql);
     return $query->getResult();
 }