Skip to content

Commit a2bcf3f

Browse files
committed
Merge remote-tracking branch 'origin/1.9.x' into 1.9.x
2 parents 7e921a0 + 0c16465 commit a2bcf3f

File tree

1 file changed

+48
-24
lines changed

1 file changed

+48
-24
lines changed

main/inc/lib/banner.lib.php

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,50 @@ function get_tabs() {
109109
$navigation['reports']['title'] = get_lang('Reports');
110110
}*/
111111

112-
// Custom tabs - 1.8 hidden feature, removed as useless
113-
//see https://support.chamilo.org/issues/7180
114-
/*
115-
for ($i = 1; $i <= 3; $i++) {
116-
if (api_get_setting('show_tabs', 'custom_tab_' . $i) == 'true') {
117-
$setting = api_get_full_setting('show_tabs', 'custom_tab_' . $i);
118-
$navigation['custom_tab_' . $i]['url'] = $setting[0]['comment'];
119-
$navigation['custom_tab_' . $i]['title'] = $setting[0]['title'];
120-
$navigation['custom_tab_' . $i]['key'] = 'custom_tab_' . $i;
112+
// Custom Tabs See BT#7180
113+
$customTabs = getCustomTabs();
114+
if (!empty($customTabs)) {
115+
foreach ($customTabs as $tab) {
116+
if (api_get_setting($tab['variable'], $tab['subkey']) == 'true') {
117+
if (!empty($tab['comment']) && $tab['comment'] !== 'ShowTabsComment') {
118+
$navigation[$tab['subkey']]['url'] = $tab['comment'];
119+
$navigation[$tab['subkey']]['title'] = $tab['title'];
120+
$navigation[$tab['subkey']]['key'] = $tab['subkey'];
121+
}
121122
}
122123
}
123-
*/
124+
}
125+
// End Custom Tabs
124126

125127
// Platform administration
126128
if (api_is_platform_admin(true)) {
127-
$navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
128-
$navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
129-
$navigation['platform_admin']['key'] = 'admin';
129+
$navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
130+
$navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
131+
$navigation['platform_admin']['key'] = 'admin';
130132
}
131133
return $navigation;
132134
}
133135

136+
/**
137+
* This function returns the custom tabs
138+
*
139+
* @return array
140+
*/
141+
function getCustomTabs() {
142+
$tableSettingsCurrent = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
143+
$sql = "SELECT * FROM $tableSettingsCurrent
144+
WHERE variable = 'show_tabs' AND
145+
subkey like 'custom_tab_%'";
146+
$result = Database::query($sql);
147+
$customTabs = array();
148+
149+
while ($row = Database::fetch_assoc($result)) {
150+
$customTabs[] = $row;
151+
}
152+
153+
return $customTabs;
154+
}
155+
134156
function return_logo($theme) {
135157
$_course = api_get_course_info();
136158
$html = '';
@@ -332,17 +354,19 @@ function return_navigation_array() {
332354
}
333355

334356
// Custom tabs
335-
for ($i=1; $i <= 3; $i++) {
336-
if (api_get_setting('show_tabs', 'custom_tab_' . $i) == 'true' &&
337-
isset($possible_tabs['custom_tab_' . $i])
338-
) {
339-
340-
$possible_tabs['custom_tab_'.$i]['url'] = api_get_path(WEB_PATH).$possible_tabs['custom_tab_'.$i]['url'];
341-
$navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
342-
} else {
343-
if (isset($possible_tabs['custom_tab_'.$i])) {
344-
$possible_tabs['custom_tab_'.$i]['url'] = api_get_path(WEB_PATH).$possible_tabs['custom_tab_' . $i]['url'];
345-
$menu_navigation['custom_tab_' . $i] = $possible_tabs['custom_tab_' . $i];
357+
$customTabs = getCustomTabs();
358+
if (!empty($customTabs)) {
359+
foreach ($customTabs as $tab) {
360+
if (api_get_setting($tab['variable'], $tab['subkey']) == 'true' &&
361+
isset($possible_tabs[$tab['subkey']])
362+
) {
363+
$possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH).$possible_tabs[$tab['subkey']]['url'];
364+
$navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
365+
} else {
366+
if (isset($possible_tabs[$tab['subkey']])) {
367+
$possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH).$possible_tabs[$tab['subkey']]['url'];
368+
$menu_navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
369+
}
346370
}
347371
}
348372
}

0 commit comments

Comments
 (0)