|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
use Chamilo\CoreBundle\Component\Utils\ChamiloApi; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* @deprecated |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Determines the possible tabs (=sections) that are available. |
|
13
|
|
|
* This function is used when creating the tabs in the third header line and |
|
14
|
|
|
* all the sections that do not appear there (as determined by the |
|
15
|
|
|
* platform admin on the Dokeos configuration settings page) |
|
16
|
|
|
* will appear in the right hand menu that appears on several other pages |
|
17
|
|
|
* @return array containing all the possible tabs |
|
18
|
|
|
* @author Patrick Cool <[email protected]>, Ghent University |
|
19
|
|
|
*/ |
|
20
|
|
|
function get_tabs($courseId = null) |
|
21
|
|
|
{ |
|
22
|
|
|
$_course = api_get_course_info($courseId); |
|
23
|
|
|
|
|
24
|
|
|
$navigation = array(); |
|
25
|
|
|
|
|
26
|
|
|
// Campus Homepage |
|
27
|
|
|
$navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php'; |
|
28
|
|
|
$navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage'); |
|
29
|
|
|
$navigation[SECTION_CAMPUS]['key'] = 'homepage'; |
|
30
|
|
|
$navigation[SECTION_CAMPUS]['icon'] = 'homepage.png'; |
|
31
|
|
|
|
|
32
|
|
|
$navigation[SECTION_CATALOG]['url'] = api_get_path(WEB_PATH).'main/auth/courses.php'; |
|
33
|
|
|
$navigation[SECTION_CATALOG]['title'] = get_lang('Courses'); |
|
34
|
|
|
$navigation[SECTION_CATALOG]['key'] = 'catalog'; |
|
35
|
|
|
$navigation[SECTION_CATALOG]['icon'] = 'catalog.png'; |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
// My Courses |
|
39
|
|
|
|
|
40
|
|
|
if (api_is_allowed_to_create_course()) { |
|
41
|
|
|
// Link to my courses for teachers |
|
42
|
|
|
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true'; |
|
43
|
|
|
} else { |
|
44
|
|
|
// Link to my courses for students |
|
45
|
|
|
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php'; |
|
46
|
|
|
} |
|
47
|
|
|
$navigation['mycourses']['title'] = get_lang('MyCourses'); |
|
48
|
|
|
$navigation['mycourses']['key'] = 'my-course'; |
|
49
|
|
|
$navigation['mycourses']['icon'] = 'my-course.png'; |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
// My Profile |
|
53
|
|
|
$navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); |
|
54
|
|
|
$navigation['myprofile']['title'] = get_lang('ModifyProfile'); |
|
55
|
|
|
$navigation['myprofile']['key'] = 'profile'; |
|
56
|
|
|
$navigation['myprofile']['icon'] = 'profile.png'; |
|
57
|
|
|
// Link to my agenda |
|
58
|
|
|
$navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal'; |
|
59
|
|
|
$navigation['myagenda']['title'] = get_lang('MyAgenda'); |
|
60
|
|
|
$navigation['myagenda']['key'] = 'agenda'; |
|
61
|
|
|
$navigation['myagenda']['icon'] = 'agenda.png'; |
|
62
|
|
|
|
|
63
|
|
|
// Gradebook |
|
64
|
|
|
if (api_get_setting('gradebook_enable') == 'true') { |
|
65
|
|
|
$navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); |
|
66
|
|
|
$navigation['mygradebook']['title'] = get_lang('MyGradebook'); |
|
67
|
|
|
$navigation['mygradebook']['key'] = 'gradebook'; |
|
68
|
|
|
$navigation['mygradebook']['icon'] = 'gradebook.png'; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
// Reporting |
|
72
|
|
|
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { |
|
73
|
|
|
// Link to my space |
|
74
|
|
|
$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':''); |
|
75
|
|
|
$navigation['session_my_space']['title'] = get_lang('MySpace'); |
|
76
|
|
|
$navigation['session_my_space']['key'] = 'my-space'; |
|
77
|
|
|
$navigation['session_my_space']['icon'] = 'my-space.png'; |
|
78
|
|
|
} else if (api_is_student_boss()) { |
|
79
|
|
|
$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH) . 'mySpace/student.php'; |
|
80
|
|
|
$navigation['session_my_space']['title'] = get_lang('MySpace'); |
|
81
|
|
|
$navigation['session_my_space']['key'] = 'my-space'; |
|
82
|
|
|
$navigation['session_my_space']['icon'] = 'my-space.png'; |
|
83
|
|
|
} else { |
|
84
|
|
|
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH); |
|
85
|
|
|
// Link to my progress |
|
86
|
|
|
switch (api_get_setting('gamification_mode')) { |
|
87
|
|
|
case 1: |
|
88
|
|
|
$navigation['session_my_progress']['url'] .= 'gamification/my_progress.php'; |
|
89
|
|
|
break; |
|
90
|
|
|
default: |
|
91
|
|
|
$navigation['session_my_progress']['url'] .= 'auth/my_progress.php'; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
$navigation['session_my_progress']['title'] = get_lang('MyProgress'); |
|
95
|
|
|
$navigation['session_my_progress']['key'] = 'my-progress'; |
|
96
|
|
|
$navigation['session_my_progress']['icon'] = 'my-progress.png'; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
// Social |
|
100
|
|
View Code Duplication |
if (api_get_setting('allow_social_tool')=='true') { |
|
101
|
|
|
$navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php'; |
|
102
|
|
|
$navigation['social']['title'] = get_lang('SocialNetwork'); |
|
103
|
|
|
$navigation['social']['key'] = 'social-network'; |
|
104
|
|
|
$navigation['social']['icon'] = 'social-network.png'; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
// Dashboard |
|
108
|
|
|
if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
|
109
|
|
|
$navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php'; |
|
110
|
|
|
$navigation['dashboard']['title'] = get_lang('Dashboard'); |
|
111
|
|
|
$navigation['dashboard']['key'] = 'dashboard'; |
|
112
|
|
|
$navigation['dashboard']['icon'] = 'dashboard.png'; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
// Reports |
|
116
|
|
|
/* |
|
117
|
|
|
if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
|
118
|
|
|
$navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php'; |
|
119
|
|
|
$navigation['reports']['title'] = get_lang('Reports'); |
|
120
|
|
|
}*/ |
|
121
|
|
|
|
|
122
|
|
|
// Custom Tabs See BT#7180 |
|
123
|
|
|
$customTabs = getCustomTabs(); |
|
124
|
|
|
if (!empty($customTabs)) { |
|
125
|
|
|
foreach ($customTabs as $tab) { |
|
126
|
|
|
if (api_get_setting($tab['variable'], $tab['subkey']) == 'true') { |
|
127
|
|
|
if (!empty($tab['comment']) && $tab['comment'] !== 'ShowTabsComment') { |
|
128
|
|
|
$navigation[$tab['subkey']]['url'] = $tab['comment']; |
|
129
|
|
|
// $tab['title'] value must be included in trad4all.inc.php |
|
130
|
|
|
$navigation[$tab['subkey']]['title'] = get_lang($tab['title']); |
|
131
|
|
|
$navigation[$tab['subkey']]['key'] = $tab['subkey']; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
// End Custom Tabs |
|
137
|
|
|
|
|
138
|
|
|
// Platform administration |
|
139
|
|
View Code Duplication |
if (api_is_platform_admin(true)) { |
|
140
|
|
|
$navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/'; |
|
141
|
|
|
$navigation['platform_admin']['title'] = get_lang('PlatformAdmin'); |
|
142
|
|
|
$navigation['platform_admin']['key'] = 'admin'; |
|
143
|
|
|
$navigation['platform_admin']['icon'] = 'admin.png'; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
return $navigation; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* This function returns the custom tabs |
|
151
|
|
|
* |
|
152
|
|
|
* @return array |
|
153
|
|
|
*/ |
|
154
|
|
|
function getCustomTabs() |
|
155
|
|
|
{ |
|
156
|
|
|
$tableSettingsCurrent = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
|
157
|
|
|
$sql = "SELECT * FROM $tableSettingsCurrent |
|
158
|
|
|
WHERE |
|
159
|
|
|
variable = 'show_tabs' AND |
|
160
|
|
|
subkey like 'custom_tab_%'"; |
|
161
|
|
|
$result = Database::query($sql); |
|
162
|
|
|
$customTabs = array(); |
|
163
|
|
|
while ($row = Database::fetch_assoc($result)) { |
|
164
|
|
|
$customTabs[] = $row; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
return $customTabs; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* Return the active logo of the portal, based on a series of settings |
|
172
|
|
|
* @param string $theme The name of the theme folder from web/css/themes/ |
|
173
|
|
|
* @return string HTML string with logo as an HTML element |
|
174
|
|
|
* @param string $theme |
|
175
|
|
|
*/ |
|
176
|
|
|
function return_logo($theme) |
|
177
|
|
|
{ |
|
178
|
|
|
$siteName = api_get_setting('siteName'); |
|
179
|
|
|
|
|
180
|
|
|
return ChamiloApi::getPlatformLogo([ |
|
181
|
|
|
'title' => $siteName, |
|
182
|
|
|
'class' => 'img-responsive', |
|
183
|
|
|
'id' => 'header-logo' |
|
184
|
|
|
]); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Return HTML string of a list as <li> items |
|
189
|
|
|
* @return string |
|
190
|
|
|
*/ |
|
191
|
|
|
function returnNotificationMenu() |
|
192
|
|
|
{ |
|
193
|
|
|
$_course = api_get_course_info(); |
|
194
|
|
|
$course_id = 0; |
|
195
|
|
|
if (!empty($_course)) { |
|
196
|
|
|
$course_id = $_course['code']; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
$user_id = api_get_user_id(); |
|
200
|
|
|
|
|
201
|
|
|
$html = ''; |
|
202
|
|
|
$cacheEnabled = function_exists('apcu_exists'); |
|
203
|
|
|
|
|
204
|
|
|
if ((api_get_setting('showonline', 'world') == 'true' && !$user_id) || |
|
205
|
|
|
(api_get_setting('showonline', 'users') == 'true' && $user_id) || |
|
206
|
|
|
(api_get_setting('showonline', 'course') == 'true' && $user_id && $course_id) |
|
207
|
|
|
) { |
|
208
|
|
|
$number = getOnlineUsersCount($cacheEnabled); |
|
209
|
|
|
$number_online_in_course = getOnlineUsersInCourseCount($user_id, $_course, $cacheEnabled); |
|
210
|
|
|
|
|
211
|
|
|
// Display the who's online of the platform |
|
212
|
|
|
if ($number && |
|
213
|
|
|
(api_get_setting('showonline', 'world') == 'true' && !$user_id) || |
|
214
|
|
|
(api_get_setting('showonline', 'users') == 'true' && $user_id) |
|
215
|
|
|
) |
|
216
|
|
|
{ |
|
217
|
|
|
$html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_self" title="'.get_lang('UsersOnline').'" >'. |
|
218
|
|
|
Display::return_icon('user.png', get_lang('UsersOnline'), array(), ICON_SIZE_TINY).' '.$number.'</a></li>'; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
// Display the who's online for the course |
|
222
|
|
|
if ($number_online_in_course && |
|
223
|
|
|
(is_array($_course) && |
|
224
|
|
|
api_get_setting('showonline', 'course') == 'true' && isset($_course['sysCode']) |
|
225
|
|
|
) |
|
226
|
|
|
) { |
|
227
|
|
|
$html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonline.php?cidReq='.$_course['sysCode'].'" target="_self">'. |
|
228
|
|
|
Display::return_icon('course.png', get_lang('UsersOnline').' '.get_lang('InThisCourse'), array(), ICON_SIZE_TINY).' '.$number_online_in_course.' </a></li>'; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
View Code Duplication |
if (isset($user_id) && api_get_session_id() != 0) { |
|
232
|
|
|
$html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$user_id.'&referer='.urlencode($_SERVER['REQUEST_URI']).'" target="_self">'. |
|
233
|
|
|
Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY).' </a></li>'; |
|
234
|
|
|
} |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
return $html; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* Return an array with different navigation menu elements |
|
242
|
|
|
* @deprecated Check src/Chamilo/CoreBundle/Menu/NavBuilder.php to handle |
|
243
|
|
|
* Chamilo menus |
|
244
|
|
|
* @return array [menu_navigation[], navigation[], possible_tabs[]] |
|
245
|
|
|
*/ |
|
246
|
|
|
function return_navigation_array() |
|
247
|
|
|
{ |
|
248
|
|
|
return ; |
|
249
|
|
|
$navigation = array(); |
|
|
|
|
|
|
250
|
|
|
$menu_navigation = array(); |
|
251
|
|
|
$possible_tabs = get_tabs(); |
|
252
|
|
|
|
|
253
|
|
|
// Campus Homepage |
|
254
|
|
|
if (api_get_setting('show_tabs', 'campus_homepage') == 'true') { |
|
255
|
|
|
$navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS]; |
|
256
|
|
|
} else { |
|
257
|
|
|
$menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS]; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
if (api_get_setting('course_catalog_published') == 'true' && api_is_anonymous()) { |
|
261
|
|
|
$navigation[SECTION_CATALOG] = $possible_tabs[SECTION_CATALOG]; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
if (api_get_user_id() && !api_is_anonymous()) { |
|
265
|
|
|
// My Courses |
|
266
|
|
View Code Duplication |
if (api_get_setting('show_tabs', 'my_courses') == 'true') { |
|
267
|
|
|
$navigation['mycourses'] = $possible_tabs['mycourses']; |
|
268
|
|
|
} else { |
|
269
|
|
|
$menu_navigation['mycourses'] = $possible_tabs['mycourses']; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
// My Profile |
|
273
|
|
|
if (api_get_setting('show_tabs', 'my_profile') == 'true' && |
|
274
|
|
|
api_get_setting('allow_social_tool') != 'true' |
|
275
|
|
|
) { |
|
276
|
|
|
$navigation['myprofile'] = $possible_tabs['myprofile']; |
|
277
|
|
|
} else { |
|
278
|
|
|
$menu_navigation['myprofile'] = $possible_tabs['myprofile']; |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
// My Agenda |
|
282
|
|
View Code Duplication |
if (api_get_setting('show_tabs', 'my_agenda') == 'true') { |
|
283
|
|
|
$navigation['myagenda'] = $possible_tabs['myagenda']; |
|
284
|
|
|
} else { |
|
285
|
|
|
$menu_navigation['myagenda'] = $possible_tabs['myagenda']; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
// Gradebook |
|
289
|
|
|
if (api_get_setting('gradebook_enable') == 'true') { |
|
290
|
|
View Code Duplication |
if (api_get_setting('show_tabs', 'my_gradebook') == 'true') { |
|
291
|
|
|
$navigation['mygradebook'] = $possible_tabs['mygradebook']; |
|
292
|
|
|
} else { |
|
293
|
|
|
$menu_navigation['mygradebook'] = $possible_tabs['mygradebook']; |
|
294
|
|
|
} |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
// Reporting |
|
298
|
|
|
if (api_get_setting('show_tabs', 'reporting') == 'true') { |
|
299
|
|
View Code Duplication |
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) { |
|
300
|
|
|
$navigation['session_my_space'] = $possible_tabs['session_my_space']; |
|
301
|
|
|
} else { |
|
302
|
|
|
$navigation['session_my_space'] = $possible_tabs['session_my_progress']; |
|
303
|
|
|
} |
|
304
|
|
View Code Duplication |
} else { |
|
305
|
|
|
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) { |
|
306
|
|
|
$menu_navigation['session_my_space'] = $possible_tabs['session_my_space']; |
|
307
|
|
|
} else { |
|
308
|
|
|
$menu_navigation['session_my_space'] = $possible_tabs['session_my_progress']; |
|
309
|
|
|
} |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
// Social Networking |
|
313
|
|
|
if (api_get_setting('show_tabs', 'social') == 'true') { |
|
314
|
|
|
if (api_get_setting('allow_social_tool') == 'true') { |
|
315
|
|
|
$navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null; |
|
316
|
|
|
} |
|
317
|
|
|
} else { |
|
318
|
|
|
$menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null; |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
// Dashboard |
|
322
|
|
|
if (api_get_setting('show_tabs', 'dashboard') == 'true') { |
|
323
|
|
|
if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
|
324
|
|
|
$navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null; |
|
325
|
|
|
} |
|
326
|
|
|
} else { |
|
327
|
|
|
$menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null; |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
// Administration |
|
331
|
|
|
if (api_is_platform_admin(true)) { |
|
332
|
|
View Code Duplication |
if (api_get_setting('show_tabs', 'platform_administration') == 'true') { |
|
333
|
|
|
$navigation['platform_admin'] = $possible_tabs['platform_admin']; |
|
334
|
|
|
} else { |
|
335
|
|
|
$menu_navigation['platform_admin'] = $possible_tabs['platform_admin']; |
|
336
|
|
|
} |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
// Reports |
|
340
|
|
|
if (!empty($possible_tabs['reports'])) { |
|
341
|
|
|
if (api_get_setting('show_tabs', 'reports') == 'true') { |
|
342
|
|
|
if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) { |
|
343
|
|
|
$navigation['reports'] = $possible_tabs['reports']; |
|
344
|
|
|
} |
|
345
|
|
|
} else { |
|
346
|
|
|
$menu_navigation['reports'] = $possible_tabs['reports']; |
|
347
|
|
|
} |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
// Custom tabs |
|
351
|
|
|
$customTabs = getCustomTabs(); |
|
352
|
|
|
|
|
353
|
|
|
if (!empty($customTabs)) { |
|
354
|
|
|
foreach ($customTabs as $tab) { |
|
355
|
|
|
if (api_get_setting($tab['variable'], $tab['subkey']) == 'true' && |
|
356
|
|
|
isset($possible_tabs[$tab['subkey']]) |
|
357
|
|
|
) { |
|
358
|
|
|
$possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH).$possible_tabs[$tab['subkey']]['url']; |
|
359
|
|
|
$navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']]; |
|
360
|
|
|
} else { |
|
361
|
|
|
if (isset($possible_tabs[$tab['subkey']])) { |
|
362
|
|
|
$possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH).$possible_tabs[$tab['subkey']]['url']; |
|
363
|
|
|
$menu_navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']]; |
|
364
|
|
|
} |
|
365
|
|
|
} |
|
366
|
|
|
} |
|
367
|
|
|
} |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
|
return array( |
|
371
|
|
|
'menu_navigation' => $menu_navigation, |
|
372
|
|
|
'navigation' => $navigation, |
|
373
|
|
|
'possible_tabs' => $possible_tabs, |
|
374
|
|
|
); |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* Return the navigation menu elements as a flat array |
|
379
|
|
|
* @return array |
|
380
|
|
|
*/ |
|
381
|
|
|
function menuArray() |
|
382
|
|
|
{ |
|
383
|
|
|
$mainNavigation = return_navigation_array(); |
|
384
|
|
|
unset($mainNavigation['possible_tabs']); |
|
385
|
|
|
unset($mainNavigation['menu_navigation']); |
|
386
|
|
|
//$navigation = $navigation['navigation']; |
|
387
|
|
|
// Get active language |
|
388
|
|
|
$lang = api_get_setting('platformLanguage'); |
|
389
|
|
View Code Duplication |
if (!empty($_SESSION['user_language_choice'])) { |
|
390
|
|
|
$lang = $_SESSION['user_language_choice']; |
|
391
|
|
|
|
|
392
|
|
|
} elseif (!empty($_SESSION['_user']['language'])) { |
|
393
|
|
|
$lang = $_SESSION['_user']['language']; |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
// Preparing home folder for multiple urls |
|
397
|
|
|
if (api_get_multiple_access_url()) { |
|
398
|
|
|
$access_url_id = api_get_current_access_url_id(); |
|
399
|
|
View Code Duplication |
if ($access_url_id != -1) { |
|
400
|
|
|
// If not a dead URL |
|
401
|
|
|
$urlInfo = api_get_access_url($access_url_id); |
|
402
|
|
|
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url'])); |
|
403
|
|
|
$cleanUrl = api_replace_dangerous_char($url); |
|
404
|
|
|
$cleanUrl = str_replace('/', '-', $cleanUrl); |
|
405
|
|
|
$cleanUrl .= '/'; |
|
406
|
|
|
$homepath = api_get_path(SYS_APP_PATH).'home/'.$cleanUrl; //homep for Home Path |
|
407
|
|
|
|
|
408
|
|
|
//we create the new dir for the new sites |
|
409
|
|
|
if (!is_dir($homepath)) { |
|
410
|
|
|
mkdir($homepath, api_get_permissions_for_new_directories()); |
|
411
|
|
|
} |
|
412
|
|
|
} |
|
413
|
|
|
} else { |
|
414
|
|
|
$homepath = api_get_path(SYS_APP_PATH).'home/'; |
|
415
|
|
|
} |
|
416
|
|
|
$ext = '.html'; |
|
417
|
|
|
$menuTabs = 'home_tabs'; |
|
418
|
|
|
$menuTabsLoggedIn = 'home_tabs_logged_in'; |
|
419
|
|
|
$pageContent = ''; |
|
420
|
|
|
// Get the extra page content, containing the links to add to the tabs |
|
421
|
|
|
if (is_file($homepath.$menuTabs.'_'.$lang.$ext) && is_readable($homepath.$menuTabs.'_'.$lang.$ext)) { |
|
422
|
|
|
$pageContent = @(string) file_get_contents($homepath . $menuTabs . '_' . $lang . $ext); |
|
423
|
|
|
} elseif (is_file($homepath.$menuTabs.$lang.$ext) && is_readable($homepath.$menuTabs.$lang.$ext)) { |
|
424
|
|
|
$pageContent = @(string) file_get_contents($homepath . $menuTabs . $lang . $ext); |
|
425
|
|
|
} |
|
426
|
|
|
// Sanitize page content |
|
427
|
|
|
$pageContent = api_to_system_encoding($pageContent, api_detect_encoding(strip_tags($pageContent))); |
|
428
|
|
|
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $pageContent); |
|
429
|
|
|
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
|
430
|
|
|
// Get the extra page content, containing the links to add to the tabs |
|
431
|
|
|
// that are only for users already logged in |
|
432
|
|
|
$openMenuTabsLoggedIn = ''; |
|
433
|
|
|
if (api_get_user_id() && !api_is_anonymous()) { |
|
434
|
|
|
if (is_file($homepath . $menuTabsLoggedIn . '_' . $lang . $ext) && is_readable($homepath . $menuTabsLoggedIn . '_' . $lang . $ext)) { |
|
435
|
|
|
$pageContent = @(string) file_get_contents($homepath . $menuTabsLoggedIn . '_' . $lang . $ext); |
|
436
|
|
|
$pageContent = str_replace('::private', '', $pageContent); |
|
437
|
|
|
} elseif (is_file($homepath . $menuTabsLoggedIn . $lang . $ext) && is_readable($homepath . $menuTabsLoggedIn . $lang . $ext)) { |
|
438
|
|
|
$pageContent = @(string) file_get_contents($homepath . $menuTabsLoggedIn . $lang . $ext); |
|
439
|
|
|
$pageContent = str_replace('::private', '', $pageContent); |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
$pageContent = api_to_system_encoding($pageContent, api_detect_encoding(strip_tags($pageContent))); |
|
443
|
|
|
$openMenuTabsLoggedIn = str_replace('{rel_path}',api_get_path(REL_PATH), $pageContent); |
|
444
|
|
|
$openMenuTabsLoggedIn = api_to_system_encoding($openMenuTabsLoggedIn, api_detect_encoding(strip_tags($openMenuTabsLoggedIn))); |
|
445
|
|
|
} |
|
446
|
|
|
if (!empty($open) || !empty($openMenuTabsLoggedIn)) { |
|
447
|
|
|
if (strpos($open.$openMenuTabsLoggedIn, 'show_menu') === false) { |
|
448
|
|
|
if (api_is_anonymous()) { |
|
449
|
|
|
$mainNavigation['navigation'][SECTION_CAMPUS] = null; |
|
450
|
|
|
} |
|
451
|
|
|
} else { |
|
452
|
|
|
if (api_get_user_id() && !api_is_anonymous()) { |
|
453
|
|
|
$list = explode("\n", $openMenuTabsLoggedIn); |
|
454
|
|
View Code Duplication |
foreach ($list as $link) { |
|
455
|
|
|
$matches = array(); |
|
456
|
|
|
$match = preg_match('$href="([^"]*)" target="([^"]*)">([^<]*)</a>$', $link, $matches); |
|
457
|
|
|
if ($match) { |
|
458
|
|
|
$mainNavigation['navigation'][$matches[3]] = array( |
|
459
|
|
|
'url' => $matches[1], |
|
460
|
|
|
'target' => $matches[2], |
|
461
|
|
|
'title' => $matches[3], |
|
462
|
|
|
'key' => 'page-' . str_replace(' ', '-', strtolower($matches[3])) |
|
463
|
|
|
); |
|
464
|
|
|
} |
|
465
|
|
|
} |
|
466
|
|
|
} else { |
|
467
|
|
|
$list = explode("\n", $open); |
|
468
|
|
View Code Duplication |
foreach ($list as $link) { |
|
469
|
|
|
$matches = array(); |
|
470
|
|
|
$match = preg_match('$href="([^"]*)" target="([^"]*)">([^<]*)</a>$', $link, $matches); |
|
471
|
|
|
if ($match) { |
|
472
|
|
|
$mainNavigation['navigation'][$matches[3]] = array( |
|
473
|
|
|
'url' => $matches[1], |
|
474
|
|
|
'target' => $matches[2], |
|
475
|
|
|
'title' => $matches[3], |
|
476
|
|
|
'key' => 'page-' . str_replace(' ', '-', strtolower($matches[3])) |
|
477
|
|
|
); |
|
478
|
|
|
} |
|
479
|
|
|
} |
|
480
|
|
|
} |
|
481
|
|
|
} |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
if (count($mainNavigation['navigation']) > 0) { |
|
485
|
|
|
//$pre_lis = ''; |
|
486
|
|
|
$activeSection = ''; |
|
487
|
|
|
foreach ($mainNavigation['navigation'] as $section => $navigation_info) { |
|
488
|
|
|
$key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:''); |
|
489
|
|
|
|
|
490
|
|
|
if (isset($GLOBALS['this_section'])) { |
|
491
|
|
|
$tempSection = $section; |
|
492
|
|
|
if ($section == 'social') { |
|
493
|
|
|
$tempSection = 'social-network'; |
|
494
|
|
|
} |
|
495
|
|
|
if ($tempSection == $GLOBALS['this_section']) { |
|
496
|
|
|
$activeSection = $section; |
|
497
|
|
|
} |
|
498
|
|
|
// If we're on the index page and a specific extra link has been |
|
499
|
|
|
// loaded |
|
500
|
|
|
if ($GLOBALS['this_section'] == SECTION_CAMPUS) { |
|
501
|
|
|
if (!empty($_GET['include'])) { |
|
502
|
|
|
$name = str_replace(' ', '-', strtolower($navigation_info['title'])) . '_' . $lang . $ext; |
|
503
|
|
|
if (strtolower($_GET['include']) == $name) { |
|
504
|
|
|
$activeSection = $section; |
|
505
|
|
|
} |
|
506
|
|
|
} |
|
507
|
|
|
} |
|
508
|
|
|
} else { |
|
509
|
|
|
$current = ''; |
|
510
|
|
|
} |
|
511
|
|
|
$mainNavigation['navigation'][$section]['current'] = ''; |
|
512
|
|
|
} |
|
513
|
|
|
if (!empty($activeSection)) { |
|
514
|
|
|
$mainNavigation['navigation'][$activeSection]['current'] = 'active'; |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
} |
|
518
|
|
|
unset($mainNavigation['navigation']['myprofile']); |
|
519
|
|
|
|
|
520
|
|
|
return $mainNavigation['navigation']; |
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
/** |
|
524
|
|
|
* Return the breadcrumb menu elements as an array of <li> items |
|
525
|
|
|
* @param array $interbreadcrumb The elements to add to the breadcrumb |
|
526
|
|
|
* @param string $language_file Deprecated |
|
527
|
|
|
* @param string $nameTools The name of the current tool (not linked) |
|
528
|
|
|
* @return string HTML string of <li> items |
|
529
|
|
|
*/ |
|
530
|
|
|
function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) |
|
531
|
|
|
{ |
|
532
|
|
|
$session_id = api_get_session_id(); |
|
533
|
|
|
$session_name = api_get_session_name($session_id); |
|
534
|
|
|
$_course = api_get_course_info(); |
|
535
|
|
|
$user_id = api_get_user_id(); |
|
536
|
|
|
$course_id = 0; |
|
537
|
|
|
if (!empty($_course)) { |
|
538
|
|
|
$course_id = $_course['real_id']; |
|
539
|
|
|
} |
|
540
|
|
|
|
|
541
|
|
|
/* Plugins for banner section */ |
|
542
|
|
|
$web_course_path = api_get_path(WEB_COURSE_PATH); |
|
543
|
|
|
|
|
544
|
|
|
/* If the user is a coach he can see the users who are logged in its session */ |
|
545
|
|
|
$navigation = array(); |
|
546
|
|
|
|
|
547
|
|
|
// part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage |
|
548
|
|
|
// hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb |
|
549
|
|
|
$session_name = cut($session_name, MAX_LENGTH_BREADCRUMB); |
|
550
|
|
|
$my_session_name = is_null($session_name) ? '' : ' ('.$session_name.')'; |
|
551
|
|
|
|
|
552
|
|
|
if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) { |
|
553
|
|
|
|
|
554
|
|
|
$navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : ''); |
|
555
|
|
|
$_course['name'] = api_htmlentities($_course['name']); |
|
556
|
|
|
$course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB); |
|
557
|
|
|
|
|
558
|
|
|
switch (api_get_setting('breadcrumbs_course_homepage')) { |
|
559
|
|
|
case 'get_lang': |
|
560
|
|
|
$navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', get_lang('CourseHomepageLink')).' '.get_lang('CourseHomepageLink'); |
|
561
|
|
|
break; |
|
562
|
|
|
case 'course_code': |
|
563
|
|
|
$navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['official_code']).' '.$_course['official_code']; |
|
564
|
|
|
break; |
|
565
|
|
|
case 'session_name_and_course_title': |
|
566
|
|
|
$navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; |
|
567
|
|
|
break; |
|
568
|
|
|
default: |
|
569
|
|
|
if (api_get_session_id() != -1 ) { |
|
570
|
|
|
$navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; |
|
571
|
|
|
} else { |
|
572
|
|
|
$navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name']).' '.$course_title; |
|
573
|
|
|
} |
|
574
|
|
|
break; |
|
575
|
|
|
} |
|
576
|
|
|
/** |
|
577
|
|
|
* @todo could be useful adding the My courses in the breadcrumb |
|
578
|
|
|
$navigation_item_my_courses['title'] = get_lang('MyCourses'); |
|
579
|
|
|
$navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php'; |
|
580
|
|
|
$navigation[] = $navigation_item_my_courses; |
|
581
|
|
|
*/ |
|
582
|
|
|
$navigation[] = $navigation_item; |
|
583
|
|
|
} |
|
584
|
|
|
|
|
585
|
|
|
/* part 2: Interbreadcrumbs. If there is an array $interbreadcrumb |
|
586
|
|
|
defined then these have to appear before the last breadcrumb |
|
587
|
|
|
(which is the tool itself)*/ |
|
588
|
|
|
if (isset($interbreadcrumb) && is_array($interbreadcrumb)) { |
|
589
|
|
|
foreach ($interbreadcrumb as $breadcrumb_step) { |
|
590
|
|
|
if (isset($breadcrumb_step['type']) && $breadcrumb_step['type'] == 'right') { |
|
591
|
|
|
continue; |
|
592
|
|
|
} |
|
593
|
|
|
if ($breadcrumb_step['url'] != '#') { |
|
594
|
|
|
$sep = strrchr($breadcrumb_step['url'], '?') ? '&' : '?'; |
|
595
|
|
|
$courseParams = strpos($breadcrumb_step['url'], 'cidReq') === false ? api_get_cidreq() : ''; |
|
596
|
|
|
$navigation_item['url'] = $breadcrumb_step['url'].$sep.$courseParams; |
|
597
|
|
|
} else { |
|
598
|
|
|
$navigation_item['url'] = '#'; |
|
599
|
|
|
} |
|
600
|
|
|
$navigation_item['title'] = $breadcrumb_step['name']; |
|
601
|
|
|
// titles for shared folders |
|
602
|
|
|
if ($breadcrumb_step['name'] == 'shared_folder') { |
|
603
|
|
|
$navigation_item['title'] = get_lang('UserFolders'); |
|
604
|
|
|
} elseif (strstr($breadcrumb_step['name'], 'shared_folder_session_')) { |
|
605
|
|
|
$navigation_item['title'] = get_lang('UserFolders'); |
|
606
|
|
|
} elseif (strstr($breadcrumb_step['name'], 'sf_user_')) { |
|
607
|
|
|
$userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8)); |
|
608
|
|
|
$navigation_item['title'] = $userinfo['complete_name']; |
|
609
|
|
|
} elseif ($breadcrumb_step['name'] == 'chat_files') { |
|
610
|
|
|
$navigation_item['title'] = get_lang('ChatFiles'); |
|
611
|
|
|
} elseif ($breadcrumb_step['name'] == 'images') { |
|
612
|
|
|
$navigation_item['title'] = get_lang('Images'); |
|
613
|
|
|
} elseif ($breadcrumb_step['name'] == 'video') { |
|
614
|
|
|
$navigation_item['title'] = get_lang('Video'); |
|
615
|
|
|
} elseif ($breadcrumb_step['name'] == 'audio') { |
|
616
|
|
|
$navigation_item['title'] = get_lang('Audio'); |
|
617
|
|
|
} elseif ($breadcrumb_step['name'] == 'flash') { |
|
618
|
|
|
$navigation_item['title'] = get_lang('Flash'); |
|
619
|
|
|
} elseif ($breadcrumb_step['name'] == 'gallery') { |
|
620
|
|
|
$navigation_item['title'] = get_lang('Gallery'); |
|
621
|
|
|
} |
|
622
|
|
|
// Fixes breadcrumb title now we applied the Security::remove_XSS and |
|
623
|
|
|
// we cut the string depending of the MAX_LENGTH_BREADCRUMB value |
|
624
|
|
|
$navigation_item['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB); |
|
625
|
|
|
$navigation_item['title'] = Security::remove_XSS($navigation_item['title']); |
|
626
|
|
|
|
|
627
|
|
|
$navigation[] = $navigation_item; |
|
628
|
|
|
} |
|
629
|
|
|
} |
|
630
|
|
|
|
|
631
|
|
|
$navigation_right = array(); |
|
632
|
|
|
|
|
633
|
|
|
if (isset($interbreadcrumb) && is_array($interbreadcrumb)) { |
|
634
|
|
|
foreach ($interbreadcrumb as $breadcrumb_step) { |
|
635
|
|
|
if (isset($breadcrumb_step['type']) && $breadcrumb_step['type'] == 'right') { |
|
636
|
|
|
if ($breadcrumb_step['url'] != '#') { |
|
637
|
|
|
$sep = (strrchr($breadcrumb_step['url'], '?') ? '&' : '?'); |
|
638
|
|
|
$navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq(); |
|
639
|
|
|
} else { |
|
640
|
|
|
$navigation_item['url'] = '#'; |
|
641
|
|
|
} |
|
642
|
|
|
$breadcrumb_step['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB); |
|
643
|
|
|
$breadcrumb_step['title'] = Security::remove_XSS($navigation_item['title']); |
|
644
|
|
|
$navigation_right[] = $breadcrumb_step; |
|
645
|
|
|
} |
|
646
|
|
|
} |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
|
|
// part 3: The tool itself. If we are on the course homepage we do not want |
|
650
|
|
|
// to display the title of the course because this |
|
651
|
|
|
// is the same as the first part of the breadcrumbs (see part 1) |
|
652
|
|
|
if (isset($nameTools)) { |
|
653
|
|
|
$navigation_item['url'] = '#'; |
|
654
|
|
|
$navigation_item['title'] = $nameTools; |
|
655
|
|
|
$navigation[] = $navigation_item; |
|
656
|
|
|
} |
|
657
|
|
|
|
|
658
|
|
|
$final_navigation = array(); |
|
659
|
|
|
$counter = 0; |
|
660
|
|
|
foreach ($navigation as $index => $navigation_info) { |
|
661
|
|
|
if (!empty($navigation_info['title'])) { |
|
662
|
|
|
if ($navigation_info['url'] == '#') { |
|
663
|
|
|
$final_navigation[$index] = $navigation_info['title']; |
|
664
|
|
|
} else { |
|
665
|
|
|
$final_navigation[$index] = '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>'; |
|
666
|
|
|
} |
|
667
|
|
|
$counter++; |
|
668
|
|
|
} |
|
669
|
|
|
} |
|
670
|
|
|
|
|
671
|
|
|
$html = ''; |
|
672
|
|
|
|
|
673
|
|
|
/* Part 4 . Show the teacher view/student view button at the right of the breadcrumb */ |
|
674
|
|
|
$view_as_student_link = null; |
|
675
|
|
|
if ($user_id && isset($course_id)) { |
|
676
|
|
|
if ((api_is_course_admin() || api_is_platform_admin() || api_is_coach(null, null, false)) && |
|
677
|
|
|
api_get_setting('student_view_enabled') === 'true' && api_get_course_info()) { |
|
678
|
|
|
$view_as_student_link = api_display_tool_view_option(); |
|
679
|
|
|
} |
|
680
|
|
|
} |
|
681
|
|
|
|
|
682
|
|
|
if (!empty($final_navigation)) { |
|
683
|
|
|
$lis = ''; |
|
684
|
|
|
$i = 0; |
|
685
|
|
|
$final_navigation_count = count($final_navigation); |
|
686
|
|
|
if (!empty($final_navigation)) { |
|
687
|
|
|
// $home_link.= '<span class="divider">/</span>'; |
|
688
|
|
|
if (!empty($home_link)) { |
|
|
|
|
|
|
689
|
|
|
$lis.= Display::tag('li', $home_link); |
|
690
|
|
|
} |
|
691
|
|
|
|
|
692
|
|
|
foreach ($final_navigation as $bread) { |
|
693
|
|
|
$bread_check = trim(strip_tags($bread)); |
|
694
|
|
|
if (!empty($bread_check)) { |
|
695
|
|
|
if ($final_navigation_count-1 > $i) { |
|
696
|
|
|
$bread .= ''; |
|
697
|
|
|
} |
|
698
|
|
|
$lis.= Display::tag('li', $bread, array('class'=>'active')); |
|
699
|
|
|
$i++; |
|
700
|
|
|
} |
|
701
|
|
|
} |
|
702
|
|
|
} else { |
|
703
|
|
|
if (!empty($home_link)) { |
|
704
|
|
|
$lis.= Display::tag('li', $home_link); |
|
705
|
|
|
} |
|
706
|
|
|
} |
|
707
|
|
|
|
|
708
|
|
|
// View as student/teacher link |
|
709
|
|
|
$view = null; |
|
710
|
|
|
if (!empty($view_as_student_link)) { |
|
711
|
|
|
$view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link','class' => 'pull-right')); |
|
712
|
|
|
} |
|
713
|
|
|
|
|
714
|
|
|
if (!empty($navigation_right)) { |
|
715
|
|
|
foreach($navigation_right as $item) { |
|
716
|
|
|
$extra_class = isset($item['class']) ? $item['class'] : null; |
|
717
|
|
|
$lis.= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right')); |
|
718
|
|
|
} |
|
719
|
|
|
} |
|
720
|
|
|
|
|
721
|
|
|
if (!empty($lis)) { |
|
722
|
|
|
$html .= $view; |
|
723
|
|
|
$html .= Display::tag('ul', $lis, array('class'=>'breadcrumb')); |
|
724
|
|
|
} |
|
725
|
|
|
|
|
726
|
|
|
} |
|
727
|
|
|
return $html; |
|
728
|
|
|
} |
|
729
|
|
|
|
|
730
|
|
|
/** |
|
731
|
|
|
* Helper function to get the number of users online, using cache if available |
|
732
|
|
|
* @param bool $cacheEnabled Whether APCu is available or not |
|
733
|
|
|
* @return int The number of users currently online |
|
734
|
|
|
*/ |
|
735
|
|
|
function getOnlineUsersCount($cacheEnabled = false) |
|
736
|
|
|
{ |
|
737
|
|
|
$number = 0; |
|
738
|
|
|
if ($cacheEnabled) { |
|
739
|
|
|
if (apcu_exists('my_campus_whoisonline_count_simple')) { |
|
740
|
|
|
$number = apcu_fetch('my_campus_whoisonline_count_simple'); |
|
741
|
|
|
} else { |
|
742
|
|
|
$number = who_is_online_count(api_get_setting('time_limit_whosonline')); |
|
743
|
|
|
apcu_store('my_campus_whoisonline_count_simple', $number, 15); |
|
744
|
|
|
} |
|
745
|
|
|
} else { |
|
746
|
|
|
$number = who_is_online_count(api_get_setting('time_limit_whosonline')); |
|
747
|
|
|
} |
|
748
|
|
|
|
|
749
|
|
|
return $number; |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
/** |
|
753
|
|
|
* Helper function to get the number of users online in a course, using cache if available |
|
754
|
|
|
* @param int $userId The user ID |
|
755
|
|
|
* @param bool $cacheEnabled Whether APCu is available or not |
|
756
|
|
|
* @return int The number of users currently online |
|
757
|
|
|
*/ |
|
758
|
|
|
function getOnlineUsersInCourseCount($userId, $_course, $cacheEnabled = false) |
|
759
|
|
|
{ |
|
760
|
|
|
$numberOnlineInCourse = 0; |
|
761
|
|
|
if (!empty($_course['id'])) { |
|
762
|
|
|
if ($cacheEnabled) { |
|
763
|
|
|
$apc = apcu_cache_info(true); |
|
764
|
|
|
if (apcu_exists('my_campus_whoisonline_count_simple_'.$_course['id'])) { |
|
765
|
|
|
$numberOnlineInCourse = apcu_fetch('my_campus_whoisonline_count_simple_'.$_course['id']); |
|
766
|
|
|
} else { |
|
767
|
|
|
$numberOnlineInCourse = who_is_online_in_this_course_count( |
|
768
|
|
|
$userId, |
|
769
|
|
|
api_get_setting('time_limit_whosonline'), |
|
770
|
|
|
$_course['id'] |
|
771
|
|
|
); |
|
772
|
|
|
apcu_store( |
|
773
|
|
|
'my_campus_whoisonline_count_simple_'.$_course['id'], |
|
774
|
|
|
$numberOnlineInCourse, |
|
775
|
|
|
15 |
|
776
|
|
|
); |
|
777
|
|
|
} |
|
778
|
|
|
} else { |
|
779
|
|
|
$numberOnlineInCourse = who_is_online_in_this_course_count( |
|
780
|
|
|
$userId, |
|
781
|
|
|
api_get_setting('time_limit_whosonline'), |
|
782
|
|
|
$_course['id'] |
|
783
|
|
|
); |
|
784
|
|
|
} |
|
785
|
|
|
} |
|
786
|
|
|
|
|
787
|
|
|
return $numberOnlineInCourse; |
|
788
|
|
|
} |
|
789
|
|
|
|
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return,dieorexitstatements that have been added for debug purposes.In the above example, the last
return falsewill never be executed, because a return statement has already been met in every possible execution path.