-
Notifications
You must be signed in to change notification settings - Fork 0
/
userdetails.php
149 lines (117 loc) · 5.11 KB
/
userdetails.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
session_start();
include_once 'include.php';
//set SESSION's value
if (!isset($_SESSION['user'])) {
header('Location:login.php');
} else {
$name = $_SESSION['user']['name'];
$myUserId = $_SESSION['user']['id'];
}
//Showing all twits of a user
if (isset($_GET['userId'])) {
//$useridSession = $_SESSION['user']['id'];
$userId = $_GET['userId'];
$userDetails = User::getUserProfile($userId);
$otherUsers = User::GetAllUsers();
$userAllTwits = new Tweet();
$resultAllTwitsQuery = Tweet::getAllMyTwits($userId);
}
if($_SERVER['REQUEST_METHOD'] == "POST"){
$switchUserTo = $_POST['twituser'];
if(isset($switchUserTo)) {
header("Location:userdetails.php?userId={$switchUserTo}");
}
}
?>
<html lang="en-EN">
<head>
<title>User's details</title>
<meta charset="utf-8">
<!-- Latest compiled and minified CSS -->
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Custom styles for this template -->
<link href="css/signin.css" rel="stylesheet">
<link href="css/jumbotron-narrow.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="index.php">My Twits</a></li>
<li role="presentation"><a href="profile.php">My Profile</a></li>
<li role="presentation"><a href="mymessages.php">My Messages</a></li>
<li role="presentation"><a href="twits.php">All Twits</a></li>
<li role="presentation"><a href="logout.php">Log out</a></li>
</ul>
</nav>
<h3 class="text-muted">Welcome <?php echo $name ?>!</h3>
</div>
<div id="content">
<h3>User's profile</h3>
<?php
foreach($userDetails as $key => $user){
echo "<div class='panel panel-default'>";
echo "<div class='panel-body'>Full name: {$user->getName()}</div>";
echo "<div class='panel-footer'>Email: {$user->getEmail()}</div>";
echo "<div class='panel-footer'>Description: {$user->getDescription()}</div>";
echo "</div>";
}
?>
<div class="btn-group" role="group">
<?php echo "<p><a class=\"btn btn-lg btn-success\" href=\"createmassage.php?receiverId={$user->getId()}\" role=\"button\">Send message to {$user->getName()}</a></p>"; ?>
</div>
<h3>Choose other user</h3>
<form action="#" method="POST" class="form-signin">
<select name="twituser" class="form-control">
<?php
foreach($otherUsers as $userChoose){
echo "<option value='{$userChoose->getId()}'>{$userChoose->getName()}</option>";
}
?>
</select>
<button type="submit" name="showuser" class="btn btn-default">Show user</button>
</form>
<h3>All twits of <?php echo $user->getName(); ?></h3>
<?php
if(count($resultAllTwitsQuery) > 0) {
foreach ($resultAllTwitsQuery as $key => $twit) {
echo "<div class='panel panel-default'>";
echo "<div class='panel-body'>{$twit->getTwitText()}</div>";
echo "<div class='panel-footer'>Created time: {$twit->getCreatedTime()}</div>";
$twitUserId = $twit->getUserId();
$twitUserDetails = User::getUserProfile($twitUserId);
foreach($twitUserDetails as $key => $user) {
echo "<div class='panel-footer'>"."Created by: {$user->getName()}, "."<a href='userdetails.php?userId={$user->getId()}'>Check user's profile</a></div>";
}
$showComments = Comment::GetAllCommentsForTwit($conn, $twit->getTwitId());
$numberOfComments = count($showComments);
echo "<div class='panel-footer'>Nr of comments: {$numberOfComments}, <a href='twitdetails.php?twitId={$twit->getTwitId()}'>Read comments</a></div>";
echo "</div>";
}
} else {
echo "<div class=\"alert alert-warning\" role=\"alert\">";
echo "User hasn't published any Twits yet";
echo '</div>';
}
?>
</div>
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="login.php">Login</a></li>
<li role="presentation"><a href="registration.php">Registration</a></li>
</ul>
</nav>
<footer class="footer">
<p>© Jakub Pawelczak</p>
</footer>
</div> <!-- /container -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
crossorigin="anonymous"></script>
</body>
</html>