forked from GibbonEdu/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·4951 lines (4504 loc) · 263 KB
/
functions.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
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once dirname(__FILE__).'/gibbon.php';
function getIPAddress() {
$return = false;
if (getenv('HTTP_CLIENT_IP'))
$return = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$return = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$return = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$return = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$return = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$return = getenv('REMOTE_ADDR');
return $return;
}
//Convert an HTML email body into a plain text email body
function emailBodyConvert($body)
{
$return = $body;
$return = preg_replace('#<br\s*/?>#i', "\n", $return);
$return = str_replace('</p>', "\n\n", $return);
$return = str_replace('</div>', "\n\n", $return);
$return = preg_replace("#\<a.+href\=[\"|\'](.+)[\"|\'].*\>.*\<\/a\>#U", '$1', $return);
$return = strip_tags($return, '<a>');
return $return ;
}
/**
* @deprecated Deprecated since version v13, to be removed in v14.
*/
function setStringReplacementList($connection2, $guid)
{
@trigger_error(sprintf('The %s() method is deprecated since version v13 and will be removed in v14. Use $gibbon->locale->setStringReplacementList() instead.', __METHOD__), E_USER_DEPRECATED);
global $gibbon, $pdo; // For backwards compatibilty
$gibbon->locale->setStringReplacementList($pdo);
}
//Custom translation function to allow custom string replacement
function __($arg1, $arg2 = null, $arg3 = null)
{
global $gibbon, $guid; // For backwards compatibilty
// Handle __($guid, $text) and __($guid, $text, $domain)
if ($arg1 == $guid) {
$text = $arg2;
$domain = $arg3;
} else {
// Handle __($text) and __($text, $domain)
$text = $arg1;
$domain = $arg2;
}
// Cancel out early for empty translations
if (empty($text)) {
return $text;
}
return $gibbon->locale->translate($text, $domain);
}
//$valueMode can be "value" or "id" according to what goes into option's value field
//$selectMode can be "value" or "id" according to what is used to preselect an option
//$honourDefault can TRUE or FALSE, and determines whether or not the default grade is selected
function renderGradeScaleSelect($connection2, $guid, $gibbonScaleID, $fieldName, $valueMode, $honourDefault = true, $width = 50, $selectedMode = 'value', $selectedValue = null)
{
$return = false;
$return .= "<select name='$fieldName' id='$fieldName' style='width: ".$width."px'>";
try {
$dataSelect = array('gibbonScaleID' => $gibbonScaleID);
$sqlSelect = 'SELECT * FROM gibbonScaleGrade WHERE gibbonScaleID=:gibbonScaleID ORDER BY sequenceNumber';
$resultSelect = $connection2->prepare($sqlSelect);
$resultSelect->execute($dataSelect);
} catch (PDOException $e) {
}
$return .= "<option value=''></option>";
$sequence = '';
$descriptor = '';
while ($rowSelect = $resultSelect->fetch()) {
$selected = '';
if ($honourDefault and is_null($selectedValue)) { //Select entry based on scale default
if ($rowSelect['isDefault'] == 'Y') {
$selected = 'selected';
}
} elseif ($selectedMode == 'value') { //Select entry based on value passed
if ($rowSelect['value'] == $selectedValue) {
$selected = 'selected';
}
} elseif ($selectedMode == 'id') { //Select entry based on id passed
if ($rowSelect['gibbonScaleGradeID'] == $selectedValue) {
$selected = 'selected';
}
}
if ($valueMode == 'value') {
$return .= "<option $selected value='".htmlPrep($rowSelect['value'])."'>".htmlPrep(__($guid, $rowSelect['value'])).'</option>';
} else {
$return .= "<option $selected value='".htmlPrep($rowSelect['gibbonScaleGradeID'])."'>".htmlPrep(__($guid, $rowSelect['value'])).'</option>';
}
}
$return .= '</select>';
return $return;
}
//Takes the provided string, and uses a tinymce style valid_elements string to strip out unwanted tags
//Not complete, as it does not strip out unwanted options, just whole tags.
function tinymceStyleStripTags($string, $connection2)
{
$return = '';
$comment = html_entity_decode($string);
$allowableTags = getSettingByScope($connection2, 'System', 'allowableHTML');
$allowableTags = preg_replace("/\[([^\[\]]|(?0))*]/", '', $allowableTags);
$allowableTagTokens = explode(',', $allowableTags);
$allowableTags = '';
foreach ($allowableTagTokens as $allowableTagToken) {
$allowableTags .= '<'.$allowableTagToken.'>';
}
$allowableTags = html_entity_decode($allowableTags);
$comment = strip_tags($comment, $allowableTags);
return $comment;
}
function getNotificationTray($connection2, $guid, $cacheLoad)
{
$return = false;
$return .= "<div style='width: 250px; float: right'>";
if (isset($_SESSION[$guid]['username']) != false) {
//MESSAGE WALL!
if (isActionAccessible($guid, $connection2, '/modules/Messenger/messageWall_view.php')) {
$return .= "<div id='messageWall' style='display: inline; float: right'>";
include './modules/Messenger/moduleFunctions.php';
$addReturn = null;
if (isset($_GET['addReturn'])) {
$addReturn = $_GET['addReturn'];
}
$updateReturn = null;
if (isset($_GET['updateReturn'])) {
$updateReturn = $_GET['updateReturn'];
}
$deleteReturn = null;
if (isset($_GET['deleteReturn'])) {
$deleteReturn = $_GET['deleteReturn'];
}
if ($cacheLoad or (@$_GET['q'] == '/modules/Messenger/messenger_post.php' and $addReturn == 'success0') or (@$_GET['q'] == '/modules/Messenger/messenger_postQuickWall.php' and $addReturn == 'success0') or (@$_GET['q'] == '/modules/Messenger/messenger_manage_edit.php' and $updateReturn == 'success0') or (@$_GET['q'] == '/modules/Messenger/messenger_manage.php' and $deleteReturn == 'success0')) {
$messages = getMessages($guid, $connection2, 'result');
$messages = unserialize($messages);
try {
$resultPosts = $connection2->prepare($messages[1]);
$resultPosts->execute($messages[0]);
} catch (PDOException $e) {
}
$_SESSION[$guid]['messageWallCount'] = 0;
if ($resultPosts->rowCount() > 0) {
$count = 0;
$output = array();
$last = '';
while ($rowPosts = $resultPosts->fetch()) {
if ($last == $rowPosts['gibbonMessengerID']) {
$output[($count - 1)]['source'] = $output[($count - 1)]['source'].'<br/>'.$rowPosts['source'];
} else {
$output[$_SESSION[$guid]['messageWallCount']]['photo'] = $rowPosts['image_240'];
$output[$_SESSION[$guid]['messageWallCount']]['subject'] = $rowPosts['subject'];
$output[$_SESSION[$guid]['messageWallCount']]['details'] = $rowPosts['body'];
$output[$_SESSION[$guid]['messageWallCount']]['author'] = formatName($rowPosts['title'], $rowPosts['preferredName'], $rowPosts['surname'], $rowPosts['category']);
$output[$_SESSION[$guid]['messageWallCount']]['source'] = $rowPosts['source'];
$output[$_SESSION[$guid]['messageWallCount']]['gibbonMessengerID'] = $rowPosts['gibbonMessengerID'];
++$_SESSION[$guid]['messageWallCount'];
$last = $rowPosts['gibbonMessengerID'];
++$count;
}
}
$_SESSION[$guid]['messageWallOutput'] = $output;
}
}
$URL = $_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/Messenger/messageWall_view.php';
if (isset($_SESSION[$guid]['messageWallCount']) == false) {
$return .= " . <a class='inactive' title='".__($guid, 'Message Wall')."' href='#'>0 x <img class='minorLinkIcon' style='margin-left: 4px; opacity: 0.2; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/messageWall.png'></a>";
} else {
if ($_SESSION[$guid]['messageWallCount'] < 1) {
$return .= " . <a class='inactive' title='".__($guid, 'Message Wall')."' href='#'>0 x <img class='minorLinkIcon' style='margin-left: 4px; opacity: 0.2; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/messageWall.png'></a>";
} else {
$return .= " . <a title='".__($guid, 'Message Wall')."' href='$URL'>".$_SESSION[$guid]['messageWallCount']." x <img class='minorLinkIcon' style='margin-left: 4px; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/messageWall.png'></a>";
if ($_SESSION[$guid]['pageLoads'] == 0 and ($_SESSION[$guid]['messengerLastBubble'] == null or $_SESSION[$guid]['messengerLastBubble'] < date('Y-m-d'))) {
$messageBubbleBGColor = getSettingByScope($connection2, 'Messenger', 'messageBubbleBGColor');
$bubbleBG = '';
if ($messageBubbleBGColor != '') {
$bubbleBG = '; background-color: rgba('.$messageBubbleBGColor.')!important';
$return .= '<style>';
$return .= ".ui-tooltip, .arrow:after { $bubbleBG }";
$return .= '</style>';
}
$messageBubbleWidthType = getSettingByScope($connection2, 'Messenger', 'messageBubbleWidthType');
$bubbleWidth = 300;
$bubbleLeft = 755;
if ($messageBubbleWidthType == 'Wide') {
$bubbleWidth = 700;
$bubbleLeft = 415;
}
$return .= "<div id='messageBubbleArrow' style=\"left: 1058px; top: 162px; z-index: 9999\" class='arrow top'></div>";
$return .= "<div id='messageBubble' style=\"left: ".$bubbleLeft.'px; top: 178px; width: '.$bubbleWidth.'px; min-width: '.$bubbleWidth.'px; max-width: '.$bubbleWidth.'px; min-height: 100px; text-align: center; padding-bottom: 10px" class="ui-tooltip ui-widget ui-corner-all ui-widget-content" role="tooltip">';
$return .= '<div class="ui-tooltip-content">';
$return .= "<div style='font-weight: bold; font-style: italic; font-size: 120%; margin-top: 10px; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px dotted rgba(255,255,255,0.5); display: block'>".__($guid, 'New Messages').'</div>';
$test = count($output);
if ($test > 3) {
$test = 3;
}
for ($i = 0; $i < $test; ++$i) {
$return .= "<span style='font-size: 120%; font-weight: bold'>";
if (strlen($output[$i]['subject']) <= 30) {
$return .= $output[$i]['subject'];
} else {
$return .= substr($output[$i]['subject'], 0, 30).'...';
}
$return .= '</span><br/>';
$return .= '<i>'.$output[$i]['author'].'</i><br/><br/>';
}
if (count($output) > 3) {
$return .= '<i>'.__($guid, 'Plus more').'...</i>';
}
$return .= '</div>';
$return .= "<div style='text-align: right; margin-top: 20px; color: #666'>";
$return .= "<a onclick='$(\"#messageBubble\").hide(\"fade\", {}, 1); $(\"#messageBubbleArrow\").hide(\"fade\", {}, 1)' style='text-decoration: none; color: #666' href='".$URL."'>".__($guid, 'Read All').'</a> . ';
$return .= "<a style='text-decoration: none; color: #666' onclick='$(\"#messageBubble\").hide(\"fade\", {}, 1000); $(\"#messageBubbleArrow\").hide(\"fade\", {}, 1000)' href='#'>".__($guid, 'Dismiss').'</a>';
$return .= '</div>';
$return .= '</div>';
$messageBubbleAutoHide = getSettingByScope($connection2, 'Messenger', 'messageBubbleAutoHide');
if ($messageBubbleAutoHide != 'N') {
$return .= '<script type="text/javascript">';
$return .= '$(function() {';
$return .= 'setTimeout(function() {';
$return .= "$(\"#messageBubble\").hide('fade', {}, 3000)";
$return .= '}, 10000);';
$return .= '});';
$return .= '$(function() {';
$return .= 'setTimeout(function() {';
$return .= "$(\"#messageBubbleArrow\").hide('fade', {}, 3000)";
$return .= '}, 10000);';
$return .= '});';
$return .= '</script>';
}
try {
$data = array('messengerLastBubble' => date('Y-m-d'), 'gibbonPersonID' => $_SESSION[$guid]['gibbonPersonID']);
$sql = 'UPDATE gibbonPerson SET messengerLastBubble=:messengerLastBubble WHERE gibbonPersonID=:gibbonPersonID';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
}
}
}
}
$return .= "</div>";
}
//GET AND SHOW LIKES
$return .= "<div id='likes' style='display: inline; float: right'>";
//Get likes
$getLikes = false;
if ($cacheLoad) {
$getLikes = true;
} elseif (isset($_GET['q'])) {
if ($_GET['q'] == 'likes.php') {
$getLikes = true;
}
}
if ($getLikes) {
$_SESSION[$guid]['likesCount'] = countLikesByRecipient($connection2, $_SESSION[$guid]['gibbonPersonID'], 'count', $_SESSION[$guid]['gibbonSchoolYearID']);
}
//Show likes
if (isset($_SESSION[$guid]['likesCount'])) {
if ($_SESSION[$guid]['likesCount'] > 0) {
$return .= " . <a title='".__($guid, 'Likes')."' href='".$_SESSION[$guid]['absoluteURL']."/index.php?q=likes.php'>".$_SESSION[$guid]['likesCount']." x <img class='minorLinkIcon' style='margin-left: 2px; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/like_large.png'></a>";
} else {
$return .= " . <a class='inactive' title='".__($guid, 'Likes')."' href='#'>".$_SESSION[$guid]['likesCount']." x <img class='minorLinkIcon' style='margin-left: 2px; opacity: 0.2; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/like_large.png'></a>";
}
}
$return .= "</div>";
//GET & SHOW NOTIFICATIONS
try {
$dataNotifications = array('gibbonPersonID' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonPersonID2' => $_SESSION[$guid]['gibbonPersonID']);
$sqlNotifications = "(SELECT gibbonNotification.*, gibbonModule.name AS source FROM gibbonNotification JOIN gibbonModule ON (gibbonNotification.gibbonModuleID=gibbonModule.gibbonModuleID) WHERE gibbonPersonID=:gibbonPersonID AND status='New')
UNION
(SELECT gibbonNotification.*, 'System' AS source FROM gibbonNotification WHERE gibbonModuleID IS NULL AND gibbonPersonID=:gibbonPersonID2 AND status='New')
ORDER BY timestamp DESC, source, text";
$resultNotifications = $connection2->prepare($sqlNotifications);
$resultNotifications->execute($dataNotifications);
} catch (PDOException $e) { }
//Refresh notifications every 10 seconds for staff, 120 seconds for everyone else
$interval = 120000;
if ($_SESSION[$guid]['gibbonRoleIDCurrentCategory'] == 'Staff') {
$interval = 10000;
}
$return .= '<script type="text/javascript">
$(document).ready(function(){
setInterval(function() {
$("#notifications").load("index_notification_ajax.php");
}, '.$interval.');
});
</script>';
$return .= "<div id='notifications' style='display: inline; float: right'>";
//CHECK FOR SYSTEM ALARM
if (isset($_SESSION[$guid]['gibbonRoleIDCurrentCategory'])) {
if ($_SESSION[$guid]['gibbonRoleIDCurrentCategory'] == 'Staff') {
$alarm = getSettingByScope($connection2, 'System', 'alarm');
if ($alarm == 'General' or $alarm == 'Lockdown' or $alarm == 'Custom') {
$type = 'general';
if ($alarm == 'Lockdown') {
$type = 'lockdown';
} elseif ($alarm == 'Custom') {
$type = 'custom';
}
$return .= "<script>
if ($('div#TB_window').is(':visible')===false) {
var url = '".$_SESSION[$guid]['absoluteURL'].'/index_notification_ajax_alarm.php?type='.$type."&KeepThis=true&TB_iframe=true&width=1000&height=500';
$(document).ready(function() {
tb_show('', url);
$('div#TB_window').addClass('alarm') ;
}) ;
}
</script>";
}
}
}
if ($resultNotifications->rowCount() > 0) {
$return .= "<a title='".__($guid, 'Notifications')."' href='".$_SESSION[$guid]['absoluteURL']."/index.php?q=notifications.php'>".$resultNotifications->rowCount().' x '."<img class='minorLinkIcon' style='margin-left: 2px; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/notifications.png'></a>";
} else {
$return .= "<a class='inactive' title='".__($guid, 'Notifications')."' href='#'>0 x <img class='minorLinkIcon' style='margin-left: 2px; opacity: 0.2; vertical-align: -75%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/notifications.png'></a>";
}
$return .= '</div>';
}
$return .= "</div>";
return $return;
}
function getMinorLinks($connection2, $guid, $cacheLoad)
{
$return = false;
if (isset($_SESSION[$guid]['username']) == false) {
if ($_SESSION[$guid]['webLink'] != '') {
$return .= __($guid, 'Return to')." <a style='margin-right: 12px' target='_blank' href='".$_SESSION[$guid]['webLink']."'>".$_SESSION[$guid]['organisationNameShort'].' '.__($guid, 'Website').'</a>';
}
} else {
$name = $_SESSION[$guid]['preferredName'].' '.$_SESSION[$guid]['surname'];
if (isset($_SESSION[$guid]['gibbonRoleIDCurrentCategory'])) {
if ($_SESSION[$guid]['gibbonRoleIDCurrentCategory'] == 'Student') {
$highestAction = getHighestGroupedAction($guid, '/modules/Students/student_view_details.php', $connection2);
if ($highestAction == 'View Student Profile_brief') {
$name = "<a href='".$_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/Students/student_view_details.php&gibbonPersonID='.$_SESSION[$guid]['gibbonPersonID']."'>".$name.'</a>';
}
}
}
$return .= $name.' . ';
$return .= "<a href='./logout.php'>".__($guid, 'Logout')."</a> . <a href='./index.php?q=preferences.php'>".__($guid, 'Preferences').'</a>';
if ($_SESSION[$guid]['emailLink'] != '') {
$return .= " . <a target='_blank' href='".$_SESSION[$guid]['emailLink']."'>".__($guid, 'Email').'</a>';
}
if ($_SESSION[$guid]['webLink'] != '') {
$return .= " . <a target='_blank' href='".$_SESSION[$guid]['webLink']."'>".$_SESSION[$guid]['organisationNameShort'].' '.__($guid, 'Website').'</a>';
}
if ($_SESSION[$guid]['website'] != '') {
$return .= " . <a target='_blank' href='".$_SESSION[$guid]['website']."'>".__($guid, 'My Website').'</a>';
}
//Check for house logo (needed to get bubble, below, in right spot)
if (isset($_SESSION[$guid]['gibbonHouseIDLogo']) and isset($_SESSION[$guid]['gibbonHouseIDName'])) {
if ($_SESSION[$guid]['gibbonHouseIDLogo'] != '') {
$return .= " . <img class='minorLinkIconLarge' title='".$_SESSION[$guid]['gibbonHouseIDName']."' style='vertical-align: -75%; margin-left: 4px' src='".$_SESSION[$guid]['absoluteURL'].'/'.$_SESSION[$guid]['gibbonHouseIDLogo']."'/>";
}
}
}
return $return;
}
//Gets the contents of the staff dashboard for the member of staff specified
function getStaffDashboardContents($connection2, $guid, $gibbonPersonID)
{
$return = false;
//GET PLANNER
$planner = false;
$date = date('Y-m-d');
if (isSchoolOpen($guid, $date, $connection2) == true and isActionAccessible($guid, $connection2, '/modules/Planner/planner.php') and $_SESSION[$guid]['username'] != '') {
try {
$data = array('gibbonSchoolYearID' => $_SESSION[$guid]['gibbonSchoolYearID'], 'date' => $date, 'gibbonPersonID' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonSchoolYearID2' => $_SESSION[$guid]['gibbonSchoolYearID'], 'date2' => $date, 'gibbonPersonID2' => $_SESSION[$guid]['gibbonPersonID']);
$sql = "(SELECT gibbonCourseClass.gibbonCourseClassID, gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonHookID, gibbonPlannerEntry.gibbonCourseClassID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkSubmission, homeworkCrowdAssess, role, date, summary, gibbonPlannerEntryStudentHomework.homeworkDueDateTime AS myHomeworkDueDateTime FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourseClassPerson ON (gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) LEFT JOIN gibbonPlannerEntryStudentHomework ON (gibbonPlannerEntryStudentHomework.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID AND gibbonPlannerEntryStudentHomework.gibbonPersonID=gibbonCourseClassPerson.gibbonPersonID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND date=:date AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND NOT role='Student - Left' AND NOT role='Teacher - Left') UNION (SELECT gibbonCourseClass.gibbonCourseClassID, gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonHookID, gibbonPlannerEntry.gibbonCourseClassID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkSubmission, homeworkCrowdAssess, role, date, summary, NULL AS myHomeworkDueDateTime FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonPlannerEntryGuest ON (gibbonPlannerEntryGuest.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID2 AND date=:date2 AND gibbonPlannerEntryGuest.gibbonPersonID=:gibbonPersonID2) ORDER BY date, timeStart, course, class";
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$planner .= "<div class='error'>".$e->getMessage().'</div>';
}
$planner .= '<h2>';
$planner .= __($guid, "Today's Lessons");
$planner .= '</h2>';
if ($result->rowCount() < 1) {
$planner .= "<div class='warning'>";
$planner .= __($guid, 'There are no records to display.');
$planner .= '</div>';
} else {
$planner .= "<div class='linkTop'>";
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL']."/index.php?q=/modules/Planner/planner.php'>".__($guid, 'View Planner').'</a>';
$planner .= '</div>';
$planner .= "<table cellspacing='0' style='width: 100%'>";
$planner .= "<tr class='head'>";
$planner .= '<th>';
$planner .= __($guid, 'Class').'<br/>';
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Lesson').'</br>';
$planner .= "<span style='font-size: 85%; font-style: italic'>".__($guid, 'Unit').'</span>';
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Homework');
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Summary');
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Like');
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Action');
$planner .= '</th>';
$planner .= '</tr>';
$count = 0;
$rowNum = 'odd';
while ($row = $result->fetch()) {
if (!($row['role'] == 'Student' and $row['viewableStudents'] == 'N')) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count;
//Highlight class in progress
if ((date('H:i:s') > $row['timeStart']) and (date('H:i:s') < $row['timeEnd']) and ($date) == date('Y-m-d')) {
$rowNum = 'current';
}
//COLOR ROW BY STATUS!
$planner .= "<tr class=$rowNum>";
$planner .= '<td>';
$planner .= $row['course'].'.'.$row['class'].'<br/>';
$planner .= "<span style='font-style: italic; font-size: 75%'>".substr($row['timeStart'], 0, 5).'-'.substr($row['timeEnd'], 0, 5).'</span>';
$planner .= '</td>';
$planner .= '<td>';
$planner .= '<b>'.$row['name'].'</b><br/>';
$planner .= "<div style='font-size: 85%; font-style: italic'>";
$unit = getUnit($connection2, $row['gibbonUnitID'], $row['gibbonHookID'], $row['gibbonCourseClassID']);
if (isset($unit[0])) {
$planner .= $unit[0];
if ($unit[1] != '') {
$planner .= '<br/><i>'.$unit[1].' '.__($guid, 'Unit').'</i>';
}
}
$planner .= '</div>';
$planner .= '</td>';
$planner .= '<td>';
if ($row['homework'] == 'N' and $row['myHomeworkDueDateTime'] == '') {
$planner .= __($guid, 'No');
} else {
if ($row['homework'] == 'Y') {
$planner .= __($guid, 'Yes').': '.__($guid, 'Teacher Recorded').'<br/>';
if ($row['homeworkSubmission'] == 'Y') {
$planner .= "<span style='font-size: 85%; font-style: italic'>+".__($guid, 'Submission').'</span><br/>';
if ($row['homeworkCrowdAssess'] == 'Y') {
$planner .= "<span style='font-size: 85%; font-style: italic'>+".__($guid, 'Crowd Assessment').'</span><br/>';
}
}
}
if ($row['myHomeworkDueDateTime'] != '') {
$planner .= __($guid, 'Yes').': '.__($guid, 'Student Recorded').'</br>';
}
}
$planner .= '</td>';
$planner .= '<td id="wordWrap">';
$planner .= $row['summary'];
$planner .= '</td>';
$planner .= '<td>';
if ($row['role'] == 'Teacher') {
$planner .= countLikesByContext($connection2, 'Planner', 'gibbonPlannerEntryID', $row['gibbonPlannerEntryID']);
} else {
$likesGiven = countLikesByContextAndGiver($connection2, 'Planner', 'gibbonPlannerEntryID', $row['gibbonPlannerEntryID'], $_SESSION[$guid]['gibbonPersonID']);
if ($likesGiven != 1) {
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/modules/Planner/plannerProcess.php?gibbonPlannerEntryID='.$row['gibbonPlannerEntryID'].'&address=/modules/Planner/planner.php&viewBy=Class&gibbonCourseClassID='.$row['gibbonCourseClassID']."&date=&returnToIndex=Y'><img src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/like_off.png'></a>";
} else {
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/modules/Planner/plannerProcess.php?gibbonPlannerEntryID='.$row['gibbonPlannerEntryID'].'&address=/modules/Planner/planner.php&viewBy=Class&gibbonCourseClassID='.$row['gibbonCourseClassID']."&date=&returnToIndex=Y'><img src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/like_on.png'></a>";
}
}
$planner .= '</td>';
$planner .= '<td>';
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/Planner/planner_view_full.php&viewBy=class&gibbonCourseClassID='.$row['gibbonCourseClassID'].'&gibbonPlannerEntryID='.$row['gibbonPlannerEntryID']."'><img title='".__($guid, 'View')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/plus.png'/></a>";
$planner .= '</td>';
$planner .= '</tr>';
}
}
$planner .= '</table>';
}
}
//GET TIMETABLE
$timetable = false;
if (isActionAccessible($guid, $connection2, '/modules/Timetable/tt.php') and $_SESSION[$guid]['username'] != '' and getRoleCategory($_SESSION[$guid]['gibbonRoleIDCurrent'], $connection2) == 'Staff') {
?>
<script type="text/javascript">
$(document).ready(function(){
$("#tt").load("<?php echo $_SESSION[$guid]['absoluteURL'] ?>/index_tt_ajax.php",{"gibbonTTID": "<?php echo @$_GET['gibbonTTID'] ?>", "ttDate": "<?php echo @$_POST['ttDate'] ?>", "fromTT": "<?php echo @$_POST['fromTT'] ?>", "personalCalendar": "<?php echo @$_POST['personalCalendar'] ?>", "schoolCalendar": "<?php echo @$_POST['schoolCalendar'] ?>", "spaceBookingCalendar": "<?php echo @$_POST['spaceBookingCalendar'] ?>"});
});
</script>
<?php
$timetable .= '<h2>'.__($guid, 'My Timetable').'</h2>';
$timetable .= "<div id='tt' name='tt' style='width: 100%; min-height: 40px; text-align: center'>";
$timetable .= "<img style='margin: 10px 0 5px 0' src='".$_SESSION[$guid]['absoluteURL']."/themes/Default/img/loading.gif' alt='".__($guid, 'Loading')."' onclick='return false;' /><br/><p style='text-align: center'>".__($guid, 'Loading').'</p>';
$timetable .= '</div>';
}
//GET ROLL GROUPS
$rollGroups = array();
$rollGroupCount = 0;
$count = 0;
try {
$dataRollGroups = array('gibbonPersonIDTutor' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonPersonIDTutor2' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonPersonIDTutor3' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonSchoolYearID' => $_SESSION[$guid]['gibbonSchoolYearID']);
$sqlRollGroups = 'SELECT * FROM gibbonRollGroup WHERE (gibbonPersonIDTutor=:gibbonPersonIDTutor OR gibbonPersonIDTutor2=:gibbonPersonIDTutor2 OR gibbonPersonIDTutor3=:gibbonPersonIDTutor3) AND gibbonSchoolYearID=:gibbonSchoolYearID';
$resultRollGroups = $connection2->prepare($sqlRollGroups);
$resultRollGroups->execute($dataRollGroups);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
while ($rowRollGroups = $resultRollGroups->fetch()) {
$rollGroups[$count][0] = $rowRollGroups['gibbonRollGroupID'];
$rollGroups[$count][1] = $rowRollGroups['nameShort'];
//Roll group table
$rollGroups[$count][2] = "<div class='linkTop' style='margin-top: 0px'>";
if ($rowRollGroups['attendance'] == 'Y') {
$rollGroups[$count][2] .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/Attendance/attendance_take_byRollGroup.php&gibbonRollGroupID='.$rowRollGroups['gibbonRollGroupID']."'>".__($guid, 'Take Attendance')."<img style='margin-left: 5px' title='".__($guid, 'Take Attendance')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/attendance.png'/></a> | ";
}
$rollGroups[$count][2] .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/indexExport.php?gibbonRollGroupID='.$rowRollGroups['gibbonRollGroupID']."'>".__($guid, 'Export to Excel')."<img style='margin-left: 5px' title='".__($guid, 'Export to Excel')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/download.png'/></a>";
$rollGroups[$count][2] .= '</div>';
$rollGroups[$count][2] .= getRollGroupTable($guid, $rowRollGroups['gibbonRollGroupID'], 5, $connection2);
$behaviourView = isActionAccessible($guid, $connection2, '/modules/Behaviour/behaviour_view.php');
if ($behaviourView) {
//Behaviour
$rollGroups[$count][3] = '';
$plural = 's';
if ($resultRollGroups->rowCount() == 1) {
$plural = '';
}
try {
$dataBehaviour = array('gibbonSchoolYearID' => $_SESSION[$guid]['gibbonSchoolYearID'], 'gibbonSchoolYearID2' => $_SESSION[$guid]['gibbonSchoolYearID'], 'gibbonRollGroupID' => $rollGroups[$count][0]);
$sqlBehaviour = 'SELECT gibbonBehaviour.*, student.surname AS surnameStudent, student.preferredName AS preferredNameStudent, creator.surname AS surnameCreator, creator.preferredName AS preferredNameCreator, creator.title FROM gibbonBehaviour JOIN gibbonPerson AS student ON (gibbonBehaviour.gibbonPersonID=student.gibbonPersonID) JOIN gibbonStudentEnrolment ON (gibbonStudentEnrolment.gibbonPersonID=student.gibbonPersonID) JOIN gibbonPerson AS creator ON (gibbonBehaviour.gibbonPersonIDCreator=creator.gibbonPersonID) WHERE gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonBehaviour.gibbonSchoolYearID=:gibbonSchoolYearID2 AND gibbonRollGroupID=:gibbonRollGroupID ORDER BY timestamp DESC';
$resultBehaviour = $connection2->prepare($sqlBehaviour);
$resultBehaviour->execute($dataBehaviour);
} catch (PDOException $e) {
$rollGroups[$count][3] .= "<div class='error'>".$e->getMessage().'</div>';
}
if (isActionAccessible($guid, $connection2, '/modules/Behaviour/behaviour_manage_add.php')) {
$rollGroups[$count][3] .= "<div class='linkTop'>";
$rollGroups[$count][3] .= "<a href='".$_SESSION[$guid]['absoluteURL']."/index.php?q=/modules/Behaviour/behaviour_manage_add.php&gibbonPersonID=&gibbonRollGroupID=&gibbonYearGroupID=&type='>".__($guid, 'Add')."<img style='margin: 0 0 -4px 5px' title='".__($guid, 'Add')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/page_new.png'/></a>";
$policyLink = getSettingByScope($connection2, 'Behaviour', 'policyLink');
if ($policyLink != '') {
$rollGroups[$count][3] .= " | <a target='_blank' href='$policyLink'>".__($guid, 'View Behaviour Policy').'</a>';
}
$rollGroups[$count][3] .= '</div>';
}
if ($resultBehaviour->rowCount() < 1) {
$rollGroups[$count][3] .= "<div class='error'>";
$rollGroups[$count][3] .= __($guid, 'There are no records to display.');
$rollGroups[$count][3] .= '</div>';
} else {
$rollGroups[$count][3] .= "<table cellspacing='0' style='width: 100%'>";
$rollGroups[$count][3] .= "<tr class='head'>";
$rollGroups[$count][3] .= '<th>';
$rollGroups[$count][3] .= __($guid, 'Student & Date');
$rollGroups[$count][3] .= '</th>';
$rollGroups[$count][3] .= '<th>';
$rollGroups[$count][3] .= __($guid, 'Type');
$rollGroups[$count][3] .= '</th>';
$rollGroups[$count][3] .= '<th>';
$rollGroups[$count][3] .= __($guid, 'Descriptor');
$rollGroups[$count][3] .= '</th>';
$rollGroups[$count][3] .= '<th>';
$rollGroups[$count][3] .= __($guid, 'Level');
$rollGroups[$count][3] .= '</th>';
$rollGroups[$count][3] .= '<th>';
$rollGroups[$count][3] .= __($guid, 'Teacher');
$rollGroups[$count][3] .= '</th>';
$rollGroups[$count][3] .= '<th>';
$rollGroups[$count][3] .= __($guid, 'Action');
$rollGroups[$count][3] .= '</th>';
$rollGroups[$count][3] .= '</tr>';
$count2 = 0;
$rowNum = 'odd';
while ($rowBehaviour = $resultBehaviour->fetch()) {
if ($count2 % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count2;
//COLOR ROW BY STATUS!
$rollGroups[$count][3] .= "<tr class=$rowNum>";
$rollGroups[$count][3] .= '<td>';
$rollGroups[$count][3] .= '<b>'.formatName('', $rowBehaviour['preferredNameStudent'], $rowBehaviour['surnameStudent'], 'Student', false).'</b><br/>';
if (substr($rowBehaviour['timestamp'], 0, 10) > $rowBehaviour['date']) {
$rollGroups[$count][3] .= __($guid, 'Date Updated').': '.dateConvertBack($guid, substr($rowBehaviour['timestamp'], 0, 10)).'<br/>';
$rollGroups[$count][3] .= __($guid, 'Incident Date').': '.dateConvertBack($guid, $rowBehaviour['date']).'<br/>';
} else {
$rollGroups[$count][3] .= dateConvertBack($guid, $rowBehaviour['date']).'<br/>';
}
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= "<td style='text-align: center'>";
if ($rowBehaviour['type'] == 'Negative') {
$rollGroups[$count][3] .= "<img title='".__($guid, 'Negative')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/iconCross.png'/> ";
} elseif ($rowBehaviour['type'] == 'Positive') {
$rollGroups[$count][3] .= "<img title='".__($guid, 'Positive')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/iconTick.png'/> ";
}
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= '<td>';
$rollGroups[$count][3] .= trim($rowBehaviour['descriptor']);
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= '<td>';
$rollGroups[$count][3] .= trim($rowBehaviour['level']);
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= '<td>';
$rollGroups[$count][3] .= formatName($rowBehaviour['title'], $rowBehaviour['preferredNameCreator'], $rowBehaviour['surnameCreator'], 'Staff', false).'<br/>';
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= '<td>';
$rollGroups[$count][3] .= "<script type='text/javascript'>";
$rollGroups[$count][3] .= '$(document).ready(function(){';
$rollGroups[$count][3] .= "\$(\".comment-$count2\").hide();";
$rollGroups[$count][3] .= "\$(\".show_hide-$count2\").fadeIn(1000);";
$rollGroups[$count][3] .= "\$(\".show_hide-$count2\").click(function(){";
$rollGroups[$count][3] .= "\$(\".comment-$count2\").fadeToggle(1000);";
$rollGroups[$count][3] .= '});';
$rollGroups[$count][3] .= '});';
$rollGroups[$count][3] .= '</script>';
if ($rowBehaviour['comment'] != '') {
$rollGroups[$count][3] .= "<a title='".__($guid, 'View Description')."' class='show_hide-$count2' onclick='false' href='#'><img style='padding-right: 5px' src='".$_SESSION[$guid]['absoluteURL']."/themes/Default/img/page_down.png' alt='".__($guid, 'Show Comment')."' onclick='return false;' /></a>";
}
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= '</tr>';
if ($rowBehaviour['comment'] != '') {
if ($rowBehaviour['type'] == 'Positive') {
$bg = 'background-color: #D4F6DC;';
} else {
$bg = 'background-color: #F6CECB;';
}
$rollGroups[$count][3] .= "<tr class='comment-$count2' id='comment-$count2'>";
$rollGroups[$count][3] .= "<td style='$bg' colspan=6>";
$rollGroups[$count][3] .= $rowBehaviour['comment'];
$rollGroups[$count][3] .= '</td>';
$rollGroups[$count][3] .= '</tr>';
}
$rollGroups[$count][3] .= '</tr>';
$rollGroups[$count][3] .= '</tr>';
}
$rollGroups[$count][3] .= '</table>';
}
}
++$count;
++$rollGroupCount;
}
//GET HOOKS INTO DASHBOARD
$hooks = array();
try {
$dataHooks = array();
$sqlHooks = "SELECT * FROM gibbonHook WHERE type='Staff Dashboard'";
$resultHooks = $connection2->prepare($sqlHooks);
$resultHooks->execute($dataHooks);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
if ($resultHooks->rowCount() > 0) {
$count = 0;
while ($rowHooks = $resultHooks->fetch()) {
$options = unserialize($rowHooks['options']);
//Check for permission to hook
try {
$dataHook = array('gibbonRoleIDCurrent' => $_SESSION[$guid]['gibbonRoleIDCurrent'], 'sourceModuleName' => $options['sourceModuleName']);
$sqlHook = "SELECT gibbonHook.name, gibbonModule.name AS module, gibbonAction.name AS action FROM gibbonHook JOIN gibbonModule ON (gibbonHook.gibbonModuleID=gibbonModule.gibbonModuleID) JOIN gibbonAction ON (gibbonAction.gibbonModuleID=gibbonModule.gibbonModuleID) JOIN gibbonPermission ON (gibbonPermission.gibbonActionID=gibbonAction.gibbonActionID) WHERE gibbonAction.gibbonModuleID=(SELECT gibbonModuleID FROM gibbonModule WHERE gibbonPermission.gibbonRoleID=:gibbonRoleIDCurrent AND name=:sourceModuleName) AND gibbonHook.type='Staff Dashboard' AND gibbonAction.name='".$options['sourceModuleAction']."' AND gibbonModule.name='".$options['sourceModuleName']."' ORDER BY name";
$resultHook = $connection2->prepare($sqlHook);
$resultHook->execute($dataHook);
} catch (PDOException $e) {
}
if ($resultHook->rowCount() == 1) {
$rowHook = $resultHook->fetch();
$hooks[$count]['name'] = $rowHooks['name'];
$hooks[$count]['sourceModuleName'] = $rowHook['module'];
$hooks[$count]['sourceModuleInclude'] = $options['sourceModuleInclude'];
++$count;
}
}
}
if ($planner == false and $timetable == false and count($hooks) < 1) {
$return .= "<div class='warning'>";
$return .= __($guid, 'There are no records to display.');
$return .= '</div>';
} else {
$staffDashboardDefaultTab = getSettingByScope($connection2, 'School Admin', 'staffDashboardDefaultTab');
$staffDashboardDefaultTabCount = null;
$return .= "<div id='".$gibbonPersonID."tabs' style='margin: 0 0'>";
$return .= '<ul>';
$tabCount = 1;
if ($planner != false or $timetable != false) {
$return .= "<li><a href='#tabs".$tabCount."'>".__($guid, 'Planner').'</a></li>';
if ($staffDashboardDefaultTab == 'Planner')
$staffDashboardDefaultTabCount = $tabCount;
++$tabCount;
}
if (count($rollGroups) > 0) {
foreach ($rollGroups as $rollGroup) {
$return .= "<li><a href='#tabs".$tabCount."'>".$rollGroup[1].'</a></li>';
++$tabCount;
if ($behaviourView) {
$return .= "<li><a href='#tabs".$tabCount."'>".$rollGroup[1].' '.__($guid, 'Behaviour').'</a></li>';
++$tabCount;
}
}
}
foreach ($hooks as $hook) {
$return .= "<li><a href='#tabs".$tabCount."'>".__($guid, $hook['name']).'</a></li>';
if ($staffDashboardDefaultTab == $hook['name'])
$staffDashboardDefaultTabCount = $tabCount;
++$tabCount;
}
$return .= '</ul>';
$tabCount = 1;
if ($planner != false or $timetable != false) {
$return .= "<div id='tabs".$tabCount."'>";
$return .= $planner;
$return .= $timetable;
$return .= '</div>';
++$tabCount;
}
if (count($rollGroups) > 0) {
foreach ($rollGroups as $rollGroup) {
$return .= "<div id='tabs".$tabCount."'>";
$return .= $rollGroup[2];
$return .= '</div>';
++$tabCount;
if ($behaviourView) {
$return .= "<div id='tabs".$tabCount."'>";
$return .= $rollGroup[3];
$return .= '</div>';
++$tabCount;
}
}
}
foreach ($hooks as $hook) {
$return .= "<div style='min-height: 100px' id='tabs".$tabCount."'>";
$include = $_SESSION[$guid]['absolutePath'].'/modules/'.$hook['sourceModuleName'].'/'.$hook['sourceModuleInclude'];
if (!file_exists($include)) {
$return .= "<div class='error'>";
$return .= __($guid, 'The selected page cannot be displayed due to a hook error.');
$return .= '</div>';
} else {
$return .= include $include;
}
++$tabCount;
$return .= '</div>';
}
$return .= '</div>';
}
$defaultTab = 0;
if (isset($_GET['tab'])) {
$defaultTab = $_GET['tab'];
}
else if (!empty($staffDashboardDefaultTabCount)) {
$defaultTab = $staffDashboardDefaultTabCount-1;
}
$return .= "<script type='text/javascript'>";
$return .= '$(function() {';
$return .= '$( "#'.$gibbonPersonID.'tabs" ).tabs({';
$return .= 'active: '.$defaultTab.',';
$return .= 'ajaxOptions: {';
$return .= 'error: function( xhr, status, index, anchor ) {';
$return .= '$( anchor.hash ).html(';
$return .= "\"Couldn't load this tab.\" );";
$return .= '}';
$return .= '}';
$return .= '});';
$return .= '});';
$return .= '</script>';
return $return;
}
//Gets the contents of the student dashboard for the student specified
function getStudentDashboardContents($connection2, $guid, $gibbonPersonID)
{
$return = false;
//GET PLANNER
$planner = false;
$date = date('Y-m-d');
if (isSchoolOpen($guid, $date, $connection2) == true and isActionAccessible($guid, $connection2, '/modules/Planner/planner.php') and $_SESSION[$guid]['username'] != '') {
try {
$data = array('gibbonSchoolYearID' => $_SESSION[$guid]['gibbonSchoolYearID'], 'date' => $date, 'gibbonPersonID' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonSchoolYearID2' => $_SESSION[$guid]['gibbonSchoolYearID'], 'date2' => $date, 'gibbonPersonID2' => $_SESSION[$guid]['gibbonPersonID']);
$sql = "(SELECT gibbonCourseClass.gibbonCourseClassID, gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonHookID, gibbonPlannerEntry.gibbonCourseClassID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkSubmission, homeworkCrowdAssess, role, date, summary, gibbonPlannerEntryStudentHomework.homeworkDueDateTime AS myHomeworkDueDateTime FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourseClassPerson ON (gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) LEFT JOIN gibbonPlannerEntryStudentHomework ON (gibbonPlannerEntryStudentHomework.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID AND gibbonPlannerEntryStudentHomework.gibbonPersonID=gibbonCourseClassPerson.gibbonPersonID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND date=:date AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND NOT role='Student - Left' AND NOT role='Teacher - Left') UNION (SELECT gibbonCourseClass.gibbonCourseClassID, gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonHookID, gibbonPlannerEntry.gibbonCourseClassID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkSubmission, homeworkCrowdAssess, role, date, summary, NULL AS myHomeworkDueDateTime FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonPlannerEntryGuest ON (gibbonPlannerEntryGuest.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID2 AND date=:date2 AND gibbonPlannerEntryGuest.gibbonPersonID=:gibbonPersonID2) ORDER BY date, timeStart, course, class";
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$planner .= "<div class='error'>".$e->getMessage().'</div>';
}
$planner .= '<h2>';
$planner .= __($guid, "Today's Lessons");
$planner .= '</h2>';
if ($result->rowCount() < 1) {
$planner .= "<div class='warning'>";
$planner .= __($guid, 'There are no records to display.');
$planner .= '</div>';
} else {
$planner .= "<div class='linkTop'>";
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL']."/index.php?q=/modules/Planner/planner.php'>".__($guid, 'View Planner').'</a>';
$planner .= '</div>';
$planner .= "<table cellspacing='0' style='width: 100%'>";
$planner .= "<tr class='head'>";
$planner .= '<th>';
$planner .= __($guid, 'Class').'<br/>';
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Lesson').'</br>';
$planner .= "<span style='font-size: 85%; font-style: italic'>".__($guid, 'Unit').'</span>';
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Homework');
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Summary');
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Like');
$planner .= '</th>';
$planner .= '<th>';
$planner .= __($guid, 'Action');
$planner .= '</th>';
$planner .= '</tr>';
$count = 0;
$rowNum = 'odd';
while ($row = $result->fetch()) {
if (!($row['role'] == 'Student' and $row['viewableStudents'] == 'N')) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count;
//Highlight class in progress
if ((date('H:i:s') > $row['timeStart']) and (date('H:i:s') < $row['timeEnd']) and ($date) == date('Y-m-d')) {
$rowNum = 'current';
}
//COLOR ROW BY STATUS!
$planner .= "<tr class=$rowNum>";
$planner .= '<td>';
$planner .= $row['course'].'.'.$row['class'].'<br/>';
$planner .= "<span style='font-style: italic; font-size: 75%'>".substr($row['timeStart'], 0, 5).'-'.substr($row['timeEnd'], 0, 5).'</span>';
$planner .= '</td>';
$planner .= '<td>';
$planner .= '<b>'.$row['name'].'</b><br/>';
$planner .= "<div style='font-size: 85%; font-style: italic'>";
$unit = getUnit($connection2, $row['gibbonUnitID'], $row['gibbonHookID'], $row['gibbonCourseClassID']);
if (isset($unit[0])) {
$planner .= $unit[0];
if ($unit[1] != '') {
$planner .= '<br/><i>'.$unit[1].' '.__($guid, 'Unit').'</i>';
}
}
$planner .= '</div>';
$planner .= '</td>';
$planner .= '<td>';
if ($row['homework'] == 'N' and $row['myHomeworkDueDateTime'] == '') {
$planner .= __($guid, 'No');
} else {
if ($row['homework'] == 'Y') {
$planner .= __($guid, 'Yes').': '.__($guid, 'Teacher Recorded').'<br/>';
if ($row['homeworkSubmission'] == 'Y') {
$planner .= "<span style='font-size: 85%; font-style: italic'>+".__($guid, 'Submission').'</span><br/>';
if ($row['homeworkCrowdAssess'] == 'Y') {
$planner .= "<span style='font-size: 85%; font-style: italic'>+".__($guid, 'Crowd Assessment').'</span><br/>';
}
}
}
if ($row['myHomeworkDueDateTime'] != '') {
$planner .= __($guid, 'Yes').': '.__($guid, 'Student Recorded').'</br>';
}
}
$planner .= '</td>';
$planner .= '<td id="wordWrap">';
$planner .= $row['summary'];
$planner .= '</td>';
$planner .= '<td>';
if ($row['role'] == 'Teacher') {
$planner .= countLikesByContext($connection2, 'Planner', 'gibbonPlannerEntryID', $row['gibbonPlannerEntryID']);
} else {
$likesGiven = countLikesByContextAndGiver($connection2, 'Planner', 'gibbonPlannerEntryID', $row['gibbonPlannerEntryID'], $_SESSION[$guid]['gibbonPersonID']);
if ($likesGiven != 1) {
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/modules/Planner/plannerProcess.php?gibbonPlannerEntryID='.$row['gibbonPlannerEntryID'].'&address=/modules/Planner/planner.php&viewBy=Class&gibbonCourseClassID='.$row['gibbonCourseClassID']."&date=&returnToIndex=Y'><img src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/like_off.png'></a>";
} else {
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/modules/Planner/plannerProcess.php?gibbonPlannerEntryID='.$row['gibbonPlannerEntryID'].'&address=/modules/Planner/planner.php&viewBy=Class&gibbonCourseClassID='.$row['gibbonCourseClassID']."&date=&returnToIndex=Y'><img src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/like_on.png'></a>";
}
}
$planner .= '</td>';
$planner .= '<td>';
$planner .= "<a href='".$_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/Planner/planner_view_full.php&viewBy=class&gibbonCourseClassID='.$row['gibbonCourseClassID'].'&gibbonPlannerEntryID='.$row['gibbonPlannerEntryID']."'><img title='".__($guid, 'View')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/plus.png'/></a>";
$planner .= '</td>';
$planner .= '</tr>';
}
}
$planner .= '</table>';
}
}
//GET TIMETABLE
$timetable = false;
if (isActionAccessible($guid, $connection2, '/modules/Timetable/tt.php') and $_SESSION[$guid]['username'] != '' and getRoleCategory($_SESSION[$guid]['gibbonRoleIDCurrent'], $connection2) == 'Student') {
?>
<script type="text/javascript">
$(document).ready(function(){
$("#tt").load("<?php echo $_SESSION[$guid]['absoluteURL'] ?>/index_tt_ajax.php",{"gibbonTTID": "<?php echo @$_GET['gibbonTTID'] ?>", "ttDate": "<?php echo @$_POST['ttDate'] ?>", "fromTT": "<?php echo @$_POST['fromTT'] ?>", "personalCalendar": "<?php echo @$_POST['personalCalendar'] ?>", "schoolCalendar": "<?php echo @$_POST['schoolCalendar'] ?>", "spaceBookingCalendar": "<?php echo @$_POST['spaceBookingCalendar'] ?>"});
});
</script>
<?php
$timetable .= '<h2>'.__($guid, 'My Timetable').'</h2>';
$timetable .= "<div id='tt' name='tt' style='width: 100%; min-height: 40px; text-align: center'>";
$timetable .= "<img style='margin: 10px 0 5px 0' src='".$_SESSION[$guid]['absoluteURL']."/themes/Default/img/loading.gif' alt='".__($guid, 'Loading')."' onclick='return false;' /><br/><p style='text-align: center'>".__($guid, 'Loading').'</p>';
$timetable .= '</div>';
}
//GET HOOKS INTO DASHBOARD
$hooks = array();
try {
$dataHooks = array();