PHP Method User::GetUserById, codiad Code Examples

This page contains top rated real world PHP examples of method User::GetUserById from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: api.php Project: heshuxian/mofang
0
 public function getuserinfo()
 {
     $jsonRet = array();
     $userObj = User::GetUserById($this->server->getOwnerId());
     unset($userObj->password);
     $jsonRet['userObj'] = $userObj;
     echo json_encode($jsonRet);
     return;
 }
Example #2
Show file File: sendMessage.php Project: adrozdek/twitter
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$user = User::GetUserById($_GET['id']);
echo "<h2>Do: {$user->getName()}</h2>";
echo "<form method='POST'>\n<textarea name='message' cols='30' rows='4'></textarea>\n<input type='submit' value='Wyślij'>\n</form>";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $newMessage = $_POST['message'];
    $sendId = $_SESSION['userId'];
    $receiveId = $_GET['id'];
    Message::CreateMessage($sendId, $receiveId, $newMessage);
    //header("Location: showUser.php?userId={$_GET['id']}");
    header("Location: showMessages.php");
}
Example #3
Show file File: showAllUsers.php Project: adrozdek/twitter
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$userSessionId = $_SESSION['userId'];
$allUsers = User::GetAllUsers();
foreach ($allUsers as $userToShow) {
    echo "<h1>{$userToShow->getName()} </h1>";
    $friendToUser = User::GetUserById($userSessionId);
    if ($friendToUser->checkIfFriendshipExist($userToShow->getId())) {
        echo "<h3>Przyjaciel :)</h3>";
    } elseif ($userToShow->checkIfYouAskedFS($userSessionId)) {
        echo "<h4>Czeka na Twoją akceptację</h4>";
    } elseif ($friendToUser->checkIfYouAskedFS($userToShow->getId())) {
        echo "<h4>Wysłałeś prośbę o przyjaźń</h4>";
    }
    echo $userToShow->getDescription() . "<br />";
    echo "<a href='showUser.php?userId={$userToShow->getId()}'>Pokaż</a> <br>";
    //KLAMRY !!
    echo "<hr />";
}
Example #4
Show file File: changeDescription.php Project: adrozdek/twitter
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$userId = $_SESSION['userId'];
$user = User::GetUserById($userId);
?>

<form method='POST'>
    Zmień opis:
    <p>
        <label>
            <textarea name='description' cols="30" rows="4"><?php 
echo $user->getDescription();
?>
</textarea>
        </label>

    </p>

    <input type='submit' value='Zmień opis'>


</form>


