-
Notifications
You must be signed in to change notification settings - Fork 1
/
collection-edit.php
195 lines (163 loc) · 7.34 KB
/
collection-edit.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
//same page as create-collection.php but all attributes of the collection are pre seleted
//ob_start needed to allow redirecting after login
ob_start();
//session_start() needed to use global session variabls $_SESSION etc
session_start();
include('includes/config.php');
require('includes/dbconnect.php');
$filename = basename(__FILE__, '.php');
$profileUserName = $_SESSION['UserName'];
if(isset($_POST['edit']) || isset($_POST['delete']) ){
include('includes/edit-collection.php');
}
if(isset($_GET['CollectionID'])){
$CollectionID = $_GET['CollectionID'];
}
if(isset($_GET['error'])){
$error = $_GET['error'];
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<script src="https://use.fontawesome.com/ed51c90fe4.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="css/offset.css">
<link rel="stylesheet" href="css/style.css">
<title>Pano - Profile</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="theme-color" content="#ffffff">
<meta property="og:title" content="Pano" />
<meta property="og:image" content="https://apppanoblob.blob.core.windows.net/assets/ogimage.jpg" />
<meta property="og:description" content="The social network taking a wider perspective " />
</head>
<body ng-app="">
<?php
include('includes/header.php');
?>
<main>
<?= $CollectionID ?>
<?php
$query1= "SELECT c.Caption, u.UserName, c.SettingID, c.GroupID FROM collections AS c LEFT JOIN user AS u on c.OwnerID = u.UserID WHERE c.CollectionID='$CollectionID'";
if($result1 = mysqli_query($conn, $query1)){
if(mysqli_num_rows($result1) == 1){
$row1 = mysqli_fetch_array($result1);
}
}
?>
<div class="alert-danger">
<?php if(isset($error)){
echo $error;
} ?>
</div>
<div class="row collection-identifier">
Collection:
</div>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post" class="form-group">
<input type="hidden" name="OwnerName" value="<?=$profileUserName?>">
<input type="hidden" name="CollectionID" value="<?=$CollectionID?>">
<div class="row collection-creation-header">
<div class="create-collection-name row">
<div class="col col-sm-12 add-padding-30">
<input type="text" class="form-control collection-name-input" id="usr" name="Caption"placeholder="Insert Awesome Name Here" ng-style="{'width': (CollectionName.length == 0 ? '360': ((CollectionName.length*18))) + 'px'}" ng-model="CollectionName" ng-init="CollectionName='<?=$row1['Caption']?>'">
by <?= $profileUserName ?>
</div>
</div>
<div class="row add-padding-20">
<p class="privacy-setting-description">
Who do you want to share this collection with?
</p>
<select class="privacy-setting" name="PrivacySetting" ng-model="PrivacySetting" ng-init="PrivacySetting = '<?=$row1['SettingID'] ?>'">
<?php
$query = "SELECT * from privacysettings";
$results = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($results)):
?>
<option value="<?=$row['SettingID'] ?>"><?=$row['Description'] ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="row group selection add-padding-20" ng-show="PrivacySetting == '4'">
<p class="privacy-group-description">
Which group do you want to share this collection with?
</p>
<select class="privacy-group-setting" name="GroupID" ng-model="GroupSelection" ng-init="GroupSelection='<?= $row1['GroupID']?>'">
<?php
// query for groups that the user is in
$query = "SELECT g.GroupID, g.GroupName, g.ShortDescrip, g.PhotoID FROM groups AS g INNER JOIN usergroupmapping AS u ON g.GroupID=u.GroupID WHERE u.UserID=" . $_SESSION['UserID'];
$results = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($results)):
?>
<option value="<?=$row['GroupID'] ?>" ><?=$row['GroupName'] ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="row add-padding-30">
<input type="submit" name="edit" class="btn btn-default lv-button create-collection-btn" value="Save" />
</div>
<div class="row add-padding-20">
<input type="submit" name="delete" class="btn btn-default lv-button delete-collection-btn" value="Delete Collection" />
</div>
</div>
<br />
</div>
<div class="content collection-creation">
<h4>Please select the pictures which should be in this collection. All pictures that are currently in the album are pre-selected.</h4>
<br />
<div class="soft-shadow">
<?php
//query for all pictures in the collection to later mark them as checked
$query = "SELECT PostID FROM photocollectionsmapping
WHERE photocollectionsmapping.`CollectionID` = '$CollectionID'";
$results = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($results)){
$picturesInCollection[] = $row['PostID'];
}
//create an array of collections
$query="SELECT PostID from posts WHERE UserID=(SELECT UserID from user WHERE UserName='$profileUserName')";
if($pictures = mysqli_query($conn, $query)){
$count = 1;
//insert the collections into the page
foreach($pictures as $picture){
$isInCollection = '';
//check if picture was already in collection
if(isset($picturesInCollection) && in_array($picture['PostID'],$picturesInCollection)){
$isInCollection = 'checked';
}
// insert a new row every two elements
if($count % 3 == 0){
echo '<div class="row picture-list-row"> ';
}
echo '
<div class="col col-sm-4 picture-list-col picture-list-picture-container">
<img src="https://apppanoblob.blob.core.windows.net/panoramas/'.$picture['PostID'].'.jpg" class="img-responsive picture-list-picture"/>
<input type="checkbox" class="create-collection-check" value="checked" name="'.$picture['PostID'].'" id="'.$picture['PostID'].'" '.$isInCollection.'/>
</div>
';
//close row every two elements and insert a dividor
if($count % 3 == 0){
echo '</div>';
}
$count += 1;
}
}
?>
</div>
</div>
</form>
</main>
<?php
include('includes/footer.php');
?>
</body>
</html>