<!--User profiles, containing reviews, ratings, and user data--> <?php //Variables if (count($user = (new GetUser($_GET['UID']))->execute()) > 0) { $user = $user[0]; } else { exit('Error. Please log in.'); } $name = ucfirst($user['first_name']) . " " . ucfirst($user['last_name']); $reviews = (new GetReviewsAbout($_GET['UID']))->execute(); ?> <section class="pagewidth login pad_bottom"> <main class='profile_display'> <?php profile_bar($user, null); ?> <?php if ($_SESSION['UID'] == $user['UID']) { echo '<form action="/tnelat/handlers/upload.php" id="upload" method="post" enctype="multipart/form-data"> <h5>Profile Picture:</h5> <input type="file" name="fileToUpload" id="fileToUpload"> </form>'; } ?> <h2>Reviews</h2> <?php if (count($reviews) == 0) { echo '<span class="message">This user has no reviews (yet!)</span>'; } else {
case 'last_name': $request = new GetUsersLikeLastName($vars['search_term']); break; case 'username': $request = new GetUsersLikeUsername($vars['search_term']); break; } //Organize Results if ($vars['sort_by'] != 'rating') { $sort = $vars['sort_by'] . ' ' . strtoupper($vars['order']); $request->order_by($sort); $sorted_users = $request->execute(); } else { $users = $request->execute(); $sorted_indices = []; foreach ($users as $index => $user) { $sorted_indices[$index] = (new GetAverageRating($user['UID']))->execute()[0][0]; } asort($sorted_indices); $sorted_users = []; foreach ($sorted_indices as $index => $rating) { $sorted_users[] = $users[$index]; } if (strtoupper($vars['order'] == 'asc')) { $sorted_users = array_reverse($sorted_users); } } foreach (array_reverse($sorted_users) as $user) { profile_bar($user, '/tnelat?src=profile&UID=' . $user['UID']); } }