-
Notifications
You must be signed in to change notification settings - Fork 4
/
mainpage.php
1052 lines (866 loc) · 34 KB
/
mainpage.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
session_start();
include_once "./server/loginService.php";
include_once "./server/loginSQL.php";
include_once "./server/connect.php";
function clean_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(!isset($_SESSION['UserId']) && !isset($_SESSION['githubUser']))
{
header('Location: ./index.php');
}
if(isset($_SESSION['githubUser']))
{
require "init.php";
$loginWebService = new LoginWebService();
$githubUser = fetchData();
$githubEmail = $githubUser['email']['email'];
$githubUsername = $githubUser['username'];
$userExists = $loginWebService->checkIfUserExistsByEmail($githubEmail);
if($userExists == true)
{
//fetch existing user
if(!isset($_SESSION)){
session_start();
}
$_SESSION['UserId'] = $loginWebService->getUserIdFromUserEmail($githubEmail);
$githubUserInfo = $loginWebService->getUserInfo($_SESSION['UserId']);
$githubUserInfo = json_decode($githubUserInfo, true);
$_SESSION['UserId'] = $githubUserInfo['userInfo'][0]['ID'];
$_SESSION['FirstName'] = $githubUserInfo['userInfo'][0]['FirstName'];
$_SESSION['LastName'] = $githubUserInfo['userInfo'][0]['LastName'];
$_SESSION['Email'] = $githubUserInfo['userInfo'][0]['Email'];
$_SESSION['ProfilePictureLoggedIn'] = "https://avatars.githubusercontent.com/". $githubUsername;
$_SESSION['Password'] = $githubUserInfo['userInfo'][0]['Password'];
$_SESSION['UserName']=$githubUserInfo['userInfo'][0]['UserName'];
$_SESSION['userType'] = $githubUserInfo['userInfo'][0]['type'];
$_SESSION['ProfilePicture'] = "https://avatars.githubusercontent.com/" . $githubUserInfo['userInfo'][0]['UserName'];
$_SESSION['displayPic'] = $githubUserInfo['userInfo'][0]['displayPic'];
//$loginWebService->updateDisplayPic($_SESSION['UserId'], 0);
//$loginWebService->uploadProfilePicture($_SESSION['UserId'], $_SESSION['ProfilePicture']);
unset ($_SESSION["githubUser"]);
}
else
{
$loginWebService->insertNewUser($githubUsername, "", $githubUsername, $githubEmail, "", "");
if(!isset($_SESSION)){
session_start();
}
$_SESSION['UserId'] = $loginWebService->getUserIdFromUserEmail($githubEmail);
$githubUserInfo = $loginWebService->getUserInfo($_SESSION['UserId']);
$githubUserInfo = json_decode($githubUserInfo, true);
$_SESSION['UserId'] = $githubUserInfo['userInfo'][0]['ID'];
$_SESSION['FirstName'] = $githubUserInfo['userInfo'][0]['FirstName'];
$_SESSION['LastName'] = $githubUserInfo['userInfo'][0]['LastName'];
$_SESSION['Email'] = $githubUserInfo['userInfo'][0]['Email'];
$_SESSION['ProfilePictureLoggedIn'] = $githubUserInfo['userInfo'][0]['ProfilePicture'];
$_SESSION['Password'] = $githubUserInfo['userInfo'][0]['Password'];
$_SESSION['UserName']=$githubUserInfo['userInfo'][0]['UserName'];
$_SESSION['userType'] = $githubUserInfo['userInfo'][0]['type'];
$_SESSION['ProfilePicture'] = "https://avatars.githubusercontent.com/" . $githubUserInfo['userInfo'][0]['UserName'];
$_SESSION['displayPic'] = $githubUserInfo['userInfo'][0]['displayPic'];
$loginWebService->addUserToGroup(3, $githubUserInfo['userInfo'][0]['ID']);
$loginWebService->updateDisplayPic($_SESSION['UserId'], 0);
$loginWebService->uploadProfilePicture($_SESSION['UserId'], $_SESSION['ProfilePicture']);
unset ($_SESSION["githubUser"]);
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$database_connection = new DatabaseConnection();
$conn = $database_connection->getConnection();
$loginWebService = new LoginWebService();
if(isset($_POST['postMessage']))
{
if($_POST['postMessage'] == "")
{
echo " <script>
var txt;
var r = confirm('Posts cannot be empty, Please try again.');
if(r==true || r==false)
{
window.location.href = 'mainpage.php';
}
</script>
";
}
else
{
if(isset($_SESSION['UserId']))
{
$userId = $_SESSION['UserId'];
$uncleanedMessage = clean_input($_POST['postMessage']);
$uncleanedMessage = mysqli_real_escape_string($conn, $uncleanedMessage);
$login = $loginWebService -> writePostToDB($userId, $uncleanedMessage);
echo "<script> window.location.href ='mainpage.php'</script>";
}
}
}
$conn->close();
}
?>
<!DOCTYPE html>
<html>
<title>Gatherly</title>
<head>
<link rel="shortcut icon" type="image/jpg" href="g.jpg">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="script.js"></script>
<script src="mainPage.js"></script>
<script src="pagination.js"></script>
</head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-blue.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
html,body,h1,h2,h3,h4,h5 {font-family: "Open Sans", sans-serif, background-color:#e6ffff}
.material-icons {vertical-align:-14%}
.fa {
font-size: 30px;
cursor: pointer;
user-select: none;
}
.fa:hover {
color: darkblue;
}
div.a {
text-indent: 70px;
border-left: 6px solid red;
background-color: lightgrey;
}
form, table {
display:inline;
margin:0px;
padding:0px;
}
.footer
{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #23b4ff;
color: white;
text-align: center;
}
pre {
height: auto;
max-height: 200px;
overflow: auto;
background-color: #eeeeee;
border-left: 11px solid #ccc;
margin: 1.7em 0 1.7em 0.3em;
word-break: normal !important;
word-wrap: normal !important;
white-space: pre !important;
}
code, samp, kbd {
font-family: "Courier New", Courier, monospace, sans-serif;
text-align: left;
color: #555;
}
pre code {
line-height: 1.6em;
font-size: 11px;
}
/*pre {
padding: 0.1em 0.5em 0.3em 0.7em;
border-left: 11px solid #ccc;
margin: 1.7em 0 1.7em 0.3em;
overflow: auto;
width: 93%;
}*/
/* target IE7 and IE6 */
*:first-child+html pre {
padding-bottom: 2em;
overflow-y: hidden;
overflow: visible;
overflow-x: auto;
}
* html pre {
padding-bottom: 2em;
overflow: visible;
overflow-x: auto;
}
*{
box-sizing:border-box;
}
body{
background-color:#dfeaef;
font-family:Arial;
}
#container{
width:750px;
height:800px;
background:#eff3f7;
margin:0 auto;
font-size:0;
border-radius:5px;
overflow:hidden;
}
main{
width:490px;
height:800px;
display:inline-block;
font-size:15px;
vertical-align:top;
}
h2,h3{
margin:0;
}
.status{
width:8px;
height:8px;
border-radius:50%;
display:inline-block;
margin-right:7px;
}
.green{
background-color:#58b666;
}
.orange{
background-color:#ff725d;
}
.blue{
background-color:#6fbced;
margin-right:0;
margin-left:7px;
}
main header{
height:110px;
padding:30px 20px 30px 40px;
}
main header > *{
display:inline-block;
vertical-align:top;
}
main header img:first-child{
border-radius:50%;
}
main header img:last-child{
width:24px;
margin-top:8px;
}
main header div{
margin-left:10px;
margin-right:145px;
}
main header h2{
font-size:16px;
margin-bottom:5px;
}
main header h3{
font-size:14px;
font-weight:normal;
color:#7e818a;
}
#chat{
padding-left:0;
margin:0;
list-style-type:none;
overflow-y:scroll;
height:535px;
border-top:2px solid #fff;
border-bottom:2px solid #fff;
}
#chat li{
padding:10px 30px;
}
#chat h2,#chat h3{
display:inline-block;
font-size:13px;
font-weight:normal;
}
#chat h3{
color:#bbb;
}
#chat .entete{
margin-bottom:5px;
}
#chat .message{
padding:20px;
color:#fff;
line-height:25px;
max-width:90%;
display:inline-block;
text-align:left;
border-radius:5px;
}
#chat .me{
text-align:right;
}
#chat .you .message{
background-color:#58b666;
}
#chat .me .message{
background-color:#6fbced;
}
#chat .triangle{
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
}
#chat .you .triangle{
border-color: transparent transparent #58b666 transparent;
margin-left:15px;
}
#chat .me .triangle{
border-color: transparent transparent #6fbced transparent;
margin-left:375px;
}
main footer{
height:155px;
padding:20px 30px 10px 20px;
}
main footer textarea{
resize:none;
border:none;
display:block;
width:100%;
height:80px;
border-radius:3px;
padding:20px;
font-size:13px;
margin-bottom:13px;
}
main footer textarea::placeholder{
color:#ddd;
}
main footer img{
height:30px;
cursor:pointer;
}
main footer a{
text-decoration:none;
text-transform:uppercase;
font-weight:bold;
color:#6fbced;
vertical-align:top;
margin-left:333px;
margin-top:5px;
display:inline-block;
}
* {
box-sizing: border-box;
}
#myInput {
background-image: url('/css/searchicon.png');
background-position: 10px 12px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
#myUL {
list-style-type: none;
padding: 0;
margin: 0;
}
#myUL li a {
border: 1px solid #ddd;
margin-top: -1px; /* Prevent double borders */
background-color: #f6f6f6;
padding: 12px;
text-decoration: none;
font-size: 18px;
color: black;
display: block
}
#myUL li a:hover:not(.header) {
background-color: #eee;
}
#welcomeMessage {
position: absolute;
width: 700px;
left: 30%;
margin-top: -5px;
}
.loadMore {
color : #fff;
background: #2196f3;
border-radius: 1.5em;
left: 30%;
padding: 1em;
text-decoration: none;
width: 100%;
}
.loadMoreGroup {
color : #fff;
background: #2196f3;
border-radius: 1.5em;
left: 30%;
padding: 1em;
text-decoration: none;
width: 100%;
}
.dropbtn {
background-color: #3498DB;
color: white;
padding: 8px;
font-size: 16px;
border: none;
}
.dropup {
position: relative;
display: inline-block;
}
.dropup-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 80px;
bottom: 30px;
z-index: 1;
}
.dropup-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropup-content a:hover {background-color: #ccc}
.dropup:hover .dropup-content {
display: block;
}
.dropup:hover .dropbtn {
background-color: #2980B9;
}
</style>
<body class="w3-theme-15", background-color="#e6ffff">
<!-- Navbar -->
<div class="w3-top">
<div class="w3-bar w3-theme-d2 w3-left-align w3-large">
<a class="w3-bar-item w3-button w3-hide-medium w3-hide-large w3-right w3-padding-large w3-hover-white w3-large w3-theme-d2" href="javascript:void(0);" onclick="openNav()"><i class="fa fa-bars"></i></a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-padding-large w3-hover-white"><i class="fa fa-home w3-margin-right"></i>Gatherly</a>
<a href= <?php if(!isset($_SESSION)){session_start(); } echo "profilepage.php?Id=" . $_SESSION['UserId'];?> button class="w3-bar-item w3-button w3-hide-small w3-padding-large w3-hover-white" onclick="openForm()" title="My Account"><i class="fa fa-user"></i>Welcome<?php if(!isset($_SESSION)){session_start(); } echo " " . $_SESSION['FirstName'] . "!";?></a>
<div class="pull-right">
<div id = "welcomeMessage">
</div>
<a href="helppage.html" class="w3-bar-item w3-button w3-hide-small w3-padding w3-hover-white"><i class="fa fa-file w3-margin-right"></i>FAQ's</a>
<form method="POST" action="server/logout.php">
<a href="server/logout.php" class="w3-bar-item w3-button w3-padding-large w3-theme-d3 pull-right" type="submit" class="btn navbar-btn btn-danger" name="logout" id="logout" value="Log Out"><i class="fa fa-sign-out w3-margin-right"></i>Log Out</a>
</form>
</div>
</div>
</div>
</div>
<!-- Page Container -->
<div class="w3-container w3-content" style="max-width:1300px;margin-top:80px">
<!-- The Grid -->
<div class="w3-row">
<!-- Left Column -->
<div class="w3-col m3">
<!-- Accordion -->
<div class="w3-card w3-round">
<div class="w3-white">
<button onclick="myFunction('Demo1')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-user fa-fw w3-margin-right"></i>Profile Picture</button>
<div id="Demo1" class="w3-hide w3-container">
<form action = "upload.php" method="POST" enctype="multipart/form-data">
<label><input type='file' name="image" accept=".png, .jpg, .jpeg"/></label>
<button name = "submit" type="submit">Upload your profile picture</button>
</form>
</br>
<label><center>Or</center></label></br>
<button class="useGravatarButton w3-button w3-block w3-theme-l1 w3-left-align">Use Gravatar</button></br>
<button class="useDefaultButton w3-button w3-block w3-theme-l1 w3-left-align">Use Default</button></br>
<button class="useProfilePicture w3-button w3-block w3-theme-l1 w3-left-align">Use Profile Picture</button></br>
</div>
<button onclick="myFunction('Demo2')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-users fa-fw w3-margin-right"></i> My Groups</button>
<div id="Demo2" class="w3-hide w3-container">
<h3>Groups you belong</h3>
<ul>
<?php
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
include_once "./server/loginService.php";
include_once "./server/loginSQL.php";
if(!isset($_SESSION)){
session_start();
}
$userID = $_SESSION['UserId'];
$MyloginWebService = new LoginWebService();
$userGroupIds = $MyloginWebService -> getUserGroups($userID);
//checks if the user is logged in, if the user is logged in then a user id exists, if not redirect to login page
if (!isset($userID) && !isset($_SESSION['githubUser']))
{
header("Location: index.php");
die();
}
//displaying the groups the user is part of
$count = count($userGroupIds);
$i = 0;
if(!empty($userGroupIds))
{
while($i != $count)
{
$groupName = $MyloginWebService ->getGroupName($userGroupIds[$i]);
$_SESSION['groupIdClicked' . $i] = $userGroupIds[$i];
echo "<form >";
echo "<input type='hidden' id='groupName' name='groupName' value='$userGroupIds[$i]'>";
echo "<button type='submit' name='action' class='w3-button w3-block w3-theme-l1 w3-left-align groupsPage'>" . $groupName . "</button> </br>";
echo "</form>";
$i = $i + 1;
}
}
$allPublicGroups = $MyloginWebService -> getAllPublicGroups();
?>
</ul>
</div>
<button onclick="myFunction('joinAgroup')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-circle-o-notch fa-fw w3-margin-right"></i>Join public groups</button>
<div id = "joinAgroup" class="w3-hide w3-container">
<h3> Enter Group Name</h3>
<form id = 'joinAgroupForum'>
<?php
if(!empty($allPublicGroups))
{
echo "<input type='text' id='myInput' onkeyup='myFunctionTwo()' placeholder='Search for public group names..' title='Type in a name'><button class = 'joinGroupBtn' >Join Group</button><br/>";
echo "<ul id='myUL'>";
foreach($allPublicGroups as $i => $item) {
if($allPublicGroups[$i]['publicGroupStatus'] == 0)
{
echo "<li><a id = 'groupNameDisplay' href='#'>" . $allPublicGroups[$i]['publicGroupName'] . "</a></li>";
}
}
echo "</ul>";
}
else {
echo "<ul id='myUL'>";
echo "<h6 id = 'therearenocomentsLabel' >There a no public groups available. Create one!</h6>";
echo "</ul>";
}
?>
</form>
</div>
<button onclick="myFunction('Findfriend')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-user-circle-o fa-fw w3-margin-right"></i>Search for a user</button>
<div id = "Findfriend" class="w3-hide w3-container">
<h3> Enter User name or email</h3>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Search</span>
<input type="text" name="search_text" id="search_text" placeholder="Search by User Details" class="form-control" />
</div>
</div>
<br />
<div id="result"></div>
</div>
<button onclick="myFunction('ownedGroupsDiv')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-balance-scale fa-fw w3-margin-right"></i>Owned Groups</button>
<div id = "ownedGroupsDiv" class="w3-hide w3-container">
<?php
if(!isset($_SESSION))
{
session_start();
}
$userId = $_SESSION['UserId'];
$loggedInUserType = $_SESSION['userType'];
if($loggedInUserType == "1")
{
$groupsOwned = $MyloginWebService-> getAllGroups();
echo "<br/>";
if($groupsOwned == "noGroupsOwned")
{
echo "<h6> You do not own any groups. Please create your own groups to invite your friends.";
}
else
{
$x = 0;
$y = 0;
$z = 0;
foreach($groupsOwned as $i => $item) {
if($groupsOwned[$i]['ownedStatus'] == 0)
{
echo "<form method='post' action='ownedGroups.php'>";
echo "<input type = 'hidden' id='" . $z . "' name= 'ownerOfGroup' value = '" . $userId . "'</input>";
echo "<input type='hidden' id='" . $x . "' name='groupNameOwned' value='" . $groupsOwned[$i]['ownedGroupName'] . "'>";
echo "<input type='hidden' id='" . $y . "' name='groupTypeOwned' value='" . $groupsOwned[$i]['ownedType'] . "'>";
echo "<input type='hidden' id='" . $groupsOwned[$i]['ownedGroupName'] . "' name='groupIdOwned' value='" . $groupsOwned[$i]['ownedGroupId'] . "'>";
echo "<button type='submit' name='action' class='w3-button w3-block w3-theme-l1 w3-left-align'>" . $groupsOwned[$i]['ownedGroupName']. "</button> </br>";
echo "</form>";
$x = $x + 1;
$y = $y + 1;
$z = $z + 1;
}
}
}
}
else
{
$groupsOwned = $MyloginWebService->getOwnedGroups($userId );
// var_dump($groupsOwned);
echo "<br/>";
if($groupsOwned == "noGroupsOwned")
{
echo "<h6> You do not own any groups. Please create your own groups to invite your friends.";
}
else
{
$x = 0;
$y = 0;
$z = 0;
foreach($groupsOwned as $i => $item) {
echo "<form method='post' action='ownedGroups.php'>";
echo "<input type = 'hidden' id='" . $z . "' name= 'ownerOfGroup' value = '" . $userId . "'</input>";
echo "<input type='hidden' id='" . $x . "' name='groupNameOwned' value='" . $groupsOwned[$i]['ownedGroupName'] . "'>";
echo "<input type='hidden' id='" . $y . "' name='groupTypeOwned' value='" . $groupsOwned[$i]['ownedType'] . "'>";
echo "<input type='hidden' id='" . $groupsOwned[$i]['ownedGroupName'] . "' name='groupIdOwned' value='" . $groupsOwned[$i]['ownedGroupId'] . "'>";
echo "<button type='submit' name='action' class='w3-button w3-block w3-theme-l1 w3-left-align'>" . $groupsOwned[$i]['ownedGroupName']. "</button> </br>";
echo "</form>";
$x = $x + 1;
$y = $y + 1;
$z = $z + 1;
}
}
}
?>
</div>
<button onclick="myFunction('Demo3')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-circle-o-notch fa-fw w3-margin-right"></i>Create a group</button>
<div id="Demo3" class="w3-hide w3-container">
<div id="createChannel" role="dialog">
<div class="modal-dialog modal-lg">
<div style="max-width: 275px;" class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Create a new group</h4>
<h6>Share a message, picture, story anything you like with your group.</h6>
</div>
<div class="modal-body newChannelDetails">
<form role="form" id="createChannelForm">
<div class="row">
<div class="form-group">
<div class="uniqueChannel"></div>
<form>
<input type="text" id="groupNameToBeCreated" name="Groupname" placeholder="Group Name"><br>
</form>
</div>
</div>
<div class="row">
<span class="type">Group style</span>
<div id = 'publicPrivateDiv' class="form-group">
<label class="radio-inline">
<input type="radio" id = 'privateGroup' name="type" value="private" checked>Private
</label>
<label class="radio-inline">
<input type="radio" id = 'publicGroup' name="type" value="public">Public
</label>
</div>
</div>
<div class="modal-footer">
<!-- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> -->
<button type="button" class="btn btn-default createChannelBtn" data-dismiss="modal">Create Group</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<button onclick="myFunction('Demo4')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-plus fa-fw w3-margin-right"></i>My Invitations</button>
<div id="Demo4"class="w3-hide w3-container">
<?php
//1.query for all the user invites the user has gotten
$loginWebService = new LoginWebService();
//$userGroupIds = $MyloginWebService -> getUserGroups($userID);
$groupIdInvitations = $loginWebService -> getListOfInvitesbyUserId($userId);
if(!empty($groupIdInvitations))
{
foreach($groupIdInvitations as $x => $item) {
echo "<div style=' border: 1px solid; padding: 10px; box-shadow: 5px 10px #888888; ' class='w3-container'>";
echo "<center><p>Group Invitation request</p></center>";
echo "<center><b><p>Group Name: " . $loginWebService->getGroupName($groupIdInvitations[$x]['groupIdInvitation']) . "</p></b></center>";
echo " <div class='w3-row w3-opacity'>";
echo "<div class='w3-half'>";
echo "<form id = '" . $groupIdInvitations[$x]['inviteId'] . "' >";
echo "<input id='groupIdInvitation' type='hidden' value = '" . $groupIdInvitations[$x]['groupIdInvitation'] . "' </input>";
echo "<button type = 'submit' class='w3-button w3-block w3-green w3-section acceptButton' title='Accept'><i class='fa fa-check'></i></button>";
echo "</form>";
echo "</div>";
echo "<div class='w3-half'>";
echo "<form id = '" . $groupIdInvitations[$x]['inviteId'] . "' <br/>";
echo "<input id = 'groupIdInvitation' type='hidden' value = '" . $groupIdInvitations[$x]['groupIdInvitation'] . "' </input>";
echo "<button type = 'submit' class='w3-button w3-block w3-red w3-section declineButton' title='Decline'><i class='fa fa-remove'></i></button>";
echo "</form>";
echo "</div>";
echo "</div>";
echo "</div>";
}
}else
{
echo "<h6> You do not have any invitations. </h6>";
}
?>
</div>
<button onclick="myFunction('Demo6')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-paper-plane" aria-hidden="true" w3-margin-right"></i> Direct Message</button>
<div id="Demo6"class="w3-hide w3-container">
<?php
$loginWebService = new LoginWebService();
$usersToDm = json_decode($loginWebService->getUserInfoDM(), true);
//echo $usersToDm['userInfo'][0]['FirstName'];
if(!empty($usersToDm))
{
foreach($usersToDm as $i => $item) {
if($usersToDm[$i]['ID'] != $_SESSION['UserId'])
{
echo "</br>";
echo "<form method='POST' action='directMessage.php'>";
echo "<input name='userIdTosendTo' type = 'hidden' value = '" . $usersToDm[$i]['ID'] . "'/>";
echo "<button class = 'w3-button w3-block w3-theme-l1 w3-left-align'>" . $usersToDm[$i]['FirstName'] . " " . $usersToDm[$i]['LastName'] . "</button>";
echo "</form>";
}
}
echo "</br>";
}
?>
</div>
</div>
<div id = 'adminPrivlages'>
<button onclick="myFunction('Demo5')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-picture-o fa-fw w3-margin-right adminModifyUsersButton"></i>Modify Group Membership</button>
<div style="display: none;" id="Demo5" class="w3-hide w3-container adminModifyUsers">
</div>
<script type="text/javascript">
$.ajax({
url : 'server/controller.php',
type : 'POST',
async: false,
data : {
'getUserType' : 'getUserType'
},
success : function(data) {
UserType = parseInt(data);
if(UserType == 0)
{
$('#adminPrivlages').remove();
}
}
});
</script>
</div>
</div>
<br>
<!-- End Left Column -->
</div>
<!-- Middle Column -->
<div class="w3-col m7">
<div id = 'groupPostForumOne'>
</div>
<div id = 'pagination_data'>
<div class="allPostsClass" id = "allPosts">
</div>
</div>
<div class = "groupPostsClass" id = "groupPosts">
</div>
<button style="display: none;" class ='loadMore'>Load More </button>
<!-- <button class ='loadMoreGroup'>Load More </button> -->
<input type="hidden" id='groupIdLoad' value="3">
<div class="w3-col m2">
<div id="Chat" class="w3-hide w3-container">
<main>
<header>
</header>
<!-- </li> -->
<!-- </ul> -->
<footer>
<textarea placeholder="Type your message"></textarea>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1940306/ico_picture.png" alt="">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1940306/ico_file.png" alt="">
<a href="#">Send</a>
</footer>
</main>
</div>
</div>
</div>
<br>
<!-- Footer -->
<!-- <div class="footer">
<p>©fordFanatics</p>
</div> -->
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
$("#output").hide();
var property = document.getElementById("file").files[0];
var image_name = property.name;
var image_extension = image_name.split('.').pop().toLowerCase();
if(image_extension == "jpg" || image_extension == "png" || image_extension == "gif"
|| image_extension == "jpeg")
{
$("#output").show();
output.src = URL.createObjectURL(event.target.files[0]);
}
else
{
$("#output").hide();
}
};
function myFunction(id) {
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
x.previousElementSibling.className += " w3-theme-d1";
} else {
x.className = x.className.replace("w3-show", "");
x.previousElementSibling.className =
x.previousElementSibling.className.replace(" w3-theme-d1", "");
}
}
function myFunctionTwo() {
var input, filter, ul, li, a, i;
input = document.getElementById("myInput");