-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
executable file
·1491 lines (1304 loc) · 69.7 KB
/
index.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
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2009 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
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 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: [email protected]
==============================================================================
*/
/**
* @package dokeos.main
* @author Patrick Cool <[email protected]>, Ghent University, Refactoring
* @version $Id: index.php 22368 2009-07-24 23:25:57Z iflorespaz $
* @todo check the different @todos in this page and really do them
* @todo check if the news management works as expected
*/
// only this script should have this constant defined. This is used to activate the javascript that
// gives the login name automatic focus in header.inc.html.
/** @todo Couldn't this be done using the $HtmlHeadXtra array? */
define('DOKEOS_HOMEPAGE', true);
// the language file
$language_file = array('courses', 'index', 'admin');
/* Flag forcing the 'current course' reset, as we're not inside a course anymore */
// maybe we should change this into an api function? an example: Coursemanager::unset();
$cidReset = true;
global $language_interface;
/*
-----------------------------------------------------------
Included libraries
-----------------------------------------------------------
*/
/** @todo make all the library files consistent, use filename.lib.php and not filename.lib.inc.php */
require_once 'main/inc/global.inc.php';
include_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
include_once api_get_path(LIBRARY_PATH) . 'debug.lib.inc.php';
include_once api_get_path(LIBRARY_PATH) . 'events.lib.inc.php';
include_once api_get_path(LIBRARY_PATH) . 'system_announcements.lib.php';
include_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
include_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
require_once (api_get_path(LIBRARY_PATH). 'language.lib.php');
require_once api_get_path(LIBRARY_PATH) . 'sublanguagemanager.lib.php';
require_once (api_get_path(LIBRARY_PATH). 'timezone.lib.php');
// for shopping cart & catalog
require_once api_get_path(SYS_PATH) . 'main/core/model/ecommerce/EcommerceCatalog.php';
require_once api_get_path(SYS_PATH) . 'main/core/controller/shopping_cart/shopping_cart_controller.php';
if (is_dir(api_get_path(SYS_PATH).'PRO')) {
if (isset($_GET['action']) && $_GET['action'] == 'makeitpro') {
header('Location: ' . api_get_path(WEB_PATH) . 'PRO/makeitpro.php?from=installdone');
exit;
}
}
define('PROMOTED', 1);
define('ACTIVE',1);
$theme_custom_index_page = array('orkyn_tablet');
$stylesheet = api_get_setting('stylesheets');
$is_customized = in_array($stylesheet, $theme_custom_index_page);
if ($is_customized) {
header('Location: custom_index.php');
exit;
}
//$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery-1.5.1.min.js" ></script>';
//Code changed like this for testing.
$htmlHeadXtra[] = '<link type="text/css" href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/thiagosf-SkitterSlideshow/css/skitter.styles.css" rel="stylesheet" />';
$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/thiagosf-SkitterSlideshow/js/jquery.skitter.min.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/general-functions.js" ></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery-ui/js/jquery-ui-1.8.1.custom.min.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery.form.js"></script>';
$htmlHeadXtra[] = '<link type="text/css" href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery-ui/css/ui-lightness/jquery-ui-1.8.1.custom.css" rel="stylesheet" />';
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css"/>';
$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.jquery.min.js" ></script>';
$slides_management_table = Database :: get_main_table(TABLE_MAIN_SLIDES_MANAGEMENT);
$rs = Database::query("SELECT * FROM $slides_management_table LIMIT 1");
$row = Database::fetch_array($rs);
$show_slide = $row['show_slide'];
$slide_speed = ($row['slide_speed'] == 0) ? 1 : $row['slide_speed'];
$slide_speed_millisec = intval($slide_speed) * 1000;
$htmlHeadXtra[] = '
<script type="text/javascript">
$(function() {
$("#accordion").accordion({
heightStyle: "content",
collapsible: true
});
});
</script>
<script type="text/javascript">
$(document).ready( function() {
$(".subscribeForm").ajaxForm(function(){
success: {
location.reload();
$("#confirmationSubs").val("sent");
document.confirmationForm.submit();
}
});
$(".chzn-select").chosen({no_results_text: "' . get_lang('NoResults') . '"});
if ($(".box_skitter_large").length > 0) {
$(".box_skitter_large").skitter({
animation: "random",
numbers_align: "center",
dots: true,
preview: true,
focus: false,
focus_position: "leftTop",
controls: false,
controls_position: "leftTop",
progressbar: false,
animateNumberOver: {"backgroundColor":"#555"},
enable_navigation_keys: true,
interval: ' . $slide_speed_millisec . '
});
}
});
</script>
<style type="text/css">
.smallwhite {
margin: 0px 15px !important;
}
</style>
';
$loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
// the section (for the tabs)
$this_section = SECTION_CAMPUS;
// Check if we have a CSS with tablet support
$css_info = array();
$css_info = api_get_css_info();
$css_type = !is_null($css_info['type']) ? $css_info['type'] : 'tablet';
/*
-----------------------------------------------------------
Action Handling
-----------------------------------------------------------
*/
/** @todo Wouldn't it make more sense if this would be done in local.inc.php so that local.inc.php become the only place where authentication is done?
* by doing this you could logout from any page instead of only from index.php. From the moment there is a logout=true in the url you will be logged out
* this can be usefull when you are on an open course and you need to log in to edit something and you immediately want to check how anonymous users
* will see it.
*/
$my_user_id = api_get_user_id();
// logout anonymous user
logout_anonymous();
if (!empty($_GET['logout'])) {
logout();
}
/*
-----------------------------------------------------------
Table definitions
-----------------------------------------------------------
*/
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
/*
-----------------------------------------------------------
Constants and CONFIGURATION parameters
-----------------------------------------------------------
*/
/** @todo these configuration settings should move to the dokeos config settings */
/** defines wether or not anonymous visitors can see a list of the courses on the Dokeos homepage that are open to the world */
$_setting['display_courses_to_anonymous_users'] = 'true';
/** @todo remove this piece of code because this is not used */
if (isset($_user['user_id'])) {
$nameTools = api_get_setting('siteName');
}
/*
==============================================================================
LOGIN
==============================================================================
*/
/**
* @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled.
* @todo consider removing this piece of code because does nothing.
*/
if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
// nice lie!!!
echo 'Attempted breakin - sysadmins notified.';
session_destroy();
die();
}
//Delete session neccesary for legal terms
if (api_get_setting('allow_terms_conditions') == 'true') {
unset($_SESSION['update_term_and_condition']);
unset($_SESSION['info_current_user']);
}
/**
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
* @todo check if this code is used. I think this code is never executed because after clicking the submit button
* the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
* on api_get_setting('page_after_login')
*/
if (!empty($_POST['submitAuth'])) {
// the user is already authenticated, we now find the last login of the user.
if (isset($_user['user_id'])) {
$sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
FROM $track_login_table
WHERE login_user_id = '" . $_user['user_id'] . "'
ORDER BY login_date DESC LIMIT 1";
$result_last_login = Database::query($sql_last_login, __FILE__, __LINE__);
if (!$result_last_login) {
if (Database::num_rows($result_last_login) > 0) {
$user_last_login_datetime = Database::fetch_array($result_last_login);
$user_last_login_datetime = $user_last_login_datetime[0];
api_session_register('user_last_login_datetime');
}
}
mysql_free_result($result_last_login);
//event_login();
if (api_is_platform_admin()) {
// decode all open event informations and fill the track_c_* tables
include api_get_path(LIBRARY_PATH) . 'stats.lib.inc.php';
decodeOpenInfos();
}
}
} // end login -- if ($_POST['submitAuth'])
else {
// only if login form was not sent because if the form is sent the user was already on the page.
event_open();
}
// the header
Display :: display_header('', 'dokeos');
if(isset($_SESSION["display_confirmation_message"])&&($_POST['confirmationSubs']!= '')){
Display :: display_confirmation_message2($_SESSION["display_confirmation_message"],false,true);
unset($_SESSION["display_confirmation_message"]);
}
echo '<form action='. api_get_self().' name="confirmationForm" method= "POST">';
echo '<input id="confirmationSubs" name="confirmationSubs" type="hidden" value= ""/>';
echo '</form>';
echo '<div id="content" class="maxcontent">';
// Plugins for loginpage_main AND campushomepage_main
if (!api_get_user_id()) {
api_plugin('loginpage_main');
} else {
api_plugin('campushomepage_main');
}
$home = 'home/';
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url_info = api_get_access_url($access_url_id);
// "http://" and the final "/" replaced
$url = substr($url_info['url'], 7, strlen($url_info['url']) - 8);
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url = $clean_url . '/';
$home_old = 'home/';
$home = 'home/' . $clean_url;
}
}
// Including the page for the news
$page_included = false;
$check1 = false;
$show_menu = true;
if ((api_is_allowed_to_create_course() || api_is_session_admin()) && ($_SESSION["studentview"] != "studentenview")) {
$show_menu = true;
}
if (!$show_menu) {
if (!($_user['user_id']) || api_is_anonymous($_user['user_id'])) {
} else {
$display_open_course = display_open_course(true);
$show_opened_courses = api_get_setting('show_opened_courses');
$display_open_course = isset($display_open_course) ? $display_open_course : false;
$show_opened_courses = isset($show_opened_courses) ? $show_opened_courses : false;
$check1 = ($display_open_course AND $show_opened_courses == 'true') ? (false) : (true);
}
}
$width = ($check1) ? "style='margin: auto!important;float:none;'" : "";
echo '<div id="content_with_menu" ' . $width . '>';
if (api_is_platform_admin()) {
echo '<div id="edit_homepage_bloc">
<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/configure_homepage.php">' . Display::return_icon('pixel.gif', get_lang('EditPublicPages'), array('class' => 'actionplaceholdericon actionedit', 'align' => 'middle')) . get_lang('EditPublicPages') . '</a>
</div>';
}
$slides_table = Database :: get_main_table(TABLE_MAIN_SLIDES);
if (isset($_REQUEST['language'])) {
$language = $_REQUEST['language'];
} else {
$language = api_get_interface_language();
// Check if current language has sublanguage
$language_id = api_get_language_id($language, false);
$sublanguages_info = SubLanguageManager::get_sublanguage_info_by_parent_id($language_id);
$platform_language = api_get_setting('platformLanguage');
if (!empty($sublanguages_info['dokeos_folder']) && $platform_language == $sublanguages_info['dokeos_folder']) {
$language = $sublanguages_info['dokeos_folder'];
}
}
$sql = "SELECT * FROM $slides_table ORDER BY display_order";
$res = Database::query($sql, __FILE__, __LINE__);
$num_of_slides_total = Database::num_rows($res);
$sql = "SELECT * FROM $slides_table WHERE language = '" . Database::escape_string(Security::remove_XSS($language)) . "' ORDER BY display_order";
$res = Database::query($sql, __FILE__, __LINE__);
$num_of_slides = Database::num_rows($res);
$slides = array();
$img_dir = api_get_path(WEB_PATH) . 'home/default_platform_document/';
if ($num_of_slides <> 0) {
while ($row = Database::fetch_array($res)) {
$image = $img_dir . $row['image'];
if (empty($row['title'])) {
$title = get_lang('Title');
} else {
$title = $row['title'];
}
if (empty($row['link'])) {
$link = '#';
} else {
$link = $row['link'];
}
if (empty($row['alternate_text'])) {
$alternate_text = get_lang('AltText');
} else {
$alternate_text = $row['alternate_text'];
}
$slides[] = array('image' => $image, 'title' => $title, 'link' => $link, 'caption' => $row['caption'], 'alttext' => $alternate_text);
}
} else {
// If don't exist slides in the site because is the first time
if ($num_of_slides_total == 0) {
// Get the array with the languages
$lang_array = api_get_languages();
// Loop for array with the languages
foreach ($lang_array['name'] as $key => $value) {
$sql = "SELECT * FROM $slides_table WHERE language = '" . Database::escape_string($lang_array["folder"][$key]) . "' ORDER BY display_order";
$res = Database::query($sql, __FILE__, __LINE__);
$num_rows = Database::num_rows($res);
if ($num_rows == 0) {
//Adding 3 default images into database
for ($i = 1; $i <= 3; $i++) {
// Set the text by default
$YourTitle = get_lang('YourTitle' . $i, 'DLTT', $lang_array["folder"][$key]);
$YourTitle = ($YourTitle == 'YourTitle' . $i) ? get_lang('YourTitle' . $i) : $YourTitle;
$AltText = get_lang('AltText' . $i, 'DLTT', $lang_array["folder"][$key]);
$AltText = ($AltText == 'AltText' . $i) ? get_lang('AltText' . $i) : $AltText;
$YourCaption = get_lang('YourCaption' . $i, 'DLTT', $lang_array["folder"][$key]);
$YourCaption = ($YourCaption == 'YourCaption' . $i) ? get_lang('YourCaption' . $i) : $YourCaption;
$sql = "INSERT INTO $slides_table(title,alternate_text,link,caption,image,language,display_order)
VALUES('" . Database::escape_string($YourTitle) . "',
'" . Database::escape_string($AltText) . "',
'#',
'" . Database::escape_string($YourCaption) . "',
'" . substr($lang_array["folder"][$key], 0, 3) . "_slide0$i.jpg',
'" . Database::escape_string($lang_array["folder"][$key]) . "','$i')";
Database::query($sql, __FILE__, __LINE__);
$updir = api_get_path(SYS_PATH) . 'home/default_platform_document/';
$thumbdir = api_get_path(SYS_PATH) . 'home/default_platform_document/template_thumb/';
// Makes a copy of the file source to dest
@copy($thumbdir . 'thumb_slide0' . $i . '.jpg', $thumbdir . 'thumb_' . substr($lang_array["folder"][$key], 0, 3) . '_slide0' . $i . '.jpg');
@copy($updir . 'slide0' . $i . '.jpg', $updir . substr($lang_array["folder"][$key], 0, 3) . '_slide0' . $i . '.jpg');
}
}
}
$pref_lang = substr(api_get_interface_language(), 0, 3);
$slides[] = array('image' => $img_dir . $pref_lang . '_slide01.jpg', 'title' => get_lang('YourTitle1'), 'link' => '#', 'caption' => get_lang('YourCaption1'), 'alttext' => get_lang('AltText1'));
$slides[] = array('image' => $img_dir . $pref_lang . '_slide02.jpg', 'title' => get_lang('YourTitle2'), 'link' => '#', 'caption' => get_lang('YourCaption2'), 'alttext' => get_lang('AltText2'));
$slides[] = array('image' => $img_dir . $pref_lang . '_slide03.jpg', 'title' => get_lang('YourTitle3'), 'link' => '#', 'caption' => get_lang('YourCaption3'), 'alttext' => get_lang('AltText3'));
$show_slide = 1;
$sql = "SELECT * FROM $slides_table WHERE language = '" . Database::escape_string($language) . "' ORDER BY display_order";
$res = Database::query($sql, __FILE__, __LINE__);
$num_of_slides = Database::num_rows($res);
} else if ($num_of_slides == 0 && $num_of_slides_total > 0) {
// Get the array with the languages
global $language_interface;
// Loop for array with the languages
$sql = "SELECT * FROM $slides_table WHERE language = '" . Database::escape_string($language_interface) . "' ORDER BY display_order";
$res = Database::query($sql, __FILE__, __LINE__);
$num_rows = Database::num_rows($res);
if ($num_rows == 0) {
//Adding 3 default images into database
for ($i = 1; $i <= 3; $i++) {
// Set the text by default
$YourTitle = get_lang('YourTitle' . $i, 'DLTT', $lang_array["folder"][$key]);
$YourTitle = ($YourTitle == 'YourTitle' . $i) ? get_lang('YourTitle' . $i) : $YourTitle;
$AltText = get_lang('AltText' . $i, 'DLTT', $lang_array["folder"][$key]);
$AltText = ($AltText == 'AltText' . $i) ? get_lang('AltText' . $i) : $AltText;
$YourCaption = get_lang('YourCaption' . $i, 'DLTT', $lang_array["folder"][$key]);
$YourCaption = ($YourCaption == 'YourCaption' . $i) ? get_lang('YourCaption' . $i) : $YourCaption;
$sql = "INSERT INTO $slides_table(title,alternate_text,link,caption,image,language,display_order)
VALUES('" . Database::escape_string($YourTitle) . "',
'" . Database::escape_string($AltText) . "',
'#',
'" . Database::escape_string($YourCaption) . "',
'" . substr($language_interface, 0, 3) . "_slide0$i.jpg',
'" . Database::escape_string($language_interface) . "','$i')";
Database::query($sql, __FILE__, __LINE__);
$updir = api_get_path(SYS_PATH) . 'home/default_platform_document/';
$thumbdir = api_get_path(SYS_PATH) . 'home/default_platform_document/template_thumb/';
// Makes a copy of the file source to dest
@copy($thumbdir . 'thumb_slide0' . $i . '.jpg', $thumbdir . 'thumb_' . substr($language_interface, 0, 3) . '_slide0' . $i . '.jpg');
@copy($updir . 'slide0' . $i . '.jpg', $updir . substr($language_interface, 0, 3) . '_slide0' . $i . '.jpg');
}
}
$pref_lang = substr(api_get_interface_language(), 0, 3);
$slides[] = array('image' => $img_dir . $pref_lang . '_slide01.jpg', 'title' => get_lang('YourTitle1'), 'link' => '#', 'caption' => get_lang('YourCaption1'), 'alttext' => get_lang('AltText1'));
$slides[] = array('image' => $img_dir . $pref_lang . '_slide02.jpg', 'title' => get_lang('YourTitle2'), 'link' => '#', 'caption' => get_lang('YourCaption2'), 'alttext' => get_lang('AltText2'));
$slides[] = array('image' => $img_dir . $pref_lang . '_slide03.jpg', 'title' => get_lang('YourTitle3'), 'link' => '#', 'caption' => get_lang('YourCaption3'), 'alttext' => get_lang('AltText3'));
$show_slide = 1;
$sql = "SELECT * FROM $slides_table WHERE language = '" . Database::escape_string($language_interface) . "' ORDER BY display_order";
$res = Database::query($sql, __FILE__, __LINE__);
$num_of_slides = Database::num_rows($res);
}
}
if (empty($_GET['action']) && $show_slide == 1 && $num_of_slides > 0) {
echo '<div id="container"><div class="box_skitter box_skitter_large"><ul>';
foreach ($slides as $slide) {
echo '<li>';
$slide_content = '{img}';
if (!empty($slide['link']) && $slide['link'] != '#') {
$slide_content = '<a href="' . $slide['link'] . '" title="' . $slide['title'] . '">{img}</a>';
}
echo str_replace('{img}', '<img src="' . $slide['image'] . '" width="720" height="240" title="' . $slide['title'] . '" alt="' . $slide['alttext'] . '" />', $slide_content);
echo '<div class="label_text">';
if (!empty($slide['caption'])) {
echo '<p>' . $slide['caption'] . '</p>';
}
echo '</div>';
echo '</li>';
}
echo '</ul></div></div>';
//slider ends here
}
/* Home custom html */
if (!empty($_GET['action']) && ($_GET['action']=='show')) {
echo '<div ' . $extra_style . '>';
$id= intval($_GET['nodeId']);
$sql = 'SELECT content FROM '.TABLE_MAIN_NODE.' WHERE id='. $id;
$res = Database::query($sql);
while ($row = Database::fetch_array($res)){
echo $row['content'];
}
//echo $contents;
echo '</div>';
//$page_included = true;
} else {
$count_lang_availables = LanguageManager::count_available_languages();
if (!empty($_SESSION['user_language_choice']) && $count_lang_availables > 1) {
$user_selected_language = $_SESSION['user_language_choice'];
} else {
$user_selected_language = api_get_setting('platformLanguage');
}
?>
<div style="margin: auto auto auto 15px; width: 720px;">
<div>
<?php
$language_id = api_get_language_id($language_interface);
$accessUrlId = api_get_current_access_url_id();
if ($accessUrlId< 0) {
$accessUrlId = 1;
}
$tblNode =Database :: get_main_table(TABLE_MAIN_NODE);
$tblHomePageNode = Database :: get_main_table(TABLE_MAIN_NODE_HOMEPAGE);
$sqlProm = "SELECT n.content, n.title, n.display_title
FROM $tblNode n
INNER JOIN $tblHomePageNode h
ON (n.id = h.node_id)
WHERE h.promoted = ".PROMOTED."
AND n.language_id IN (". $language_id.",0)
AND n.access_url_id =".$accessUrlId."
AND n.active = 1
AND n.enabled= 1";
$results = Database::query($sqlProm, __FILE__, __LINE__);
echo '<table>';
echo '<style>#content{background:#ffffff !important;}</style>';
while ($row = Database::fetch_array($results))
{
if($row['display_title'] == 1) {
echo '<tr><th class="title-pages-home">';
echo '<div>'.$row['title'].'</div>';
echo '</th></tr>';
}
echo '<tr><td>';
echo '<div>'. str_replace('{WEB_PATH}', api_get_path(WEB_PATH), $row['content']) .'</div>';
echo '</td></tr>';
}
echo '</table>';
?>
</div>
<?php
$user_info = api_get_user_info(api_get_user_id());
$now = date('Y:m:d H:i:s');
$status = $user_info['status'];
$visible_by_learner = ($status == STUDENT)? 1 : -1;
$visible_by_trainer = ($status == COURSEMANAGER)? 1 : -1;
$tblNews=Database::get_main_table(TABLE_MAIN_NODE_NEWS);
$sqlNews = "SELECT node.id,
node.title,
node.content,
news.start_date,
news.end_date
FROM $tblNode node INNER JOIN $tblNews news
ON (node.id=news.node_id)
WHERE node.active = 1
AND node.language_id IN (". $language_id.",0)
AND node.access_url_id =".$accessUrlId."
AND node.enabled = 1
AND '$now' BETWEEN news.start_date AND news.end_date
AND (visible_by_trainer=". $visible_by_trainer ."
OR visible_by_learner=". $visible_by_learner ."
OR visible_by_guest=1)
ORDER BY
news.start_date DESC";
$isIE89 = api_get_navigator();
$resultsNews = Database::query($sqlNews, __FILE__, __LINE__);
$num = Database::num_rows($resultsNews);
if ($num>0){
if (api_get_setting('stylesheets') == 'dokeos2_roullier') { // added old news block for customized clients (example: roullier), it should be other setting.
echo '<div class="sectiontitle portal_news">';
echo '<div class="system_announcements">';
echo '<h2><strong>'.get_lang('SystemAnnouncements').'</strong></h2>';
echo '<table border="0">';
while ($row = Database::fetch_array($resultsNews)) {
echo '<tr class="system_announcement">
<td width="80px" valign="top" class="system_announcement_title">'
.date('d-m-Y', strtotime($row['start_date'])).'
</td>
<td valign="top">
<a name="ann'.$row['id'].'" href="'.api_get_path(WEB_PATH).'news_list.php#'.$row['id'].'">'.$row['title'].'</a>
</td>
</tr>';
}
echo '<tr><td colspan="2">';
echo '<a class="btn-announcement" href="'.api_get_path(WEB_PATH).'news_list.php">'.get_lang("More").'</a>';
echo '</td></tr>';
echo '</table>';
echo '</div>';
echo '</div>';
}
else {
echo '<div class="portal-news-wrapper">';
echo '<div class="wrapper-tag"><div class="a1"></div><div class="a2">'. get_lang('SystemAnnouncements').'</div><div class="a3"></div><div class="a4"></div> </div>';
echo '<div id="accordion">';
while ($row = Database::fetch_array($resultsNews)) {
echo '<h3> <a href="#">' . $row['title'] . '</a></h3>';
$isIframe = preg_match("/<iframe/", $row['content']);
if ($isIframe == 1){
if($isIE89['shortname']=='msie'){
echo '<script type="text/javascript">$("embed").css("height","300")</script>';
}
}
echo '<div><p>'. TimeZone::ConvertTimeFromServerToUser(api_get_user_id(), $row['start_date']).'</p><p>'. $row['content'] . '</p></div>';
}
echo '</div>';
echo '</div>';
}
}
?>
</div>
<?php
}
echo '</div>';
$show_menu = false;
if ((api_is_allowed_to_create_course() || api_is_session_admin()) && ($_SESSION["studentview"] != "studentenview")) {
$show_menu = true;
}
if ($show_menu) {
echo '<div class="menu" id="menu">';
display_anonymous_menu();
if (api_get_setting('show_opened_courses') == 'true') {
display_open_course();
}
echo '</div>';
} else {
if (!($_user['user_id']) || api_is_anonymous($_user['user_id'])) {
echo '<div class="menu" id="menu">';
display_anonymous_menu();
if (api_get_setting('show_opened_courses') == 'true') {
display_open_course();
}
echo '</div>';
} else {
/*$show_opened_courses = api_get_setting('show_opened_courses');
$display_open_course = display_open_course($);*/
echo '<div class="menu" id="menu">';
display_anonymous_menu();
if (api_get_setting('show_opened_courses') == 'true') {
display_open_course();
}
echo '</div>';
}
}
function check_left_empty() {
if (!($_user['user_id']) || api_is_anonymous($_user['user_id'])) {
$login = true;
} else {
$login = false;
}
$show_opened_courses = api_get_setting('show_opened_courses');
$display_open_course = display_open_course(true);
$display_open_course = ($display_open_course == 0) ? true : false;
if ($display_open_course AND $login AND $show_opened_courses) {
return true;
} else {
return false;
}
}
function display_open_course($count = false) {
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT * FROM $tbl_course WHERE visibility = 3";
if (isset($_SESSION['_user']['user_id']) && $_SESSION['_user']['user_id'] != 0) {
$sql = "SELECT * FROM $tbl_course WHERE visibility = 3 or visibility=2";
}
$res = Database::query($sql, __FILE__, __LINE__);
$num_rows = Database::num_rows($res);
if ($count) {
return $num_rows;
}
if ($num_rows <> 0) {
echo '<div class="menu" id="menu">';
echo "<div class=\"section\">";
echo '<div class="row"><div class="form_header">' . get_lang('OpenCourses') . '</div></div><br />';
echo " <div class=\"sectioncontent\">";
while ($row = Database::fetch_array($res)) {
$title = $row['title'];
$directory = $row['directory'];
echo '<a href="' . api_get_path(WEB_COURSE_PATH) . $directory . '/?id_session=0"><img alt="' . $title . '" title="' . $title . '" src="main/img/catalogue_22.png" style="vertical-align:text-bottom;" /> ' . $title . '</a><br />';
}
echo '</div></div></div>';
echo '</div>';
}
}
echo '</div>';
// display the footer
Display :: display_footer();
function logout_anonymous() {
$anonymous_uid = api_get_anonymous_id();
$logged_uid = api_get_user_id();
if (api_is_anonymous($logged_uid, true)) {
api_session_unregister('_user');
}
}
/**
* This function handles the logout and is called whenever there is a $_GET['logout']
*
* @author Patrick Cool <[email protected]>, Ghent University
*/
function logout() {
global $_configuration, $extAuthSource;
// variable initialisation
$query_string = '';
if (!empty($_SESSION['user_language_choice'])) {
$query_string = '?language=' . $_SESSION['user_language_choice'];
}
// Database table definition
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
// selecting the last login of the user
$uid = intval($_GET['uid']);
$sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='$uid' ORDER BY login_date DESC LIMIT 0,1";
$q_last_connection = Database::query($sql_last_connection, __FILE__, __LINE__);
if (Database::num_rows($q_last_connection) > 0) {
$i_id_last_connection = Database::result($q_last_connection, 0, 'login_id');
}
if (!isset($_SESSION['login_as'])) {
$current_date = date('Y-m-d H:i:s', time());
$s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date='" . $current_date . "' WHERE login_id='$i_id_last_connection'";
Database::query($s_sql_update_logout_date, __FILE__, __LINE__);
}
LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
//the following code enables the use of an external logout function.
//example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
// then a function called ldap_logout() inside that file
// (using *authent_name*_logout as the function name) and the following code
// will find and execute it
$uinfo = api_get_user_info($uid);
if (($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) && is_array($extAuthSource)) {
if (is_array($extAuthSource[$uinfo['auth_source']])) {
$subarray = $extAuthSource[$uinfo['auth_source']];
if (!empty($subarray['logout']) && file_exists($subarray['logout'])) {
include_once ($subarray['logout']);
$logout_function = $uinfo['auth_source'] . '_logout';
if (function_exists($logout_function)) {
$logout_function($uinfo);
}
}
}
}
if (api_get_setting('cas_activate') == 'true') {
require_once(api_get_path(SYS_PATH) . 'main/auth/cas/authcas.php');
if (cas_is_authenticated() != false) {
error_log('cas log out');
cas_logout();
}
}
api_session_destroy();
header("Location: index.php$query_string");
exit();
}
/**
* This function checks if there are courses that are open to the world in the platform course categories (=faculties)
*
* @param unknown_type $category
* @return boolean
*/
function category_has_open_courses($category) {
global $setting_show_also_closed_courses;
$user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'";
$sql_result = Database::query($sql_query, __FILE__, __LINE__);
while ($course = Database::fetch_array($sql_result)) {
if (!$setting_show_also_closed_courses) {
if ((api_get_user_id() > 0 && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
return true; //at least one open course
}
} else {
if (isset($course['visibility'])) {
return true; //at least one course (does not matter weither it's open or not because $setting_show_also_closed_courses = true
}
}
}
return false;
}
function display_create_course_link() {
echo "<li><a href=\"main/create_course/add_course.php\">" . get_lang("CourseCreate") . "</a></li>";
}
function display_edit_course_list_links() {
echo "<li><a href=\"main/auth/courses.php\">" . get_lang("SortMyCourses") . "</a></li>";
}
/**
* Trainers manual, Video tutorials and Trainers training is displayed.
*
* @author Ricardo Garcia Rodriguez <[email protected]>
*/
function display_trainer_links() {
$user_selected_language = api_get_interface_language();
if (!isset($user_selected_language)) {
$user_selected_language = api_get_setting('platformLanguage');
}
$trainers_training_link = 'http://www.dokeos.com/en/training/';
if ($user_selected_language == "french") {
$trainers_training_link = 'http://www.dokeos.com/fr/training/';
}
echo "<li><a href=\"http://www.dokeos.com/en/trainer-manual/\">" . get_lang('TrainersManual') . "</a></li>";
echo "<li><a href=\"http://www.dokeos.com/en/video-tutorials/\">" . get_lang('VideoTutorials') . "</a></li>";
echo "<li><a href=\"" . $trainers_training_link . "\">" . get_lang('TrainersTraining') . "</a></li>";
}
function display_logo_dokeos(){
$html .= '<div class="dokeos-logo">';
$html .= '<a href="http://www.dokeos.com" target="_blank" >';
$html .= '<img alt="www.dokeos.com" title="www.dokeos.com" src="' . api_get_path(WEB_IMG_PATH) . 'logo-dokeos-icon-4.png" />' . get_lang('dokeos');
$html .= '</a>';
$html .= '</div>';
return $html;
}
function display_like_on_socialred(){
$user_selected_language = api_get_interface_language();
if (!isset($user_selected_language)) {
$user_selected_language = api_get_setting('platformLanguage');
}
switch($user_selected_language){
case 'french':
$dokeosclub = "http://www.facebook.com/dokeosclub.fr";
$language = "fr_FR";
break;
case 'spanish':
$dokeosclub = "http://www.facebook.com/dokeoslatino";
$language = "es_LA";
break;
default:
$dokeosclub = "http://www.facebook.com/dokeosclub.en";
$language = "en_EN";
break;
}
$like .= '<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/'.$language.'/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));</script>';
$like .= '<div class="fb-like" data-href="'.$dokeosclub.'" data-send="false" data-layout="box_count" data-width="450" data-show-faces="false"></div>';
$html = (!empty($user_selected_language)) ? '<div style="float: right;width: auto;" >'.$like.'</div>' : '';
$likeOnSocialRed = api_get_setting('show_like_on_facebook');
if($likeOnSocialRed == 'true'){
return $html;
}
}
/**
* Displays the menu for anonymous users:
* login form, useful links, help section
* Warning: function defines globals
* @version 1.0.1
* @todo does $_plugins need to be global?
*/
if (api_get_setting('display_catalog_on_homepage') == 'true' && api_get_setting('enable_shop_tool') == 'true') {
echo '<input type="hidden" name="varLangStart" id="varLangStart" value="' . get_lang('FirstPage') . '" />';
echo '<input type="hidden" name="varLangEnd" id="varLangEnd" value="' . get_lang('LastPage') . '" />';
}
function display_anonymous_menu() {
global $loginFailed, $_plugins, $_user, $menu_navigation, $css_type;
global $home, $home_old;
// language
$platformLanguage = api_get_setting('platformLanguage');
$user_selected_language = api_get_interface_language();
if (!isset($user_selected_language)) {
$user_selected_language = $platformLanguage;
}
$language_id = api_get_language_id($user_selected_language);
// access url id
$accessUrlId = api_get_current_access_url_id();
if ($accessUrlId< 0) {
$accessUrlId = 1;
}
if (!($_user['user_id']) || api_is_anonymous($_user['user_id'])) { // only display if the user isn't logged in
display_login_form();
if ($loginFailed) {
handle_login_failed();
}
if (api_number_of_plugins('loginpage_menu') > 0) {
echo '<div class="note" style="background: none">';
api_plugin('loginpage_menu');
echo '</div>';
}
}
if (api_get_setting('display_categories_on_homepage') == 'true') {
echo '<div class="section">';
display_anonymous_course_list();
echo '</div>';
}
if (isset($_SESSION['_user']['user_id']) && $_SESSION['_user']['user_id'] != 0) {
$show_menu = false;
$show_course_link = false;
if ((api_is_allowed_to_create_course() || api_is_session_admin()) && ($_SESSION["studentview"] != "studentenview")) {
$show_menu = true;
}
if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
$show_course_link = true;
} else {
if (api_get_setting('allow_students_to_browse_courses') == 'true') {
$show_course_link = true;
}
}
if ($show_menu) {
echo "<div class=\"section overflow\">";
if ($css_type == 'tablet') {
echo api_display_tool_title(get_lang('MenuUser'), 'tablet_title');
display_create_course_link_tablet();
if ($show_digest_link) {
display_digest($toolsList, $digest, $orderKey, $courses);
}
} else {
echo " <div class='sectiontitle'>" . get_lang("MenuUser") . "</div>";
echo " <div class='sectioncontent'>";
echo " <ul class='menulist nobullets'>";
display_create_course_link();
echo " </ul>";
echo " </div>";
}
echo '</div>';
}
if (!empty($menu_navigation)) {
echo "<div class='section'>";
echo "<div class='sectiontitle'>" . get_lang("MainNavigation") . "</div>";
echo '<div class="sectioncontent">';
echo "<ul class='menulist nobullets'>";
foreach ($menu_navigation as $section => $navigation_info) {
$current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
echo '<li' . $current . '>';
echo '<a href="' . $navigation_info['url'] . '" target="_self">' . $navigation_info['title'] . '</a>';