';
$theme = api_get_setting('course.homepage_view');
if ($theme == 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = array();
if (is_array($toolList) && count($toolList)>0) {
foreach ($toolList 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[] = $toolList[$key];
}
$toolList = $my_temp_tool_array;
} else {
$toolList = 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();
$items = array();
$app_plugin = new AppPlugin();
if (isset($toolList)) {
$lnk = '';
foreach ($toolList as & $tool) {
$item = array();
$tool['admin'] = isset($tool['admin']) ? $tool['admin'] : null;
$tool['id'] = isset($tool['id']) ? $tool['id'] : null;
$tool['target'] = isset($tool['target']) ? $tool['target'] : null;
if (isset($tool['link_id'])) {
$tool['original_link'] = api_get_path(WEB_CODE_PATH).'link/link_goto.php?link_id='.$tool['link_id'].'&'.api_get_cidreq();
$tool['link'] = $tool['original_link'];
} else {
$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') {
// 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
);
if (!empty($tool['id'])) {
$link['cmd'] = $urlGenerator->generate(
'chamilo_core_tool_coursehome_coursehome_hideicon',
array(
'courseCode' => api_get_course_id(),
'iconId' => $tool['id']
)
);
}
$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);
if (!empty($tool['id'])) {
$link['cmd'] = $urlGenerator->generate(
'chamilo_core_tool_coursehome_coursehome_showicon',
array(
'courseCode' => api_get_course_id(),
'iconId' => $tool['id']
)
);
}
$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'] .= null;
}
// 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 (!empty($tool['custom_icon'])) {
$tool['image'] = self::getCustomIconPath($courseInfo).$tool['custom_icon'];
}
if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
$class = 'invisible';
$info = pathinfo($tool['image']);
$dirName = null;
if ($info['dirname'] != '.') {
$dirName = $info['dirname'].'/';
}
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
$tool['image'] = $dirName.$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'.api_get_course_id().'\',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'.api_get_course_id().'\',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);
$toolTip = $tool_name;
if (!empty($tool['description'])) {
$toolTip = $tool['description'];
}
$tool_link_params['data-original-title'] = $toolTip;
$tool_link_params['data-toggle'] = 'tooltip';
//$tool_link_params['title'] = $toolTip;
// 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();
}
if (!empty($tool['custom_icon'])) {
//self::getCustomIconPath($courseInfo)
$icon = Display::img(
$tool['image'],
null,
array('class' => 'tool-icon', 'id' => 'toolimage_'.$tool['id'])
);
} else {
$image = (substr($tool['image'], 0, strpos($tool['image'], '.'))).'.png';
$icon = Display::return_icon(
$image,
null,
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;
} // 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 .= '