function removeUser($userNameRemove) { $mysession = new Session(); $mysession->initSession(); $wallRepo = new WallRepositoryService(); $userRepo = new UserRepositoryService(); $userName = $_SESSION['usuario']; $wallId = $wallRepo->getWallIdByUserName($userName); $userIdRemove = $userRepo->getUserIdByName($userNameRemove); $results = $wallRepo->removeUser($userIdRemove, $wallId); if ($results === TRUE) { $response['valid'] = true; } else { $response['errorMsg'] = "Lo sentimos, hubo un error al eliminar el usuario de su lista."; $response['valid'] = false; } echo json_encode($response); }
<?php require_once dirname(__DIR__) . "/services/UserRepositoryService.php"; $userRepo = new UserRepositoryService(); $userName = $_POST['userName']; $result = $userRepo->verifyUser($userName); if ($result == null) { $response['errorMsg'] = "Lo sentimos, el usuario ingresado no existe."; $response['valid'] = false; } else { $response['valid'] = true; } echo json_encode($response);
<?php require_once dirname(__DIR__) . "/services/WallRepositoryService.php"; require_once dirname(__DIR__) . "/services/UserRepositoryService.php"; $wallRepo = new WallRepositoryService(); $userRepo = new UserRepositoryService(); $userId = $_SESSION['id']; $wallId = $userRepo->getWallIdById($userId); //$privacity = isset($_POST['change']) ? $_POST['change'] : $wallRepo -> getPrivacityById($wallId); $privacity = $wallRepo->getPrivacityById($wallId); $checkedPrivate = ""; $checkedSemiPrivate = ""; $checkedNormal = ""; $checkedSemiPublic = ""; $checkedPublic = ""; $usersPrivate = null; $usersSemiPrivate = null; switch ($privacity) { case 'privado': $checkedPrivate = "checked"; $usersPrivate = $wallRepo->getUsersById($wallId); break; case 'semiprivado': $checkedSemiPrivate = "checked"; $usersSemiPrivate = $wallRepo->getUsersById($wallId); break; case 'normal': $checkedNormal = "checked"; break; case 'semipublico': $checkedSemiPublic = "checked";
<?php require_once dirname(__DIR__) . "/services/WallRepositoryService.php"; require_once dirname(__DIR__) . "/services/UserRepositoryService.php"; require_once dirname(__DIR__) . "/domain/Session.php"; $mysession = new Session(); $mysession->initSession(); $wallRepo = new WallRepositoryService(); $userRepo = new UserRepositoryService(); $json = $_POST['data']; $data = json_decode($json, true); $newData['privacity'] = $data['opt']; if (isset($_SESSION['usuario']) and preg_match("/^[a-zA-ZñÑáéíóÁÉÍÓÚ]*\$/", $_SESSION['usuario'])) { $userName = $_SESSION['usuario']; $newData['wallId'] = $wallRepo->getWallIdByUserName($userName); if ($data['opt'] == 'private') { //Obtengo el userId de cada userName $newUsers = array(); foreach ($data['users'] as $user) { $newUsers[] = $userRepo->getUserIdByName($user); } $newData['users'] = $newUsers; } else { if ($data['opt'] == 'semiprivate') { //Obtengo el userId de cada userName $newUsers = array(); foreach ($data['users'] as $user) { $newUsers[] = $userRepo->getUserIdByName($user); } $newData['users'] = $newUsers; }