Exemplo n.º 1
0
 /**
  * Update a room right
  *
  * @param      Client  $client          The client to update the room right to
  * @param      string  $roomRightName   The room right name
  * @param      bool    $value           The new room right value
  *
  * @return     bool    True if the room right has been updated, false otherwise
  */
 public function updateRoomRight(Client $client, string $roomRightName, bool $value) : bool
 {
     $roomRight = $client->getUser()->getRoomRight()->getEntityById($this->room->id);
     // Create the room right if it does not exist and add it to the user room right collection
     if ($roomRight === null) {
         $roomRight = new RoomRight();
         $roomRight->idRoom = $this->room->id;
         $roomRight->idUser = $client->getUser()->id;
         $client->getUser()->getRoomRight()->add($roomRight);
     }
     $roomRightEntityManager = new RoomRightEntityManager($roomRight);
     return $roomRightEntityManager->update($roomRightName, $value);
 }
Exemplo n.º 2
0
 /**
  * Save the current user collection
  *
  * @return     bool  True if the user collection has been saved, false otherwise
  */
 public function saveUserCollection() : bool
 {
     $userEntityManager = new UserEntityManager();
     $userRightEntityManager = new UserRightEntityManager();
     $roomRightEntityManager = new RoomRightEntityManager();
     $success = $userEntityManager->saveCollection($this->userCollection);
     if ($success) {
         foreach ($this->userCollection as $user) {
             if ($success && $user->getRight() !== null) {
                 $success = $userRightEntityManager->saveEntity($user->getRight());
             }
             if ($success && $user->getRoomRight() !== null) {
                 $success = $roomRightEntityManager->saveCollection($user->getRoomRight());
             }
         }
     }
     return $success;
 }