forked from barrysspace/entrada-1x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.inc.php
2090 lines (1921 loc) · 135 KB
/
edit.inc.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
/**
* Entrada [ http://www.entrada-project.org ]
*
* Entrada 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.
*
* Entrada 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 Entrada. If not, see <http://www.gnu.org/licenses/>.
*
* @author Organisation: Queen's University
* @author Unit: School of Medicine
* @author Developer: James Ellis <james.ellis@queensu.ca>
* @copyright Copyright 2010 Queen's University. All Rights Reserved.
*
*/
if ((!defined("PARENT_INCLUDED")) || (!defined("IN_COURSES"))) {
exit;
} elseif ((!isset($_SESSION["isAuthorized"])) || (!$_SESSION["isAuthorized"])) {
header("Location: ".ENTRADA_URL);
exit;
} elseif (!$ENTRADA_ACL->amIAllowed("course", "update", false)) {
add_error("Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:".html_encode($AGENT_CONTACTS["administrator"]["email"])."\">".html_encode($AGENT_CONTACTS["administrator"]["name"])."</a> for assistance.");
echo display_error();
application_log("error", "Group [".$_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"]."] and role [".$_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"]."] does not have access to this module [".$MODULE."]");
} else {
if ($COURSE_ID) {
$query = " SELECT * FROM `courses`
WHERE `course_id` = ".$db->qstr($COURSE_ID)."
AND `course_active` = '1'";
$course_details = $db->GetRow($query);
if ($course_details && $ENTRADA_ACL->amIAllowed(new CourseResource($course_details["course_id"], $course_details["organisation_id"]), "update")) {
$HEAD[] = "<script type=\"text/javascript\">var SITE_URL = '".ENTRADA_URL."';</script>";
$HEAD[] = "<script type=\"text/javascript\">var DELETE_IMAGE_URL = '".ENTRADA_URL."/images/minus-sign.png';</script>";
$HEAD[] = "<script type=\"text/javascript\" src=\"".ENTRADA_URL."/javascript/picklist.js\"></script>\n";
$HEAD[] = "<script type=\"text/javascript\" src=\"".ENTRADA_URL."/javascript/AutoCompleteList.js?release=".html_encode(APPLICATION_VERSION)."\"></script>";
$HEAD[] = "<script type=\"text/javascript\" src=\"".ENTRADA_URL."/javascript/objectives.js?release=".html_encode(APPLICATION_VERSION)."\"></script>";
$HEAD[] = "<script type=\"text/javascript\" src=\"".ENTRADA_URL."/javascript/objectives_course.js?release=".html_encode(APPLICATION_VERSION)."\"></script>";
$HEAD[] = "<script type=\"text/javascript\" src=\"".ENTRADA_URL."/javascript/keywords_course.js?release=".html_encode(APPLICATION_VERSION)."\"></script>";
$BREADCRUMB[] = array("url" => ENTRADA_URL."/admin/".$MODULE."?".replace_query(array("section" => "edit", "id" => $COURSE_ID, "step" => false)), "title" => "Editing " . $module_singular_name);
/**
* Fetch the Clinical Presentation details.
*/
$clinical_presentations_list = array();
$clinical_presentations = array();
$results = fetch_clinical_presentations();
if ($results) {
foreach ($results as $result) {
$clinical_presentations_list[$result["objective_id"]] = $result["objective_name"];
}
} else {
$clinical_presentations_list = false;
}
if ((isset($_POST["clinical_presentations"])) && (is_array($_POST["clinical_presentations"])) && (count($_POST["clinical_presentations"]))) {
foreach ($_POST["clinical_presentations"] as $objective_id) {
if ($objective_id = clean_input($objective_id, array("trim", "int"))) {
$query = "SELECT a.`objective_id`
FROM `global_lu_objectives` AS a
JOIN `objective_organisation` AS b
ON a.`objective_id` = b.`objective_id`
WHERE a.`objective_id` = ".$db->qstr($objective_id)."
AND b.`organisation_id` = ".$db->qstr($ENTRADA_USER->getActiveOrganisation())."
ORDER BY a.`objective_order` ASC";
$result = $db->GetRow($query);
if ($result) {
$clinical_presentations[$objective_id] = $clinical_presentations_list[$objective_id];
}
}
}
}
courses_subnavigation($course_details, "details");
echo "<h1>Editing " . $module_singular_name . "</h1>\n";
$PROCESSED["permission"] = $course_details["permission"];
$PROCESSED["sync_ldap"] = $course_details["sync_ldap"];
$PROCESSED["sync_ldap_courses"] = $course_details["sync_ldap_courses"];
// Error Checking
switch($STEP) {
case 2 :
if ($ENTRADA_ACL->amIAllowed(new CourseResource($COURSE_ID, $ENTRADA_USER->getActiveOrganisation()), "update")) {
$PROCESSED["organisation_id"] = $ENTRADA_USER->getActiveOrganisation();
} else {
add_error("You do not have permission to update a course for this organisation. This error has been logged and will be investigated.");
application_log("error", "Proxy id [".$ENTRADA_USER->getID()."] tried to create a course within an organisation [".$ENTRADA_USER->getActiveOrganisation()."] they didn't have permissions on. ");
}
/**
* Non-required field "curriculum_type_id" / Curriculum Category
*/
if ((isset($_POST["curriculum_type_id"])) && ($curriculum_type_id = clean_input($_POST["curriculum_type_id"], array("int")))) {
$PROCESSED["curriculum_type_id"] = $curriculum_type_id;
} else {
$PROCESSED["curriculum_type_id"] = 0;
}
/**
* Required field "course_name" / Course Name.
*/
if ((isset($_POST["course_name"])) && ($course_name = clean_input($_POST["course_name"], array("notags", "trim")))) {
$PROCESSED["course_name"] = $course_name;
} else {
add_error("The <strong>" . $module_singular_name . " Name</strong> field is required.");
}
/**
* Non-required field "course_code" / Course Code.
*/
if ((isset($_POST["course_code"])) && ($course_code = clean_input($_POST["course_code"], array("notags", "trim")))) {
$PROCESSED["course_code"] = $course_code;
} else {
add_error("The <strong>" . $module_singular_name . " Code</strong> field is required and must be provided.");
}
/**
* Check to see if notifications are enabled or not for events in this course.
*/
if ((isset($_POST["notifications"])) && (!clean_input($_POST["notifications"], "int"))) {
$PROCESSED["notifications"] = 0;
} else {
$PROCESSED["notifications"] = 1;
}
/**
* Check to see if whether this course is open or closed.
*/
if ((isset($_POST["permission"])) && ($_POST["permission"] == "closed")) {
$PROCESSED["permission"] = "closed";
} else {
$PROCESSED["permission"] = "open";
}
/**
* Check to see if this course audience should syncronize with LDAP or not.
*/
$PROCESSED["sync_ldap_courses"] = "";
if ((isset($_POST["sync_ldap"])) && ($_POST["sync_ldap"] == "1")) {
$PROCESSED["sync_ldap"] = 1;
} else {
$PROCESSED["sync_ldap"] = 0;
}
/*
* Process the ldap sync course list.
*/
$PROCESSED["sync_ldap_courses"] = "";
$clean_ldap_course_codes = array();
if (isset($_POST["sync_ldap_courses"]) && !empty($_POST["sync_ldap_courses"])) {
$sync_ldap_courses = explode(",", $_POST["sync_ldap_courses"]);
foreach ($sync_ldap_courses as $course_code) {
if ($tmp_input = clean_input($course_code, array("trim", "striptags", "alphanumeric"))) {
if (!in_array(strtoupper($tmp_input), $clean_ldap_course_codes)) {
$clean_ldap_course_codes[] = strtoupper($tmp_input);
}
}
}
if (isset($clean_ldap_course_codes) && !empty($clean_ldap_course_codes)) {
$PROCESSED["sync_ldap_courses"] = implode(", ", $clean_ldap_course_codes);
}
}
if (empty($PROCESSED["sync_ldap_courses"]) && $PROCESSED["sync_ldap"] != 0) {
add_error("The LDAP synchronization course list can not be empty.");
}
/**
* Check to see if the course groups should syncronize with LDAP or not.
*/
if ((isset($_POST["sync_groups"])) && ($_POST["sync_groups"] == "1")) {
$PROCESSED["sync_groups"] = 1;
} else {
$PROCESSED["sync_groups"] = 0;
}
$posted_objectives = array();
$PRIMARY_OBJECTIVES = array();
if ((isset($_POST["primary_objectives"])) && ($objectives = $_POST["primary_objectives"]) && (count($objectives))) {
foreach ($objectives as $objective_key => $objective) {
$PRIMARY_OBJECTIVES[] = clean_input($objective, "int");
$objective_importance[$objective] = "1";
$posted_objectives["primary"][] = clean_input($objective, "int");
}
}
$SECONDARY_OBJECTIVES = array();
if ((isset($_POST["secondary_objectives"])) && ($objectives = $_POST["secondary_objectives"]) && (count($objectives))) {
foreach ($objectives as $objective_key => $objective) {
$SECONDARY_OBJECTIVES[] = clean_input($objective, "int");
$objective_importance[$objective] = "2";
$posted_objectives["secondary"][] = clean_input($objective, "int");
}
}
$TERTIARY_OBJECTIVES = array();
if ((isset($_POST["tertiary_objectives"])) && ($objectives = $_POST["tertiary_objectives"]) && (count($objectives))) {
foreach ($objectives as $objective_key => $objective) {
$TERTIARY_OBJECTIVES[] = clean_input($objective, "int");
$objective_importance[$objective] = "3";
$posted_objectives["tertiary"][] = clean_input($objective, "int");
}
}
/**
* Non-required field "pcoord_id" .
*/
if ((isset($_POST["pcoord_id"])) && ($pcoord_id = clean_input($_POST["pcoord_id"], "int"))) {
$PROCESSED["pcoord_id"] = $pcoord_id;
} else {
$PROCESSED["pcoord_id"] = 0;
}
/**
* Non-required field "evalrep_id".
*/
if ((isset($_POST["evalrep_id"])) && ($evalrep_id = clean_input($_POST["evalrep_id"], "int"))) {
$PROCESSED["evalrep_id"] = $evalrep_id;
} else {
$PROCESSED["evalrep_id"] = 0;
}
/**
* Non-required field "studrep_id" .
*/
if ((isset($_POST["studrep_id"])) && ($studrep_id = clean_input($_POST["studrep_id"], "int"))) {
$PROCESSED["studrep_id"] = $studrep_id ;
} else {
$PROCESSED["studrep_id"] = 0;
}
if (isset($_POST["post_action"])) {
switch($_POST["post_action"]) {
case "content" :
$_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "content";
break;
case "new" :
$_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "new";
break;
case "index" :
default :
$_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "index";
break;
}
} else {
$_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"] = "content";
}
$period_list = array();
if (isset($_POST["periods"]) && is_array($_POST["periods"]) && $periods = $_POST["periods"]) {
foreach ($periods as $key => $unproced_period) {
$period_id = (int)$unproced_period;
$period_list[] = $period_id;
$group_members = array();
$individual_members = array();
if (isset($_POST["group_audience_members"][$key]) && strlen($_POST["group_audience_members"][$key]) && $group_member_string = clean_input($_POST["group_audience_members"][$key],array("trim","notags"))) {
$group_members = explode(",",$group_member_string);
if ($group_members) {
foreach ($group_members as $member) {
$group_list[$period_id][] = $member;
$PROCESSED["periods"][$period_id][] = array("audience_type"=>'group_id',"audience_value"=>$member,"cperiod_id"=>$period_id,"audience_active"=>1);
}
}
}
if (isset($_POST["individual_audience_members"][$key]) && strlen($_POST["individual_audience_members"][$key]) && $individual_member_string = clean_input($_POST["individual_audience_members"][$key],array("trim","notags"))) {
$individual_members = explode(",",$individual_member_string);
if ($individual_members) {
foreach ($individual_members as $member) {
$individual_list[$period_id][] = $member;
$PROCESSED["periods"][$period_id][]=array("audience_type"=>'proxy_id',"audience_value"=>$member,"cperiod_id"=>$period_id,"audience_active"=>1);
}
}
}
if (!$group_members && !$individual_members) {
$query = " SELECT *
FROM `curriculum_periods`
WHERE `cperiod_id` = " . $db->qstr($unproced_period);
$curriculum_period = $db->getRow($query);
if ($curriculum_period["curriculum_period_title"]) {
add_error("The <strong>" . $curriculum_period["curriculum_period_title"] . "</strong> curriculum period requires an audience.");
} else {
$error_title = date("F jS, Y",$curriculum_period["start_date"])." to ".date("F jS, Y",$curriculum_period["finish_date"]);
add_error("The <strong>" . $error_title . "</strong> curriculum period requires an audience.");
}
$PROCESSED["periods"][$period_id][]=array("audience_type"=>'',"audience_value"=>0,"cperiod_id"=>$period_id,"audience_active"=>0);
}
}
}
if (isset($_POST["syllabus_id"]) && $tmp_input = clean_input($_POST["syllabus_id"], array("int"))) {
$PROCESSED["syllabus"]["syllabus_id"] = $tmp_input;
}
if (isset($_POST["syllabus_enabled"]) && $tmp_input = clean_input($_POST["syllabus_enabled"], array("trim", "striptags"))) {
$PROCESSED["syllabus"]["syllabus_enabled"] = $tmp_input == "enabled" ? 1 : 0;
} else {
$PROCESSED["syllabus"]["syllabus_enabled"] = 0;
}
if ($PROCESSED["syllabus"]["syllabus_enabled"] == 1) {
if (isset($_POST["syllabus_template"]) && $tmp_input = clean_input($_POST["syllabus_template"], array("trim", "striptags"))) {
$PROCESSED["syllabus"]["syllabus_template"] = $tmp_input;
}
}
if (isset($_POST["course_report_ids"])) {
$PROCESSED["course_report_ids"] = array();
foreach ($_POST["course_report_ids"] as $index => $tmp_input) {
if ($course_report_id = clean_input($tmp_input, "int")) {
$PROCESSED["course_report_ids"][] = $course_report_id;
}
}
}
if (!has_error()) {
$PROCESSED["updated_date"] = time();
$PROCESSED["updated_by"] = $ENTRADA_USER->getID();
if ($db->AutoExecute("courses", $PROCESSED, "UPDATE", "`course_id`=".$db->qstr($COURSE_ID))) {
/**
* Update corresponding course website contacts if one exists for this course.
*/
$community_id = $db->GetOne("SELECT `community_id` FROM `community_courses` WHERE `course_id` = ".$db->qstr($COURSE_ID));
if ($community_id) {
$query = "SELECT `proxy_id` FROM `course_contacts` WHERE `course_id` = ".$db->qstr($COURSE_ID);
$results = $db->GetAll($query);
if ($results) {
$delete_ids_string = false;
foreach ($results as $result) {
if ($delete_ids_string) {
$delete_ids_string .= ", ".$db->qstr($result["proxy_id"]);
} else {
$delete_ids_string = $result["proxy_id"];
}
}
$db->Execute("UPDATE `community_members` SET `member_acl` = '0' WHERE `proxy_id` IN (".$delete_ids_string.") AND `community_id` = ".$db->qstr($community_id));
}
}
/**
* Insert Clinical Presentations.
*/
$query = "DELETE FROM `course_objectives` WHERE `objective_type` = 'event' AND `course_id` = ".$db->qstr($COURSE_ID);
if ($db->Execute($query)) {
if ((is_array($clinical_presentations)) && (count($clinical_presentations))) {
foreach ($clinical_presentations as $objective_id => $presentation_name) {
if (!$db->AutoExecute("course_objectives", array("course_id" => $COURSE_ID, "objective_id" => $objective_id, "objective_type" => "event", "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID()), "INSERT")) {
add_error("There was an error when trying to insert a "clinical presentation" into the system. System administrators have been informed of this error; please try again later.");
application_log("error", "Unable to insert a new clinical presentation to the database when adding a new event. Database said: ".$db->ErrorMsg());
}
}
}
}
$query = "DELETE FROM `course_contacts` WHERE `course_id`=".$db->qstr($COURSE_ID)." AND `contact_type` != 'pcoordinator'";
if ($db->Execute($query)) {
if ((isset($_POST["associated_director"])) && ($associated_directors = explode(",", $_POST["associated_director"])) && (@is_array($associated_directors)) && (@count($associated_directors))) {
$community_member = false;
$order = 0;
foreach ($associated_directors as $proxy_id) {
if ($proxy_id = clean_input($proxy_id, array("trim", "int"))) {
if (!$db->AutoExecute("course_contacts", array("course_id" => $COURSE_ID, "proxy_id" => $proxy_id, "contact_type" => "director", "contact_order" => $order), "INSERT")) {
add_error("There was an error when trying to insert a "" . $module_singular_name . " Director" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new course_contact to the database when updating an event. Database said: ".$db->ErrorMsg());
} else {
$order++;
$community_member = $db->GetOne("SELECT `proxy_id` FROM `community_members` WHERE `proxy_id` = ".$db->qstr($proxy_id)." AND `community_id` = ".$db->qstr($community_id));
if (!$community_member) {
if ($community_id && !$db->AutoExecute("community_members", array("community_id" => $community_id, "proxy_id" => $proxy_id, "member_active" => 1, "member_joined" => time(), "member_acl" => 1), "INSERT")) {
add_error("There was an error when trying to insert a "Curriculum Coordinator" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new community_member to the database when updating an event. Database said: ".$db->ErrorMsg());
}
} else {
if ($community_id && !$db->AutoExecute("community_members", array("member_active" => 1, "member_acl" => 1), "UPDATE", "`community_id` = ".$db->qstr($community_id)." AND `proxy_id` = ".$db->qstr($proxy_id))) {
add_error("There was an error when trying to insert a "Curriculum Coordinator" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new community_member to the database when updating an event. Database said: ".$db->ErrorMsg());
}
}
}
}
}
}
if ((isset($_POST["associated_coordinator"])) && ($associated_coordinators = explode(",", $_POST["associated_coordinator"])) && (@is_array($associated_coordinators)) && (@count($associated_coordinators))) {
$community_member = false;
foreach ($associated_coordinators as $proxy_id) {
if ($proxy_id = clean_input($proxy_id, array("trim", "int"))) {
if (!$db->AutoExecute("course_contacts", array("course_id" => $COURSE_ID, "proxy_id" => $proxy_id, "contact_type" => "ccoordinator"), "INSERT")) {
add_error("There was an error when trying to insert a "Curriculum Coordinator" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new course_contact to the database when updating an event. Database said: ".$db->ErrorMsg());
} else {
$community_member = $db->GetOne("SELECT `proxy_id` FROM `community_members` WHERE `proxy_id` = ".$db->qstr($proxy_id)." AND `community_id` = ".$db->qstr($community_id));
if (!$community_member) {
if ($community_id && !$db->AutoExecute("community_members", array("community_id" => $community_id, "proxy_id" => $proxy_id, "member_active" => 1, "member_joined" => time(), "member_acl" => 1), "INSERT")) {
add_error("There was an error when trying to insert a "Curriculum Coordinator" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new community_member to the database when updating an event. Database said: ".$db->ErrorMsg());
}
} else {
if ($community_id && !$db->AutoExecute("community_members", array("member_active" => 1, "member_acl" => 1), "UPDATE", "`community_id` = ".$db->qstr($community_id)." AND `proxy_id` = ".$db->qstr($proxy_id))) {
add_error("There was an error when trying to insert a "Curriculum Coordinator" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new community_member to the database when updating an event. Database said: ".$db->ErrorMsg());
}
}
}
}
}
}
if (isset($PROCESSED["pcoord_id"]) && $PROCESSED["pcoord_id"]) {
if ($community_id && !$db->AutoExecute("community_members", array("community_id" => $community_id, "proxy_id" => $PROCESSED["pcoord_id"], "member_active" => 1, "member_joined" => time(), "member_acl" => 1), "INSERT")) {
add_error("There was an error when trying to insert a "Curriculum Coordinator" into the system. The system administrator was informed of this error; please try again later.");
application_log("error", "Unable to insert a new community_member to the database when updating an event. Database said: ".$db->ErrorMsg());
}
}
}
// Update MeSH keywords
if (isset($_POST["delete_keywords"])) {
if (trim($_POST["delete_keywords"][0]) !== "") {
$lis = explode(",", $_POST["delete_keywords"][0]);
$count = count($lis);
if ($count > 0) {
// Removed the keywords in the delete array.
for ($i=0; $i<$count; $i++) {
if (trim($lis[$i]) != "") {
$query = " DELETE
FROM `course_keywords`
WHERE keyword_id = ". $db->qstr($lis[$i])." AND course_id = ".$db->qstr($COURSE_ID);
$db->Execute($query);
}
}
}
}
}
if (isset($_POST["add_keywords"][0])) {
if (trim($_POST["add_keywords"][0]) !== "") {
$lis = explode(",", $_POST["add_keywords"][0]);
$count = count($lis);
if ($count > 0) {
// Add the keywords n the add array.
for ($i=0; $i<$count; $i++) {
if (trim($lis[$i]) != "") {
$query = " INSERT INTO `course_keywords` (course_id, keyword_id, updated_date, updated_by)
VALUES (".$db->qstr($COURSE_ID).", ". $db->qstr($lis[$i]).", ". $db->qstr(time()). ", ". $db->qstr($ENTRADA_USER->getID()).")";
$db->Execute($query);
}
}
}
}
}
$query = "SELECT * FROM `course_objectives` WHERE `objective_type` = 'course' AND `course_id` = ".$db->qstr($COURSE_ID);
$course_objectives = $db->GetAll($query);
$objective_details = array();
if ($course_objectives && count($course_objectives)) {
foreach ($course_objectives as $course_objective) {
if ($course_objective["objective_details"]) {
$objective_details[$course_objective["objective_id"]]["details"] = $course_objective["objective_details"];
$objective_details[$course_objective["objective_id"]]["found"] = false;
}
}
}
$all_objectives = array_merge($PRIMARY_OBJECTIVES, $SECONDARY_OBJECTIVES, $TERTIARY_OBJECTIVES);
$active_objectives = Models_Course_Objective::fetchAllByCourseID($COURSE_ID, "course");
if ($active_objectives) {
// deactivate the objectives that have been removed.
foreach ($active_objectives as $objective) {
if (!in_array($objective->getObjectiveID(), $all_objectives)) {
$objective->fromArray(array("active" => "0", "objective_finish" => time()))->update();
}
}
}
$objectives_added = 0;
if (!empty($all_objectives)) {
foreach ($all_objectives as $objective_id) {
$course_objective = new Models_Course_Objective(array(
"course_id" => $COURSE_ID,
"objective_id" => $objective_id,
"importance" => $objective_importance[$objective_id],
"objective_type" => "course",
"objective_details" => $objective_details[$objective_id]["details"],
"objective_start" => time(),
"objective_finish" => NULL,
"updated_date" => time(),
"updated_by" => $ENTRADA_USER->getID(),
"active" => "1"
));
if ($course_objective->insert()) {
$objectives_added++;
}
}
}
if (isset($PROCESSED["course_report_ids"]) && count($PROCESSED["course_report_ids"]) > 0) {
//remove existing course_reports for this course before adding the new set of course reports.
$query = "DELETE FROM `course_reports` WHERE `course_id` = ".$db->qstr($COURSE_ID);
if (!$db->Execute($query)) {
add_error("An error occurred while editing course reports. The system administrator was informed of this error; please try again later.");
application_log("error", "Error inserting course reports for course id: " . $COURSE_ID);
}
if (!has_error()) {
foreach ($PROCESSED["course_report_ids"] as $index => $course_report_id) {
$PROCESSED["course_report_id"] = $course_report_id;
$PROCESSED["course_id"] = $COURSE_ID;
if ($db->AutoExecute("course_reports", $PROCESSED, "INSERT")) {
add_statistic("Course Edit", "edit", "course_reports.course_report_id", $PROCESSED["course_report_id"], $ENTRADA_USER->getID());
} else {
add_error("An error occurred while editing course reports. The system administrator was informed of this error; please try again later.");
application_log("error", "Error inserting course reports for course id: " . $COURSE_ID);
}
}
}
} else {
//No course reports for this course.
$query = "DELETE FROM `course_reports` WHERE `course_id` = ".$db->qstr($COURSE_ID);
$db->Execute($query);
}
$query = " DELETE FROM `course_audience` WHERE `course_id` = ".$db->qstr($COURSE_ID).(isset($period_list)?" AND `cperiod_id` NOT IN (".implode(",",$period_list).")":"");
$db->Execute($query);
if (isset($PROCESSED["periods"]) && is_array($PROCESSED["periods"]) && $PROCESSED["periods"]) {
foreach ($PROCESSED["periods"] as $period_id=>$period) {
$query = " DELETE FROM `course_audience` WHERE `course_id` = ".$db->qstr($COURSE_ID)." AND `cperiod_id` = ".$db->qstr($period_id)." AND `audience_type` = 'group_id'".(isset($group_list[$period_id])?" AND `audience_value` NOT IN (".implode(",",$group_list[$period_id]).")":"");
$db->Execute($query);
$query = " DELETE FROM `course_audience` WHERE `course_id` = ".$db->qstr($COURSE_ID)." AND `cperiod_id` = ".$db->qstr($period_id)." AND `audience_type` = 'proxy_id'".(isset($individual_list[$period_id])?" AND `audience_value` NOT IN (".implode(",",$individual_list[$period_id]).")":"");
$db->Execute($query);
foreach ($period as $key=>$audience) {
$audience["course_id"] = $COURSE_ID;
$query = " SELECT * FROM `course_audience`
WHERE `course_id` = ".$db->qstr($COURSE_ID)."
AND `cperiod_id` = ".$db->qstr($audience["cperiod_id"])."
AND `audience_type` = ".$db->qstr($audience["audience_type"])."
AND `audience_value` = ".$db->qstr($audience["audience_value"])."
AND `audience_active` = 1";
if (!$row = $db->GetRow($query)) {
if (!$db->AutoExecute("course_audience",$audience,"INSERT")) {
add_error("An error occurred while adding the student with id ".$member." as an audience member.");
}
}
}
}
} else {
$query = "DELETE FROM `course_audience` WHERE `course_id` = ".$db->qstr($COURSE_ID);
$db->Execute($query);
}
if (isset($PROCESSED["syllabus"])) {
if (isset($PROCESSED["syllabus"]["syllabus_id"])) {
$mode = "UPDATE";
$where = "`syllabus_id` = ".$db->qstr($PROCESSED["syllabus"]["syllabus_id"]);
$syllabus_data["syllabus_id"] = $PROCESSED["syllabus"]["syllabus_id"];
} else {
$mode = "INSERT";
$where = "1 = 1";
}
if (!empty($period_list)) {
$query = "SELECT * FROM `curriculum_periods` WHERE `cperiod_id` IN (".implode(",", $period_list).") ORDER BY `start_date` DESC LIMIT 1";
$period_data = $db->GetRow($query);
} else {
$period_data["start_date"] = mktime(0, 0, 0, 1);
$period_data["finish_date"] = mktime(0, 0, 0, 12);
}
$syllabus_start = date("n", $period_data["start_date"]);
$syllabus_finish = date("n", $period_data["finish_date"]);
$syllabus_data["course_id"] = $COURSE_ID;
$syllabus_data["template"] = $PROCESSED["syllabus"]["syllabus_template"];
$syllabus_data["active"] = $PROCESSED["syllabus"]["syllabus_enabled"];
$syllabus_data["syllabus_start"] = $syllabus_start;
$syllabus_data["syllabus_finish"] = $syllabus_finish;
if (!$db->AutoExecute("course_syllabi", $syllabus_data, $mode, $where)) {
add_error("An error ocurred while attempting to update the course syllabus, an administrator has been informed, please try again later.");
application_log("error", "Error on course syllabus ".$mode.", DB said: ".$db->ErrorMsg());
}
}
if (!has_error()) {
switch($_SESSION[APPLICATION_IDENTIFIER]["tmp"]["post_action"]) {
case "content" :
$url = ENTRADA_URL."/admin/".$MODULE."?section=content&id=".$COURSE_ID;
$msg = "You will now be redirected to the course content page; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"".$url."\" style=\"font-weight: bold\">click here</a> to continue.";
break;
case "new" :
$url = ENTRADA_URL."/admin/".$MODULE."?section=add";
$msg = "You will now be redirected to add a new course; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"".$url."\" style=\"font-weight: bold\">click here</a> to continue.";
break;
case "index" :
default :
$url = ENTRADA_URL."/admin/".$MODULE;
$msg = "You will now be redirected to the course index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"".$url."\" style=\"font-weight: bold\">click here</a> to continue.";
break;
}
$ONLOAD[] = "setTimeout('window.location=\\'".$url."\\'', 5000)";
add_success("You have successfully edited <strong>".html_encode($PROCESSED["course_name"])."</strong> in the system.<br /><br />".$msg);
application_log("success", $module_singular_name . " [".$COURSE_ID."] has been modified.");
}
} else {
add_error("There was a problem updating this course in the system. The system administrator was informed of this error; please try again later.");
application_log("error", "There was an error updating a course. Database said: ".$db->ErrorMsg());
}
}
if (has_error()) {
$STEP = 1;
}
break;
case 1 :
default :
$PROCESSED = $course_details;
break;
}
// Display Content
switch($STEP) {
case 2 :
if ($SUCCESS) {
echo display_success();
}
if ($NOTICE) {
echo display_notice();
}
if ($ERROR) {
echo display_error();
}
break;
case 1 :
default :
$query = " SELECT *
FROM `course_reports`
WHERE `course_id` = ".$db->qstr($COURSE_ID);
$results = $db->GetAll($query);
if (!isset($PROCESSED["course_report_ids"])) {
$PROCESSED["course_report_ids"] = array();
if ($results) {
foreach ($results as $result) {
$PROCESSED["course_report_ids"][] = $result["course_report_id"];
}
}
}
?>
<script type="text/javascript">
<?php
$query = " SELECT * FROM `groups` AS a
JOIN `group_organisations` AS b
ON a.`group_id`=b.`group_id`
WHERE b.`organisation_id` = ".$db->qstr($ENTRADA_USER->getActiveOrganisation())."
AND a.`group_active` = 1
ORDER BY a.`group_name` ASC";
if ($groups = $db->GetAll($query)) {
echo "var is_groups=true;";
echo "var group_ids = new Array();";
echo "var group_names = new Array();";
foreach ($groups as $key=>$group) {
echo "group_ids[".$key."] = ".$group["group_id"].";";
echo "group_names[".$key."] = '".$group["group_name"]."';";
}
} else {
echo "var is_groups = false;\n";
}
?>
</script>
<?php
$LASTUPDATED = $course_details["updated_date"];
$course_directors = array();
$curriculum_coordinators = array();
$chosen_course_directors = array();
$query = "SELECT a.* FROM `course_audience` AS a
JOIN `curriculum_periods` AS b
ON a.`cperiod_id` = b.`cperiod_id`
WHERE a.`course_id` = ".$db->qstr($COURSE_ID)."
AND a.`audience_active` = 1
AND (a.`enroll_finish` = 0 OR a.`enroll_finish` > ".$db->qstr(time()).")
AND b.`finish_date` >= ".$db->qstr(time());
$course_audience = $db->GetAll($query);
if ($course_audience) {
$PROCESSED["cperiod_id"] = $course_audience[0]["cperiod_id"];
foreach ($course_audience as $audience_member) {
if ($audience_member["audience_type"] == "group_id") {
$query = "SELECT `group_id`,`group_name` FROM `groups` WHERE `group_id` = ".$db->qstr($audience_member["audience_value"]);
$result = $db->GetRow($query);
if ($result) {
$PROCESSED["groups"][] = array("id"=>$result["group_id"],"title"=>$result["group_name"]);
}
} else {
$PROCESSED["associated_students"][] = $audience_member["audience_value"];
}
}
}
if (!isset($PROCESSED["periods"])) {
$query = " SELECT * FROM `course_audience` WHERE `course_id` = ".$db->qstr($COURSE_ID)." AND `audience_active` = 1";
$audience = $db->GetAll($query);
$PROCESSED["periods"] = array();
if ($audience) {
foreach ($audience as $member) {
$PROCESSED["periods"][$member["cperiod_id"]][]=$member;
}
}
}
$query = " SELECT `".AUTH_DATABASE."`.`user_data`.`id` AS `proxy_id`, CONCAT_WS(', ', `".AUTH_DATABASE."`.`user_data`.`lastname`, `".AUTH_DATABASE."`.`user_data`.`firstname`) AS `fullname`, `".AUTH_DATABASE."`.`organisations`.`organisation_id`
FROM `".AUTH_DATABASE."`.`user_data`
LEFT JOIN `".AUTH_DATABASE."`.`user_access`
ON `".AUTH_DATABASE."`.`user_access`.`user_id` = `".AUTH_DATABASE."`.`user_data`.`id`
LEFT JOIN `".AUTH_DATABASE."`.`organisations`
ON `".AUTH_DATABASE."`.`user_access`.`organisation_id` = `".AUTH_DATABASE."`.`organisations`.`organisation_id`
WHERE `".AUTH_DATABASE."`.`user_access`.`group` = 'faculty'
AND (`".AUTH_DATABASE."`.`user_access`.`role` = 'director' OR `".AUTH_DATABASE."`.`user_access`.`role` = 'admin')
AND `".AUTH_DATABASE."`.`user_access`.`app_id` = '".AUTH_APP_ID."'
AND `".AUTH_DATABASE."`.`user_access`.`account_active` = 'true'
AND `".AUTH_DATABASE."`.`user_access`.`organisation_id` = " . $ENTRADA_USER->getActiveOrganisation() . "
ORDER BY `fullname` ASC";
$results = ((USE_CACHE) ? $db->CacheGetAll(AUTH_CACHE_TIMEOUT, $query) : $db->GetAll($query));
if ($results) {
foreach ($results as $result) {
$course_directors[$result["proxy_id"]] = array('proxy_id'=>$result["proxy_id"], 'fullname'=>$result["fullname"], 'organisation_id'=>$result['organisation_id']);
}
$DIRECTOR_LIST = $course_directors;
}
$query = " SELECT `".AUTH_DATABASE."`.`user_data`.`id` AS `proxy_id`, CONCAT_WS(', ', `".AUTH_DATABASE."`.`user_data`.`lastname`, `".AUTH_DATABASE."`.`user_data`.`firstname`) AS `fullname`, `".AUTH_DATABASE."`.`organisations`.`organisation_id`
FROM `".AUTH_DATABASE."`.`user_data`
LEFT JOIN `".AUTH_DATABASE."`.`user_access`
ON `".AUTH_DATABASE."`.`user_access`.`user_id` = `".AUTH_DATABASE."`.`user_data`.`id`
LEFT JOIN `".AUTH_DATABASE."`.`organisations`
ON `".AUTH_DATABASE."`.`user_data`.`organisation_id` = `".AUTH_DATABASE."`.`organisations`.`organisation_id`
WHERE `".AUTH_DATABASE."`.`user_access`.`group` = 'staff'
AND `".AUTH_DATABASE."`.`user_access`.`role` = 'admin'
AND `".AUTH_DATABASE."`.`user_access`.`app_id` = '".AUTH_APP_ID."'
AND `".AUTH_DATABASE."`.`user_access`.`account_active` = 'true'
ORDER BY `fullname` ASC";
$results = ((USE_CACHE) ? $db->CacheGetAll(AUTH_CACHE_TIMEOUT, $query) : $db->GetAll($query));
if ($results) {
foreach ($results as $result) {
$curriculum_coordinators[$result["proxy_id"]] = array('proxy_id'=>$result["proxy_id"], 'fullname'=>$result["fullname"], 'organisation_id'=>$result['organisation_id']);
}
$COORDINATOR_LIST = $curriculum_coordinators;
}
/**
* Non-required field "associated_faculty" / Associated Faculty (array of proxy ids).
* This is actually accomplished after the event is inserted below.
*/
if ((isset($_POST["associated_director"]))) {
$associated_director = explode(',', $_POST["associated_director"]);
foreach ($associated_director as $contact_order => $proxy_id) {
if ($proxy_id = clean_input($proxy_id, array("trim", "int"))) {
$chosen_course_directors[(int) $contact_order] = $proxy_id;
}
}
} else {
$query = "SELECT * FROM `course_contacts` WHERE `course_id` = ".$db->qstr($COURSE_ID)." AND `contact_type` = 'director' ORDER BY `contact_order` ASC";
$results = $db->GetAll($query);
if ($results) {
foreach ($results as $result) {
$chosen_course_directors[$result["contact_order"]] = $course_directors[$result["proxy_id"]]["proxy_id"];
}
}
}
if ((isset($_POST["associated_coordinator"]))) {
$associated_coordinator = explode(',', $_POST["associated_coordinator"]);
foreach ($associated_coordinator as $contact_order => $proxy_id) {
if ($proxy_id = clean_input($proxy_id, array("trim", "int"))) {
$chosen_ccoordinators[] = $proxy_id;
}
}
} else {
$query = "SELECT * FROM `course_contacts` WHERE `course_id`=".$db->qstr($COURSE_ID)." AND `contact_type` = 'ccoordinator'";
$results = $db->GetAll($query);
if ($results) {
foreach ($results as $result) {
$chosen_ccoordinators[] = $result["proxy_id"];
}
}
}
// Compiles Program Coordinator list
$programcoodinators = array();
$query = " SELECT `".AUTH_DATABASE."`.`user_data`.`id` AS `proxy_id`, CONCAT_WS(', ', `".AUTH_DATABASE."`.`user_data`.`lastname`, `".AUTH_DATABASE."`.`user_data`.`firstname`) AS `fullname`,`".AUTH_DATABASE."`.`user_data`.`id`, `".AUTH_DATABASE."`.`organisations`.`organisation_title`
FROM `".AUTH_DATABASE."`.`user_data`
LEFT JOIN `".AUTH_DATABASE."`.`user_access`
ON `".AUTH_DATABASE."`.`user_access`.`user_id` = `".AUTH_DATABASE."`.`user_data`.`id`
LEFT JOIN `".AUTH_DATABASE."`.`organisations`
ON `".AUTH_DATABASE."`.`user_access`.`organisation_id` = `".AUTH_DATABASE."`.`organisations`.`organisation_id`
WHERE `".AUTH_DATABASE."`.`user_access`.`role` = 'pcoordinator'
AND `".AUTH_DATABASE."`.`user_access`.`app_id` = '".AUTH_APP_ID."'
AND `".AUTH_DATABASE."`.`user_access`.`account_active` = 'true'
AND `".AUTH_DATABASE."`.`user_access`.`organisation_id` = " . $ENTRADA_USER->getActiveOrganisation() . "
ORDER BY `fullname` ASC";
$results = ((USE_CACHE) ? $db->CacheGetAll(AUTH_CACHE_TIMEOUT, $query) : $db->GetAll($query));
if ($results) {
foreach ($results as $result) {
$programcoodinators[$result["proxy_id"]] = $result["fullname"]. ' (' . $result['organisation_title'].')';
}
}
// Compiles Evaluation Representative (evalrep_id) list
$evaluationreps = array();
$query = " SELECT `".AUTH_DATABASE."`.`user_data`.`id` AS `proxy_id`, CONCAT_WS(', ', `".AUTH_DATABASE."`.`user_data`.`lastname`, `".AUTH_DATABASE."`.`user_data`.`firstname`) AS `fullname`,`".AUTH_DATABASE."`.`user_data`.`id`, `".AUTH_DATABASE."`.`organisations`.`organisation_title`
FROM `".AUTH_DATABASE."`.`user_data`
LEFT JOIN `".AUTH_DATABASE."`.`user_access`
ON `".AUTH_DATABASE."`.`user_access`.`user_id` = `".AUTH_DATABASE."`.`user_data`.`id`
LEFT JOIN `".AUTH_DATABASE."`.`organisations`
ON `".AUTH_DATABASE."`.`user_data`.`organisation_id` = `".AUTH_DATABASE."`.`organisations`.`organisation_id`
WHERE `".AUTH_DATABASE."`.`user_access`.`group` = 'faculty'
AND `".AUTH_DATABASE."`.`user_access`.`app_id` = '".AUTH_APP_ID."'
AND `".AUTH_DATABASE."`.`user_access`.`account_active` = 'true'
ORDER BY `fullname` ASC";
$results = ((USE_CACHE) ? $db->CacheGetAll(AUTH_CACHE_TIMEOUT, $query) : $db->GetAll($query));
if ($results) {
foreach ($results as $result) {
$evaluationreps[$result["proxy_id"]] = $result["fullname"] . ' (' . $result['organisation_title'].')';
}
}
// Compiles Student Representative (evalrep_id) list
$studentreps = array();
$query = " SELECT `".AUTH_DATABASE."`.`user_data`.`id` AS `proxy_id`, CONCAT_WS(', ', `".AUTH_DATABASE."`.`user_data`.`lastname`, `".AUTH_DATABASE."`.`user_data`.`firstname`) AS `fullname`,`".AUTH_DATABASE."`.`user_data`.`id`, `".AUTH_DATABASE."`.`organisations`.`organisation_title`
FROM `".AUTH_DATABASE."`.`user_data`
LEFT JOIN `".AUTH_DATABASE."`.`user_access`
ON `".AUTH_DATABASE."`.`user_access`.`user_id` = `".AUTH_DATABASE."`.`user_data`.`id`
LEFT JOIN `".AUTH_DATABASE."`.`organisations`
ON `".AUTH_DATABASE."`.`user_data`.`organisation_id` = `".AUTH_DATABASE."`.`organisations`.`organisation_id`
WHERE `".AUTH_DATABASE."`.`user_access`.`group` = 'student'
AND `".AUTH_DATABASE."`.`user_access`.`app_id` = '".AUTH_APP_ID."'
AND `".AUTH_DATABASE."`.`user_access`.`account_active` = 'true'
ORDER BY `fullname` ASC";
$results = ((USE_CACHE) ? $db->CacheGetAll(AUTH_CACHE_TIMEOUT, $query) : $db->GetAll($query));
if ($results) {
foreach ($results as $result) {
$studentreps[$result["proxy_id"]] = $result["fullname"] . ' (' . $result['organisation_title'].')';
}
}
/**
* Compiles the list of students.
*/
$STUDENT_LIST = array();
$query = " SELECT a.`id` AS `proxy_id`, b.`role`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`, a.`organisation_id`
FROM `".AUTH_DATABASE."`.`user_data` AS a
LEFT JOIN `".AUTH_DATABASE."`.`user_access` AS b
ON a.`id` = b.`user_id`
WHERE b.`app_id` = ".$db->qstr(AUTH_APP_ID)."
AND b.`account_active` = 'true'
AND (b.`access_starts` = '0' OR b.`access_starts` <= ".$db->qstr(time()).")
AND (b.`access_expires` = '0' OR b.`access_expires` > ".$db->qstr(time()).")
AND b.`group` = 'student'
AND b.`role` >= '".(date("Y") - ((date("m") < 7) ? 2 : 1))."'
ORDER BY b.`role` ASC, a.`lastname` ASC, a.`firstname` ASC";
$results = $db->GetAll($query);
if ($results) {
foreach ($results as $result) {
$STUDENT_LIST[$result["proxy_id"]] = array('proxy_id' => $result["proxy_id"], 'fullname' => $result["fullname"], 'organisation_id' => $result['organisation_id']);
}
}
if (has_error()) {
echo display_error();
}
?>
<form class="form-horizontal" action="<?php echo ENTRADA_URL; ?>/admin/<?php echo $MODULE; ?>?<?php echo replace_query(array("step" => 2)); ?>" method="post" id="editCourseForm">
<h2 title="Course Details Section"><?php echo $module_singular_name; ?> Details</h2>
<div id="course-details-section">
<div class="control-group">
<label for="curriculum_type_id" class="control-label form-nrequired">Curriculum Category</label>
<div class="controls">
<select id="curriculum_type_id" name="curriculum_type_id" style="width: 250px" onchange="loadCurriculumPeriods(this.options[this.selectedIndex].value)">
<option value="0"<?php echo (((!isset($PROCESSED["curriculum_type_id"])) || (!(int) $PROCESSED["curriculum_type_id"])) ? " selected=\"selected\"" : ""); ?>>- Select Curriculum Category -</option>
<?php
$query = " SELECT a.* FROM `curriculum_lu_types` AS a
JOIN `curriculum_type_organisation` AS b
ON a.`curriculum_type_id` = b.`curriculum_type_id`
WHERE a.`curriculum_type_active` = 1
AND b.`organisation_id` = ".$db->qstr($ENTRADA_USER->getActiveOrganisation())."
ORDER BY `curriculum_type_order` ASC";
$results = $db->GetAll($query);
if ($results) {
foreach ($results as $result) {
echo "<option value=\"".(int) $result["curriculum_type_id"]."\"".(((isset($PROCESSED["curriculum_type_id"])) && ($PROCESSED["curriculum_type_id"] == $result["curriculum_type_id"])) ? " selected=\"selected\"" : "").">".html_encode($result["curriculum_type_name"])."</option>\n";
}
}
?>
</select>
</div>
</div>
<div class="control-group">
<label for="course_name" class="form-nrequired control-label"><?php echo $module_singular_name; ?> Name</label>
<div class="controls">
<input type="text" id="course_name" name="course_name" value="<?php echo html_encode($PROCESSED["course_name"]); ?>" maxlength="85" class="span7">
</div>
</div>
<div class="control-group">
<label for="course_code" class="form-nrequired control-label"><?php echo $module_singular_name; ?> Code</label>
<div class="controls">
<input type="text" id="course_code" name="course_code" value="<?php echo html_encode($PROCESSED["course_code"]); ?>" maxlength="16" class="span7">
</div>
</div>
<div class="control-group">
<label class="form-nrequired control-label">Reminder Notifications</label>
<div class="controls">
<label for="notification_on" class="radio">
<input type="radio" name="notifications" id="notification_on" value="1"<?php echo (((!isset($PROCESSED["notifications"])) || ((isset($PROCESSED["notifications"])) && ($PROCESSED["notifications"]))) ? " checked=\"checked\"" : ""); ?> />
Send e-mail notifications to faculty for events under this <?php echo strtolower($module_singular_name); ?>.
</label>
<label for="notification_off" class="radio">
<input type="radio" name="notifications" id="notification_off" value="0"<?php echo (((isset($PROCESSED["notifications"])) && (!(int) $PROCESSED["notifications"])) ? " checked=\"checked\"" : ""); ?> />
<strong>Do not</strong> send e-mail notifications to faculty for events under this <?php echo strtolower($module_singular_name); ?>.
</label>
</div>
</div>
<div class="control-group">
<label class="control-label form-nrequired"><?php echo $module_singular_name; ?> Permissions</label>
<div class="controls">
<label for="visibility_on" class="radio">
<input type="radio" name="permission" id="visibility_on" value="open"<?php echo (((!isset($PROCESSED["permission"])) || ((isset($PROCESSED["permission"])) && ($PROCESSED["permission"] == "open"))) ? " checked=\"checked\"" : ""); ?> />
This <?php echo strtolower($module_singular_name); ?> is <strong>open</strong> and visible to all logged in users.
</label>
<label for="visibility_off" class="radio">
<input type="radio" name="permission" id="visibility_off" value="closed"<?php echo (((isset($PROCESSED["permission"])) && ($PROCESSED["permission"] == "closed")) ? " checked=\"checked\"" : ""); ?> />
This <?php echo strtolower($module_singular_name); ?> is <strong>private</strong> and only visible to logged in users enrolled in the <?php echo strtolower($module_singular_name); ?>.
</label>
</div>
</div>
<script type="text/javascript">
jQuery(function($) {
$("input[name='sync_ldap']").on("change", function() {
if ($(this).val() == "1") {
$(".ldap-course-sync-list").slideDown("fast");
if ($("textarea[name='sync_ldap_courses']").val().length <= 0) {
$("textarea[name='sync_ldap_courses']").attr("value", $("#course_code").val());
}
} else {
$(".ldap-course-sync-list").slideUp("fast");
}
});
});
</script>
<div class="control-group">
<label class="control-label form-nrequired">Audience Sync</label>
<div class="controls">
<label for="sync_off" class="radio">
<input type="radio" name="sync_ldap" id="sync_off" value="0"<?php echo (((!isset($PROCESSED["sync_ldap"])) || (isset($PROCESSED["sync_ldap"])) && (!(int)$PROCESSED["sync_ldap"])) ? " checked=\"checked\"" : ""); ?> />The audience will be managed manually and <strong>should not</strong> be synced with the LDAP server.