<div class="listRoons"> <?php $roons = $_REQUEST["roons"]; if (count($roons) > 0) { foreach ($roons as $room) { //If the room doesn't belong to the user and it isn't active, nothing will be printed if (!($room->getUserId() != $_SESSION['id'] && $room->getActive() == 0)) { // Instantiates the permissions of the room $_POST['currentRoom'] = $room->getRoomId(); $action = new ActionMapping(); $action->setName("listPermissions"); $action->setType("ListPermissionsAction"); $action->setRole(""); $listPermissionsAction = new ListPermissionsAction(); $listPermissionsAction->execute($action); $permissions = $_REQUEST["permissions"]; // List users $action = new ActionMapping(); $action->setName("listUsers"); $action->setType("ListUsersAction"); $action->setRole(""); $listUsersAction = new ListUsersAction(); $listUsersAction->execute($action); $listUsers = $_REQUEST['users']; if (isset($listEnableUsers) || isset($listAllowedUsers)) { unset($listEnableUsers); unset($listAllowedUsers); } // Coloca em um vetor os usuários que ainda não tem permissão na sala corrente foreach ($listUsers as $user) {
public function execute($action) { $forwards = $action->getForwards(); // Checks if all fields were provided if (!empty($_POST['roomId']) && !empty($_POST['roomName']) && !empty($_POST['idsSelecteds'])) { $idRoom = $_POST['roomId']; $roomName = $_POST['roomName']; $listUsers = explode("-", $_POST['idsSelecteds']); $listUsers[] = $_SESSION['id']; $_POST['currentRoom'] = $idRoom; // Upadate user; $resultRoom = $this->dao->updateRoomData($idRoom, $roomName); // Delete old permissions $listPermissions = new ListPermissionsAction(); $listPermissions->execute($action); $permissions = $_REQUEST["permissions"]; foreach ($permissions as $permission) { $resultDeletePermissions = $this->dao->deletePermission($permission); } // Instantiates a new room permission; foreach ($listUsers as $allowedUserId) { if ($allowedUserId != 0) { $permission = new Permission(); $permission->setUserId($allowedUserId); $permission->setRoomId($idRoom); $resultPermission = $this->dao->savePermission($permission); } } // Showing the page $this->pageController->run($forwards['success']); } else { // It will set a variable with the id of the button // that opens the modal window that was active $_SESSION['openModalWindow'] = "#btnUptRoom"; // Error if there are blank fields $_REQUEST["errorMsg"] = $this->message->getText("error.blankField"); $this->pageController->run($forwards['error']); } }