/** * @param User $user * @param Thread $thread * @param integer $inviter */ public function __construct($user, $thread, $inviter) { $this->user = $user; $this->thread = $thread; $this->inviter = $inviter; $user->addUserThread($this); $thread->addUserThread($this); }
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; }
/** * Return the absolute directory path where uploaded * user's documents should be saved. * * @param User $user * @return string */ protected function getUploadRootDirForUser(User $user) { return $this->getUploadRootDir() . $user->getEmail() . '/'; }
/** * 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(); } } }