';
$theme = api_get_setting('homepage_view');
if ($theme == 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = array();
if (is_array($all_tools_list) && count($all_tools_list)>0) {
foreach ($all_tools_list as $key => $new_tool) {
$tool_name = self::translate_tool_name($new_tool);
$order_tool_list [$key]= $tool_name;
}
natsort($order_tool_list);
$my_temp_tool_array = array();
foreach ($order_tool_list as $key => $new_tool) {
$my_temp_tool_array[] = $all_tools_list[$key];
}
$all_tools_list = $my_temp_tool_array;
} else {
$all_tools_list = array();
}
}
$courseInfo = api_get_course_info();
$web_code_path = api_get_path(WEB_CODE_PATH);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$is_platform_admin = api_is_platform_admin();
$session_id = api_get_session_id();
$i = 0;
$items = array();
$app_plugin = new AppPlugin();
if (isset($all_tools_list)) {
$lnk = '';
foreach ($all_tools_list as & $tool) {
$item = array();
$tool['original_link'] = $tool['link'];
// Re-writing URL for new tools
$newTools = array(TOOL_CURRICULUM);
$toolName = isset($tool['name']) ? $tool['name'] : null;
if (in_array($toolName, $newTools)) {
$tool['link'] = $courseInfo['course_web_public_url'].$tool['name'].'/';
}
if ($tool['image'] == 'scormbuilder.gif') {
// display links to lp only for current session
/*if ($session_id != $tool['session_id']) {
continue;
}*/
// check if the published learnpath is visible for student
$published_lp_id = self::get_published_lp_id_from_link($tool['link']);
if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id, api_get_user_id())) {
continue;
}
}
if ($session_id != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
continue;
}
if ($tool['name'] == 'course_description') {
$tool['link'] = 'course_description/index.php';
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
$item['extra'] = null;
if ($is_allowed_to_edit && !api_is_coach()) {
if (empty($session_id)) {
if ($tool['visibility'] == '1' && $tool['admin'] != '1') {
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'), array('id' => 'linktool_'.$tool['id']), ICON_SIZE_MEDIUM, false);
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
}
if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'), array('id' => 'linktool_'.$tool['id']), ICON_SIZE_MEDIUM, false);
$link['cmd'] = 'restore=yes';
$lnk[] = $link;
}
}
if (!empty($tool['adminlink'])) {
$item['extra'] = '
'.Display::return_icon('edit.gif', get_lang('Edit')).'';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($tool['admin'] != '1') {
$link['cmd'] = 'hide=yes';
}
}
$item['visibility'] = null;
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($tool['adminlink'])) {
$item['visibility'] .= '
'.$this_link['name'].'';
}
}
} else {
$item['visibility'] .= ' ';
}
// NOTE : Table contains only the image file name, not full path
if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
$tool['link'] = $web_code_path.$tool['link'];
}
if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
$class = 'invisible';
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
$tool['image'] = $basename.'_na.'.$info['extension'];
} else {
$class = '';
}
$qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
// If it's a link, we don't add the cidReq
if ($tool['image'] == 'file_html.gif' || $tool['image'] == 'file_html_na.gif') {
$tool['link'] = $tool['link'].$qm_or_amp;
} else {
$tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
}
$tool_link_params = array();
//@todo this visio stuff should be removed
if (strpos($tool['name'], 'visio_') !== false) {
$tool_link_params = array(
'id' => 'tooldesc_'.$tool["id"],
'href' => '"javascript: void(0);"',
'class' => $class,
'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_visio'.$_SESSION['_cid'].'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')',
'target' => $tool['target']);
} elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
$tool_link_params = array(
'id' => 'tooldesc_'.$tool["id"],
'class' => $class,
'href' => 'javascript: void(0);',
'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')',
'target' => $tool['target']);
} else {
if (count(explode('type=classroom',$tool['link'])) == 2 || count(explode('type=conference', $tool['link'])) == 2) {
$tool_link_params = array(
'id' => 'tooldesc_'.$tool["id"],
'href' => $tool['link'],
'class' => $class,
'target' => '_blank');
} else {
$tool_link_params = array(
'id' => 'tooldesc_'.$tool["id"],
'href' => $tool['link'],
'class' => $class,
'target' => $tool['target']);
}
}
$tool_name = self::translate_tool_name($tool);
// Including Courses Plugins
// Creating title and the link
if (isset($tool['category']) && $tool['category'] == 'plugin') {
$plugin_info = $app_plugin->get_plugin_info($tool['name']);
if (isset($plugin_info) && isset($plugin_info['title'])) {
$tool_name = $plugin_info['title'];
}
$tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH).$tool['original_link'].'?'.api_get_cidreq();
}
$icon = Display::return_icon($tool['image'], $tool_name, array('class' => 'tool-icon', 'id' => 'toolimage_'.$tool['id']), ICON_SIZE_BIG, false);
$userInfo = api_get_user_info();
$userStatus = isset($userInfo['status']) ? $userInfo['status'] : null;
// Validation when belongs to a session
$session_img = api_get_session_image($tool['session_id'], $userStatus);
$item['url_params'] = $tool_link_params;
$item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
$item['tool'] = $tool;
$item['name'] = $tool_name;
$tool_link_params['id'] = 'is'.$tool_link_params['id'];
$item['link'] = Display::url($tool_name.$session_img, $tool_link_params['href'], $tool_link_params);
$items[] = $item;
$i++;
} // end of foreach
}
$i = 0;
$html = '';
$counter = 0;
if (!empty($items)) {
foreach ($items as $item) {
switch ($theme) {
case 'activity_big':
$data = '';
if ($counter == 0) {
$html .= $rowDiv;
}
$html .= '
';
if ($counter == 2) {
$html .= '
';
$counter = -1;
}
$counter++;
break;
case 'activity':
if ($counter == 0) {
$html .= $rowDiv;
}
$html .= '';
$content = $item['extra'];
$content .= $item['visibility'];
$content .= $item['icon'];
$content .= $item['link'];
$html .= Display::div($content, array('class'=>'activity_content'));
$html .= '
';
if ($counter == 1) {
$html .= '';
$counter = -1;
}
$counter++;
break;
case 'vertical_activity':
if ($i == 0) {
$html .= '