public function chatRoom($name, $type, $status, User $owner) { $resourceType = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('claroline_chat_room'); $chatRoom = new ChatRoom(); $chatRoom->setName($name); $chatRoom->setRoomName(uniqid()); $chatRoom->setRoomType($type); $chatRoom->setRoomStatus($status); $this->om->persist($chatRoom); $this->container->get('claroline.manager.resource_manager')->create($chatRoom, $resourceType, $owner); return $chatRoom; }
private function hasChatRoomRight(ChatRoom $chatRoom, $right) { $collection = new ResourceCollection([$chatRoom->getResourceNode()]); return $this->authorization->isGranted($right, $collection); }
public function editChatRoom(ChatRoom $chatRoom, $type, $status) { $chatRoom->setRoomType($type); $chatRoom->setRoomStatus($status); $this->om->persist($chatRoom); $this->om->flush(); return $chatRoom; }
public function copyChatRoom(ChatRoom $chatRoom) { $newRoom = new ChatRoom(); $newRoom->setName($chatRoom->getName()); $newRoom->setRoomName($chatRoom->getRoomName()); $newRoom->setRoomStatus($chatRoom->getRoomStatus()); $this->om->persist($newRoom); $messages = $chatRoom->getMessages(); foreach ($messages as $message) { $newMessage = new ChatRoomMessage(); $newMessage->setChatRoom($newRoom); $newMessage->setContent($message->getContent()); $newMessage->setUsername($message->getUsername()); $newMessage->setCreationDate($message->getCreationDate()); $this->om->persist($newMessage); } return $newRoom; }