示例#1
0
 private function createDialog(User $user, User $recipientUser)
 {
     $thread = $this->em->getRepository('NetworkStoreBundle:Thread')->findByUsers($user->getId(), $recipientUser->getId());
     if (!$thread or count($thread) == 0) {
         // there's no 1x1 thread between this pair of users
         // so we're creating a new one
         $thread = new Thread();
         $thread->setTopic('no topic');
         $this->persistAndFlush($thread);
         //because of foreign key error
         $thread->addUser($user, $user->getId())->addUser($recipientUser, $user->getId());
         $this->persistAndFlush($thread);
     } elseif (count($thread) > 1) {
         throw new Exception('SERVER ERROR: 2 dialogs between 2 persons');
     } else {
         $thread = $thread[0];
     }
     return $thread;
 }
示例#2
0
 /**
  * increase counters of unreadposts in UserThread except $user
  *
  * @param User $user
  */
 public function incUnreadPosts($user)
 {
     foreach ($this->userThreads as $ut) {
         if ($ut->getUser()->getId() != $user->getId()) {
             $ut->incUnreadPosts();
         }
     }
 }