-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_objectlist.php
100 lines (97 loc) · 4.27 KB
/
admin_objectlist.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
<?php include("includes/db.php");?>
<?php include("includes/authcheck.php"); ?>
<?php if ($_SESSION['User']['role'] < 2) header('Location: ' . $baseUrl . 'user.php') ?>
<?php
if (isset($_GET['delete'])) {
$query = mysql_query("DELETE objects.*, object_options.*, coordinates.*
FROM objects
LEFT JOIN object_options ON object_options.object_id = objects.id
LEFT JOIN coordinates ON coordinates.object_id = objects.id
WHERE objects.id = " . $_GET['delete']);
$query = mysql_query("DELETE gallery.*, pictures.*
FROM gallery
LEFT JOIN pictures ON pictures.gallery_id = gallery.id
WHERE gallery.object_id = " . $_GET['delete']);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>DigDig - Worlds Diggers and Archeologist club</title>
<link rel="shortcut icon" href="/digdig/img/favico.ico"/>
<!-- Pievienojam skriptus -->
<?php include("includes/scripts.php"); ?>
<!-- END -->
<script type="text/javascript">
var url = "<?php echo 'http://localhost/digdig/'?>";
</script>
</head>
<body class="user-page">
<div id="header-wrap">
<?php include("includes/header.php"); ?>
</div>
<div id="cont-wrapper">
<div id="content">
<h2 class="home-heading main view">
<span>User menu</span>
</h2>
<div class="leftcol">
<ul class="user-menu-list">
<li class="active"><a href="admin_objectlist.php">Admin object list</a></li>
<li><a href="admin_newsarticle.php">Add news article</a></li>
<?php if ($_SESSION['User']['role'] == 3): ?>
<li><a href="admin_aboutus.php">About us</a></li>
<?php endif ?>
</ul>
</div>
<div class="maincol admin">
<?php
$result = mysql_query("
SELECT objects.*, object_options.main_text, users.id AS user_id, users.name, users.surname, users.email,
(SELECT COUNT(comments.id)
FROM comments
WHERE comments.object_id = objects.id
) AS comment_count,
(SELECT COUNT(pictures.id)
FROM pictures
WHERE pictures.gallery_id = (SELECT gallery.id
FROM gallery
WHERE gallery.object_id = objects.id LIMIT 1)
) AS picture_count
FROM objects
LEFT JOIN object_options ON object_options.object_id = objects.id
LEFT JOIN users ON users.id = objects.user_id
WHERE object_options.main_text != ''");
?>
<div class="admin-listview-heading">
<div class="title">Title</div>
<div class="descr">Description</div>
<div class="photocount">Photos count</div>
<div class="comment-count">Comments count</div>
<div class="user">User</div>
<div class="actions">Actions</div>
<br style="clear: both;"/>
</div>
<div class="line"></div>
<?php while ($object = mysql_fetch_array($result, MYSQL_ASSOC)): ?>
<div class="admin-listview">
<div class="title"><?php echo $object['title'] ?></div>
<div class="descr"><?php echo $object['description'] ?></div>
<div class="photocount"><?php echo $object['picture_count'] ?></div>
<div class="comment-count"><?php echo $object['comment_count'] ?></div>
<div class="user"><?php echo $object['name'] . ' ' . $object['surname'] ?></div>
<div class="actions"><a class="admin-delete" onclick="if(!confirm('Are you sure, about deletion?')) return false;" href="<?php echo $baseUrl ?>admin_objectlist.php?delete=<?php echo $object['id'] ?>">[delete]</a></div>
<br style="clear: both;"/>
</div>
<?php endwhile ?>
</div>
</div>
<br style="clear: both;"/>
</div>
<div id="footer-wrap">
<?php include('includes/footer.php'); ?>
</div>
</body>
</html>