Redirect user.php->profile.php, show deletes on report.php, open modal with row info
This commit is contained in:
parent
ab2dcbb5e9
commit
cc7bdf6b3a
|
|
@ -46,6 +46,41 @@
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function getTopDeletions($page, $max) {
|
||||
if(!$this->isConnected()) {
|
||||
throw new StorageConnectionException();
|
||||
}
|
||||
if($page < 1) {
|
||||
$page = 1;
|
||||
}
|
||||
if($max < 1) {
|
||||
$max = 1;
|
||||
}
|
||||
$q = $this->db->prepare('SELECT td.*, tq.question as question
|
||||
FROM triviadelete td
|
||||
INNER JOIN triviaquestion tq
|
||||
ON tq.id=td.line_num
|
||||
ORDER BY id DESC LIMIT :offset, :maxResults');
|
||||
$q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max));
|
||||
if ($q === false) {
|
||||
throw new StorageSchemaException();
|
||||
}
|
||||
$result = $q->fetchAll();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCountDeletions() {
|
||||
if(!$this->isConnected()) {
|
||||
throw new StorageConnectionException();
|
||||
}
|
||||
$q = $this->db->query('SELECT count(id) FROM triviareport');
|
||||
if ($q === false) {
|
||||
throw new StorageSchemaException();
|
||||
}
|
||||
$result = $q->fetchColumn();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTopReports($page, $max) {
|
||||
if(!$this->isConnected()) {
|
||||
throw new StorageConnectionException();
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ try {
|
|||
}
|
||||
$storage->close();
|
||||
?>
|
||||
<table class="table">
|
||||
<table class="table modal-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Round #</th>
|
||||
|
|
@ -98,6 +98,7 @@ try {
|
|||
|
||||
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/triviatime.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -40,6 +40,16 @@ if($newPage < 1) {
|
|||
$newPage = 1;
|
||||
}
|
||||
|
||||
if(array_key_exists('dp', $_GET)) {
|
||||
$deletePage = $_GET['dp'];
|
||||
}
|
||||
if(!isset($deletePage)) {
|
||||
$deletePage = 1;
|
||||
}
|
||||
if($deletePage < 1) {
|
||||
$deletePage = 1;
|
||||
}
|
||||
|
||||
$maxResults = 5;
|
||||
?>
|
||||
<head>
|
||||
|
|
@ -100,7 +110,7 @@ $maxResults = 5;
|
|||
echo "<div class='alert alert-error'>Error: Database is not available</div>";
|
||||
}
|
||||
?>
|
||||
<table class="table">
|
||||
<table class="table modal-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Report #</th>
|
||||
|
|
@ -147,7 +157,7 @@ $maxResults = 5;
|
|||
echo "<div class='alert alert-error'>Error: Database is not available</div>";
|
||||
}
|
||||
?>
|
||||
<table class="table">
|
||||
<table class="table modal-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Edit #</th>
|
||||
|
|
@ -219,7 +229,6 @@ $maxResults = 5;
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h2>Added Questions</h2>
|
||||
|
|
@ -235,7 +244,7 @@ $maxResults = 5;
|
|||
echo "<div class='alert alert-error'>Error: Database is not available</div>";
|
||||
}
|
||||
?>
|
||||
<table class="table">
|
||||
<table class="table modal-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
|
|
@ -262,6 +271,50 @@ $maxResults = 5;
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h2>Pending Deletions</h2>
|
||||
<?php
|
||||
$resultCount = 0;
|
||||
$result = array();
|
||||
try {
|
||||
$result = $storage->getTopDeletions($deletePage, $maxResults);
|
||||
$resultCount = $storage->getCountDeletions();
|
||||
} catch(StorageSchemaException $e) {
|
||||
echo "<div class='alert alert-error'>Error: Database schema is not queryable</div>";
|
||||
} catch(StorageConnectionException $e) {
|
||||
echo "<div class='alert alert-error'>Error: Database is not available</div>";
|
||||
}
|
||||
?>
|
||||
<table class="table modal-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th class="hidden-phone">Username</th>
|
||||
<th>New Question</th>
|
||||
<th>Question #</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach($result as $res) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . $res['id'] . '</td>';
|
||||
echo '<td class="hidden-phone">' . $res['username'] . '</td>';
|
||||
echo '<td class="breakable">' . $res['question'] . '</td>';
|
||||
echo '<td>' . $res['line_num'] . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
$pagination = new Paginator($deletePage, $resultCount, $maxResults, 'dp');
|
||||
$pagination->paginate();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>© Trivialand 2013 - <a target="_blank" href="https://github.com/tannn/TriviaTime">Github</a></p>
|
||||
</div>
|
||||
|
|
@ -270,6 +323,7 @@ $maxResults = 5;
|
|||
|
||||
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/triviatime.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
38
php/user.php
38
php/user.php
|
|
@ -1,5 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<?php
|
||||
include('config.php');
|
||||
include('includes/pagination.php');
|
||||
|
|
@ -32,8 +30,28 @@ if($page < 1) {
|
|||
}
|
||||
|
||||
$maxResults = 10;
|
||||
$usersCount = 0;
|
||||
$users = array();
|
||||
$errors = array();
|
||||
|
||||
?>
|
||||
try {
|
||||
$users = $storage->getUserLikeUsernameCanonical($usernameCanonical, $page, $maxResults);
|
||||
$usersCount = $storage->getCountUserLikeUsernameCanonical($usernameCanonical);
|
||||
} catch(StorageSchemaException $e) {
|
||||
$errors[] = "Error: Database schema is not queryable";
|
||||
} catch(StorageConnectionException $e) {
|
||||
$errors[] = "Error: Database is not available";
|
||||
}
|
||||
|
||||
$storage->close();
|
||||
|
||||
// Redirect to profile if only 1 result found
|
||||
if(count($users) == 1) {
|
||||
header('Location: profile.php?username=' . $users[0]['username']);
|
||||
die();
|
||||
}
|
||||
?><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Players · TriviaTime</title>
|
||||
|
|
@ -84,15 +102,10 @@ $maxResults = 10;
|
|||
<input type="submit"></input>
|
||||
</form>
|
||||
<?php
|
||||
$usersCount = 0;
|
||||
$users = array();
|
||||
try {
|
||||
$users = $storage->getUserLikeUsernameCanonical($usernameCanonical, $page, $maxResults);
|
||||
$usersCount = $storage->getCountUserLikeUsernameCanonical($usernameCanonical);
|
||||
} catch(StorageSchemaException $e) {
|
||||
echo "<div class='alert alert-error'>Error: Database schema is not queryable</div>";
|
||||
} catch(StorageConnectionException $e) {
|
||||
echo "<div class='alert alert-error'>Error: Database is not available</div>";
|
||||
if(count($errors) != 0) {
|
||||
foreach($errors as $error) {
|
||||
echo "<div class='alert alert-error'>$error</div>";
|
||||
}
|
||||
}
|
||||
if($usersCount==0) {
|
||||
echo "<div class='alert alert-error'>User not found.</div>";
|
||||
|
|
@ -101,7 +114,6 @@ $maxResults = 10;
|
|||
if($usernameCanonical=='') {
|
||||
echo "<div class='alert alert-info'>Enter a username above to search for stats.</div>";
|
||||
}
|
||||
$storage->close();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue