|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Class IndexManager |
|
6
|
|
|
*/ |
|
7
|
|
|
class IndexManager |
|
8
|
|
|
{ |
|
9
|
|
|
const VIEW_BY_DEFAULT = 0; |
|
10
|
|
|
const VIEW_BY_SESSION = 1; |
|
11
|
|
|
|
|
12
|
|
|
// An instance of the template engine |
|
13
|
|
|
public $tpl = false; |
|
14
|
|
|
public $name = ''; |
|
15
|
|
|
public $home = ''; |
|
16
|
|
|
public $default_home = 'home/'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Construct |
|
20
|
|
|
* @param string $title |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct($title) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->tpl = new Template($title); |
|
|
|
|
|
|
25
|
|
|
$this->home = api_get_home_path(); |
|
26
|
|
|
$this->user_id = api_get_user_id(); |
|
27
|
|
|
$this->load_directories_preview = false; |
|
28
|
|
|
|
|
29
|
|
|
if (api_get_setting('show_documents_preview') == 'true') { |
|
30
|
|
|
$this->load_directories_preview = true; |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param bool $setLoginForm |
|
36
|
|
|
*/ |
|
37
|
|
|
function set_login_form($setLoginForm = true) |
|
38
|
|
|
{ |
|
39
|
|
|
global $loginFailed; |
|
40
|
|
|
$this->tpl->setLoginForm($setLoginForm); |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function return_exercise_block($personal_course_list) |
|
44
|
|
|
{ |
|
45
|
|
|
$exercise_list = array(); |
|
46
|
|
|
if (!empty($personal_course_list)) { |
|
47
|
|
|
foreach($personal_course_list as $course_item) { |
|
48
|
|
|
$course_code = $course_item['c']; |
|
49
|
|
|
$session_id = $course_item['id_session']; |
|
50
|
|
|
|
|
51
|
|
|
$exercises = ExerciseLib::get_exercises_to_be_taken( |
|
52
|
|
|
$course_code, |
|
53
|
|
|
$session_id |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
foreach($exercises as $exercise_item) { |
|
57
|
|
|
$exercise_item['course_code'] = $course_code; |
|
58
|
|
|
$exercise_item['session_id'] = $session_id; |
|
59
|
|
|
$exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC'); |
|
60
|
|
|
|
|
61
|
|
|
$exercise_list[] = $exercise_item; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
if (!empty($exercise_list)) { |
|
65
|
|
|
$exercise_list = msort($exercise_list, 'tms'); |
|
66
|
|
|
$my_exercise = $exercise_list[0]; |
|
67
|
|
|
$url = Display::url($my_exercise['title'], api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id']); |
|
68
|
|
|
$this->tpl->assign('exercise_url', $url); |
|
|
|
|
|
|
69
|
|
|
$this->tpl->assign('exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT)); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
function return_announcements($show_slide = true) |
|
75
|
|
|
{ |
|
76
|
|
|
//// Display System announcements |
|
77
|
|
|
$hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected'); |
|
78
|
|
|
$currentUserId = api_get_user_id(); |
|
79
|
|
|
if ($hideAnnouncements == 'true' && empty($currentUserId)) { |
|
80
|
|
|
return null; |
|
81
|
|
|
} |
|
82
|
|
|
$announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null; |
|
83
|
|
|
$announcement = intval($announcement); |
|
84
|
|
|
|
|
85
|
|
|
if (!api_is_anonymous() && $this->user_id) { |
|
86
|
|
|
$visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT; |
|
87
|
|
|
if ($show_slide) { |
|
88
|
|
|
$announcements = SystemAnnouncementManager:: display_announcements_slider( |
|
89
|
|
|
$visibility, |
|
90
|
|
|
$announcement |
|
91
|
|
|
); |
|
92
|
|
|
} else { |
|
93
|
|
|
$announcements = SystemAnnouncementManager:: display_all_announcements( |
|
94
|
|
|
$visibility, |
|
95
|
|
|
$announcement |
|
96
|
|
|
); |
|
97
|
|
|
} |
|
98
|
|
|
} else { |
|
99
|
|
|
if ($show_slide) { |
|
100
|
|
|
$announcements = SystemAnnouncementManager:: display_announcements_slider( |
|
101
|
|
|
SystemAnnouncementManager::VISIBLE_GUEST, |
|
102
|
|
|
$announcement |
|
103
|
|
|
); |
|
104
|
|
|
} else { |
|
105
|
|
|
$announcements = SystemAnnouncementManager:: display_all_announcements( |
|
106
|
|
|
SystemAnnouncementManager::VISIBLE_GUEST, |
|
107
|
|
|
$announcement |
|
108
|
|
|
); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
return $announcements; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Alias for the online_logout() function |
|
117
|
|
|
* @param bool $redirect Whether to ask online_logout to redirect to index.php or not |
|
118
|
|
|
*/ |
|
119
|
|
|
function logout($redirect = true) |
|
120
|
|
|
{ |
|
121
|
|
|
online_logout($this->user_id, true); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* This function checks if there are courses that are open to the world in the platform course categories (=faculties) |
|
126
|
|
|
* |
|
127
|
|
|
* @param string $category |
|
128
|
|
|
* @return boolean |
|
129
|
|
|
*/ |
|
130
|
|
|
function category_has_open_courses($category) |
|
131
|
|
|
{ |
|
132
|
|
|
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; |
|
133
|
|
|
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
134
|
|
|
$category = Database::escape_string($category); |
|
135
|
|
|
$sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'"; |
|
136
|
|
|
$sql_result = Database::query($sql_query); |
|
137
|
|
|
while ($course = Database::fetch_array($sql_result)) { |
|
138
|
|
|
if (!$setting_show_also_closed_courses) { |
|
139
|
|
|
if ((api_get_user_id() > 0 && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { |
|
140
|
|
|
return true; //at least one open course |
|
141
|
|
|
} |
|
142
|
|
|
} else { |
|
143
|
|
|
if (isset($course['visibility'])) { |
|
144
|
|
|
return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true). |
|
145
|
|
|
} |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
return false; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
function return_teacher_link() |
|
153
|
|
|
{ |
|
154
|
|
|
$html = ''; |
|
155
|
|
|
$show_menu = false; |
|
156
|
|
|
if (!empty($this->user_id)) { |
|
157
|
|
|
// tabs that are deactivated are added here |
|
158
|
|
|
|
|
159
|
|
|
$show_menu = false; |
|
160
|
|
|
$show_create_link = false; |
|
161
|
|
|
$show_course_link = false; |
|
162
|
|
|
|
|
163
|
|
|
if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { |
|
164
|
|
|
$show_menu = true; |
|
165
|
|
|
$show_course_link = true; |
|
166
|
|
|
$show_create_link = true; |
|
167
|
|
|
} else { |
|
168
|
|
|
if (api_get_setting('allow_students_to_browse_courses') == 'true') { |
|
169
|
|
|
$show_menu = true; |
|
170
|
|
|
$show_course_link = true; |
|
171
|
|
|
} |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
if ($show_menu && ($show_create_link || $show_course_link )) { |
|
175
|
|
|
$show_menu = true; |
|
176
|
|
|
} else { |
|
177
|
|
|
$show_menu = false; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
// My Account section |
|
182
|
|
|
|
|
183
|
|
|
if ($show_menu) { |
|
184
|
|
|
$html .= '<ul class="nav nav-pills nav-stacked">'; |
|
185
|
|
|
if ($show_create_link) { |
|
186
|
|
|
$html .= '<li class="add-course"><a href="' . api_get_path(WEB_CODE_PATH) . 'create_course/add_course.php">'.Display::return_icon('new-course.png', get_lang('CourseCreate')).(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>'; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
if ($show_course_link) { |
|
190
|
|
|
if (!api_is_drh() && !api_is_session_admin()) { |
|
191
|
|
|
$html .= '<li class="list-course"><a href="'. api_get_path(WEB_CODE_PATH) . 'auth/courses.php">'. Display::return_icon('catalog-course.png', get_lang('CourseCatalog')) .get_lang('CourseCatalog').'</a></li>'; |
|
192
|
|
|
} else { |
|
193
|
|
|
$html .= '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'dashboard/index.php">'.get_lang('Dashboard').'</a></li>'; |
|
194
|
|
|
} |
|
195
|
|
|
} |
|
196
|
|
|
$html .= '</ul>'; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
if (!empty($html)) { |
|
200
|
|
|
$html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block', null, 'teachers', 'teachersCollapse'); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
return $html; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Includes a created page |
|
208
|
|
|
* @return string |
|
209
|
|
|
*/ |
|
210
|
|
|
public function return_home_page() |
|
211
|
|
|
{ |
|
212
|
|
|
$userId = api_get_user_id(); |
|
213
|
|
|
// Including the page for the news |
|
214
|
|
|
$html = ''; |
|
215
|
|
|
|
|
216
|
|
|
if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { |
|
217
|
|
|
$open = @(string)file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']); |
|
218
|
|
|
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
|
219
|
|
|
} else { |
|
220
|
|
|
// Hiding home top when user not connected. |
|
221
|
|
|
$hideTop = api_get_setting('hide_home_top_when_connected'); |
|
222
|
|
|
if ($hideTop == 'true' && !empty($userId)) { |
|
223
|
|
|
return $html; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
View Code Duplication |
if (!empty($_SESSION['user_language_choice'])) { |
|
227
|
|
|
$user_selected_language = $_SESSION['user_language_choice']; |
|
228
|
|
|
} elseif (!empty($_SESSION['_user']['language'])) { |
|
229
|
|
|
$user_selected_language = $_SESSION['_user']['language']; |
|
230
|
|
|
} else { |
|
231
|
|
|
$user_selected_language = api_get_setting('platformLanguage'); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
$home_top_temp = ''; |
|
235
|
|
|
|
|
236
|
|
|
// Try language specific home |
|
237
|
|
|
if (file_exists($this->home.'home_top_'.$user_selected_language.'.html')) { |
|
238
|
|
|
$home_top_temp = file_get_contents($this->home.'home_top_'.$user_selected_language.'.html'); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
// Try default language home |
|
242
|
|
|
if (empty($home_top_temp)) { |
|
243
|
|
|
if (file_exists($this->home.'home_top.html')) { |
|
244
|
|
|
$home_top_temp = file_get_contents($this->home.'home_top.html'); |
|
245
|
|
|
} else { |
|
246
|
|
|
if (file_exists($this->default_home.'home_top.html')) { |
|
247
|
|
|
$home_top_temp = file_get_contents($this->default_home . 'home_top.html'); |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
if (trim($home_top_temp) == '' && api_is_platform_admin()) { |
|
253
|
|
|
$home_top_temp = '<div class="welcome-mascot">' . get_lang('PortalHomepageDefaultIntroduction') . '</div>'; |
|
254
|
|
|
} else { |
|
255
|
|
|
$home_top_temp = '<div class="welcome-home-top-temp">' . $home_top_temp . '</div>'; |
|
256
|
|
|
} |
|
257
|
|
|
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); |
|
258
|
|
|
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
return $html; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
function return_notice() |
|
265
|
|
|
{ |
|
266
|
|
|
$sys_path = api_get_path(SYS_PATH); |
|
267
|
|
|
$user_selected_language = api_get_interface_language(); |
|
268
|
|
|
|
|
269
|
|
|
$html = ''; |
|
270
|
|
|
// Notice |
|
271
|
|
|
$home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice_'.$user_selected_language.'.html'); |
|
272
|
|
|
if (empty($home_notice)) { |
|
273
|
|
|
$home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice.html'); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
if (!empty($home_notice)) { |
|
277
|
|
|
$home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice))); |
|
278
|
|
|
//$home_notice = Display::div($home_notice, array('class' => 'homepage_notice')); |
|
279
|
|
|
$html = self::show_right_block( |
|
280
|
|
|
get_lang('Notice'), |
|
281
|
|
|
$home_notice, |
|
282
|
|
|
'notice_block', |
|
283
|
|
|
null, |
|
284
|
|
|
'notices', |
|
285
|
|
|
'noticesCollapse' |
|
286
|
|
|
); |
|
287
|
|
|
} |
|
288
|
|
|
return $html; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
function return_help() |
|
292
|
|
|
{ |
|
293
|
|
|
$user_selected_language = api_get_interface_language(); |
|
294
|
|
|
$sys_path = api_get_path(SYS_PATH); |
|
295
|
|
|
$platformLanguage = api_get_setting('platformLanguage'); |
|
296
|
|
|
|
|
297
|
|
|
// Help section. |
|
298
|
|
|
/* Hide right menu "general" and other parts on anonymous right menu. */ |
|
299
|
|
|
|
|
300
|
|
|
if (!isset($user_selected_language)) { |
|
301
|
|
|
$user_selected_language = $platformLanguage; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
$html = null; |
|
305
|
|
|
$home_menu = @(string)file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html'); |
|
306
|
|
|
if (!empty($home_menu)) { |
|
307
|
|
|
$home_menu_content = '<ul class="nav nav-pills nav-stacked">'; |
|
308
|
|
|
$home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu))); |
|
309
|
|
|
$home_menu_content .= '</ul>'; |
|
310
|
|
|
$html .= self::show_right_block( |
|
311
|
|
|
get_lang('MenuGeneral'), |
|
312
|
|
|
$home_menu_content, |
|
313
|
|
|
'help_block', |
|
314
|
|
|
null, |
|
315
|
|
|
'helps', |
|
316
|
|
|
'helpsCollapse' |
|
317
|
|
|
); |
|
318
|
|
|
} |
|
319
|
|
|
return $html; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
function return_skills_links() |
|
323
|
|
|
{ |
|
324
|
|
|
$content = ''; |
|
325
|
|
|
$content .= '<ul class="nav nav-pills nav-stacked">'; |
|
326
|
|
|
/** |
|
327
|
|
|
* Generate the block for show a panel with links to My Certificates and Certificates Search pages |
|
328
|
|
|
* @return string The HTML code for the panel |
|
329
|
|
|
*/ |
|
330
|
|
|
$certificatesItem = null; |
|
331
|
|
|
|
|
332
|
|
View Code Duplication |
if (!api_is_anonymous()) { |
|
333
|
|
|
$certificatesItem = Display::tag( |
|
334
|
|
|
'li', |
|
335
|
|
|
Display::url(Display::return_icon('graduation.png',get_lang('MyCertificates'),null,ICON_SIZE_SMALL). |
|
336
|
|
|
get_lang('MyCertificates'), |
|
337
|
|
|
api_get_path(WEB_CODE_PATH) . "gradebook/my_certificates.php" |
|
338
|
|
|
) |
|
339
|
|
|
); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
$searchItem = null; |
|
343
|
|
|
|
|
344
|
|
View Code Duplication |
if (api_get_setting('allow_public_certificates') == 'true') { |
|
345
|
|
|
$searchItem = Display::tag( |
|
346
|
|
|
'li', |
|
347
|
|
|
Display::url(Display::return_icon('search_graduation.png',get_lang('Search'),null,ICON_SIZE_SMALL). |
|
348
|
|
|
get_lang('Search'), |
|
349
|
|
|
api_get_path(WEB_CODE_PATH) . "gradebook/search.php" |
|
350
|
|
|
) |
|
351
|
|
|
); |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
if (empty($certificatesItem) && empty($searchItem)) { |
|
355
|
|
|
return null; |
|
356
|
|
|
}else{ |
|
357
|
|
|
$content.= $certificatesItem; |
|
358
|
|
|
$content.= $searchItem; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
if (api_get_setting('allow_skills_tool') == 'true') { |
|
362
|
|
|
|
|
363
|
|
|
$content .= Display::tag('li', Display::url(Display::return_icon('skill-badges.png',get_lang('MySkills'),null,ICON_SIZE_SMALL).get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/my_skills_report.php')); |
|
364
|
|
|
$allowSkillsManagement = api_get_setting('allow_hr_skills_management') == 'true'; |
|
365
|
|
View Code Duplication |
if (($allowSkillsManagement && api_is_drh()) || api_is_platform_admin()) { |
|
366
|
|
|
$content .= Display::tag('li', |
|
367
|
|
|
Display::url(Display::return_icon('edit-skill.png', get_lang('MySkills'), null, |
|
368
|
|
|
ICON_SIZE_SMALL) . get_lang('ManageSkills'), |
|
369
|
|
|
api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php')); |
|
370
|
|
|
} |
|
371
|
|
|
} |
|
372
|
|
|
$content .= '</ul>'; |
|
373
|
|
|
$html = self::show_right_block( |
|
374
|
|
|
get_lang("Skills"), |
|
375
|
|
|
$content, |
|
376
|
|
|
'skill_block', |
|
377
|
|
|
null, |
|
378
|
|
|
'skills', |
|
379
|
|
|
'skillsCollapse' |
|
380
|
|
|
); |
|
381
|
|
|
|
|
382
|
|
|
return $html; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* Reacts on a failed login: |
|
387
|
|
|
* Displays an explanation with a link to the registration form. |
|
388
|
|
|
* |
|
389
|
|
|
* @version 1.0.1 |
|
390
|
|
|
*/ |
|
391
|
|
|
function handle_login_failed() |
|
392
|
|
|
{ |
|
393
|
|
|
return $this->tpl->handleLoginFailed(); |
|
|
|
|
|
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* Display list of courses in a category. |
|
398
|
|
|
* (for anonymous users) |
|
399
|
|
|
* |
|
400
|
|
|
* @version 1.1 |
|
401
|
|
|
* @author Patrick Cool <[email protected]>, Ghent University - refactoring and code cleaning |
|
402
|
|
|
* @author Julio Montoya <[email protected]>, Beeznest template modifs |
|
403
|
|
|
*/ |
|
404
|
|
|
function return_courses_in_categories() |
|
405
|
|
|
{ |
|
406
|
|
|
$result = ''; |
|
407
|
|
|
$stok = Security::get_token(); |
|
408
|
|
|
|
|
409
|
|
|
// Initialization. |
|
410
|
|
|
$user_identified = (api_get_user_id() > 0 && !api_is_anonymous()); |
|
411
|
|
|
$web_course_path = api_get_path(WEB_COURSE_PATH); |
|
412
|
|
|
$category = Database::escape_string($_GET['category']); |
|
413
|
|
|
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; |
|
414
|
|
|
|
|
415
|
|
|
// Database table definitions. |
|
416
|
|
|
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
417
|
|
|
$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY); |
|
418
|
|
|
|
|
419
|
|
|
// Get list of courses in category $category. |
|
420
|
|
|
$sql_get_course_list = "SELECT * FROM $main_course_table cours |
|
421
|
|
|
WHERE category_code = '".Database::escape_string($_GET['category'])."' |
|
422
|
|
|
ORDER BY title, UPPER(visual_code)"; |
|
423
|
|
|
|
|
424
|
|
|
// Showing only the courses of the current access_url_id. |
|
425
|
|
|
if (api_is_multiple_url_enabled()) { |
|
426
|
|
|
$url_access_id = api_get_current_access_url_id(); |
|
427
|
|
|
if ($url_access_id != -1) { |
|
428
|
|
|
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
429
|
|
|
$sql_get_course_list = "SELECT * FROM $main_course_table as course |
|
430
|
|
|
INNER JOIN $tbl_url_rel_course as url_rel_course |
|
431
|
|
|
ON (url_rel_course.c_id = course.id) |
|
432
|
|
|
WHERE |
|
433
|
|
|
access_url_id = $url_access_id AND |
|
434
|
|
|
category_code = '".Database::escape_string($_GET['category'])."' |
|
435
|
|
|
ORDER BY title, UPPER(visual_code)"; |
|
436
|
|
|
} |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
// Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' |
|
440
|
|
|
$sql_result_courses = Database::query($sql_get_course_list); |
|
441
|
|
|
|
|
442
|
|
|
while ($course_result = Database::fetch_array($sql_result_courses)) { |
|
443
|
|
|
$course_list[] = $course_result; |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
// $setting_show_also_closed_courses |
|
447
|
|
|
if ($user_identified) { |
|
448
|
|
|
if ($setting_show_also_closed_courses) { |
|
449
|
|
|
$platform_visible_courses = ''; |
|
450
|
|
|
} else { |
|
451
|
|
|
$platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )"; |
|
452
|
|
|
} |
|
453
|
|
|
} else { |
|
454
|
|
|
if ($setting_show_also_closed_courses) { |
|
455
|
|
|
$platform_visible_courses = ''; |
|
456
|
|
|
} else { |
|
457
|
|
|
$platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )"; |
|
458
|
|
|
} |
|
459
|
|
|
} |
|
460
|
|
|
$sqlGetSubCatList = " |
|
461
|
|
|
SELECT t1.name, |
|
462
|
|
|
t1.code, |
|
463
|
|
|
t1.parent_id, |
|
464
|
|
|
t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse |
|
465
|
|
|
FROM $main_category_table t1 |
|
466
|
|
|
LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id |
|
467
|
|
|
LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses) |
|
468
|
|
|
WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." |
|
469
|
|
|
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; |
|
470
|
|
|
|
|
471
|
|
|
// Showing only the category of courses of the current access_url_id |
|
472
|
|
|
if (api_is_multiple_url_enabled()) { |
|
473
|
|
|
$courseCategoryCondition = null; |
|
474
|
|
|
if (isMultipleUrlSupport()) { |
|
475
|
|
|
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); |
|
476
|
|
|
$courseCategoryCondition = " INNER JOIN $table a ON (t1.id = a.course_category_id)"; |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
$url_access_id = api_get_current_access_url_id(); |
|
480
|
|
|
if ($url_access_id != -1) { |
|
481
|
|
|
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
482
|
|
|
$sqlGetSubCatList = " |
|
483
|
|
|
SELECT t1.name, |
|
484
|
|
|
t1.code, |
|
485
|
|
|
t1.parent_id, |
|
486
|
|
|
t1.children_count, |
|
487
|
|
|
COUNT(DISTINCT t3.code) AS nbCourse |
|
488
|
|
|
FROM $main_category_table t1 |
|
489
|
|
|
$courseCategoryCondition |
|
490
|
|
|
LEFT JOIN $main_category_table t2 ON t1.code = t2.parent_id |
|
491
|
|
|
LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses) |
|
492
|
|
|
INNER JOIN $tbl_url_rel_course as url_rel_course |
|
493
|
|
|
ON (url_rel_course.c_id = t3.id) |
|
494
|
|
|
WHERE |
|
495
|
|
|
url_rel_course.access_url_id = $url_access_id AND |
|
496
|
|
|
t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")." |
|
497
|
|
|
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count |
|
498
|
|
|
ORDER BY t1.tree_pos, t1.name"; |
|
499
|
|
|
} |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
$resCats = Database::query($sqlGetSubCatList); |
|
503
|
|
|
$thereIsSubCat = false; |
|
504
|
|
|
if (Database::num_rows($resCats) > 0) { |
|
505
|
|
|
$htmlListCat = Display::page_header(get_lang('CatList')); |
|
506
|
|
|
$htmlListCat .= '<ul>'; |
|
507
|
|
|
$htmlTitre = ''; |
|
508
|
|
|
while ($catLine = Database::fetch_array($resCats)) { |
|
509
|
|
|
$category_has_open_courses = self::category_has_open_courses($catLine['code']); |
|
510
|
|
|
if ($category_has_open_courses) { |
|
511
|
|
|
// The category contains courses accessible to anonymous visitors. |
|
512
|
|
|
$htmlListCat .= '<li>'; |
|
513
|
|
|
$htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>'; |
|
514
|
|
|
if (api_get_setting('show_number_of_courses') == 'true') { |
|
515
|
|
|
$htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')'; |
|
516
|
|
|
} |
|
517
|
|
|
$htmlListCat .= "</li>"; |
|
518
|
|
|
$thereIsSubCat = true; |
|
519
|
|
|
} elseif ($catLine['children_count'] > 0) { |
|
520
|
|
|
// The category has children, subcategories. |
|
521
|
|
|
$htmlListCat .= '<li>'; |
|
522
|
|
|
$htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>'; |
|
523
|
|
|
$htmlListCat .= "</li>"; |
|
524
|
|
|
$thereIsSubCat = true; |
|
525
|
|
|
} elseif (api_get_setting('show_empty_course_categories') == 'true') { |
|
526
|
|
|
/* End changed code to eliminate the (0 courses) after empty categories. */ |
|
527
|
|
|
$htmlListCat .= '<li>'; |
|
528
|
|
|
$htmlListCat .= $catLine['name']; |
|
529
|
|
|
$htmlListCat .= "</li>"; |
|
530
|
|
|
$thereIsSubCat = true; |
|
531
|
|
|
} // Else don't set thereIsSubCat to true to avoid printing things if not requested. |
|
532
|
|
|
// TODO: deprecate this useless feature - this includes removing system variable |
|
533
|
|
|
if (empty($htmlTitre)) { |
|
534
|
|
|
$htmlTitre = '<p>'; |
|
535
|
|
|
if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { |
|
536
|
|
|
$htmlTitre .= '<a href="'.api_get_self().'"><< '.get_lang('BackToHomePage').'</a>'; |
|
537
|
|
|
} |
|
538
|
|
|
$htmlTitre .= "</p>"; |
|
539
|
|
|
} |
|
540
|
|
|
} |
|
541
|
|
|
$htmlListCat .= "</ul>"; |
|
542
|
|
|
} |
|
543
|
|
|
$result .= $htmlTitre; |
|
544
|
|
|
if ($thereIsSubCat) { |
|
545
|
|
|
$result .= $htmlListCat; |
|
546
|
|
|
} |
|
547
|
|
|
while ($categoryName = Database::fetch_array($resCats)) { |
|
548
|
|
|
$result .= '<h3>' . $categoryName['name'] . "</h3>\n"; |
|
549
|
|
|
} |
|
550
|
|
|
$numrows = Database::num_rows($sql_result_courses); |
|
551
|
|
|
$courses_list_string = ''; |
|
552
|
|
|
$courses_shown = 0; |
|
553
|
|
|
if ($numrows > 0) { |
|
554
|
|
|
$courses_list_string .= Display::page_header(get_lang('CourseList')); |
|
555
|
|
|
$courses_list_string .= "<ul>"; |
|
556
|
|
|
if (api_get_user_id()) { |
|
557
|
|
|
$courses_of_user = self::get_courses_of_user(api_get_user_id()); |
|
558
|
|
|
} |
|
559
|
|
|
foreach ($course_list as $course) { |
|
560
|
|
|
// $setting_show_also_closed_courses |
|
561
|
|
|
if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) { continue; } |
|
562
|
|
|
if (!$setting_show_also_closed_courses) { |
|
563
|
|
|
// If we do not show the closed courses |
|
564
|
|
|
// we only show the courses that are open to the world (to everybody) |
|
565
|
|
|
// and the courses that are open to the platform (if the current user is a registered user. |
|
566
|
|
|
if (($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { |
|
567
|
|
|
$courses_shown++; |
|
568
|
|
|
$courses_list_string .= "<li>"; |
|
569
|
|
|
$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />'; |
|
570
|
|
|
$course_details = array(); |
|
571
|
|
|
if (api_get_setting('display_coursecode_in_courselist') == 'true') { |
|
572
|
|
|
$course_details[] = $course['visual_code']; |
|
573
|
|
|
} |
|
574
|
|
|
if (api_get_setting('display_teacher_in_courselist') == 'true') { |
|
575
|
|
|
$course_details[] = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); |
|
576
|
|
|
} |
|
577
|
|
View Code Duplication |
if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { |
|
578
|
|
|
$course_details[] = $course['course_language']; |
|
579
|
|
|
} |
|
580
|
|
|
$courses_list_string .= implode(' - ', $course_details); |
|
581
|
|
|
$courses_list_string .= "</li>"; |
|
582
|
|
|
} |
|
583
|
|
|
} else { |
|
584
|
|
|
// We DO show the closed courses. |
|
585
|
|
|
// The course is accessible if (link to the course homepage): |
|
586
|
|
|
// 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); |
|
587
|
|
|
// 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); |
|
588
|
|
|
// 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED; |
|
589
|
|
|
// 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting); |
|
590
|
|
|
// 5. the user is the platform admin api_is_platform_admin(). |
|
591
|
|
|
|
|
592
|
|
|
$courses_shown++; |
|
593
|
|
|
$courses_list_string .= "<li>"; |
|
594
|
|
|
if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD |
|
595
|
|
|
|| ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) |
|
596
|
|
|
|| ($user_identified && array_key_exists($course['code'], $courses_of_user) |
|
597
|
|
|
&& $course['visibility'] != COURSE_VISIBILITY_CLOSED) |
|
598
|
|
|
|| $courses_of_user[$course['code']]['status'] == '1' |
|
599
|
|
|
|| api_is_platform_admin()) { |
|
600
|
|
|
$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'; |
|
601
|
|
|
} |
|
602
|
|
|
$courses_list_string .= $course['title']; |
|
603
|
|
|
if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD |
|
604
|
|
|
|| ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) |
|
605
|
|
|
|| ($user_identified && array_key_exists($course['code'], $courses_of_user) |
|
606
|
|
|
&& $course['visibility'] != COURSE_VISIBILITY_CLOSED) |
|
607
|
|
|
|| $courses_of_user[$course['code']]['status'] == '1' |
|
608
|
|
|
|| api_is_platform_admin()) { |
|
609
|
|
|
$courses_list_string .= '</a><br />'; |
|
610
|
|
|
} |
|
611
|
|
|
$course_details = array(); |
|
612
|
|
|
if (api_get_setting('display_coursecode_in_courselist') == 'true') { |
|
613
|
|
|
$course_details[] = $course['visual_code']; |
|
614
|
|
|
} |
|
615
|
|
|
// if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { |
|
616
|
|
|
// $courses_list_string .= ' - '; |
|
617
|
|
|
// } |
|
618
|
|
|
if (api_get_setting('display_teacher_in_courselist') == 'true') { |
|
619
|
|
|
if (!empty($course['tutor_name'])) { |
|
620
|
|
|
$course_details[] = $course['tutor_name']; |
|
621
|
|
|
} |
|
622
|
|
|
} |
|
623
|
|
View Code Duplication |
if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { |
|
624
|
|
|
$course_details[] = $course['course_language']; |
|
625
|
|
|
} |
|
626
|
|
|
|
|
627
|
|
|
$courses_list_string .= implode(' - ', $course_details); |
|
628
|
|
|
// We display a subscription link if: |
|
629
|
|
|
// 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied |
|
630
|
|
|
// 2. |
|
631
|
|
|
if ($user_identified && !array_key_exists($course['code'], $courses_of_user)) { |
|
632
|
|
|
if ($course['subscribe'] == '1') { |
|
633
|
|
|
$courses_list_string .= ' <a class="btn btn-primary" href="main/auth/courses.php?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&category_code='.Security::remove_XSS($_GET['category']).'">'.get_lang('Subscribe').'</a><br />'; |
|
634
|
|
|
} else { |
|
635
|
|
|
$courses_list_string .= '<br />'.get_lang('SubscribingNotAllowed'); |
|
636
|
|
|
} |
|
637
|
|
|
} |
|
638
|
|
|
$courses_list_string .= "</li>"; |
|
639
|
|
|
} //end else |
|
640
|
|
|
} // end foreach |
|
641
|
|
|
$courses_list_string .= "</ul>"; |
|
642
|
|
|
} |
|
643
|
|
|
if ($courses_shown > 0) { |
|
644
|
|
|
// Only display the list of courses and categories if there was more than |
|
645
|
|
|
// 0 courses visible to the world (we're in the anonymous list here). |
|
646
|
|
|
$result .= $courses_list_string; |
|
647
|
|
|
} |
|
648
|
|
|
if ($category != '') { |
|
649
|
|
|
$result .= '<p><a href="'.api_get_self().'"> ' . |
|
650
|
|
|
Display :: return_icon('back.png', get_lang('BackToHomePage')). |
|
651
|
|
|
get_lang('BackToHomePage') . '</a></p>'; |
|
652
|
|
|
} |
|
653
|
|
|
return $result; |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
/** |
|
657
|
|
|
* retrieves all the courses that the user has already subscribed to |
|
658
|
|
|
* @author Patrick Cool <[email protected]>, Ghent University, Belgium |
|
659
|
|
|
* @param int $user_id: the id of the user |
|
|
|
|
|
|
660
|
|
|
* @return array an array containing all the information of the courses of the given user |
|
661
|
|
|
*/ |
|
662
|
|
|
public function get_courses_of_user($user_id) |
|
663
|
|
|
{ |
|
664
|
|
|
$table_course = Database::get_main_table(TABLE_MAIN_COURSE); |
|
665
|
|
|
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
666
|
|
|
// Secondly we select the courses that are in a category (user_course_cat <> 0) |
|
667
|
|
|
// and sort these according to the sort of the category |
|
668
|
|
|
$user_id = intval($user_id); |
|
669
|
|
|
$sql_select_courses = "SELECT |
|
670
|
|
|
course.code k, |
|
671
|
|
|
course.visual_code vc, |
|
672
|
|
|
course.subscribe subscr, |
|
673
|
|
|
course.unsubscribe unsubscr, |
|
674
|
|
|
course.title i, |
|
675
|
|
|
course.tutor_name t, |
|
676
|
|
|
course.directory dir, |
|
677
|
|
|
course_rel_user.status status, |
|
678
|
|
|
course_rel_user.sort sort, |
|
679
|
|
|
course_rel_user.user_course_cat user_course_cat |
|
680
|
|
|
FROM |
|
681
|
|
|
$table_course course, |
|
682
|
|
|
$table_course_user course_rel_user |
|
683
|
|
|
WHERE |
|
684
|
|
|
course.id = course_rel_user.c_id AND |
|
685
|
|
|
course_rel_user.user_id = '".$user_id."' AND |
|
686
|
|
|
course_rel_user.relation_type <> ".COURSE_RELATION_TYPE_RRHH." |
|
687
|
|
|
ORDER BY course_rel_user.sort ASC"; |
|
688
|
|
|
$result = Database::query($sql_select_courses); |
|
689
|
|
|
$courses = array(); |
|
690
|
|
View Code Duplication |
while ($row = Database::fetch_array($result)) { |
|
691
|
|
|
// We only need the database name of the course. |
|
692
|
|
|
$courses[$row['k']] = array( |
|
693
|
|
|
'code' => $row['k'], |
|
694
|
|
|
'visual_code' => $row['vc'], |
|
695
|
|
|
'title' => $row['i'], |
|
696
|
|
|
'directory' => $row['dir'], |
|
697
|
|
|
'status' => $row['status'], |
|
698
|
|
|
'tutor' => $row['t'], |
|
699
|
|
|
'subscribe' => $row['subscr'], |
|
700
|
|
|
'unsubscribe' => $row['unsubscr'], |
|
701
|
|
|
'sort' => $row['sort'], |
|
702
|
|
|
'user_course_category' => $row['user_course_cat'] |
|
703
|
|
|
); |
|
704
|
|
|
} |
|
705
|
|
|
return $courses; |
|
706
|
|
|
} |
|
707
|
|
|
|
|
708
|
|
|
/** |
|
709
|
|
|
* @todo use the template system |
|
710
|
|
|
* @param $title |
|
711
|
|
|
* @param $content |
|
712
|
|
|
* @param string $id |
|
713
|
|
|
* @param array $params |
|
714
|
|
|
* @param string $idAccordion |
|
715
|
|
|
* @param string $idCollapse |
|
716
|
|
|
* @return null|string |
|
717
|
|
|
*/ |
|
718
|
|
|
public function show_right_block( |
|
719
|
|
|
$title, |
|
720
|
|
|
$content, |
|
721
|
|
|
$id = '', |
|
722
|
|
|
$params = [], |
|
723
|
|
|
$idAccordion = '', |
|
724
|
|
|
$idCollapse = '' |
|
725
|
|
|
) { |
|
726
|
|
|
if (!empty($idAccordion)) { |
|
727
|
|
|
$html = null; |
|
728
|
|
|
$html .= '<div class="panel-group" id="'.$idAccordion.'" role="tablist" aria-multiselectable="true">' . PHP_EOL; |
|
729
|
|
|
$html .= '<div class="panel panel-default" id="'.$id.'">' . PHP_EOL; |
|
730
|
|
|
$html .= '<div class="panel-heading" role="tab"><h4 class="panel-title">' . PHP_EOL; |
|
731
|
|
|
$html .= '<a role="button" data-toggle="collapse" data-parent="#'.$idAccordion.'" href="#'.$idCollapse.'" aria-expanded="true" aria-controls="'.$idCollapse.'">'.$title.'</a>' . PHP_EOL; |
|
732
|
|
|
$html .= '</h4></div>' . PHP_EOL; |
|
733
|
|
|
$html .= '<div id="'.$idCollapse.'" class="panel-collapse collapse in" role="tabpanel">' . PHP_EOL; |
|
734
|
|
|
$html .= '<div class="panel-body">'.$content.'</div>' . PHP_EOL; |
|
735
|
|
|
$html .= '</div></div></div>' . PHP_EOL; |
|
736
|
|
|
|
|
737
|
|
View Code Duplication |
} else { |
|
738
|
|
|
if (!empty($id)) { |
|
739
|
|
|
$params['id'] = $id; |
|
740
|
|
|
} |
|
741
|
|
|
$params['class'] = 'panel panel-default'; |
|
742
|
|
|
$html = null; |
|
743
|
|
|
if (!empty($title)) { |
|
744
|
|
|
$html .= '<div class="panel-heading">'.$title.'</div>' . PHP_EOL; |
|
745
|
|
|
} |
|
746
|
|
|
$html.= '<div class="panel-body">'.$content.'</div>' . PHP_EOL; |
|
747
|
|
|
$html = Display::div($html, $params); |
|
748
|
|
|
} |
|
749
|
|
|
return $html; |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
/** |
|
753
|
|
|
* Adds a form to let users login |
|
754
|
|
|
* @version 1.1 |
|
755
|
|
|
*/ |
|
756
|
|
|
public function display_login_form() |
|
757
|
|
|
{ |
|
758
|
|
|
return $this->tpl->displayLoginForm(); |
|
|
|
|
|
|
759
|
|
|
} |
|
760
|
|
|
|
|
761
|
|
|
/** |
|
762
|
|
|
* @todo use FormValidator |
|
763
|
|
|
* @return string |
|
764
|
|
|
*/ |
|
765
|
|
|
public function return_search_block() |
|
766
|
|
|
{ |
|
767
|
|
|
$html = ''; |
|
768
|
|
|
if (api_get_setting('search_enabled') == 'true') { |
|
769
|
|
|
$search_btn = get_lang('Search'); |
|
770
|
|
|
$search_content = '<form action="main/search/" method="post"> |
|
771
|
|
|
<div class="form-group"> |
|
772
|
|
|
<input type="text" id="query" class="form-control" name="query" value="" /> |
|
773
|
|
|
<button class="btn btn-default" type="submit" name="submit" value="'.$search_btn.'" />'.$search_btn.' </button> |
|
774
|
|
|
</div></form>'; |
|
775
|
|
|
$html .= self::show_right_block(get_lang('Search'), $search_content, 'search_block'); |
|
776
|
|
|
} |
|
777
|
|
|
|
|
778
|
|
|
return $html; |
|
779
|
|
|
} |
|
780
|
|
|
|
|
781
|
|
|
/** |
|
782
|
|
|
* @return string |
|
783
|
|
|
*/ |
|
784
|
|
|
public function return_classes_block() |
|
785
|
|
|
{ |
|
786
|
|
|
$html = ''; |
|
787
|
|
|
if (api_get_setting('show_groups_to_users') == 'true') { |
|
788
|
|
|
$usergroup = new UserGroup(); |
|
789
|
|
|
$usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id()); |
|
790
|
|
|
$classes = ''; |
|
791
|
|
|
if (!empty($usergroup_list)) { |
|
792
|
|
|
foreach($usergroup_list as $group_id) { |
|
793
|
|
|
$data = $usergroup->get($group_id); |
|
794
|
|
|
$data['name'] = Display::url($data['name'], api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id']); |
|
795
|
|
|
$classes .= Display::tag('li', $data['name']); |
|
796
|
|
|
} |
|
797
|
|
|
} |
|
798
|
|
View Code Duplication |
if (api_is_platform_admin()) { |
|
799
|
|
|
$classes .= Display::tag( |
|
800
|
|
|
'li', |
|
801
|
|
|
Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add') |
|
802
|
|
|
); |
|
803
|
|
|
} |
|
804
|
|
|
if (!empty($classes)) { |
|
805
|
|
|
$classes = Display::tag('ul', $classes, array('class'=>'nav nav-pills nav-stacked')); |
|
806
|
|
|
$html .= self::show_right_block(get_lang('Classes'), $classes, 'classes_block'); |
|
807
|
|
|
} |
|
808
|
|
|
} |
|
809
|
|
|
return $html; |
|
810
|
|
|
} |
|
811
|
|
|
|
|
812
|
|
|
/** |
|
813
|
|
|
* @return null|string |
|
814
|
|
|
*/ |
|
815
|
|
|
public function return_user_image_block() |
|
816
|
|
|
{ |
|
817
|
|
|
$html = null; |
|
818
|
|
|
if (!api_is_anonymous()) { |
|
819
|
|
|
$userPicture = UserManager::getUserPicture(api_get_user_id()); |
|
820
|
|
|
$content = null; |
|
821
|
|
|
|
|
822
|
|
View Code Duplication |
if (api_get_setting('allow_social_tool') == 'true') { |
|
823
|
|
|
$content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php"> |
|
824
|
|
|
<img class="img-circle" src="' . $userPicture . '" ></a>'; |
|
825
|
|
|
} else { |
|
826
|
|
|
$content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php"> |
|
827
|
|
|
<img class="img-circle" title="' . get_lang('EditProfile') . '" src="' . $userPicture. '" ></a>'; |
|
828
|
|
|
} |
|
829
|
|
|
|
|
830
|
|
|
$html = self::show_right_block( |
|
831
|
|
|
null, |
|
832
|
|
|
$content, |
|
833
|
|
|
'user_image_block', |
|
834
|
|
|
array('style' => 'text-align:center;') |
|
835
|
|
|
); |
|
836
|
|
|
} |
|
837
|
|
|
|
|
838
|
|
|
return $html; |
|
839
|
|
|
} |
|
840
|
|
|
|
|
841
|
|
|
/** |
|
842
|
|
|
* @return null|string|void |
|
843
|
|
|
*/ |
|
844
|
|
|
public function return_profile_block() |
|
845
|
|
|
{ |
|
846
|
|
|
global $_configuration; |
|
847
|
|
|
$user_id = api_get_user_id(); |
|
848
|
|
|
|
|
849
|
|
|
if (empty($user_id)) { |
|
850
|
|
|
return; |
|
851
|
|
|
} |
|
852
|
|
|
|
|
853
|
|
|
$userGroup = new UserGroup(); |
|
854
|
|
|
|
|
855
|
|
|
$profile_content = '<ul class="nav nav-pills nav-stacked">'; |
|
856
|
|
|
|
|
857
|
|
|
// @todo Add a platform setting to add the user image. |
|
858
|
|
|
if (api_get_setting('allow_message_tool') == 'true') { |
|
859
|
|
|
// New messages. |
|
860
|
|
|
$number_of_new_messages = MessageManager::get_new_messages(); |
|
861
|
|
|
// New contact invitations. |
|
862
|
|
|
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); |
|
863
|
|
|
|
|
864
|
|
|
// New group invitations sent by a moderator. |
|
865
|
|
|
$group_pending_invitations = $userGroup->get_groups_by_user( |
|
866
|
|
|
api_get_user_id(), |
|
867
|
|
|
GROUP_USER_PERMISSION_PENDING_INVITATION, |
|
868
|
|
|
false |
|
869
|
|
|
); |
|
870
|
|
|
$group_pending_invitations = count($group_pending_invitations); |
|
871
|
|
|
|
|
872
|
|
|
$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations; |
|
873
|
|
|
$cant_msg = Display::badge($number_of_new_messages); |
|
874
|
|
|
|
|
875
|
|
|
$link = ''; |
|
876
|
|
|
if (api_get_setting('allow_social_tool') == 'true') { |
|
877
|
|
|
$link = '?f=social'; |
|
878
|
|
|
} |
|
879
|
|
|
$profile_content .= '<li class="inbox-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.Display::return_icon('inbox.png',get_lang('Inbox'),null,ICON_SIZE_SMALL).get_lang('Inbox').$cant_msg.' </a></li>'; |
|
880
|
|
|
$profile_content .= '<li class="new-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.Display::return_icon('new-message.png',get_lang('Compose'),null,ICON_SIZE_SMALL).get_lang('Compose').' </a></li>'; |
|
881
|
|
|
|
|
882
|
|
View Code Duplication |
if (api_get_setting('allow_social_tool') == 'true') { |
|
883
|
|
|
$total_invitations = Display::badge($total_invitations); |
|
884
|
|
|
$profile_content .= '<li class="invitations-social"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitations.png',get_lang('PendingInvitations'),null,ICON_SIZE_SMALL).get_lang('PendingInvitations').$total_invitations.'</a></li>'; |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
|
|
if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) { |
|
888
|
|
|
$myFiles = '<li class="myfiles-social"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.get_lang('MyFiles').'</a></li>'; |
|
889
|
|
|
|
|
890
|
|
|
if (api_get_setting('allow_my_files') === 'false') { |
|
891
|
|
|
$myFiles = ''; |
|
892
|
|
|
} |
|
893
|
|
|
|
|
894
|
|
|
$profile_content .= $myFiles; |
|
895
|
|
|
} |
|
896
|
|
|
} |
|
897
|
|
|
|
|
898
|
|
|
$editProfileUrl = Display::getProfileEditionLink($user_id); |
|
899
|
|
|
|
|
900
|
|
|
$profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.Display::return_icon('edit-profile.png',get_lang('EditProfile'),null,ICON_SIZE_SMALL).get_lang('EditProfile').'</a></li>'; |
|
901
|
|
|
$profile_content .= '</ul>'; |
|
902
|
|
|
$html = self::show_right_block( |
|
903
|
|
|
get_lang('Profile'), |
|
904
|
|
|
$profile_content, |
|
905
|
|
|
'profile_block', |
|
906
|
|
|
null, |
|
907
|
|
|
'profile', |
|
908
|
|
|
'profileCollapse' |
|
909
|
|
|
); |
|
910
|
|
|
|
|
911
|
|
|
return $html; |
|
912
|
|
|
} |
|
913
|
|
|
|
|
914
|
|
|
public function return_navigation_links() |
|
915
|
|
|
{ |
|
916
|
|
|
$html = ''; |
|
917
|
|
|
|
|
918
|
|
|
// Deleting the myprofile link. |
|
919
|
|
|
if (api_get_setting('allow_social_tool') == 'true') { |
|
920
|
|
|
unset($this->tpl->menu_navigation['myprofile']); |
|
921
|
|
|
} |
|
922
|
|
|
|
|
923
|
|
|
// Main navigation section. |
|
924
|
|
|
// Tabs that are deactivated are added here. |
|
925
|
|
|
if (!empty($this->tpl->menu_navigation)) { |
|
926
|
|
|
$content = '<ul class="nav nav-pills nav-stacked">'; |
|
927
|
|
|
foreach ($this->tpl->menu_navigation as $section => $navigation_info) { |
|
928
|
|
|
$current = $section == $GLOBALS['this_section'] ? ' id="current"' : ''; |
|
929
|
|
|
$content .= '<li'.$current.'>'; |
|
930
|
|
|
$content .= '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>'; |
|
931
|
|
|
$content .= '</li>'; |
|
932
|
|
|
} |
|
933
|
|
|
$content .= '</ul>'; |
|
934
|
|
|
$html = self::show_right_block(get_lang('MainNavigation'), $content, 'navigation_link_block'); |
|
935
|
|
|
} |
|
936
|
|
|
return $html; |
|
937
|
|
|
} |
|
938
|
|
|
|
|
939
|
|
|
/** |
|
940
|
|
|
* @return null|string |
|
941
|
|
|
*/ |
|
942
|
|
|
public function return_course_block() |
|
943
|
|
|
{ |
|
944
|
|
|
$html = ''; |
|
945
|
|
|
|
|
946
|
|
|
$show_create_link = false; |
|
947
|
|
|
$show_course_link = false; |
|
948
|
|
|
|
|
949
|
|
|
if ((api_get_setting('allow_users_to_create_courses') == 'false' && |
|
950
|
|
|
!api_is_platform_admin()) || api_is_student() |
|
951
|
|
|
) { |
|
952
|
|
|
$display_add_course_link = false; |
|
953
|
|
|
} else { |
|
954
|
|
|
$display_add_course_link = true; |
|
955
|
|
|
} |
|
956
|
|
|
|
|
957
|
|
|
if ($display_add_course_link) { |
|
958
|
|
|
$show_create_link = true; |
|
959
|
|
|
} |
|
960
|
|
|
|
|
961
|
|
|
if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { |
|
962
|
|
|
$show_course_link = true; |
|
963
|
|
|
} else { |
|
964
|
|
|
if (api_get_setting('allow_students_to_browse_courses') == 'true') { |
|
965
|
|
|
$show_course_link = true; |
|
966
|
|
|
} |
|
967
|
|
|
} |
|
968
|
|
|
|
|
969
|
|
|
// My account section |
|
970
|
|
|
$my_account_content = '<ul class="nav nav-pills nav-stacked">'; |
|
971
|
|
|
|
|
972
|
|
|
if ($show_create_link) { |
|
973
|
|
|
$my_account_content .= '<li class="add-course"><a href="main/create_course/add_course.php">'; |
|
974
|
|
|
if (api_get_setting('course_validation') == 'true' && !api_is_platform_admin()) { |
|
975
|
|
|
$my_account_content .= Display::return_icon('new-course.png',get_lang('CreateCourseRequest'),null,ICON_SIZE_SMALL); |
|
976
|
|
|
$my_account_content .= get_lang('CreateCourseRequest'); |
|
977
|
|
|
} else { |
|
978
|
|
|
$my_account_content .= Display::return_icon('new-course.png',get_lang('CourseCreate'),null,ICON_SIZE_SMALL); |
|
979
|
|
|
$my_account_content .= get_lang('CourseCreate'); |
|
980
|
|
|
} |
|
981
|
|
|
$my_account_content .= '</a></li>'; |
|
982
|
|
|
|
|
983
|
|
|
if (SessionManager::allowToManageSessions()) { |
|
984
|
|
|
$my_account_content .= '<li class="add-course"><a href="main/session/session_add.php">'; |
|
985
|
|
|
$my_account_content .= Display::return_icon('session.png',get_lang('AddSession'),null,ICON_SIZE_SMALL); |
|
986
|
|
|
$my_account_content .= get_lang('AddSession'); |
|
987
|
|
|
$my_account_content .= '</a></li>'; |
|
988
|
|
|
} |
|
989
|
|
|
} |
|
990
|
|
|
|
|
991
|
|
|
//Sort courses |
|
992
|
|
|
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses'; |
|
993
|
|
|
$img_order= Display::return_icon('order-course.png',get_lang('SortMyCourses'),null,ICON_SIZE_SMALL); |
|
994
|
|
|
$my_account_content .= '<li class="order-course">'.Display::url($img_order.get_lang('SortMyCourses'), $url, array('class' => 'sort course')).'</li>'; |
|
995
|
|
|
|
|
996
|
|
|
// Session history |
|
997
|
|
|
if (isset($_GET['history']) && intval($_GET['history']) == 1) { |
|
998
|
|
|
$my_account_content .= '<li class="history-course"><a href="user_portal.php">'.Display::return_icon('history-course.png',get_lang('DisplayTrainingList'),null,ICON_SIZE_SMALL).get_lang('DisplayTrainingList').'</a></li>'; |
|
999
|
|
|
} else { |
|
1000
|
|
|
$my_account_content .= '<li class="history-course"><a href="user_portal.php?history=1" >'.Display::return_icon('history-course.png',get_lang('HistoryTrainingSessions'),null,ICON_SIZE_SMALL).get_lang('HistoryTrainingSessions').'</a></li>'; |
|
1001
|
|
|
} |
|
1002
|
|
|
|
|
1003
|
|
|
// Course catalog |
|
1004
|
|
|
|
|
1005
|
|
View Code Duplication |
if ($show_course_link) { |
|
1006
|
|
|
if (!api_is_drh()) { |
|
1007
|
|
|
$my_account_content .= '<li class="list-course"><a href="main/auth/courses.php" >'.Display::return_icon('catalog-course.png',get_lang('CourseCatalog'),null,ICON_SIZE_SMALL).get_lang('CourseCatalog').'</a></li>'; |
|
1008
|
|
|
} else { |
|
1009
|
|
|
$my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>'; |
|
1010
|
|
|
} |
|
1011
|
|
|
} |
|
1012
|
|
|
|
|
1013
|
|
|
$my_account_content .= '</ul>'; |
|
1014
|
|
|
|
|
1015
|
|
|
if (!empty($my_account_content)) { |
|
1016
|
|
|
$html = self::show_right_block( |
|
1017
|
|
|
get_lang('Courses'), |
|
1018
|
|
|
$my_account_content, |
|
1019
|
|
|
'course_block', |
|
1020
|
|
|
null, |
|
1021
|
|
|
'course', |
|
1022
|
|
|
'courseCollapse' |
|
1023
|
|
|
); |
|
1024
|
|
|
} |
|
1025
|
|
|
return $html; |
|
1026
|
|
|
} |
|
1027
|
|
|
|
|
1028
|
|
|
/** |
|
1029
|
|
|
* Prints the session and course list (user_portal.php) |
|
1030
|
|
|
* @param int $user_id |
|
1031
|
|
|
* @return string |
|
1032
|
|
|
*/ |
|
1033
|
|
|
public function returnCoursesAndSessions($user_id) |
|
1034
|
|
|
{ |
|
1035
|
|
|
global $_configuration; |
|
1036
|
|
|
|
|
1037
|
|
|
$gamificationModeIsActive = api_get_setting('gamification_mode'); |
|
1038
|
|
|
|
|
1039
|
|
|
$load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false; |
|
1040
|
|
View Code Duplication |
if ($load_history) { |
|
1041
|
|
|
// Load sessions in category in *history* |
|
1042
|
|
|
$session_categories = UserManager::get_sessions_by_category($user_id, true); |
|
1043
|
|
|
} else { |
|
1044
|
|
|
// Load sessions in category |
|
1045
|
|
|
$session_categories = UserManager::get_sessions_by_category($user_id, false); |
|
1046
|
|
|
} |
|
1047
|
|
|
|
|
1048
|
|
|
$html = ''; |
|
1049
|
|
|
// Showing history title |
|
1050
|
|
View Code Duplication |
if ($load_history) { |
|
1051
|
|
|
$html .= Display::page_subheader(get_lang('HistoryTrainingSession')); |
|
1052
|
|
|
if (empty($session_categories)) { |
|
1053
|
|
|
$html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); |
|
1054
|
|
|
} |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
$courses_html = ''; |
|
1058
|
|
|
$special_courses = ''; |
|
1059
|
|
|
$sessionCount = 0; |
|
1060
|
|
|
$courseCount = 0; |
|
1061
|
|
|
|
|
1062
|
|
|
// If we're not in the history view... |
|
1063
|
|
|
if (!isset($_GET['history'])) { |
|
1064
|
|
|
// Display special courses. |
|
1065
|
|
|
$specialCourses = CourseManager::display_special_courses( |
|
1066
|
|
|
$user_id, |
|
1067
|
|
|
$this->load_directories_preview |
|
1068
|
|
|
); |
|
1069
|
|
|
$special_courses = $specialCourses['html']; |
|
1070
|
|
|
// Display courses. |
|
1071
|
|
|
$courses = CourseManager::display_courses( |
|
1072
|
|
|
$user_id, |
|
1073
|
|
|
$this->load_directories_preview |
|
1074
|
|
|
); |
|
1075
|
|
|
$courses_html .= $courses['html']; |
|
1076
|
|
|
$courseCount = $specialCourses['course_count'] + $courses['course_count']; |
|
1077
|
|
|
} |
|
1078
|
|
|
|
|
1079
|
|
|
$sessions_with_category = ''; |
|
1080
|
|
|
$sessions_with_no_category = ''; |
|
1081
|
|
|
|
|
1082
|
|
|
$coursesListSessionStyle = api_get_configuration_value('courses_list_session_title_link'); |
|
1083
|
|
|
$coursesListSessionStyle = $coursesListSessionStyle === false ? 1 : $coursesListSessionStyle; |
|
1084
|
|
|
if (api_is_drh()) { |
|
1085
|
|
|
$coursesListSessionStyle = 1; |
|
1086
|
|
|
} |
|
1087
|
|
|
|
|
1088
|
|
|
if (is_array($session_categories)) { |
|
1089
|
|
|
foreach ($session_categories as $session_category) { |
|
1090
|
|
|
$session_category_id = $session_category['session_category']['id']; |
|
1091
|
|
|
|
|
1092
|
|
|
// Sessions and courses that are not in a session category |
|
1093
|
|
|
if ( |
|
1094
|
|
|
empty($session_category_id) && |
|
1095
|
|
|
isset($session_category['sessions']) |
|
1096
|
|
|
) { |
|
1097
|
|
|
// Independent sessions |
|
1098
|
|
|
foreach ($session_category['sessions'] as $session) { |
|
1099
|
|
|
$session_id = $session['session_id']; |
|
1100
|
|
|
|
|
1101
|
|
|
// Don't show empty sessions. |
|
1102
|
|
|
if (count($session['courses']) < 1) { |
|
1103
|
|
|
continue; |
|
1104
|
|
|
} |
|
1105
|
|
|
|
|
1106
|
|
|
// Courses inside the current session. |
|
1107
|
|
|
$date_session_start = $session['access_start_date']; |
|
1108
|
|
|
$date_session_end = $session['access_end_date']; |
|
1109
|
|
|
$coachAccessStartDate = $session['coach_access_start_date']; |
|
1110
|
|
|
$coachAccessEndDate = $session['coach_access_end_date']; |
|
1111
|
|
|
|
|
1112
|
|
|
$session_now = time(); |
|
1113
|
|
|
$count_courses_session = 0; |
|
1114
|
|
|
|
|
1115
|
|
|
// Loop course content |
|
1116
|
|
|
$html_courses_session = []; |
|
1117
|
|
|
$atLeastOneCourseIsVisible = false; |
|
1118
|
|
|
|
|
1119
|
|
|
foreach ($session['courses'] as $course) { |
|
1120
|
|
|
$is_coach_course = api_is_coach($session_id, $course['real_id']); |
|
1121
|
|
|
$allowed_time = 0; |
|
1122
|
|
|
$dif_time_after = 0; |
|
1123
|
|
|
|
|
1124
|
|
|
if (!empty($date_session_start) && |
|
1125
|
|
|
$date_session_start != '0000-00-00 00:00:00' |
|
1126
|
|
|
) { |
|
1127
|
|
|
if ($is_coach_course) { |
|
1128
|
|
|
$allowed_time = api_strtotime($coachAccessStartDate); |
|
1129
|
|
|
} else { |
|
1130
|
|
|
$allowed_time = api_strtotime($date_session_start); |
|
1131
|
|
|
} |
|
1132
|
|
|
|
|
1133
|
|
View Code Duplication |
if (!isset($_GET['history'])) { |
|
1134
|
|
|
if (!empty($date_session_end) && |
|
1135
|
|
|
$date_session_end != '0000-00-00 00:00:00' |
|
1136
|
|
|
) { |
|
1137
|
|
|
$endSessionToTms = api_strtotime($date_session_end); |
|
1138
|
|
|
if ($session_now > $endSessionToTms) { |
|
1139
|
|
|
$dif_time_after = $session_now - $endSessionToTms; |
|
1140
|
|
|
$dif_time_after = round($dif_time_after / 86400); |
|
1141
|
|
|
} |
|
1142
|
|
|
} |
|
1143
|
|
|
} |
|
1144
|
|
|
} |
|
1145
|
|
|
|
|
1146
|
|
|
if ( |
|
1147
|
|
|
$session_now > $allowed_time |
|
1148
|
|
|
//($coachAccessEndDate > $dif_time_after - 1) |
|
1149
|
|
|
) { |
|
1150
|
|
|
// Read only and accessible. |
|
1151
|
|
|
$atLeastOneCourseIsVisible = true; |
|
1152
|
|
|
|
|
1153
|
|
|
if (api_get_setting('hide_courses_in_sessions') == 'false') { |
|
1154
|
|
|
$courseUserHtml = CourseManager::get_logged_user_course_html( |
|
1155
|
|
|
$course, |
|
1156
|
|
|
$session_id, |
|
1157
|
|
|
'session_course_item', |
|
1158
|
|
|
true, |
|
1159
|
|
|
$this->load_directories_preview |
|
1160
|
|
|
); |
|
1161
|
|
|
if (isset($courseUserHtml[1])) { |
|
1162
|
|
|
$course_session = $courseUserHtml[1]; |
|
1163
|
|
|
$course_session['skill'] = isset($courseUserHtml['skill']) ? $courseUserHtml['skill'] : ''; |
|
1164
|
|
|
$html_courses_session[] = $course_session; |
|
1165
|
|
|
} |
|
1166
|
|
|
} |
|
1167
|
|
|
$count_courses_session++; |
|
1168
|
|
|
} |
|
1169
|
|
|
} |
|
1170
|
|
|
|
|
1171
|
|
|
// No courses to show. |
|
1172
|
|
|
if ($atLeastOneCourseIsVisible == false) { |
|
1173
|
|
|
if (empty($html_courses_session)) { |
|
1174
|
|
|
continue; |
|
1175
|
|
|
} |
|
1176
|
|
|
} |
|
1177
|
|
|
|
|
1178
|
|
|
if ($count_courses_session > 0) { |
|
1179
|
|
|
$params = array( |
|
1180
|
|
|
'id' => $session_id |
|
1181
|
|
|
); |
|
1182
|
|
|
$session_box = Display::get_session_title_box($session_id); |
|
1183
|
|
|
|
|
1184
|
|
|
$extra_info = !empty($session_box['coach']) ? $session_box['coach'] : null; |
|
1185
|
|
|
$extra_info .= !empty($session_box['coach']) |
|
1186
|
|
|
? ' - ' . $session_box['dates'] |
|
1187
|
|
|
: $session_box['dates']; |
|
1188
|
|
|
$extra_info .= isset($session_box['duration']) |
|
1189
|
|
|
? ' ' . $session_box['duration'] |
|
1190
|
|
|
: null; |
|
1191
|
|
|
|
|
1192
|
|
|
$params['extra_fields'] = $session_box['extra_fields']; |
|
1193
|
|
|
$params['course_list_session_style'] = $coursesListSessionStyle; |
|
1194
|
|
|
|
|
1195
|
|
|
$params['title'] = $session_box['title']; |
|
1196
|
|
|
$params['subtitle'] = $extra_info; |
|
1197
|
|
|
$params['show_actions'] = api_is_platform_admin() ? true : false; |
|
1198
|
|
|
|
|
1199
|
|
|
if (api_get_setting('hide_courses_in_sessions') == 'false') { |
|
|
|
|
|
|
1200
|
|
|
// $params['extra'] .= $html_courses_session; |
|
1201
|
|
|
} |
|
1202
|
|
|
|
|
1203
|
|
|
$params['description'] = $session_box['description']; |
|
1204
|
|
|
$params['show_description'] = $session_box['show_description']; |
|
1205
|
|
|
$params['courses'] = $html_courses_session; |
|
1206
|
|
|
$params['show_simple_session_info'] = false; |
|
1207
|
|
|
|
|
1208
|
|
|
if ( |
|
1209
|
|
|
isset($_configuration['show_simple_session_info']) && |
|
1210
|
|
|
$_configuration['show_simple_session_info'] |
|
1211
|
|
|
) { |
|
1212
|
|
|
$params['show_simple_session_info'] = true; |
|
1213
|
|
|
} |
|
1214
|
|
|
|
|
1215
|
|
|
if ($gamificationModeIsActive) { |
|
1216
|
|
|
$params['stars'] = GamificationUtils::getSessionStars($params['id'], $this->user_id); |
|
1217
|
|
|
$params['progress'] = GamificationUtils::getSessionProgress($params['id'], $this->user_id); |
|
1218
|
|
|
$params['points'] = GamificationUtils::getSessionPoints($params['id'], $this->user_id); |
|
1219
|
|
|
} |
|
1220
|
|
|
|
|
1221
|
|
|
$this->tpl->assign('session', $params); |
|
|
|
|
|
|
1222
|
|
|
$this->tpl->assign('gamification_mode', $gamificationModeIsActive); |
|
|
|
|
|
|
1223
|
|
|
|
|
1224
|
|
|
$sessions_with_no_category .= $this->tpl->fetch( |
|
|
|
|
|
|
1225
|
|
|
$this->tpl->get_template('/user_portal/session.tpl') |
|
|
|
|
|
|
1226
|
|
|
); |
|
1227
|
|
|
|
|
1228
|
|
|
$sessionCount++; |
|
1229
|
|
|
} |
|
1230
|
|
|
} |
|
1231
|
|
|
} else { |
|
1232
|
|
|
// All sessions included in |
|
1233
|
|
|
$count_courses_session = 0; |
|
1234
|
|
|
$html_sessions = ''; |
|
1235
|
|
|
if (isset($session_category['sessions'])) { |
|
1236
|
|
|
foreach ($session_category['sessions'] as $session) { |
|
1237
|
|
|
$session_id = $session['session_id']; |
|
1238
|
|
|
|
|
1239
|
|
|
// Don't show empty sessions. |
|
1240
|
|
|
if (count($session['courses']) < 1) { |
|
1241
|
|
|
continue; |
|
1242
|
|
|
} |
|
1243
|
|
|
|
|
1244
|
|
|
$date_session_start = $session['access_start_date']; |
|
1245
|
|
|
$date_session_end = $session['access_end_date']; |
|
1246
|
|
|
$coachAccessStartDate = $session['coach_access_start_date']; |
|
1247
|
|
|
$coachAccessEndDate = $session['coach_access_end_date']; |
|
1248
|
|
|
|
|
1249
|
|
|
$session_now = time(); |
|
1250
|
|
|
$html_courses_session = []; |
|
1251
|
|
|
$count = 0; |
|
1252
|
|
|
|
|
1253
|
|
|
foreach ($session['courses'] as $course) { |
|
1254
|
|
|
$is_coach_course = api_is_coach( |
|
1255
|
|
|
$session_id, |
|
1256
|
|
|
$course['real_id'] |
|
1257
|
|
|
); |
|
1258
|
|
|
|
|
1259
|
|
|
$dif_time_after = 0; |
|
1260
|
|
|
$allowed_time = 0; |
|
1261
|
|
|
if ($is_coach_course) { |
|
1262
|
|
|
// 24 hours = 86400 |
|
1263
|
|
|
if ($date_session_start != '0000-00-00 00:00:00') { |
|
1264
|
|
|
$allowed_time = api_strtotime($coachAccessStartDate); |
|
1265
|
|
|
} |
|
1266
|
|
View Code Duplication |
if (!isset($_GET['history'])) { |
|
1267
|
|
|
if ($date_session_end != '0000-00-00 00:00:00') { |
|
1268
|
|
|
$endSessionToTms = api_strtotime( |
|
1269
|
|
|
$date_session_end |
|
1270
|
|
|
); |
|
1271
|
|
|
if ($session_now > $endSessionToTms) { |
|
1272
|
|
|
$dif_time_after = $session_now - $endSessionToTms; |
|
1273
|
|
|
$dif_time_after = round( |
|
1274
|
|
|
$dif_time_after / 86400 |
|
1275
|
|
|
); |
|
1276
|
|
|
} |
|
1277
|
|
|
} |
|
1278
|
|
|
} |
|
1279
|
|
|
} else { |
|
1280
|
|
|
$allowed_time = api_strtotime( |
|
1281
|
|
|
$date_session_start |
|
1282
|
|
|
); |
|
1283
|
|
|
} |
|
1284
|
|
|
|
|
1285
|
|
|
if ( |
|
1286
|
|
|
$session_now > $allowed_time //&& |
|
1287
|
|
|
//$coachAccessEndDate > $dif_time_after - 1 |
|
1288
|
|
|
) { |
|
1289
|
|
|
if (api_get_setting('hide_courses_in_sessions') == 'false') { |
|
1290
|
|
|
$c = CourseManager:: get_logged_user_course_html( |
|
1291
|
|
|
$course, |
|
1292
|
|
|
$session_id, |
|
1293
|
|
|
'session_course_item' |
|
1294
|
|
|
); |
|
1295
|
|
|
$html_courses_session[] = $c[1]; |
|
1296
|
|
|
} |
|
1297
|
|
|
$count_courses_session++; |
|
1298
|
|
|
$count++; |
|
1299
|
|
|
} |
|
1300
|
|
|
} |
|
1301
|
|
|
|
|
1302
|
|
|
$sessionParams = array(); |
|
1303
|
|
|
// Category |
|
1304
|
|
|
if ($count > 0) { |
|
1305
|
|
|
$session_box = Display:: get_session_title_box($session_id); |
|
1306
|
|
|
$sessionParams['id'] = $session_id; |
|
1307
|
|
|
//$sessionParams['show_link_to_session'] = !api_is_drh() && $sessionTitleLink; |
|
1308
|
|
|
$sessionParams['course_list_session_style'] = $coursesListSessionStyle; |
|
1309
|
|
|
$sessionParams['title'] = $session_box['title']; |
|
1310
|
|
|
$sessionParams['subtitle'] = (!empty($session_box['coach']) |
|
1311
|
|
|
? $session_box['coach'] . ' | ' |
|
1312
|
|
|
: '') . $session_box['dates']; |
|
1313
|
|
|
$sessionParams['show_actions'] = api_is_platform_admin(); |
|
1314
|
|
|
$sessionParams['courses'] = $html_courses_session; |
|
1315
|
|
|
$sessionParams['show_simple_session_info'] = false; |
|
1316
|
|
|
|
|
1317
|
|
|
if ( |
|
1318
|
|
|
isset($_configuration['show_simple_session_info']) && |
|
1319
|
|
|
$_configuration['show_simple_session_info'] |
|
1320
|
|
|
) { |
|
1321
|
|
|
$sessionParams['show_simple_session_info'] = true; |
|
1322
|
|
|
} |
|
1323
|
|
|
|
|
1324
|
|
|
$this->tpl->assign('session', $sessionParams); |
|
|
|
|
|
|
1325
|
|
|
$html_sessions .= $this->tpl->fetch( |
|
|
|
|
|
|
1326
|
|
|
$this->tpl->get_template('user_portal/session.tpl') |
|
|
|
|
|
|
1327
|
|
|
); |
|
1328
|
|
|
|
|
1329
|
|
|
$sessionCount++; |
|
1330
|
|
|
} |
|
1331
|
|
|
} |
|
1332
|
|
|
} |
|
1333
|
|
|
|
|
1334
|
|
|
if ($count_courses_session > 0) { |
|
1335
|
|
|
$categoryParams = array( |
|
1336
|
|
|
'id' => $session_category['session_category']['id'], |
|
1337
|
|
|
'title' => $session_category['session_category']['name'], |
|
1338
|
|
|
'show_actions' => api_is_platform_admin(), |
|
1339
|
|
|
'subtitle' => null, |
|
1340
|
|
|
'sessions' => $html_sessions |
|
1341
|
|
|
); |
|
1342
|
|
|
|
|
1343
|
|
|
$session_category_start_date = $session_category['session_category']['date_start']; |
|
1344
|
|
|
$session_category_end_date = $session_category['session_category']['date_end']; |
|
1345
|
|
|
|
|
1346
|
|
|
if ( |
|
1347
|
|
|
!empty($session_category_start_date) && |
|
1348
|
|
|
$session_category_start_date != '0000-00-00' && |
|
1349
|
|
|
!empty($session_category_end_date) && |
|
1350
|
|
|
$session_category_end_date != '0000-00-00' |
|
1351
|
|
|
) { |
|
1352
|
|
|
$categoryParams['subtitle'] = sprintf( |
|
1353
|
|
|
get_lang('FromDateXToDateY'), |
|
1354
|
|
|
$session_category['session_category']['date_start'], |
|
1355
|
|
|
$session_category['session_category']['date_end'] |
|
1356
|
|
|
); |
|
1357
|
|
|
} else { |
|
1358
|
|
|
if ( |
|
1359
|
|
|
!empty($session_category_start_date) && |
|
1360
|
|
|
$session_category_start_date != '0000-00-00' |
|
1361
|
|
|
) { |
|
1362
|
|
|
$categoryParams['subtitle'] = get_lang('From') . ' ' . $session_category_start_date; |
|
1363
|
|
|
} |
|
1364
|
|
|
|
|
1365
|
|
|
if ( |
|
1366
|
|
|
!empty($session_category_end_date) && |
|
1367
|
|
|
$session_category_end_date != '0000-00-00' |
|
1368
|
|
|
) { |
|
1369
|
|
|
$categoryParams['subtitle'] = get_lang('Until') . ' ' . $session_category_end_date; |
|
1370
|
|
|
} |
|
1371
|
|
|
} |
|
1372
|
|
|
|
|
1373
|
|
|
$this->tpl->assign('session_category', $categoryParams); |
|
|
|
|
|
|
1374
|
|
|
$sessions_with_category .= $this->tpl->fetch( |
|
|
|
|
|
|
1375
|
|
|
"{$this->tpl->templateFolder}/user_portal/session_category.tpl" |
|
1376
|
|
|
); |
|
1377
|
|
|
} |
|
1378
|
|
|
} |
|
1379
|
|
|
} |
|
1380
|
|
|
} |
|
1381
|
|
|
|
|
1382
|
|
|
return [ |
|
1383
|
|
|
'html' => $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses, |
|
1384
|
|
|
'session_count' => $sessionCount, |
|
1385
|
|
|
'course_count' => $courseCount |
|
1386
|
|
|
]; |
|
1387
|
|
|
} |
|
1388
|
|
|
|
|
1389
|
|
|
/** |
|
1390
|
|
|
* Shows a welcome message when the user doesn't have any content in the course list |
|
1391
|
|
|
*/ |
|
1392
|
|
|
public function return_welcome_to_course_block() |
|
1393
|
|
|
{ |
|
1394
|
|
|
$count_courses = CourseManager::count_courses(); |
|
1395
|
|
|
$tpl = $this->tpl->get_template('layout/welcome_to_course.tpl'); |
|
|
|
|
|
|
1396
|
|
|
|
|
1397
|
|
|
$course_catalog_url = api_get_path(WEB_CODE_PATH).'auth/courses.php'; |
|
1398
|
|
|
$course_list_url = api_get_path(WEB_PATH).'user_portal.php'; |
|
1399
|
|
|
|
|
1400
|
|
|
$this->tpl->assign('course_catalog_url', $course_catalog_url); |
|
|
|
|
|
|
1401
|
|
|
$this->tpl->assign('course_list_url', $course_list_url); |
|
|
|
|
|
|
1402
|
|
|
$this->tpl->assign('course_catalog_link', Display::url(get_lang('Here'), $course_catalog_url)); |
|
|
|
|
|
|
1403
|
|
|
$this->tpl->assign('course_list_link', Display::url(get_lang('Here'), $course_list_url)); |
|
|
|
|
|
|
1404
|
|
|
$this->tpl->assign('count_courses', $count_courses); |
|
|
|
|
|
|
1405
|
|
|
|
|
1406
|
|
|
return $this->tpl->fetch($tpl); |
|
|
|
|
|
|
1407
|
|
|
} |
|
1408
|
|
|
|
|
1409
|
|
|
/** |
|
1410
|
|
|
* @return array |
|
1411
|
|
|
*/ |
|
1412
|
|
|
public function return_hot_courses() |
|
1413
|
|
|
{ |
|
1414
|
|
|
return CourseManager::return_hot_courses(30, 6); |
|
1415
|
|
|
} |
|
1416
|
|
|
|
|
1417
|
|
|
/** |
|
1418
|
|
|
* UserPortal view for session, return the HTLK of the course list |
|
1419
|
|
|
* @param $user_id |
|
1420
|
|
|
* @return string |
|
1421
|
|
|
*/ |
|
1422
|
|
|
public function returnCoursesAndSessionsViewBySession($user_id) |
|
1423
|
|
|
{ |
|
1424
|
|
|
$sessionCount = 0; |
|
1425
|
|
|
$courseCount = 0; |
|
1426
|
|
|
|
|
1427
|
|
|
$load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false; |
|
1428
|
|
|
|
|
1429
|
|
View Code Duplication |
if ($load_history) { |
|
1430
|
|
|
//Load sessions in category in *history* |
|
1431
|
|
|
$session_categories = UserManager::get_sessions_by_category($user_id, true); |
|
1432
|
|
|
} else { |
|
1433
|
|
|
//Load sessions in category |
|
1434
|
|
|
$session_categories = UserManager::get_sessions_by_category($user_id, false); |
|
1435
|
|
|
} |
|
1436
|
|
|
|
|
1437
|
|
|
$html = ''; |
|
1438
|
|
|
|
|
1439
|
|
|
//Showing history title |
|
1440
|
|
View Code Duplication |
if ($load_history) { |
|
1441
|
|
|
$html .= Display::page_subheader(get_lang('HistoryTrainingSession')); |
|
1442
|
|
|
if (empty($session_categories)) { |
|
1443
|
|
|
$html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); |
|
1444
|
|
|
} |
|
1445
|
|
|
} |
|
1446
|
|
|
|
|
1447
|
|
|
$specialCourses = ''; |
|
1448
|
|
|
$loadDirs = $this->load_directories_preview; |
|
1449
|
|
|
|
|
1450
|
|
|
// If we're not in the history view... |
|
1451
|
|
|
$listCoursesInfo = array(); |
|
1452
|
|
|
if (!isset($_GET['history'])) { |
|
1453
|
|
|
// Display special courses |
|
1454
|
|
|
$specialCoursesResult = CourseManager::display_special_courses( |
|
1455
|
|
|
$user_id, |
|
1456
|
|
|
$loadDirs |
|
1457
|
|
|
); |
|
1458
|
|
|
$specialCourses = $specialCoursesResult['html']; |
|
1459
|
|
|
|
|
1460
|
|
|
// Display courses |
|
1461
|
|
|
// [code=>xxx, real_id=>000] |
|
1462
|
|
|
$listCourses = CourseManager::get_courses_list_by_user_id($user_id, false); |
|
1463
|
|
|
foreach ($listCourses as $i => $listCourseCodeId) { |
|
1464
|
|
|
list($userCategoryId, $userCatTitle) = CourseManager::getUserCourseCategoryForCourse( |
|
1465
|
|
|
$user_id, |
|
1466
|
|
|
$listCourseCodeId['real_id'] |
|
1467
|
|
|
); |
|
1468
|
|
|
$listCourse = api_get_course_info_by_id($listCourseCodeId['real_id']); |
|
1469
|
|
|
$listCoursesInfo[] = array( |
|
1470
|
|
|
'course' => $listCourse, |
|
1471
|
|
|
'code' => $listCourseCodeId['code'], |
|
1472
|
|
|
'id' => $listCourseCodeId['real_id'], |
|
1473
|
|
|
'title' => $listCourse['title'], |
|
1474
|
|
|
'userCatId' => $userCategoryId, |
|
1475
|
|
|
'userCatTitle' => $userCatTitle |
|
1476
|
|
|
); |
|
1477
|
|
|
$courseCount++; |
|
1478
|
|
|
} |
|
1479
|
|
|
usort($listCoursesInfo, 'self::compareByCourse'); |
|
1480
|
|
|
} |
|
1481
|
|
|
|
|
1482
|
|
|
if (is_array($session_categories)) { |
|
1483
|
|
|
// all courses that are in a session |
|
1484
|
|
|
$listCoursesInSession = SessionManager::getNamedSessionCourseForCoach($user_id); |
|
1485
|
|
|
} |
|
1486
|
|
|
|
|
1487
|
|
|
// we got all courses |
|
1488
|
|
|
// for each user category, sorted alphabetically, display courses |
|
1489
|
|
|
$listUserCategories = CourseManager::get_user_course_categories($user_id); |
|
1490
|
|
|
$listCoursesAlreadyDisplayed = array(); |
|
1491
|
|
|
uasort($listUserCategories, "self::compareListUserCategory"); |
|
1492
|
|
|
$listUserCategories[0] = ''; |
|
1493
|
|
|
|
|
1494
|
|
|
$html = '<div class="session-view-block">'; |
|
1495
|
|
|
|
|
1496
|
|
|
foreach ($listUserCategories as $userCategoryId => $userCatTitle) { |
|
1497
|
|
|
// add user category |
|
1498
|
|
|
$userCategoryHtml = ''; |
|
1499
|
|
|
if ($userCategoryId != 0) { |
|
1500
|
|
|
$userCategoryHtml = '<div class="session-view-well ">'; |
|
1501
|
|
|
} |
|
1502
|
|
|
$userCategoryHtml .= self::getHtmlForUserCategory($userCategoryId, $userCatTitle); |
|
1503
|
|
|
|
|
1504
|
|
|
// look for course in this userCat in session courses : $listCoursesInSession |
|
1505
|
|
|
$htmlCategory = ''; |
|
1506
|
|
|
if (isset($listCoursesInSession[$userCategoryId])) { |
|
1507
|
|
|
// list of courses in this user cat |
|
1508
|
|
|
foreach ($listCoursesInSession[$userCategoryId]['courseInUserCatList'] as $i => $listCourse) { |
|
1509
|
|
|
// add course |
|
1510
|
|
|
$listCoursesAlreadyDisplayed[$listCourse['courseId']] = 1; |
|
1511
|
|
|
if ($userCategoryId == 0) { |
|
1512
|
|
|
$htmlCategory .= '<div class="session-view-well session-view-row well" >'; |
|
1513
|
|
|
} else { |
|
1514
|
|
|
$htmlCategory .= '<div class="session-view-row" >'; |
|
1515
|
|
|
} |
|
1516
|
|
|
$coursesInfo = $listCourse['course']; |
|
1517
|
|
|
|
|
1518
|
|
|
$htmlCategory .= self::getHtmlForCourse( |
|
1519
|
|
|
$coursesInfo, |
|
1520
|
|
|
$userCategoryId, |
|
1521
|
|
|
1, |
|
1522
|
|
|
$loadDirs |
|
1523
|
|
|
); |
|
1524
|
|
|
// list of session category |
|
1525
|
|
|
$htmlSessionCategory = '<div class="session-view-row" style="display:none;" id="courseblock-'.$coursesInfo['real_id'].'">'; |
|
1526
|
|
|
foreach ($listCourse['sessionCatList'] as $j => $listCategorySession) { |
|
1527
|
|
|
// add session category |
|
1528
|
|
|
$htmlSessionCategory .= self::getHtmlSessionCategory( |
|
1529
|
|
|
$listCategorySession['catSessionId'], |
|
1530
|
|
|
$listCategorySession['catSessionName'] |
|
1531
|
|
|
); |
|
1532
|
|
|
// list of session |
|
1533
|
|
|
$htmlSession = ''; // start |
|
1534
|
|
|
foreach ($listCategorySession['sessionList'] as $k => $listSession) { |
|
1535
|
|
|
// add session |
|
1536
|
|
|
$htmlSession .= '<div class="session-view-row">'; |
|
1537
|
|
|
$htmlSession .= self::getHtmlForSession( |
|
1538
|
|
|
$listSession['sessionId'], |
|
1539
|
|
|
$listSession['sessionName'], |
|
1540
|
|
|
$listCategorySession['catSessionId'], |
|
1541
|
|
|
$coursesInfo |
|
1542
|
|
|
); |
|
1543
|
|
|
$htmlSession .= '</div>'; |
|
1544
|
|
|
$sessionCount++; |
|
1545
|
|
|
} |
|
1546
|
|
|
$htmlSession .= ''; // end session block |
|
1547
|
|
|
$htmlSessionCategory .= $htmlSession; |
|
1548
|
|
|
} |
|
1549
|
|
|
$htmlSessionCategory .= '</div>'; // end session cat block |
|
1550
|
|
|
$htmlCategory .= $htmlSessionCategory .'</div>' ; |
|
1551
|
|
|
$htmlCategory .= ''; // end course block |
|
1552
|
|
|
} |
|
1553
|
|
|
$userCategoryHtml .= $htmlCategory; |
|
1554
|
|
|
} |
|
1555
|
|
|
|
|
1556
|
|
|
// look for courses in this userCat in not in session courses : $listCoursesInfo |
|
1557
|
|
|
// if course not already added |
|
1558
|
|
|
$htmlCategory = ''; |
|
1559
|
|
|
foreach ($listCoursesInfo as $i => $listCourse) { |
|
1560
|
|
|
if ($listCourse['userCatId'] == $userCategoryId && !isset($listCoursesAlreadyDisplayed[$listCourse['id']])) { |
|
1561
|
|
|
if ($userCategoryId != 0) { |
|
1562
|
|
|
$htmlCategory .= '<div class="session-view-row" >'; |
|
1563
|
|
|
} else { |
|
1564
|
|
|
$htmlCategory .= '<div class="session-view-well well">'; |
|
1565
|
|
|
} |
|
1566
|
|
|
$htmlCategory .= self::getHtmlForCourse( |
|
1567
|
|
|
$listCourse['course'], |
|
1568
|
|
|
$userCategoryId, |
|
1569
|
|
|
0, |
|
1570
|
|
|
$loadDirs |
|
1571
|
|
|
); |
|
1572
|
|
|
$htmlCategory .= '</div>'; |
|
1573
|
|
|
} |
|
1574
|
|
|
} |
|
1575
|
|
|
$htmlCategory .= ''; |
|
1576
|
|
|
$userCategoryHtml .= $htmlCategory; // end user cat block |
|
1577
|
|
|
if ($userCategoryId != 0) { |
|
1578
|
|
|
$userCategoryHtml .= '</div>'; |
|
1579
|
|
|
} |
|
1580
|
|
|
$html .= $userCategoryHtml; // |
|
1581
|
|
|
} |
|
1582
|
|
|
$html .= '</div>'; |
|
1583
|
|
|
|
|
1584
|
|
|
return [ |
|
1585
|
|
|
'html' => $html.$specialCourses, |
|
1586
|
|
|
'session_count' => $sessionCount, |
|
1587
|
|
|
'course_count' => $courseCount |
|
1588
|
|
|
]; |
|
1589
|
|
|
} |
|
1590
|
|
|
|
|
1591
|
|
|
/** |
|
1592
|
|
|
* Return HTML code for personal user course category |
|
1593
|
|
|
* @param $id |
|
1594
|
|
|
* @param $title |
|
1595
|
|
|
* @return string |
|
1596
|
|
|
*/ |
|
1597
|
|
View Code Duplication |
private static function getHtmlForUserCategory($id, $title) |
|
1598
|
|
|
{ |
|
1599
|
|
|
if ($id == 0) { |
|
1600
|
|
|
return ''; |
|
1601
|
|
|
} |
|
1602
|
|
|
$icon = Display::return_icon( |
|
1603
|
|
|
'folder_yellow.png', |
|
1604
|
|
|
$title, |
|
1605
|
|
|
array('class' => 'sessionView'), |
|
1606
|
|
|
ICON_SIZE_LARGE |
|
1607
|
|
|
); |
|
1608
|
|
|
|
|
1609
|
|
|
return "<div class='session-view-user-category'>$icon<span>$title</span></div>"; |
|
1610
|
|
|
} |
|
1611
|
|
|
|
|
1612
|
|
|
/** |
|
1613
|
|
|
* return HTML code for course display in session view |
|
1614
|
|
|
* @param array $courseInfo |
|
1615
|
|
|
* @param $userCategoryId |
|
1616
|
|
|
* @param bool $displayButton |
|
1617
|
|
|
* @param $loadDirs |
|
1618
|
|
|
* @return string |
|
1619
|
|
|
*/ |
|
1620
|
|
|
private static function getHtmlForCourse( |
|
1621
|
|
|
$courseInfo, |
|
1622
|
|
|
$userCategoryId, |
|
1623
|
|
|
$displayButton = false, |
|
1624
|
|
|
$loadDirs |
|
1625
|
|
|
) { |
|
1626
|
|
|
if (empty($courseInfo)) { |
|
1627
|
|
|
return ''; |
|
1628
|
|
|
} |
|
1629
|
|
|
|
|
1630
|
|
|
$id = $courseInfo['real_id']; |
|
1631
|
|
|
$title = $courseInfo['title']; |
|
1632
|
|
|
$code = $courseInfo['code']; |
|
1633
|
|
|
|
|
1634
|
|
|
$class = 'session-view-lvl-6'; |
|
1635
|
|
|
if ($userCategoryId != 0 && !$displayButton) { |
|
1636
|
|
|
$class = 'session-view-lvl-7'; |
|
1637
|
|
|
} |
|
1638
|
|
|
|
|
1639
|
|
|
$class2 = 'session-view-lvl-6'; |
|
1640
|
|
|
if ($displayButton || $userCategoryId != 0) { |
|
1641
|
|
|
$class2 = 'session-view-lvl-7'; |
|
1642
|
|
|
} |
|
1643
|
|
|
|
|
1644
|
|
|
$button = ''; |
|
1645
|
|
|
if ($displayButton) { |
|
1646
|
|
|
$button = '<input id="session-view-button-'.intval($id).'" class="session-view-button btn btn-default" type="button" onclick="hideUnhide(\'courseblock-'.intval($id).'\', \'session-view-button-'.intval($id).'\', \'+\', \'-\')" value="+" />'; |
|
1647
|
|
|
} |
|
1648
|
|
|
|
|
1649
|
|
|
$icon = Display::return_icon( |
|
1650
|
|
|
'blackboard.png', |
|
1651
|
|
|
$title, |
|
1652
|
|
|
array('class' => 'sessionView'), |
|
1653
|
|
|
ICON_SIZE_LARGE |
|
1654
|
|
|
); |
|
1655
|
|
|
|
|
1656
|
|
|
$courseLink = $courseInfo['course_public_url'].'?id_session=0'; |
|
1657
|
|
|
|
|
1658
|
|
|
// get html course params |
|
1659
|
|
|
// ['right_actions'] ['teachers'] ['notifications'] |
|
1660
|
|
|
$tabParams = CourseManager::getCourseParamsForDisplay($id, $loadDirs); |
|
1661
|
|
|
// teacher list |
|
1662
|
|
|
if (!empty($tabParams['teachers'])) { |
|
1663
|
|
|
$teachers = '<p class="'.$class2.' view-by-session-teachers">'.$tabParams['teachers'].'</p>'; |
|
1664
|
|
|
} |
|
1665
|
|
|
|
|
1666
|
|
|
// notification |
|
1667
|
|
|
if (!empty($tabParams['right_actions'])) { |
|
1668
|
|
|
$rightActions = '<div class="view-by-session-right-actions">'.$tabParams['right_actions'].'</div>'; |
|
1669
|
|
|
} |
|
1670
|
|
|
|
|
1671
|
|
|
return "<div> |
|
1672
|
|
|
$button |
|
1673
|
|
|
<span class='$class'>$icon |
|
1674
|
|
|
<a class='sessionView' href='$courseLink'>$title</a> |
|
1675
|
|
|
</span>".$tabParams['notifications']."$rightActions |
|
1676
|
|
|
</div> |
|
1677
|
|
|
$teachers"; |
|
1678
|
|
|
} |
|
1679
|
|
|
|
|
1680
|
|
|
/** |
|
1681
|
|
|
* return HTML code for session category |
|
1682
|
|
|
* @param $id |
|
1683
|
|
|
* @param $title |
|
1684
|
|
|
* @return string |
|
1685
|
|
|
*/ |
|
1686
|
|
View Code Duplication |
private static function getHtmlSessionCategory($id, $title) |
|
1687
|
|
|
{ |
|
1688
|
|
|
if ($id == 0) { |
|
1689
|
|
|
return ''; |
|
1690
|
|
|
} |
|
1691
|
|
|
|
|
1692
|
|
|
$icon = Display::return_icon( |
|
1693
|
|
|
'folder_blue.png', |
|
1694
|
|
|
$title, |
|
1695
|
|
|
array('class' => 'sessionView'), |
|
1696
|
|
|
ICON_SIZE_LARGE |
|
1697
|
|
|
); |
|
1698
|
|
|
|
|
1699
|
|
|
return "<div class='session-view-session-category'> |
|
1700
|
|
|
<span class='session-view-lvl-2'> |
|
1701
|
|
|
$icon |
|
1702
|
|
|
<span>$title</span> |
|
1703
|
|
|
</span> |
|
1704
|
|
|
</div>"; |
|
1705
|
|
|
} |
|
1706
|
|
|
|
|
1707
|
|
|
/** |
|
1708
|
|
|
* return HTML code for session |
|
1709
|
|
|
* @param int $id session id |
|
1710
|
|
|
* @param string $title session title |
|
1711
|
|
|
* @param int $categorySessionId |
|
1712
|
|
|
* @param array $courseInfo |
|
1713
|
|
|
* |
|
1714
|
|
|
* @return string |
|
1715
|
|
|
*/ |
|
1716
|
|
|
private static function getHtmlForSession($id, $title, $categorySessionId, $courseInfo) |
|
1717
|
|
|
{ |
|
1718
|
|
|
$html = ''; |
|
1719
|
|
|
|
|
1720
|
|
|
if ($categorySessionId == 0) { |
|
1721
|
|
|
$class1 = 'session-view-lvl-2'; // session |
|
1722
|
|
|
$class2 = 'session-view-lvl-4'; // got to course in session link |
|
1723
|
|
|
} else { |
|
1724
|
|
|
$class1 = 'session-view-lvl-3'; // session |
|
1725
|
|
|
$class2 = 'session-view-lvl-5'; // got to course in session link |
|
1726
|
|
|
} |
|
1727
|
|
|
|
|
1728
|
|
|
$icon = Display::return_icon( |
|
1729
|
|
|
'blackboard_blue.png', |
|
1730
|
|
|
$title, |
|
1731
|
|
|
array('class' => 'sessionView'), |
|
1732
|
|
|
ICON_SIZE_LARGE |
|
1733
|
|
|
); |
|
1734
|
|
|
$courseLink = $courseInfo['course_public_url'].'?id_session='.intval($id); |
|
1735
|
|
|
|
|
1736
|
|
|
$html .= "<span class='$class1 session-view-session'>$icon$title</span>"; |
|
1737
|
|
|
$html .= '<div class="'.$class2.' session-view-session-go-to-course-in-session"> |
|
1738
|
|
|
<a class="" href="'.$courseLink.'">'.get_lang('GoToCourseInsideSession').'</a></div>'; |
|
1739
|
|
|
|
|
1740
|
|
|
return '<div>'.$html.'</div>'; |
|
1741
|
|
|
} |
|
1742
|
|
|
|
|
1743
|
|
|
/** |
|
1744
|
|
|
* @param $listA |
|
1745
|
|
|
* @param $listB |
|
1746
|
|
|
* @return int |
|
1747
|
|
|
*/ |
|
1748
|
|
|
private static function compareByCourse($listA, $listB) |
|
|
|
|
|
|
1749
|
|
|
{ |
|
1750
|
|
|
if ($listA['userCatTitle'] == $listB['userCatTitle']) { |
|
1751
|
|
|
if ($listA['title'] == $listB['title']) { |
|
1752
|
|
|
return 0; |
|
1753
|
|
|
} else if($listA['title'] > $listB['title']) { |
|
1754
|
|
|
return 1; |
|
1755
|
|
|
} else { |
|
1756
|
|
|
return -1; |
|
1757
|
|
|
} |
|
1758
|
|
|
} else if ($listA['userCatTitle'] > $listB['userCatTitle']) { |
|
1759
|
|
|
return 1; |
|
1760
|
|
|
} else { |
|
1761
|
|
|
return -1; |
|
1762
|
|
|
} |
|
1763
|
|
|
} |
|
1764
|
|
|
|
|
1765
|
|
|
/** |
|
1766
|
|
|
* @param $listA |
|
1767
|
|
|
* @param $listB |
|
1768
|
|
|
* @return int |
|
1769
|
|
|
*/ |
|
1770
|
|
View Code Duplication |
public static function compareListUserCategory($listA, $listB) |
|
1771
|
|
|
{ |
|
1772
|
|
|
if ($listA['title'] == $listB['title']) { |
|
1773
|
|
|
return 0; |
|
1774
|
|
|
} else if($listA['title'] > $listB['title']) { |
|
1775
|
|
|
return 1; |
|
1776
|
|
|
} else { |
|
1777
|
|
|
return -1; |
|
1778
|
|
|
} |
|
1779
|
|
|
} |
|
1780
|
|
|
|
|
1781
|
|
|
/** |
|
1782
|
|
|
* @param $view |
|
1783
|
|
|
* @param $userId |
|
1784
|
|
|
*/ |
|
1785
|
|
|
public static function setDefaultMyCourseView($view, $userId) |
|
1786
|
|
|
{ |
|
1787
|
|
|
setcookie('defaultMyCourseView'.$userId, $view); |
|
1788
|
|
|
} |
|
1789
|
|
|
} |
|
1790
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..