-
Notifications
You must be signed in to change notification settings - Fork 0
/
persons.php
99 lines (75 loc) · 2.98 KB
/
persons.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
<?php
/**
* @author Simon Hintersonnleitner <[email protected]>
* Meine Lieblingsorte ist ein MultiMediaProjekt 1 des Studiengangs MultimediaTechnology der Fachhochschule Salzburg.
*/
include 'system/php/functions.php';
checklogin();
$pagetitle = "Meine Lieblingsorte";
if(isset($_GET['view']))
{
$view = $_GET['view'];
}
else
{
$view = 1;
}
$stm = $dbh->query("SELECT * FROM user WHERE isActive = 1 ORDER BY cover DESC;");
$response = $stm->fetchAll();
$userId = $_SESSION['id'];
$stm = $dbh->query("SELECT * FROM user WHERE id = $userId;");
$response1 = $stm->fetch();
include 'template/beginHeader.php';
?>
<link rel="stylesheet" type="text/css" href="system/css/index.css">
<?php
include 'template/endHeader.php';
include 'template/menue.php';
?>
<div class="container">
<h3>Alle Personen</h3>
<a href="persons.php?view=1" class="btn btn-default btn-sm">Gitteransicht</a>
<a href="persons.php?view=2" class="btn btn-default btn-sm">Tabellenansicht</a>
<br>
</div>
<div class="container">
<?php if($view == 1): /*Gridview*/?>
<?php foreach ($response as $user):?>
<div class='col-md-3'>
<h3><?php echo $user->firstname." ".$user->lastname; ?></h3>
<small><a href="places.php?userId=<?php echo $user->id; ?>"><?php $count = getPlaceCountByUserId($user->id,$dbh); echo ($count == 1) ? $count." Ort" : $count." Orte" ;?> veröffentlicht</a> </small>
<?php
if($user->cover != null)
{
$srcParts = pathinfo("img/upload/".$user->id.'/'.$user->cover);
$newSrc = $srcParts['dirname'] . '/' . $srcParts['filename'] . '_croped.'. $srcParts['extension'];
}
else
{
$newSrc = "img/upload/placeholder.png";
}
?>
<a href="person.php?id=<?php echo $user->id; ?>"><img src="<?php echo $newSrc ; ?>" alt=""></a>
</div>
<?php endforeach; ?>
<?php endif;?>
<?php if($view == 2):/*ListView*/?>
<div class="list-group">
<?php foreach ($response as $user):?>
<a href='person.php?id=<?php echo $user->id; ?>' class="list-group-item"><?php echo $user->firstname." ".$user->lastname;?><span class="badge"><?php echo getPlaceCountByUserId($user->id,$dbh);?></span>
<?php if($response1->isAdmin != 0 || $response1->id == $user->id):?>
<form action="personDelete.php" method="post" class="form-inline">
<input type="hidden" name="id" value='<?php echo $user->id; ?>'>
<input type="submit" name="del" class="btn btn-default btn-xs" value="löschen">
</form>
<form action="editPerson.php" method="post" class="form-inline">
<input type="hidden" name="id" value='<?php echo $user->id; ?>'>
<input type="submit" name="edit" class="btn btn-default btn-xs" value="bearbeiten">
</form>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>
<?php endif;?>
</div>
<?php include 'template/footer.php';?>