//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) { if ($user->getUserId() != $_SESSION['id']) { foreach ($permissions as $permission) { if ($user->getUserId() == $permission->getUserId()) { $control = TRUE; } }
public function execute($action) { //error_reporting(E_ALL); //ini_set("display_errors", 1); $forwards = $action->getForwards(); $strJson = str_replace('\\', '', $_POST['json']); $json = json_decode(utf8_encode($strJson)); $data = $json->{'logindata'}; $sucess = false; $createdUser = false; if (!is_null($data->{'email'})) { $user = $this->dao->getUserByEmail($data->{'email'}); if (!$user) { // Store a new user $user = new User(); $user->setName($data->{'name'}); $user->setEmail($data->{'email'}); $user->setPassword($data->{'passoword'}); if ($data->{'roomCreator'} == 'F0') { $user->setRoomcreator(true); } else { $user->setRoomcreator(false); } // Saving a new user $this->dao->saveNewUser($user); $createdUser = true; } //else{ //TODO verificar a senha //} // Store data in PHP SESSION if ($user) { $sucess = true; $_SESSION['id'] = $user->getUserId(); $_SESSION['name'] = $user->getName(); $_SESSION['roomCreator'] = $user->getRoomcreator(); $_SESSION['email'] = $user->getEmail(); $_SESSION['user'] = $user; } else { //TODO ajustar quando o login nao funciona $sucess = false; $_REQUEST["errorMsg"] = $this->message->getText("error.loginFail"); $this->pageController->run($forwards['error']); } } else { //TODO ajustar quando o login nao funciona $sucess = false; $_REQUEST["errorMsg"] = $this->message->getText("error.loginFail"); $this->pageController->run($forwards['error']); } if ($createdUser == true) { // Verifica se o usuario foi criado, se sim, manda para uma pagina de sucesso $action = new ActionMapping(); $action->setName("createdUserSuccess"); $action->setType("ForwardAction"); $action->setRole(""); $action->setForwards(array("success" => ".createdUserSuccess")); $forwardAction = new ForwardAction(); $forwardAction->execute($action); } else { if ($sucess) { $_REQUEST["msg"] = "Sua conta foi criada com sucesso no Quadro Branco, por favor, volte e entre novamente"; $action = new ActionMapping(); $action->setName("listRoons"); $action->setType("ListRoonsAction"); $action->setRole(""); $action->setForwards(array("success" => ".showUserPage", "error" => ".error")); $listRoonsAction = new ListRoonsAction(); $listRoonsAction->execute($action); } } }
public function execute($action) { if (isset($_SESSION["idRoom"])) { // Setting the room state to off $this->dao->updateRoomState($_SESSION["idRoom"], false, 0); } unset($_SESSION['id']); unset($_SESSION['name']); unset($_SESSION['user']); session_destroy(); $action = new ActionMapping(); $action->setName("loginForm"); $action->setType("ForwardAction"); $action->setRole(""); $action->setForwards(array("success" => ".showLoginForm", "error" => ".error")); $forwardAction = new ForwardAction(); $forwardAction->execute($action); }
/** * Returns true if the current user is the owner of the room. * * @param : Nothing * @return Boolean : True to the owner of the room */ function isRoomOwner() { if (!isset($_GET['idRoom'])) { $_GET['idRoom'] = $_SESSION['idRoomAux']; unset($_SESSION['idRoomAux']); } $action = new ActionMapping(); $action->setName("listRoons"); $action->setType("ListRoonsAction"); $action->setRole(""); $listRoonsAction = new ListRoonsAction(); $listRoonsAction->execute($action); $roons = $_REQUEST["roons"]; foreach ($roons as $room) { if ($room->getRoomId() == $_GET['idRoom'] && $room->getUserId() == $_SESSION['id']) { $control = true; $_SESSION['roomOwner'] = $room->getUserId(); } } return $control; }
/** * Metodo responsavel por criar o array de objetos ActionMapping * @return : void */ private function createActionsMappings() { $actionsList = $this->_document->getElementsByTagName('action'); foreach ($actionsList as $action) { $actionMapping = new ActionMapping(); if ($action->hasAttribute("ssl")) { if ($action->getAttribute("ssl") == "false") { $actionMapping->setSSL(0); } else { $actionMapping->setSSL(1); } } if ($action->hasAttribute("authentication")) { if ($action->getAttribute("authentication") == "false") { $actionMapping->setAuthentication(0); } else { $actionMapping->setAuthentication(1); } } if ($action->hasChildNodes()) { $actionChildNode = $action->childNodes; foreach ($actionChildNode as $actionChild) { if ($actionChild->nodeName == "name") { $actionMapping->setName($actionChild->nodeValue); } if ($actionChild->nodeName == "type") { $actionMapping->setType($actionChild->nodeValue); } if ($actionChild->nodeName == "role") { $actionMapping->setRole($actionChild->nodeValue); } if ($actionChild->nodeName == "forwards") { $actionMapping->setForwards($this->createForwards($actionChild)); } if ($actionChild->nodeName == "validation") { $actionMapping->setValidations($this->createValidation($actionChild)); } } $this->_actionsMapping[] = $actionMapping; } } }