<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $newDescription = $_POST['description'];
Example #5
Show file File: showAllTweets.php Project: adrozdek/twitter
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$allTweets = Tweet::ShowAllTweets();
echo "<h1>Najnowsze tweety:</h1>";
foreach ($allTweets as $tweetToShow) {
    $userId = $tweetToShow->getUserId();
    $tweetingUser = User::GetUserById($userId);
    echo "<h2>{$tweetingUser->getName()}</h2>";
    if ($_SESSION['userId'] != $userId) {
        echo "<a href='showUser.php?userId={$userId}'>Pokaż profil'</a> <br />";
    }
    echo "{$tweetToShow->getTweetText()} <br />";
    echo "{$tweetToShow->getTweetDate()}<br>";
    $tweetToShowId = $tweetToShow->getId();
    $coms = count($tweetToShow->getAllComments());
    echo "Liczba komentarzy: {$coms} <br />";
    echo "<a href='showTweet.php?id={$tweetToShow->getId()}'>Pokaż </a>";
    if ($_SESSION['userId'] == $userId) {
        echo "<a href='editTweet.php?id={$tweetToShowId}'> Edytuj</a>";
        echo "<a href='removeTweet.php?id={$tweetToShowId}'> Usuń</a>";
    }
    echo "<hr />";
}
Example #6
Show file File: showTweet.php Project: adrozdek/twitter
0
$userId = (int) $tweetToShow->getUserId();
$user = User::GetUserById($userId);
echo "<h1> {$user->getName()}</h1>";
echo $tweetToShow->getTweetText() . "<br>";
echo $tweetToShow->getTweetDate() . "<br />";
$coms = count($tweetToShow->getAllComments());
if ($_SESSION['userId'] == $userId) {
    echo "<a href='editTweet.php?id={$id}'> Edytuj</a>";
    echo "<a href='removeTweet.php?id={$id}'> Usuń</a>";
}
echo "<br>Liczba komentarzy: {$coms} ";
echo "<hr />";
echo "\n<form method='post'>\n    <label>\n        <input type='text' name='comment' placeholder='wpisz swój komentarz'>\n     </label>\n    <input type='submit'>\n</form>\n";
foreach ($tweetToShow->getAllComments() as $comment) {
    $idOfCommentingUser = $comment->getUserId();
    $commentingUser = User::GetUserById($idOfCommentingUser);
    echo "<h3>{$commentingUser->getName()}</h3>";
    echo $comment->getCommentText() . "<br>";
    echo $comment->getCommentDate() . "<br>";
    echo "<hr />";
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (strlen($_POST['comment']) > 0) {
        $commentText = $_POST['comment'];
        $comment = Comment::CreateComment($_GET['id'], $commentText);
        header("Location: showTweet.php?id={$id}");
        return $comment;
    }
    return false;
}
?>
Example #7
Show file File: showUser.php Project: adrozdek/twitter
0
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
if (isset($_GET["userId"])) {
    $userId = $_GET["userId"];
} else {
    $userId = $_SESSION["userId"];
}
$userToShow = User::GetUserById($userId);
if ($userToShow !== FALSE) {
    echo "<h2>{$userToShow->getName()}</h2>";
    //nawiasy klamrowe wymagane
    echo "O mnie: {$userToShow->getDescription()} <br />";
    if ($_SESSION['userId'] != $userId) {
        echo "<a href='sendMessage.php?id={$userId}'>Wyślij wiadomość <br/> </a>";
        $friendToUser = User::GetUserById($_SESSION['userId']);
        if ($friendToUser->checkIfFriendshipExist($userId)) {
            echo "Przyjaciel :)";
        } elseif ($friendToUser->checkIfYouAskedFS($userId)) {
            echo "<a href='addFriend.php?id={$userId}'>Usuń zaproszenie do znajomych</a>";
        } elseif ($userToShow->checkIfYouAskedFS($_SESSION['userId'])) {
            echo "<a href='addFriend.php?id={$userId}'>Potwierdź zaproszenie do znajomych</a>";
        } else {
            echo "<a href='addFriend.php?id={$userId}'>Wyślij zaproszenie do znajomych</a>";
        }
    }
    if ($userToShow->getId() === $_SESSION['userId']) {
        ?>
        <h3>Nowy tweet</h3>
        <form action='showUser.php' method='post'>
            <label>
Example #8
Show file File: deleteTweet.php Project: kabaj/Twitter
0
<?php

require_once "./src/conection.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$id = $_GET['id'];
$tweetToRemove = Tweet::LoadTweetById($id);
$userId = User::GetUserById($id);
if ($_SESSION['userId'] == $tweetToRemove->getUserId()) {
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $tweetToRemove->removeTweet();
        header("Location: showUser.php?userId=" . $userId->getId());
    }
    echo "\n    <form method='POST'>\n    <p>\n    Napewno chcesz usunac tweeta?\n    </p>\n    <input type='submit' value='Usun'>\n    </form>";
} else {
    echo "Nie da rady";
}
Example #9
Show file File: addFriend.php Project: adrozdek/twitter
0
        echo "<form method='post'><input type='submit' value='Tak'></form>";
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $userSession->acceptFriendship($friendId);
            header("Location: showUser.php?userId={$friendId}");
        }
    } else {
        echo "Jesteś pewny, że chcesz wysłać użytkownikowi zaproszenie do znajomych? Będziesz wtedy widział jego tweety na stronie głównej.";
        echo "<form method='post'><input type='submit' value='Tak'></form>";
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            Friend::CreateFriendship($userId, $friendId);
            header("Location: showUser.php?userId={$friendId}");
        }
    }
} elseif (isset($_GET['idR']) && $_GET['idR'] != $userId) {
    $friendRemove = $_GET['idR'];
    $friendToRemove = User::GetUserById($friendRemove);
    var_dump($friendToRemove);
    var_dump($userSession);
    if ($friendToRemove->checkIfYouAskedFS($userId)) {
        echo "Chcesz usunąć zaproszenie od użytkownika {$friendToRemove->getName()}?";
        echo "<form method='post'><input type='submit' value='Tak'></form>";
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $friendToRemove->removeFriendship($userSession);
            header("Location: showAllFriends.php");
        }
    }
    if ($userSession->checkIfYouAskedFS($friendRemove)) {
        echo "Chcesz usunąć zaproszenie wysłane do użytkownika {$friendToRemove->getName()}?";
        echo "<form method='post'><input type='submit' value='Tak'></form>";
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $userSession->removeFriendship($friendRemove);
Example #10
Show file File: changePassword.php Project: adrozdek/twitter
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$user = User::GetUserById($_SESSION['userId']);
?>

    <form method='POST'>

        <fieldset>
            <legend>Zmień hasło</legend>

            <p>
                <label>Stare hasło:
                    <input type='password' name='oldpassword'>
                </label>
            </p>
            <p>
                <label>Nowe hasło:
                    <input type='password' name='password1'>
                </label>
            </p>
            <p>
                <label>Powtórz hasło:
                    <input type='password' name='password2'>
                </label>
            <p>
                <input type='submit' value='Zmień hasło'>
            </p>
Example #11
Show file File: editUser.php Project: aggie29/Tweeter
0
<?php

require_once "./src/connection.php";
if (isset($_GET["userId"])) {
    $userId = $_GET["userId"];
} else {
    $userId = $_SESSION['userId'];
}
$userToEdit = User::GetUserById($userId);
$userToEdit = User::GetUserById($_SESSION['userID']);
var_dump($_SESSION['userID']);
if ($userToEdit->getID() === $_SESSION['userId']) {
    $user->setDescription($_POST['description']);
    $user->saveTODB();
} else {
    echo "zle dane do zmiany opisu";
}
?>


<form action="editUser.php" method="post">
    <label>
Description:
        <input type="text" name="description">
    </label>
    <input type="submit">
</form>
Example #12
Show file File: EditUser.php Project: reagne/Tweet
0
<?php

require_once "./src/connection.php";
if (isset($_SESSION['userId'])) {
    echo "\n    <a href='ShowUser.php'>Home</a> | <a href='Logout.php'>Wyloguj</a>\n    <br>";
} else {
    header("Location: Login.php");
}
if (isset($_GET['userId'])) {
    $userId = $_GET['userId'];
} else {
    $userId = $_SESSION['userId'];
}
$userToEdit = User::GetUserById($userId);
if ($userToEdit !== FALSE) {
    if ($userToEdit->getId() === $_SESSION['userId']) {
        echo "Twoj obecny opis: {$userToEdit->getDescription()}<br>";
        echo "Zmien: <br>";
        echo "\n        <form action=EditUser.php method='POST'>\n        <input type='text' name='new_description''>\n        <input type='submit'>\n        </form>\n        ";
        if ($_SERVER['REQUEST_METHOD'] === "POST") {
            $userToEdit->setDescription($_POST["new_description"]);
            $userToEdit->saveToDb();
            if ($userToEdit !== FALSE) {
                echo "Twoj opis zostal zmieniony";
            } else {
                echo "Opis nieprawidlowy";
            }
        }
    }
} else {
    echo "Nie ma takiego uzytkownika";
Example #13
Show file File: showTweet.php Project: kabaj/Twitter
0
// 3
$user = User::GetUserById($userId);
// 3
echo '<h1>' . $user->getName() . '</h1>';
echo $tweetToShow->getTweetText() . "<br>";
echo $tweetToShow->getTweetDate() . "<br />";
$coms = count($tweetToShow->getAllComments());
if ($_SESSION['userId'] == $userId) {
    echo "<a href='editTweet.php?tweetId='.{$tweetId}> Edycja</a>";
    echo "  |  ";
    echo "<a href='deleteTweet.php?id='.{$tweetId}> Usun</a>";
}
echo "<br>Liczba komentarzy: {$coms} ";
echo "<hr />";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (strlen($_POST['comment']) > 0) {
        $commentText = $_POST['comment'];
        $comment = Comment::CreateComment($_GET['id'], $commentText);
        header("Location: showTweet.php?id=" . $tweetId);
        return $comment;
    }
    return false;
}
echo "<form  method='post'>\n    <label>\n        Dodaj Komentarz:\n        <br>\n        <input type='text' name='comment'>\n    </label>\n    <input type='submit'>\n    </form>";
foreach ($tweetToShow->getAllComments() as $comment) {
    $commenter = $comment->getUserId();
    $commenter = User::GetUserById($commenter);
    echo "<h1>{$commenter->getName()}</h1>";
    echo $comment->getCommentText() . "<br>";
    echo $comment->getCommentDate() . "<br>";
}
Example #14
Show file File: ShowUser.php Project: reagne/Tweet
0
<?php

require_once "./src/connection.php";
if (isset($_SESSION['userId'])) {
    echo "\n    <a href='ShowUser.php'>Home</a> | <a href='ShowAllUsers.php'>Znajdz uzytkownika</a> | <a href='Logout.php'>Wyloguj</a> | <a href='EditUser.php'>Edytuj swoje dane</a>\n    <br><br>";
} else {
    header("Location: Login.php");
}
if (isset($_GET['userId'])) {
    $userId = $_GET['userId'];
} else {
    $userId = $_SESSION['userId'];
}
$userToShow = User::GetUserById($userId);
if ($userToShow !== FALSE) {
    if ($userToShow->getId() !== $_SESSION['userId']) {
        echo "<h1>{$userToShow->getName()}</h1>";
    }
    if ($userToShow->getId() === $_SESSION['userId']) {
        echo "<h1>Witaj {$userToShow->getName()}</h1>";
        echo "\n        <a href='AllMessages.php?userId={$userToShow->getId()}'>Twoje wiadomosci</a>\n        <br><br>";
        if ($_SERVER['REQUEST_METHOD'] === "POST") {
            $tweet = Tweet::CreateTweet($_SESSION['userId'], $_POST['tweet_text']);
            if ($tweet === FALSE) {
                echo "Nieprawidlowy wpis.<br>";
            }
        }
        echo "\n        <form action='ShowUser.php' method='POST'>\n        <label>Dodaj Tweet'a:</label>\n        <input type='text' name='tweet_text''>\n        <input type='submit'>\n        </form>\n        ";
    }
    foreach ($userToShow->loadAllTweets() as $tweet) {
        echo "{$tweet->getText()} | Komentarze: {$tweet->numberOfComments()} | ";
Example #15
Show file File: showMessages.php Project: adrozdek/twitter
0
    }
    echo "{$message->getMessageDate()} <br />";
    if ($message->getOpened() == 1) {
        //sprawdzenie statusu odczytania
        echo "Status: Nieodczytana <br />";
    } else {
        echo "<strong>Status: </strong>Odczytana <br />";
    }
    echo "<a href='showMessage.php?id={$message->getId()}'>Pokaż wiadomość</a>";
    //przekierowanie do strony konkretnej wiadomości
    echo "<hr /><br />";
}
echo "<h2>Wysłane:</h2>";
foreach ($user->loadAllSentMessages() as $message) {
    //var_dump($message);
    $receivingUser = User::GetUserById($message->getReceiveId());
    $beginning = substr($message->getMessageText(), 0, 30);
    echo "<h3>Odbiorca: {$receivingUser->getName()}</h3>";
    if (strlen($message->getMessageText()) < 30) {
        echo "{$beginning} <br />";
    } else {
        echo $beginning . "(...) <br />";
    }
    echo "{$message->getMessageDate()} <br />";
    if ($message->getOpened() == 1) {
        echo "Status: Nieodczytana <br />";
    } else {
        echo "<strong>Status: </strong>Odczytana <br />";
    }
    echo "<a href='showMessage.php?id={$message->getId()}'>Pokaż wiadomość</a>";
    echo "<hr />";
Example #16
Show file File: user_helper.php Project: heshuxian/mofang
0
 /**
  * Get Current User
  *
  * @return object or null
  */
 function GetCurrentUser($bForceLoad = false)
 {
     if (User::IsAuthenticated()) {
         $userid = $_SESSION["PANDORA_USERNAME"];
         $user = User::GetUserById($userid, $bForceLoad);
         if ($user) {
             return $user;
         } else {
             $this->load->helper("cookie");
             unset($_SESSION['PANDORA_USERNAME']);
             unset($_SESSION['PANDORA_HASH']);
             unset($_SESSION["PANDORA_USERID"]);
             delete_cookie("PANDORA_HASH");
         }
     }
     $this->load->library('session');
     $this->session->set_userdata('returnUrl', $_SERVER['REQUEST_URI']);
     header("Location:" . site_url('/login'));
     exit;
     //return null;
 }
Example #17
Show file File: showMessage.php Project: adrozdek/twitter
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
$messageId = $_GET['id'];
//var_dump(Message::LoadMessageById($messageId));
$messageToShow = Message::LoadMessageById($messageId);
if ($messageToShow->getSendId() == $_SESSION['userId'] || $messageToShow->getReceiveId() == $_SESSION['userId']) {
    //zagwarantowanie, że wiadomość może zobaczyć tylko wysyłający, bądź odbiorca
    $sendingUser = User::GetUserById($messageToShow->getSendId());
    $receiveingUser = User::GetUserById($messageToShow->getReceiveId());
    //var_dump($receiveingUser);
    if ($_SESSION['userId'] == $messageToShow->getReceiveId()) {
        $messageToShow->updateOpened();
    }
    //var_dump($sendingUser);
    echo "<strong> Odbiorca:</strong> {$receiveingUser->getName()} <br />\n    <strong>Nadawca:</strong> {$sendingUser->getName()} <br />\n    <strong>Treść: </strong> {$messageToShow->getMessageText()} <br />\n    {$messageToShow->getMessageDate()} <br />";
    if ($_SESSION['userId'] != $messageToShow->getReceiveId()) {
        //wysłanie kolejnej wiadomości do tego samego użytkownika
        echo "<a href='sendMessage.php?id={$receiveingUser->getId()}'>Wyślij kolejną wiadomość do {$receiveingUser->getName()}</a> <br />";
    }
    if ($_SESSION['userId'] != $messageToShow->getSendId()) {
        //wysłanie odpowiedzi na wiadomość użytkownika
        echo "<a href='sendMessage.php?id={$sendingUser->getId()}'>Odpowiedz użytkownikowi {$sendingUser->getName()}</a> <br />";
    }
    echo "<a href='showMessages.php'>Wróć do wszystkich wiadomości</a>\n    ";
    //var_dump($_SESSION['userId']);      //int
    //var_dump($receiveingUser->getId());  //int
    //było 1 i 6, ale if działał na odwrót