Refactoring of the course home, also added the new ajax reponses files see CT#431

skala
Julio Montoya 16 years ago
parent 503025f81c
commit c67d8b16b8
  1. 303
      main/course_home/2column.php
  2. 61
      main/course_home/3column.php
  3. 593
      main/course_home/activity.php
  4. 287
      main/course_home/btf_functions.php
  5. 67
      main/course_home/course_home.php
  6. 87
      main/inc/ajax/course_home.ajax.php
  7. 862
      main/inc/lib/course_home.lib.php
  8. 49
      main/inc/lib/main_api.lib.php

@ -1,28 +1,5 @@
<?php // $Id: 2column.php,v 1.5 2006/08/10 14:34:54 pcool Exp $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2003 Ghent University
Copyright (c) 2001 Universite Catholique de Louvain
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* HOME PAGE FOR EACH COURSE
@ -36,259 +13,7 @@
* @package dokeos.course_home
==============================================================================
*/
/*
==============================================================================
FUNCTIONS
==============================================================================
*/
/**
* Displays the tools of a certain category.
*
* @return void
* @param string $course_tool_category contains the category of tools to display:
* "Public", "PublicButHide", "courseAdmin", "claroAdmin"
*/
function show_tools($course_tool_category)
{
global $charset;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
switch ($course_tool_category)
{
case TOOL_PUBLIC:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=1 ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=0 AND admin=0 ORDER BY id",__FILE__,__LINE__);
$colLink ="##808080";
break;
case TOOL_COURSE_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE admin=1 AND visibility != 2 ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_PLATFORM_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = 2 ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
}
$i=0;
// grabbing all the tools from $course_tool_table
while ($temp_row = Database::fetch_array($result))
{
if($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif')
{
$temp_row['image']=str_replace('.gif','_na.gif',$temp_row['image']);
}
$all_tools_list[]=$temp_row;
}
// grabbing all the links that have the property on_homepage set to 1
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
switch ($course_tool_category)
{
case TOOL_PUBLIC:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 1";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 0";
break;
default:
$sql_links = null;
break;
}
if( $sql_links != null )
{
$properties = array();
$result_links=Database::query($sql_links,__FILE__,__LINE__);
while ($links_row=Database::fetch_array($result_links))
{
unset($properties);
$properties['name']=$links_row['title'];
$properties['link']=$links_row['url'];
$properties['visibility']=$links_row['visibility'];
$properties['image']=($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)?"external_na.gif":"external.gif";
$properties['adminlink']=api_get_path(WEB_CODE_PATH)."link/link.php?action=editlink&id=".$links_row['id'];
$all_tools_list[]=$properties;
}
}
if (isset($all_tools_list))
{
$lnk = array();
foreach ($all_tools_list as $toolsRow)
{
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
if (!($i%2))
{
echo "<tr valign=\"top\">\n";
}
// NOTE : table contains only the image file name, not full path
if(!stristr($toolsRow['link'],'http://') && !stristr($toolsRow['link'],'https://') && !stristr($toolsRow['link'],'ftp://'))
{
$toolsRow['link']=$web_code_path.$toolsRow['link'];
}
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)
{
$class="class=\"invisible\"";
}
$qm_or_amp = ((strpos($toolsRow['link'],'?')===FALSE)?'?':'&amp;');
$toolsRow['link'] = $toolsRow['link'];
echo '<td width="50%" height="30">';
if(strpos($toolsRow['name'],'visio_')!==false)
{
echo '<a '.$class.' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']).(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()) . '\',\'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="' . $toolsRow['target'] . '">';
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
echo '<a href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']) .(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()). '\',\'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="' . $toolsRow['target'] . '"'.$class.'>';
*/
echo '<a href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']).$qm_or_amp.api_get_cidreq() . '\',\'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="' . $toolsRow['target'] . '"'.$class.'>';
}
else
{
echo '<a href="'. htmlspecialchars($toolsRow['link']).(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()).'" target="' , $toolsRow['target'], '" '.$class.'>';
}
/*
echo Display::return_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name']))),'&nbsp;', ($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif" || $toolsRow['image']=="scormbuilder.gif" || $toolsRow['image']=="blog.gif") ? htmlspecialchars( $toolsRow['name'],ENT_QUOTES,$charset) : get_lang(ucfirst($toolsRow['name'])),'</a>';
*/
if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
|| $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
|| $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
|| $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
{
$tool_name = htmlspecialchars($toolsRow['name'], ENT_QUOTES, $charset);
}
else
{
$tool_name = get_lang(ucfirst($toolsRow['name']));
}
echo Display::return_icon($toolsRow['image'], $tool_name),'&nbsp;', $tool_name,'</a>';
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
if ($toolsRow["visibility"] == '1')
{
$link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)
{
$link['name'] = Display::return_icon('add.gif', get_lang('Activate'));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
if($toolsRow["added_tool"] == 1)
{
$link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
$link['cmd'] = "remove=yes";
$lnk[] = $link;
}
}
if ($toolsRow['adminlink'])
{
echo '<a href="'.$toolsRow['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
//echo "edit link:".$properties['adminlink'];
}
}
if ( api_is_platform_admin() )
{
if ($toolsRow["visibility"]==2)
{
$link['name'] = Display::return_icon('undelete.gif', get_lang('Activate'));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
if($toolsRow["added_tool"] == 1)
{
$link['name'] = get_lang("Delete");
$link['cmd'] = "askDelete=yes";
$lnk[] = $link;
}
}
if ($toolsRow["visibility"] == 0 && $toolsRow["added_tool"] == 0)
{
$link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
$link['cmd'] = "remove=yes";
$lnk[] = $link;
}
}
if (is_array($lnk))
{
foreach($lnk as $this_link)
{
if (!$toolsRow['adminlink'])
{
echo "<a href=\"" .api_get_self(). "?".api_get_cidreq()."&amp;id=" . $toolsRow["id"] . "&amp;" . $this_link['cmd'] . "\">" . $this_link['name'] . "</a>";
}
}
}
// Allow editing of invisible homepage links (modified external_module)
/*
if ($toolsRow["added_tool"] == 1 &&
api_is_allowed_to_edit() && !$toolsRow["visibility"])
*/
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit(null,true) && !$toolsRow["visibility"]
&& $toolsRow['image'] != 'scormbuilder.gif' && $toolsRow['image'] != 'scormbuilder_na.gif')
echo "<a class=\"nobold\" href=\"" . api_get_path(WEB_PATH) .
'main/external_module/external_module.php' .
"?".api_get_cidreq()."&amp;id=".$toolsRow["id"]."\">". get_lang("Edit"). "</a>";
echo "</td>\n";
if($i%2)
{
echo "</tr>\n";
}
$i++;
}
}
if($i%2)
{
echo "<td width=\"50%\">&nbsp;</td>\n",
"</tr>\n";
}
}
require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
/*
==============================================================================
MAIN CODE
@ -300,8 +25,7 @@ function show_tools($course_tool_category)
Work with data post askable by admin of course (franglais, clean this)
-----------------------------------------------------------
*/
if (api_is_allowed_to_edit(null,true))
{
if (api_is_allowed_to_edit(null,true)) {
/* Work request */
/*
@ -395,7 +119,7 @@ if (api_is_platform_admin())
echo "<div class=\"everybodyview\">";
echo "<table width=\"100%\">";
show_tools(TOOL_PUBLIC);
CourseHome::show_tool_2column(TOOL_PUBLIC);
echo "</table>";
echo "</div>";
@ -408,15 +132,14 @@ echo "</div>";
*/
// start of tools for CourseAdmins (teachers/tutors)
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
if (api_is_allowed_to_edit(null,true) && !api_is_coach()) {
echo "<div class=\"courseadminview\">";
echo "<span class=\"viewcaption\">";
echo get_lang("CourseAdminOnly");
echo "</span>";
echo "<table width=\"100%\">";
show_tools(TOOL_COURSE_ADMIN);
CourseHome::show_tool_2column(TOOL_COURSE_ADMIN);
/*
-----------------------------------------------------------
@ -425,15 +148,14 @@ if (api_is_allowed_to_edit(null,true) && !api_is_coach())
*/
echo "<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n",
"<tr>\n",
"<td colspan=\"4\">\n",
"<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n",get_lang("InLnk"),"</font></div>",
"</td>\n",
"</tr>\n";
show_tools(TOOL_PUBLIC_BUT_HIDDEN);
CourseHome::show_tool_2column(TOOL_PUBLIC_BUT_HIDDEN);
echo "</table>";
echo "</div> ";
}
@ -444,14 +166,13 @@ if (api_is_allowed_to_edit(null,true) && !api_is_coach())
-----------------------------------------------------------
*/
if (api_is_platform_admin() && api_is_allowed_to_edit(null,true) && !api_is_coach())
{
if (api_is_platform_admin() && api_is_allowed_to_edit(null,true) && !api_is_coach()) {
?>
<div class="platformadminview">
<span class="viewcaption"><?php echo get_lang("PlatformAdminOnly"); ?></span>
<table width="100%">
<?php
show_tools(TOOL_PLATFORM_ADMIN);
CourseHome::show_tool_2column(TOOL_PLATFORM_ADMIN);
?>
</table>
</div>

@ -1,33 +1,8 @@
<?php
// $Id: 3column.php,v 1.2 2006/08/10 14:26:12 pcool Exp $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2003 Ghent University
Copyright (c) 2001 Universite Catholique de Louvain
Copyright (c) various contributors
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* HOME PAGE FOR EACH COURSE (BASIC TOOLS FIXED)
* HOME PAGE FOR EACH COURSE (BASIC TOOLS FIXED)
*
* This page, included in every course's index.php is the home
* page.To make administration simple, the professor edits his
@ -38,18 +13,17 @@
* @package dokeos.course_home
==============================================================================
*/
require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
$hide = isset($_GET['hide']) && $_GET['hide'] == 'yes' ? 'yes' : null;
$restore = isset($_GET['restore']) && $_GET['restore'] == 'yes' ? 'yes' : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
include('../../main/course_home/btf_functions.php'); // RH: extra ../
$TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
$TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
// WORK with data post askable by admin of course
if (api_is_allowed_to_edit(null,true))
{
if (api_is_allowed_to_edit(null,true)) {
/* Work request */
/*> > > > > > > > > > > > MODIFY HOME PAGE < < < < < < < < < < < <*/
@ -125,9 +99,9 @@ if (api_is_allowed_to_edit(null,true))
Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE id=$id");
}
/*--------------------------------------
HIDE
--------------------------------------*/
/*--------------------------------------
HIDE
--------------------------------------*/
elseif ($hide) // visibility 1 -> 0
{
@ -135,9 +109,9 @@ if (api_is_allowed_to_edit(null,true))
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
}
/*--------------------------------------
REACTIVATE
--------------------------------------*/
/*--------------------------------------
REACTIVATE
--------------------------------------*/
elseif ($restore) // visibility 0,2 -> 1
{
@ -254,8 +228,10 @@ echo "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
echo "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
echo "<tr>\n<td colspan=\"6\">";
showtools2('Basic');
showtools2('External');
CourseHome::show_tool_3column('Basic');
CourseHome::show_tool_3column('External');
echo "</td>\n</tr>\n";
@ -263,14 +239,13 @@ echo "</td>\n</tr>\n";
PROF ONLY VIEW
==========================*/
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
if (api_is_allowed_to_edit(null,true) && !api_is_coach()) {
echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
"<tr>\n","<td colspan=\"6\">\n",
"<font color=\"#F66105\">\n",get_lang('CourseAdminOnly'),"</font>\n",
"</td>\n","</tr>\n";
echo "<tr>\n<td colspan=\"6\">";
showtools2('courseAdmin');
CourseHome::show_tool_3column('courseAdmin');
echo "</td>\n</tr>\n";
}
@ -288,7 +263,7 @@ if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
"<font color=\"#F66105\" >",get_lang('PlatformAdminOnly'),"</font>\n",
"</td>\n","</tr>\n";
echo "<tr>\n<td colspan=\"6\">";
showtools2('platformAdmin');
CourseHome::show_tool_3column('platformAdmin');
echo "</td>\n</tr>\n";
}

@ -1,28 +1,5 @@
<?php // $Id: activity.php,v 1.5 2006/08/10 14:34:54 pcool Exp $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2003 Ghent University
Copyright (c) 2001 Universite Catholique de Louvain
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* HOME PAGE FOR EACH COURSE
@ -37,473 +14,42 @@
==============================================================================
*/
require_once '../../main/inc/global.inc.php';
/*
==============================================================================
FUNCTIONS
==============================================================================
*/
/**
* Gets the tools of a certain category. Returns an array expected
* by show_tools_category()
* @param string $course_tool_category contains the category of tools to
* display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform"
* @return array
*/
function get_tools_category($course_tool_category) {
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_platform_admin = api_is_platform_admin();
$all_tools_list = array();
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id,true,true);
require_once api_get_path(LIBRARY_PATH).'course_home.lib.php';
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
//$visibility_codition = !api_is_coach()?" visibility = '1' AND ":" ";
$sql = "SELECT * FROM $course_tool_table WHERE visibility = '1' AND (category = 'authoring' OR category = 'interaction') $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_AUTHORING:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'authoring' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_INTERACTION:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'interaction' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_ADMIN_VISIBLE:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_ADMIN_PLATEFORM:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
}
while ($temp_row = Database::fetch_array($result)) {
$all_tools_list[]=$temp_row;
}
/*if(api_is_course_coach())
// MAIN CODE
if(api_is_allowed_to_edit(null,true)) {
//HIDE
if(!empty($_GET['hide'])) // visibility 1 -> 0
{
$result = Database::query("SELECT * FROM $course_tool_table WHERE name='tracking'",__FILE__,__LINE__);
$all_tools_list[]=Database :: fetch_array($result);
}*/
$i=0;
// grabbing all the links that have the property on_homepage set to 1
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
switch ($course_tool_category) {
case TOOL_AUTHORING:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' $condition_session";
break;
case TOOL_INTERACTION:
$sql_links = null;
/*
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' ";
*/
break;
case TOOL_STUDENT_VIEW:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' $condition_session";
break;
case TOOL_ADMIN:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' $condition_session";
break;
default:
$sql_links = null;
break;
}
//edit by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
if ($sql_links != null) {
$result_links = Database::query($sql_links,__FILE__,__LINE__);
$properties = array();
if (Database::num_rows($result_links) > 0) {
while ($links_row = Database::fetch_array($result_links)) {
unset($properties);
$properties['name'] = $links_row['title'];
$properties['session_id'] = $links_row['session_id'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['image'] = ($links_row['visibility']== '0') ? "file_html.gif" : "file_html.gif";
$properties['adminlink'] = api_get_path(WEB_CODE_PATH) . "link/link.php?action=editlink&id=".$links_row['id'];
$properties['target'] = $links_row['target'];
$tmp_all_tools_list[] = $properties;
}
}
}
if (isset($tmp_all_tools_list)) {
foreach ($tmp_all_tools_list as $toolsRow) {
if ($toolsRow['image'] == 'blog.gif') {
// Init
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
// Get blog id
$blog_id = substr($toolsRow['link'], strrpos($toolsRow['link'], '=') + 1, strlen($toolsRow['link']));
// Get blog members
if($is_platform_admin) {
$sql_blogs = "
SELECT *
FROM " . $tbl_blogs_rel_user . " blogs_rel_user
WHERE blog_id = " . $blog_id;
} else {
$sql_blogs = "
SELECT *
FROM " . $tbl_blogs_rel_user . " blogs_rel_user
WHERE
blog_id = " . $blog_id . " AND
user_id = " . api_get_user_id();
}
$result_blogs = Database::query($sql_blogs, __FILE__, __LINE__);
if (Database::num_rows($result_blogs) > 0) {
$all_tools_list[] = $toolsRow;
}
} else {
$all_tools_list[] = $toolsRow;
}
}
}
return $all_tools_list;
}
/**
* Displays the tools of a certain category.
* @param array List of tools as returned by get_tools_category()
* @return void
*/
function show_tools_category($all_tools_list)
{
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_platform_admin = api_is_platform_admin();
if (isset($all_tools_list)) {
$lnk = '';
foreach ($all_tools_list as $toolsRow) {
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
if (!($i%2)) {
echo "<tr valign=\"top\">\n";
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
echo '<td width="50%">' . "\n";
if ($is_allowed_to_edit && !api_is_coach()) {
if ($toolsRow['visibility'] == '1' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
if ($toolsRow['visibility'] == '0' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
}
if (!empty($toolsRow['adminlink'])) {
echo '<a href="'.$toolsRow['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($toolsRow['admin'] !='1') {
$link['cmd'] = "hide=yes";
}
}
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($toolsRow['adminlink'])) {
echo "<a class=\"make_visible_and_invisible\" href=\"" .api_get_self(). "?".api_get_cidreq()."&amp;id=" . $toolsRow["id"] . "&amp;" . $this_link['cmd'] . "\">" . $this_link['name'] . "</a>";
//echo "<a class=\"make_visible_and_invisible\" href=\"javascript:void(0)\" >" . $this_link['name'] . "</a>";
}
}
} else { echo '&nbsp;&nbsp;&nbsp;&nbsp;';}
// NOTE : table contains only the image file name, not full path
if (!stristr($toolsRow['link'], 'http://')
&& !stristr($toolsRow['link'], 'https://')
&& !stristr($toolsRow['link'],'ftp://')) {
$toolsRow['link'] = $web_code_path . $toolsRow['link'];
}
if ($toolsRow['visibility'] == '0' && $toolsRow['admin'] != '1') {
$class="class=\"invisible\"";
$info = pathinfo($toolsRow['image']);
$basename = basename ($toolsRow['image'],'.'.$info['extension']); // $file is set to "index"
$toolsRow['image'] = $basename.'_na.'.$info['extension'];
} else {
$class='';
}
$qm_or_amp = ((strpos($toolsRow['link'], '?') === FALSE) ? '?' : '&amp;');
//If it's a link, we don't add the cidReq
if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif') {
$toolsRow['link'] = $toolsRow['link'].$qm_or_amp;
} else {
$toolsRow['link'] = $toolsRow['link'].$qm_or_amp.api_get_cidreq();
}
if (strpos($toolsRow['name'],'visio_')!==false) {
/*
$toollink = "\t" . '<a ' . $class . ' href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']) . '\',\'window_visio\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $toolsRow['target'] . '">';
*/
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
$my_tool_link = "\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
} elseif (strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true) {
/*
$toollink = "\t" . '<a ' . $class . ' href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
*/
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
$my_tool_link="\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
} else {
if (count(explode('type=classroom',$toolsRow['link']))==2 || count(explode('type=conference',$toolsRow['link']))==2) {
//$toollink = "\t" . '<a ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
$my_tool_link = "\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
} else {
//$toollink = "\t" . '<a ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
$my_tool_link = "\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
}
}
echo $toollink;
//var_dump($toollink);
/*
Display::display_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name'])));
*/
if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
|| $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
|| $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
|| $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
{
$tool_name = stripslashes($toolsRow['name']);
} else {
$tool_name = get_lang(ucfirst($toolsRow['name']));
}
Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon','id'=>'toolimage_'.$toolsRow["id"]));
//validacion when belongs to a session
$session_img = api_get_session_image($toolsRow['session_id'], $_user['status']);
echo '</a> ';
echo $my_tool_link;
/*
echo ($toolsRow['image'] == 'file_html_na.gif' || $toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif' || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif' || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif') ? ' '.stripslashes($toolsRow['name']) : ' '.get_lang(ucfirst($toolsRow['name']));
*/
echo "{$tool_name}$session_img";
echo "\t" . '</a>';
echo '</td>';
if ($i%2) {
echo "</tr>";
}
$i++;
}
}
if ($i%2) {
echo "<td width=\"50%\">&nbsp;</td>\n",
"</tr>\n";
}
}
//End of functions show tools
/*
==============================================================================
MAIN CODE
==============================================================================
*/
/*
-----------------------------------------------------------
Work with data post askable by admin of course (franglais, clean this)
-----------------------------------------------------------
*/
//$session_id = api_get_session_id();
if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
if(api_is_allowed_to_edit(null,true)) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_id = Security::remove_XSS($_GET["id"]);
$tool_info = api_get_tool_information($tool_id);
$tool_visibility = $tool_info['visibility'];
$tool_image = $tool_info['image'];
$new_image = str_replace('.gif','_na.gif',$tool_image);
$requested_image = ($tool_visibility == 0 ) ? $tool_image : $new_image;
$requested_clase = ($tool_visibility == 0 ) ? 'visible' : 'invisible';
$requested_message = ($tool_visibility == 0 ) ? 'is_active' : 'is_inactive';
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
//HIDE AND REACTIVATE TOOL
if ($_GET["id"]==strval(intval($_GET["id"]))) {
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select,__FILE__,__LINE__);
$row_select = Database::fetch_array($res_select);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else $sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
*/
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
Database::query($sql,__FILE__,__LINE__);
}
/*
-----------------------------------------------------------
HIDE
-----------------------------------------------------------
*/
/* if(isset($_GET['visibility']) && $_GET['visibility']==0) // visibility 1 -> 0
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
}
}
/*
-----------------------------------------------------------
REACTIVATE
-----------------------------------------------------------
*/
/* elseif(isset($_GET['visibility'])&& $_GET['visibility']==1) // visibility 0,2 -> 1
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
Database::query("UPDATE $tool_table SET visibility=1 WHERE id='".intval($_GET["id"])."'",__FILE__,__LINE__);
}
}
*/
$response_data = array(
'image' => $requested_image,
'tclass' => $requested_clase,
'message' => $requested_message,
'view' => $requested_view
);
print(json_encode($response_data));
exit;
}
} else {
if(api_is_allowed_to_edit(null,true)) {
/*
-----------------------------------------------------------
HIDE
-----------------------------------------------------------
*/
if(!empty($_GET['hide'])) // visibility 1 -> 0
{
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select,__FILE__,__LINE__);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
}*/
}
} else {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
}
/*
-----------------------------------------------------------
REACTIVATE
-----------------------------------------------------------
*/
elseif(!empty($_GET['restore'])) // visibility 0,2 -> 1
{
$sql = "UPDATE $tool_table SET visibility=1 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
}
}*/
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
} elseif(!empty($_GET['restore'])) {
// visibility 0,2 -> 1
//REACTIVATE
$sql = "UPDATE $tool_table SET visibility=1 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
}
}
// work with data post askable by admin of course
if (api_is_platform_admin()) {
// Show message to confirm that a tools must be hidden from available tools
// visibility 0,1->2
@ -517,7 +63,6 @@ if (api_is_platform_admin()) {
</div>
<?php
}
/*
* Process hiding a tools from available tools.
*/
@ -529,65 +74,6 @@ if (api_is_platform_admin()) {
}
/*
==============================================================================
SESSION DATA
==============================================================================
*/
/**
* Shows the general data for a particular meeting
*
* @param id session id
* @return string session data
*
*/
function show_session_data($id_session) {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
if ($id_session!=strval(intval($id_session))) {
return '';
} else {
$id_session = intval($id_session);
}
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$session_table.'
LEFT JOIN '.$user_table.'
ON id_coach = user_id
WHERE '.$session_table.'.id='.$id_session;
$rs = Database::query($sql, __FILE__, __LINE__);
$session = Database::store_result($rs);
$session = $session[0];
$sql_category = 'SELECT name FROM '.$session_category_table.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs_category = Database::query($sql_category, __FILE__, __LINE__);
$session_category = '';
if (Database::num_rows($rs_category) > 0) {
$rows_session_category = Database::store_result($rs_category);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
if ($session['date_start'] == '00-00-0000') {
$msg_date = get_lang('NoTimeLimits');
} else {
$msg_date = get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'];
}
$output = '';
if (!empty($session_category)) {
$output .= '<tr><td>'. get_lang('SessionCategory') . ': ' . '<b>' . $session_category .'</b></td></tr>';
}
$output .= '<tr><td style="width:50%">'. get_lang('SessionName') . ': ' . '<b>' . $session['name'] .'</b></td><td>'. get_lang('GeneralCoach') . ': ' . '<b>' . $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' .'</b></td></tr>';
$output .= '<tr><td>'. get_lang('SessionIdentifier') . ': '. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) .'</td><td>'. get_lang('Date') . ': ' . '<b>' . $msg_date .'</b></td></tr>';
return $output;
}
/*
==============================================================================
COURSE ADMIN ONLY VIEW
@ -635,19 +121,28 @@ if(api_is_allowed_to_edit(null,true) && !api_is_coach()) {
<div class="courseadminview">
<span class="viewcaption"><?php echo get_lang("Authoring") ?></span>
<table width="100%">
<?php $my_list = get_tools_category(TOOL_AUTHORING); show_tools_category($my_list);?>
<?php
$my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
CourseHome::show_tools_category($my_list);
?>
</table>
</div>
<div class="courseadminview">
<span class="viewcaption"><?php echo get_lang("Interaction") ?></span>
<table width="100%">
<?php $my_list = get_tools_category(TOOL_INTERACTION); show_tools_category($my_list);?>
<?php
$my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
CourseHome::show_tools_category($my_list);
?>
</table>
</div>
<div class="courseadminview">
<span class="viewcaption"><?php echo get_lang("Administration") ?></span>
<table width="100%">
<?php $my_list = get_tools_category(TOOL_ADMIN_PLATEFORM); show_tools_category($my_list);?>
<?php
$my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATEFORM);
CourseHome::show_tools_category($my_list);
?>
</table>
</div>
@ -659,7 +154,7 @@ if(api_is_allowed_to_edit(null,true) && !api_is_coach()) {
<div class="courseadminview">
<span class="viewcaption"><?php echo get_lang("SessionData") ?></span>
<table width="100%">
<?php echo show_session_data($id_session);?>
<?php echo CourseHome::show_session_data($id_session);?>
</table>
</div>
<?php
@ -667,25 +162,19 @@ if(api_is_allowed_to_edit(null,true) && !api_is_coach()) {
?>
<div class="Authoringview">
<table width="100%">
<?php $my_list = get_tools_category(TOOL_STUDENT_VIEW); show_tools_category($my_list);?>
<?php $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW); show_tools_category($my_list);?>
</table>
</div>
<?php
/*
==============================================================================
TOOLS AUTHORING
==============================================================================
*/
// TOOLS AUTHORING
} else {
$my_list = get_tools_category(TOOL_STUDENT_VIEW);
$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
if (count($my_list)>0) {
?>
<div class="Authoringview">
<table width="100%">
<?php show_tools_category($my_list);?>
<?php CourseHome::show_tools_category($my_list);?>
</table>
</div>
<?php

@ -1,287 +0,0 @@
<?php
// $Id: btf_functions.php 20027 2009-04-23 19:18:54Z cfasanando $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2003 Ghent University
Copyright (c) 2001 Universite Catholique de Louvain
Copyright (c) various contributors
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* HOME PAGE FUNCTIONS (BASIC TOOLS FIXED)
*
* This page, included in every course's index.php is the home
* page.To make administration simple, the professor edits his
* course from it's home page. Only the login detects that the
* visitor is allowed to activate, deactivate home page links,
* access to Professor's tools (statistics, edit forums...).
*
* @package dokeos.course_home
==============================================================================
*/
function showtools2($cat)
{
global $_user, $charset;
$TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
$TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
$numcols = 3;
$table = new HTML_Table('width="100%"');
$toolsRow_all = array ();
switch ($cat)
{
case 'Basic' :
$sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.link=t.link AND t.position='basic' ORDER BY t.row, t.column";
break;
case 'External' :
if (api_is_allowed_to_edit())
{
$sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE (a.link=t.link AND t.position='external')
OR (a.visibility <= 1 AND (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image)
ORDER BY a.id";
}
else
{
$sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.visibility = 1 AND ((a.link=t.link AND t.position='external')
OR ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image))
ORDER BY a.id";
}
break;
case 'courseAdmin' :
$sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE admin=1 AND a.link=t.link ORDER BY t.row, t.column";
break;
case 'platformAdmin' :
$sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE visibility = 2 ORDER BY id";
}
$result = Database::query($sql, __FILE__, __LINE__);
// grabbing all the tools from $course_tool_table
while ($tempRow = Database::fetch_array($result))
{
/*
if ($tempRow['img'] !== "scormbuilder.gif" AND $tempRow['img'] !== "blog.gif")
*/
if ($tempRow['img'] != 'file_html.gif' && $tempRow['img'] != 'file_html_na.gif'
&& $tempRow['img'] != 'scormbuilder.gif' && $tempRow['img'] != 'scormbuilder_na.gif'
&& $tempRow['img'] != 'blog.gif' && $tempRow['img'] != 'blog_na.gif'
&& $tempRow['img'] != 'external.gif' && $tempRow['img'] != 'external_na.gif')
{
$tempRow['name_translated'] = get_lang(ucfirst($tempRow['name']));
}
$toolsRow_all[] = $tempRow;
}
// grabbing all the links that have the property on_homepage set to 1
if ($cat == "External")
{
$tbl_link = Database :: get_course_table(TABLE_LINK);
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if (api_is_allowed_to_edit(null,true))
{
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility != 2";
}
else
{
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 1";
}
$result_links = Database::query($sql_links);
while ($links_row = Database::fetch_array($result_links))
{
$properties = array ();
$properties['name'] = $links_row['title'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['img'] = 'external.gif';
$properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&amp;id='.$links_row['id'];
$toolsRow_all[] = $properties;
}
}
$cell_number = 0;
// draw line between basic and external, only if there are entries in External
if ($cat == "External" && count($toolsRow_all))
{
$table->setCellContents(0, 0, '<hr noshade="noshade" size="1"/>');
$table->updateCellAttributes(0, 0, 'colspan="3"');
$cell_number += $numcols;
}
foreach ($toolsRow_all as $toolsRow)
{
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
$cell_content = '';
// the name of the tool
$tool_name = ($toolsRow['name_translated'] != "" ? $toolsRow['name_translated'] : htmlspecialchars($toolsRow['name'],ENT_QUOTES,$charset)); // RH: added htmlspecialchars
$link_annex = '';
// the url of the tool
if ($toolsRow['img'] != "external.gif")
{
$toolsRow['link'] = api_get_path(WEB_CODE_PATH).$toolsRow['link'];
$qm_or_amp = ((strpos($toolsRow['link'], '?') === FALSE) ? '?' : '&amp;');
$link_annex = $qm_or_amp.api_get_cidreq();
}
else // if an external link ends with 'login=', add the actual login...
{
$pos = strpos($toolsRow['link'], "?login=");
$pos2 = strpos($toolsRow['link'], "&amp;login=");
if ($pos !== false or $pos2 !== false)
{
$link_annex = $_user['username'];
}
}
// setting the actual image url
$toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img'];
// VISIBLE
if ($toolsRow['visibility'] or $cat == 'courseAdmin' or $cat == 'platformAdmin')
{
if(strpos($toolsRow['name'],'visio_')!==false)
{
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' . $toolsRow['link'].$link_annex . '\',\'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="' . $toolsRow['target'] . '"><img src="'.$toolsRow['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
$cell_content .= '<a href="#" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '"><img src="'.$toolsRow['img'].'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '"><img src="'.$toolsRow['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
else
{
/*
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'"><img src="'.$toolsRow['img'].'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'"><img src="'.$toolsRow['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
}
// INVISIBLE
else
{
if (api_is_allowed_to_edit(null,true))
{
if(strpos($toolsRow['name'],'visio_')!==false)
{
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' . $toolsRow['link'].$link_annex . '\',\'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="' . $toolsRow['target'] . '"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n";
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
$cell_content .= '<a href="#" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
else
{
/*
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n";// don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n";// don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
}
else
{
/*
$cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
$cell_content .= '<span class="invisible">'.$tool_name.'</span>';
}
}
$lnk = array ();
if (api_is_allowed_to_edit(null,true) && $cat != "courseAdmin" && !strpos($toolsRow['link'], 'learnpath_handler.php?learnpath_id') && !api_is_coach())
{
if ($toolsRow["visibility"])
{
$link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'), array('style' => 'vertical-align:middle;'));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
else
{
$link['name'] = Display::return_icon('add.gif', get_lang('Activate'), array('style' => 'vertical-align:middle;'));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
/*if($toolsRow["img"] == $dokeosRepositoryWeb."img/external.gif")
{
$link['name'] = get_lang('Remove'); $link['cmd'] = "remove=yes";
if ($toolsRow["visibility"]==2 and $cat=="platformAdmin")
{
$link['name'] = get_lang('Delete'); $link['cmd'] = "askDelete=yes";
$lnk[] = $link;
}
}*/
}
//echo "<div class=courseadmin>";
if (is_array($lnk))
{
foreach ($lnk as $thisLnk)
{
if ($toolsRow['adminlink'])
{
$cell_content .= '<a href="'.$properties['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
//echo "edit link:".$properties['adminlink'];
}
else
{
$cell_content .= "<a href=\"".api_get_self()."?id=".$toolsRow["id"]."&amp;".$thisLnk['cmd']."\">".$thisLnk['name']."</a>";
}
}
}
// RH: Allow editing of invisible homepage links (modified external_module)
/*
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit() && !$toolsRow["visibility"])
*/
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit() && !$toolsRow["visibility"]
&& $toolsRow['image'] != 'scormbuilder.gif' && $toolsRow['image'] != 'scormbuilder_na.gif')
{
$cell_content .= "<a class=\"nobold\" href=\"".api_get_path(WEB_CODE_PATH).'external_module/external_module.php'."?id=".$toolsRow["id"]."\">".get_lang("Edit")."</a>";
}
}
$table->setCellContents($cell_number / $numcols, ($cell_number) % $numcols, $cell_content);
$table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
$cell_number ++;
}
$table->display();
} // end function showtools2($cat)
?>

@ -1,31 +1,7 @@
<?php // $Id: course_home.php 22294 2009-07-22 19:27:47Z iflorespaz $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2003 Ghent University
Copyright (c) 2001 Universite Catholique de Louvain
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
<?php
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* HOME PAGE FOR EACH COURSE
HOME PAGE FOR EACH COURSE
*
* This page, included in every course's index.php is the home
* page. To make administration simple, the teacher edits his
@ -49,18 +25,11 @@
*
*
* @package dokeos.course_home
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* INIT SECTION */
// Name of the language file that needs to be included.
$language_file = 'course_home';
$use_anonymous = true;
// Inlcuding the global initialization file.
@ -88,7 +57,7 @@ $(document).ready(function() {
$("#id_confirmation_message").hide();
},
type: "GET",
url: "'.api_get_path(WEB_CODE_PATH).'course_home/activity.php",
url: "'.api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=set_visibility",
data: "id=" + my_tool_id + "&sent_http_request=1",
success: function(data) {
eval("var info=" + data);
@ -139,11 +108,7 @@ if (isset($_SESSION['_gid'])) {
// The section for the tabs
$this_section = SECTION_COURSES;
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
// Libraries
include_once api_get_path(LIBRARY_PATH).'course.lib.php';
include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
@ -165,19 +130,15 @@ define ('TOOL_ADMIN_PLATEFORM', 'tooladminplatform');
//define ('TOOL_ADMIN_COURS_INVISIBLE', 'tooladmincoursinvisible');
define ('TOOL_STUDENT_VIEW', 'toolstudentview');
define ('TOOL_ADMIN_VISIBLE', 'tooladminvisible');
/*
-----------------------------------------------------------
Virtual course support code
-----------------------------------------------------------
*/
$user_id = api_get_user_id();
$course_code = $_course['sysCode'];
$course_info = Database::get_course_info($course_code);
$return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
$course_title = $return_result['title'];
$course_code = $return_result['code'];
/* Virtual course support code */
$user_id = api_get_user_id();
$course_code = $_course['sysCode'];
$course_info = Database::get_course_info($course_code);
$return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
$course_title = $return_result['title'];
$course_code = $return_result['code'];
$_course['name'] = $course_title;
$_course['official_code'] = $course_code;
@ -261,4 +222,4 @@ elseif(api_get_setting('homepage_view') == '3column') {
FOOTER
==============================================================================
*/
Display::display_footer();
Display::display_footer();

@ -0,0 +1,87 @@
<?php
/**
* This class response to the Ajax calls
*
*/
require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'set_visibility':
if(api_is_allowed_to_edit(null,true)) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_id = Security::remove_XSS($_GET["id"]);
$tool_info = api_get_tool_information($tool_id);
$tool_visibility = $tool_info['visibility'];
$tool_image = $tool_info['image'];
$new_image = str_replace('.gif','_na.gif',$tool_image);
$requested_image = ($tool_visibility == 0 ) ? $tool_image : $new_image;
$requested_clase = ($tool_visibility == 0 ) ? 'visible' : 'invisible';
$requested_message = ($tool_visibility == 0 ) ? 'is_active' : 'is_inactive';
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
$requested_view = ($tool_visibility == 0 ) ? 'visible.gif' : 'invisible.gif';
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
//HIDE AND REACTIVATE TOOL
if ($_GET["id"]==strval(intval($_GET["id"]))) {
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select,__FILE__,__LINE__);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else $sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
*/
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
Database::query($sql,__FILE__,__LINE__);
}
/*
-----------------------------------------------------------
HIDE
-----------------------------------------------------------
*/
/* if(isset($_GET['visibility']) && $_GET['visibility']==0) // visibility 1 -> 0
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
}
}
/*
-----------------------------------------------------------
REACTIVATE
-----------------------------------------------------------
*/
/* elseif(isset($_GET['visibility'])&& $_GET['visibility']==1) // visibility 0,2 -> 1
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
Database::query("UPDATE $tool_table SET visibility=1 WHERE id='".intval($_GET["id"])."'",__FILE__,__LINE__);
}
}
*/
$response_data = array(
'image' => $requested_image,
'tclass' => $requested_clase,
'message' => $requested_message,
'view' => $requested_view
);
print(json_encode($response_data));
exit;
}
break;
default:
echo '';
}
?>

@ -0,0 +1,862 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
class CourseHome {
/**
* Gets the html content to show in the 3 column view
*/
public static function show_tool_3column($cat) {
global $_user, $charset;
$TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
$TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
$numcols = 3;
$table = new HTML_Table('width="100%"');
$toolsRow_all = array ();
switch ($cat) {
case 'Basic' :
$sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.link=t.link AND t.position='basic' ORDER BY t.row, t.column";
break;
case 'External' :
if (api_is_allowed_to_edit()) {
$sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE (a.link=t.link AND t.position='external')
OR (a.visibility <= 1 AND (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image)
ORDER BY a.id";
} else {
$sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.visibility = 1 AND ((a.link=t.link AND t.position='external')
OR ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image))
ORDER BY a.id";
}
break;
case 'courseAdmin' :
$sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE admin=1 AND a.link=t.link ORDER BY t.row, t.column";
break;
case 'platformAdmin' :
$sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE visibility = 2 ORDER BY id";
}
$result = Database::query($sql, __FILE__, __LINE__);
// grabbing all the tools from $course_tool_table
while ($tempRow = Database::fetch_array($result))
{
/*
if ($tempRow['img'] !== "scormbuilder.gif" AND $tempRow['img'] !== "blog.gif")
*/
if ($tempRow['img'] != 'file_html.gif' && $tempRow['img'] != 'file_html_na.gif'
&& $tempRow['img'] != 'scormbuilder.gif' && $tempRow['img'] != 'scormbuilder_na.gif'
&& $tempRow['img'] != 'blog.gif' && $tempRow['img'] != 'blog_na.gif'
&& $tempRow['img'] != 'external.gif' && $tempRow['img'] != 'external_na.gif')
{
$tempRow['name_translated'] = get_lang(ucfirst($tempRow['name']));
}
$toolsRow_all[] = $tempRow;
}
// grabbing all the links that have the property on_homepage set to 1
if ($cat == "External")
{
$tbl_link = Database :: get_course_table(TABLE_LINK);
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if (api_is_allowed_to_edit(null,true))
{
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility != 2";
}
else
{
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 1";
}
$result_links = Database::query($sql_links);
while ($links_row = Database::fetch_array($result_links))
{
$properties = array ();
$properties['name'] = $links_row['title'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['img'] = 'external.gif';
$properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&amp;id='.$links_row['id'];
$toolsRow_all[] = $properties;
}
}
$cell_number = 0;
// draw line between basic and external, only if there are entries in External
if ($cat == "External" && count($toolsRow_all))
{
$table->setCellContents(0, 0, '<hr noshade="noshade" size="1"/>');
$table->updateCellAttributes(0, 0, 'colspan="3"');
$cell_number += $numcols;
}
foreach ($toolsRow_all as $toolsRow)
{
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
$cell_content = '';
// the name of the tool
$tool_name = ($toolsRow['name_translated'] != "" ? $toolsRow['name_translated'] : htmlspecialchars($toolsRow['name'],ENT_QUOTES,$charset)); // RH: added htmlspecialchars
$link_annex = '';
// the url of the tool
if ($toolsRow['img'] != "external.gif")
{
$toolsRow['link'] = api_get_path(WEB_CODE_PATH).$toolsRow['link'];
$qm_or_amp = ((strpos($toolsRow['link'], '?') === FALSE) ? '?' : '&amp;');
$link_annex = $qm_or_amp.api_get_cidreq();
}
else // if an external link ends with 'login=', add the actual login...
{
$pos = strpos($toolsRow['link'], "?login=");
$pos2 = strpos($toolsRow['link'], "&amp;login=");
if ($pos !== false or $pos2 !== false)
{
$link_annex = $_user['username'];
}
}
// setting the actual image url
$toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img'];
// VISIBLE
if ($toolsRow['visibility'] or $cat == 'courseAdmin' or $cat == 'platformAdmin')
{
if(strpos($toolsRow['name'],'visio_')!==false)
{
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' . $toolsRow['link'].$link_annex . '\',\'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="' . $toolsRow['target'] . '"><img src="'.$toolsRow['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
$cell_content .= '<a href="#" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '"><img src="'.$toolsRow['img'].'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '"><img src="'.$toolsRow['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
else
{
/*
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'"><img src="'.$toolsRow['img'].'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'"><img src="'.$toolsRow['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
}
// INVISIBLE
else
{
if (api_is_allowed_to_edit(null,true))
{
if(strpos($toolsRow['name'],'visio_')!==false)
{
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' . $toolsRow['link'].$link_annex . '\',\'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="' . $toolsRow['target'] . '"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n";
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
$cell_content .= '<a href="#" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' .$toolsRow['link'].$link_annex. '\',\'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="' . $toolsRow['target'] . '" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n"; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
else
{
/*
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'.$tool_name.'</a>'."\n";// don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'."\n";// don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
}
}
else
{
/*
$cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" alt="'.get_lang(ucfirst($toolsRow['name'])).' " align="absmiddle" border="0">'; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
*/
$cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $toolsRow['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'; // don't replace img with display::return_icon because $toolsRow['img'] = api_get_path(WEB_IMG_PATH).$toolsRow['img']
$cell_content .= '<span class="invisible">'.$tool_name.'</span>';
}
}
$lnk = array ();
if (api_is_allowed_to_edit(null,true) && $cat != "courseAdmin" && !strpos($toolsRow['link'], 'learnpath_handler.php?learnpath_id') && !api_is_coach())
{
if ($toolsRow["visibility"])
{
$link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'), array('style' => 'vertical-align:middle;'));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
else
{
$link['name'] = Display::return_icon('add.gif', get_lang('Activate'), array('style' => 'vertical-align:middle;'));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
/*if($toolsRow["img"] == $dokeosRepositoryWeb."img/external.gif")
{
$link['name'] = get_lang('Remove'); $link['cmd'] = "remove=yes";
if ($toolsRow["visibility"]==2 and $cat=="platformAdmin")
{
$link['name'] = get_lang('Delete'); $link['cmd'] = "askDelete=yes";
$lnk[] = $link;
}
}*/
}
//echo "<div class=courseadmin>";
if (is_array($lnk))
{
foreach ($lnk as $thisLnk)
{
if ($toolsRow['adminlink'])
{
$cell_content .= '<a href="'.$properties['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
//echo "edit link:".$properties['adminlink'];
}
else
{
$cell_content .= "<a href=\"".api_get_self()."?id=".$toolsRow["id"]."&amp;".$thisLnk['cmd']."\">".$thisLnk['name']."</a>";
}
}
}
// RH: Allow editing of invisible homepage links (modified external_module)
/*
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit() && !$toolsRow["visibility"])
*/
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit() && !$toolsRow["visibility"]
&& $toolsRow['image'] != 'scormbuilder.gif' && $toolsRow['image'] != 'scormbuilder_na.gif')
{
$cell_content .= "<a class=\"nobold\" href=\"".api_get_path(WEB_CODE_PATH).'external_module/external_module.php'."?id=".$toolsRow["id"]."\">".get_lang("Edit")."</a>";
}
}
$table->setCellContents($cell_number / $numcols, ($cell_number) % $numcols, $cell_content);
$table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
$cell_number ++;
}
$table->display();
} // end function showtools2($cat)
/**
* Displays the tools of a certain category.
*
* @return void
* @param string $course_tool_category contains the category of tools to display:
* "Public", "PublicButHide", "courseAdmin", "claroAdmin"
*/
function show_tool_2column($course_tool_category) {
global $charset;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
switch ($course_tool_category)
{
case TOOL_PUBLIC:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=1 ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=0 AND admin=0 ORDER BY id",__FILE__,__LINE__);
$colLink ="##808080";
break;
case TOOL_COURSE_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE admin=1 AND visibility != 2 ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_PLATFORM_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = 2 ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
}
$i=0;
// grabbing all the tools from $course_tool_table
while ($temp_row = Database::fetch_array($result))
{
if($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif')
{
$temp_row['image']=str_replace('.gif','_na.gif',$temp_row['image']);
}
$all_tools_list[]=$temp_row;
}
// grabbing all the links that have the property on_homepage set to 1
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
switch ($course_tool_category)
{
case TOOL_PUBLIC:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 1";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 0";
break;
default:
$sql_links = null;
break;
}
if( $sql_links != null )
{
$properties = array();
$result_links=Database::query($sql_links,__FILE__,__LINE__);
while ($links_row=Database::fetch_array($result_links))
{
unset($properties);
$properties['name']=$links_row['title'];
$properties['link']=$links_row['url'];
$properties['visibility']=$links_row['visibility'];
$properties['image']=($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)?"external_na.gif":"external.gif";
$properties['adminlink']=api_get_path(WEB_CODE_PATH)."link/link.php?action=editlink&id=".$links_row['id'];
$all_tools_list[]=$properties;
}
}
if (isset($all_tools_list))
{
$lnk = array();
foreach ($all_tools_list as $toolsRow)
{
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
if (!($i%2))
{
echo "<tr valign=\"top\">\n";
}
// NOTE : table contains only the image file name, not full path
if(!stristr($toolsRow['link'],'http://') && !stristr($toolsRow['link'],'https://') && !stristr($toolsRow['link'],'ftp://'))
{
$toolsRow['link']=$web_code_path.$toolsRow['link'];
}
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)
{
$class="class=\"invisible\"";
}
$qm_or_amp = ((strpos($toolsRow['link'],'?')===FALSE)?'?':'&amp;');
$toolsRow['link'] = $toolsRow['link'];
echo '<td width="50%" height="30">';
if(strpos($toolsRow['name'],'visio_')!==false)
{
echo '<a '.$class.' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']).(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()) . '\',\'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="' . $toolsRow['target'] . '">';
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
echo '<a href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']) .(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()). '\',\'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="' . $toolsRow['target'] . '"'.$class.'>';
*/
echo '<a href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']).$qm_or_amp.api_get_cidreq() . '\',\'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="' . $toolsRow['target'] . '"'.$class.'>';
}
else
{
echo '<a href="'. htmlspecialchars($toolsRow['link']).(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()).'" target="' , $toolsRow['target'], '" '.$class.'>';
}
/*
echo Display::return_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name']))),'&nbsp;', ($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif" || $toolsRow['image']=="scormbuilder.gif" || $toolsRow['image']=="blog.gif") ? htmlspecialchars( $toolsRow['name'],ENT_QUOTES,$charset) : get_lang(ucfirst($toolsRow['name'])),'</a>';
*/
if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
|| $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
|| $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
|| $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
{
$tool_name = htmlspecialchars($toolsRow['name'], ENT_QUOTES, $charset);
}
else
{
$tool_name = get_lang(ucfirst($toolsRow['name']));
}
echo Display::return_icon($toolsRow['image'], $tool_name),'&nbsp;', $tool_name,'</a>';
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
if ($toolsRow["visibility"] == '1')
{
$link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)
{
$link['name'] = Display::return_icon('add.gif', get_lang('Activate'));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
if($toolsRow["added_tool"] == 1)
{
$link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
$link['cmd'] = "remove=yes";
$lnk[] = $link;
}
}
if ($toolsRow['adminlink'])
{
echo '<a href="'.$toolsRow['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
//echo "edit link:".$properties['adminlink'];
}
}
if ( api_is_platform_admin() )
{
if ($toolsRow["visibility"]==2)
{
$link['name'] = Display::return_icon('undelete.gif', get_lang('Activate'));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
if($toolsRow["added_tool"] == 1)
{
$link['name'] = get_lang("Delete");
$link['cmd'] = "askDelete=yes";
$lnk[] = $link;
}
}
if ($toolsRow["visibility"] == 0 && $toolsRow["added_tool"] == 0)
{
$link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
$link['cmd'] = "remove=yes";
$lnk[] = $link;
}
}
if (is_array($lnk))
{
foreach($lnk as $this_link)
{
if (!$toolsRow['adminlink'])
{
echo "<a href=\"" .api_get_self(). "?".api_get_cidreq()."&amp;id=" . $toolsRow["id"] . "&amp;" . $this_link['cmd'] . "\">" . $this_link['name'] . "</a>";
}
}
}
// Allow editing of invisible homepage links (modified external_module)
/*
if ($toolsRow["added_tool"] == 1 &&
api_is_allowed_to_edit() && !$toolsRow["visibility"])
*/
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit(null,true) && !$toolsRow["visibility"]
&& $toolsRow['image'] != 'scormbuilder.gif' && $toolsRow['image'] != 'scormbuilder_na.gif')
echo "<a class=\"nobold\" href=\"" . api_get_path(WEB_PATH) .
'main/external_module/external_module.php' .
"?".api_get_cidreq()."&amp;id=".$toolsRow["id"]."\">". get_lang("Edit"). "</a>";
echo "</td>\n";
if($i%2)
{
echo "</tr>\n";
}
$i++;
}
}
if($i%2)
{
echo "<td width=\"50%\">&nbsp;</td>\n",
"</tr>\n";
}
}
/**
* Gets the tools of a certain category. Returns an array expected
* by show_tools_category()
* @param string $course_tool_category contains the category of tools to
* display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform"
* @return array
*/
public static function get_tools_category($course_tool_category) {
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_platform_admin = api_is_platform_admin();
$all_tools_list = array();
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id,true,true);
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
//$visibility_codition = !api_is_coach()?" visibility = '1' AND ":" ";
$sql = "SELECT * FROM $course_tool_table WHERE visibility = '1' AND (category = 'authoring' OR category = 'interaction') $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_AUTHORING:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'authoring' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_INTERACTION:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'interaction' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_ADMIN_VISIBLE:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_ADMIN_PLATEFORM:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
}
while ($temp_row = Database::fetch_array($result)) {
$all_tools_list[]=$temp_row;
}
/*if(api_is_course_coach())
{
$result = Database::query("SELECT * FROM $course_tool_table WHERE name='tracking'",__FILE__,__LINE__);
$all_tools_list[]=Database :: fetch_array($result);
}*/
$i=0;
// grabbing all the links that have the property on_homepage set to 1
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
switch ($course_tool_category) {
case TOOL_AUTHORING:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' $condition_session";
break;
case TOOL_INTERACTION:
$sql_links = null;
/*
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' ";
*/
break;
case TOOL_STUDENT_VIEW:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' $condition_session";
break;
case TOOL_ADMIN:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.on_homepage='1' $condition_session";
break;
default:
$sql_links = null;
break;
}
//edit by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
if ($sql_links != null) {
$result_links = Database::query($sql_links,__FILE__,__LINE__);
$properties = array();
if (Database::num_rows($result_links) > 0) {
while ($links_row = Database::fetch_array($result_links)) {
unset($properties);
$properties['name'] = $links_row['title'];
$properties['session_id'] = $links_row['session_id'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['image'] = ($links_row['visibility']== '0') ? "file_html.gif" : "file_html.gif";
$properties['adminlink'] = api_get_path(WEB_CODE_PATH) . "link/link.php?action=editlink&id=".$links_row['id'];
$properties['target'] = $links_row['target'];
$tmp_all_tools_list[] = $properties;
}
}
}
if (isset($tmp_all_tools_list)) {
foreach ($tmp_all_tools_list as $toolsRow) {
if ($toolsRow['image'] == 'blog.gif') {
// Init
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
// Get blog id
$blog_id = substr($toolsRow['link'], strrpos($toolsRow['link'], '=') + 1, strlen($toolsRow['link']));
// Get blog members
if($is_platform_admin) {
$sql_blogs = "
SELECT *
FROM " . $tbl_blogs_rel_user . " blogs_rel_user
WHERE blog_id = " . $blog_id;
} else {
$sql_blogs = "
SELECT *
FROM " . $tbl_blogs_rel_user . " blogs_rel_user
WHERE
blog_id = " . $blog_id . " AND
user_id = " . api_get_user_id();
}
$result_blogs = Database::query($sql_blogs, __FILE__, __LINE__);
if (Database::num_rows($result_blogs) > 0) {
$all_tools_list[] = $toolsRow;
}
} else {
$all_tools_list[] = $toolsRow;
}
}
}
return $all_tools_list;
}
/**
* Displays the tools of a certain category.
* @param array List of tools as returned by get_tools_category()
* @return void
*/
public static function show_tools_category($all_tools_list)
{
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_platform_admin = api_is_platform_admin();
$i = 0;
if (isset($all_tools_list)) {
$lnk = '';
foreach ($all_tools_list as $toolsRow) {
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
if (!($i%2)) {
echo "<tr valign=\"top\">\n";
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
echo '<td width="50%">' . "\n";
if ($is_allowed_to_edit && !api_is_coach()) {
if ($toolsRow['visibility'] == '1' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
if ($toolsRow['visibility'] == '0' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
}
if (!empty($toolsRow['adminlink'])) {
echo '<a href="'.$toolsRow['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($toolsRow['admin'] !='1') {
$link['cmd'] = "hide=yes";
}
}
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($toolsRow['adminlink'])) {
echo '<a class="make_visible_and_invisible" href="'.api_get_self(). '?'.api_get_cidreq()."&amp;id=" . $toolsRow['id'] . "&amp;" . $this_link['cmd'] . "\">" . $this_link['name'] . "</a>";
}
}
} else { echo '&nbsp;&nbsp;&nbsp;&nbsp;';}
// NOTE : table contains only the image file name, not full path
if (!stristr($toolsRow['link'], 'http://')
&& !stristr($toolsRow['link'], 'https://')
&& !stristr($toolsRow['link'],'ftp://')) {
$toolsRow['link'] = $web_code_path . $toolsRow['link'];
}
if ($toolsRow['visibility'] == '0' && $toolsRow['admin'] != '1') {
$class="class=\"invisible\"";
$info = pathinfo($toolsRow['image']);
$basename = basename ($toolsRow['image'],'.'.$info['extension']); // $file is set to "index"
$toolsRow['image'] = $basename.'_na.'.$info['extension'];
} else {
$class='';
}
$qm_or_amp = ((strpos($toolsRow['link'], '?') === FALSE) ? '?' : '&amp;');
//If it's a link, we don't add the cidReq
if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif') {
$toolsRow['link'] = $toolsRow['link'].$qm_or_amp;
} else {
$toolsRow['link'] = $toolsRow['link'].$qm_or_amp.api_get_cidreq();
}
if (strpos($toolsRow['name'],'visio_')!==false) {
/*
$toollink = "\t" . '<a ' . $class . ' href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']) . '\',\'window_visio\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $toolsRow['target'] . '">';
*/
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
$my_tool_link = "\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
} elseif (strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true) {
/*
$toollink = "\t" . '<a ' . $class . ' href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
*/
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
$my_tool_link="\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['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="' . $toolsRow['target'] . '">';
} else {
if (count(explode('type=classroom',$toolsRow['link']))==2 || count(explode('type=conference',$toolsRow['link']))==2) {
//$toollink = "\t" . '<a ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
$my_tool_link = "\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
} else {
//$toollink = "\t" . '<a ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
$toollink = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
$my_tool_link = "\t" . '<a id="istooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
}
}
echo $toollink;
//var_dump($toollink);
/*
Display::display_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name'])));
*/
if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
|| $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
|| $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
|| $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
{
$tool_name = stripslashes($toolsRow['name']);
} else {
$tool_name = get_lang(ucfirst($toolsRow['name']));
}
Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon','id'=>'toolimage_'.$toolsRow["id"]));
//validacion when belongs to a session
$session_img = api_get_session_image($toolsRow['session_id'], $_user['status']);
echo '</a> ';
echo $my_tool_link;
/*
echo ($toolsRow['image'] == 'file_html_na.gif' || $toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif' || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif' || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif') ? ' '.stripslashes($toolsRow['name']) : ' '.get_lang(ucfirst($toolsRow['name']));
*/
echo "{$tool_name}$session_img";
echo "\t" . '</a>';
echo '</td>';
if ($i%2) {
echo "</tr>";
}
$i++;
}
}
if ($i%2) {
echo "<td width=\"50%\">&nbsp;</td>\n",
"</tr>\n";
}
}
/**
* Shows the general data for a particular meeting
*
* @param id session id
* @return string session data
*
*/
public static function show_session_data($id_session) {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
if ($id_session!=strval(intval($id_session))) {
return '';
} else {
$id_session = intval($id_session);
}
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$session_table.'
LEFT JOIN '.$user_table.'
ON id_coach = user_id
WHERE '.$session_table.'.id='.$id_session;
$rs = Database::query($sql, __FILE__, __LINE__);
$session = Database::store_result($rs);
$session = $session[0];
$sql_category = 'SELECT name FROM '.$session_category_table.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs_category = Database::query($sql_category, __FILE__, __LINE__);
$session_category = '';
if (Database::num_rows($rs_category) > 0) {
$rows_session_category = Database::store_result($rs_category);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
if ($session['date_start'] == '00-00-0000') {
$msg_date = get_lang('NoTimeLimits');
} else {
$msg_date = get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'];
}
$output = '';
if (!empty($session_category)) {
$output .= '<tr><td>'. get_lang('SessionCategory') . ': ' . '<b>' . $session_category .'</b></td></tr>';
}
$output .= '<tr><td style="width:50%">'. get_lang('SessionName') . ': ' . '<b>' . $session['name'] .'</b></td><td>'. get_lang('GeneralCoach') . ': ' . '<b>' . $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' .'</b></td></tr>';
$output .= '<tr><td>'. get_lang('SessionIdentifier') . ': '. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) .'</td><td>'. get_lang('Date') . ': ' . '<b>' . $msg_date .'</b></td></tr>';
return $output;
}
}
?>

@ -345,7 +345,8 @@ function api_get_path($path_type, $path = null) {
INCLUDE_PATH => 'inc/',
LIBRARY_PATH => 'inc/lib/',
CONFIGURATION_PATH => 'inc/conf/',
WEB_LIBRARY_PATH => 'inc/lib/'
WEB_LIBRARY_PATH => 'inc/lib/',
WEB_AJAX_PATH => 'inc/ajax/'
);
static $resource_paths = array(
@ -437,42 +438,42 @@ function api_get_path($path_type, $path = null) {
//
// Initialization of a table taht contains common-purpose paths.
//
$paths[WEB_PATH] = $root_web;
$paths[SYS_PATH] = $root_sys;
$paths[REL_PATH] = $root_rel;
$paths[WEB_PATH] = $root_web;
$paths[SYS_PATH] = $root_sys;
$paths[REL_PATH] = $root_rel;
$paths[WEB_SERVER_ROOT_PATH] = $server_base_web.'/';
$paths[SYS_SERVER_ROOT_PATH] = $server_base_sys.'/';
$paths[WEB_COURSE_PATH] = $root_web.$course_folder;
$paths[SYS_COURSE_PATH] = $root_sys.$course_folder;
$paths[REL_COURSE_PATH] = $root_rel.$course_folder;
$paths[REL_CODE_PATH] = $root_rel.$code_folder;
$paths[WEB_CODE_PATH] = $root_web.$code_folder;
$paths[WEB_COURSE_PATH] = $root_web.$course_folder;
$paths[SYS_COURSE_PATH] = $root_sys.$course_folder;
$paths[REL_COURSE_PATH] = $root_rel.$course_folder;
$paths[REL_CODE_PATH] = $root_rel.$code_folder;
$paths[WEB_CODE_PATH] = $root_web.$code_folder;
// Elimination of an obsolete configuration setting.
//$paths[SYS_CODE_PATH] = $GLOBALS['clarolineRepositorySys'];
$paths[SYS_CODE_PATH] = $root_sys.$code_folder;
$paths[SYS_CODE_PATH] = $root_sys.$code_folder;
//
// Now we can switch into api_get_path() "terminology".
$paths[SYS_LANG_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_LANG_PATH];
$paths[WEB_IMG_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_IMG_PATH];
$paths[SYS_LANG_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_LANG_PATH];
$paths[WEB_IMG_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_IMG_PATH];
// TODO: This path may depend on the configuration option? To be researched.
// Maybe a new constant like WEB_USER_CSS_PATH has to be defined?
$paths[WEB_CSS_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_CSS_PATH];
$paths[WEB_CSS_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_CSS_PATH];
//
$paths[GARBAGE_PATH] = $paths[SYS_PATH].$paths[GARBAGE_PATH]; // Deprecated?
$paths[SYS_PLUGIN_PATH] = $paths[SYS_PATH].$paths[SYS_PLUGIN_PATH];
$paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$paths[WEB_PLUGIN_PATH];
$paths[SYS_ARCHIVE_PATH] = $paths[SYS_PATH].$paths[SYS_ARCHIVE_PATH];
$paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$paths[WEB_ARCHIVE_PATH];
$paths[GARBAGE_PATH] = $paths[SYS_PATH].$paths[GARBAGE_PATH]; // Deprecated?
$paths[SYS_PLUGIN_PATH] = $paths[SYS_PATH].$paths[SYS_PLUGIN_PATH];
$paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$paths[WEB_PLUGIN_PATH];
$paths[SYS_ARCHIVE_PATH] = $paths[SYS_PATH].$paths[SYS_ARCHIVE_PATH];
$paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$paths[WEB_ARCHIVE_PATH];
// A change for Dokeos 1.8.6.2
// Calculation in the previous way does not rely on configuration settings and in some cases gives unexpected results.
//$paths[INCLUDE_PATH] = $include_path_sys; // Old behaviour, Dokeos 1.8.6.1.
$paths[INCLUDE_PATH] = $paths[SYS_CODE_PATH].$paths[INCLUDE_PATH]; // New behaviour, coherrent with the model, Dokeos 1.8.6.2.
$paths[INCLUDE_PATH] = $paths[SYS_CODE_PATH].$paths[INCLUDE_PATH]; // New behaviour, coherrent with the model, Dokeos 1.8.6.2.
//
$paths[LIBRARY_PATH] = $paths[SYS_CODE_PATH].$paths[LIBRARY_PATH];
$paths[CONFIGURATION_PATH] = $paths[SYS_CODE_PATH].$paths[CONFIGURATION_PATH];
$paths[WEB_LIBRARY_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_LIBRARY_PATH];
$paths[LIBRARY_PATH] = $paths[SYS_CODE_PATH].$paths[LIBRARY_PATH];
$paths[CONFIGURATION_PATH] = $paths[SYS_CODE_PATH].$paths[CONFIGURATION_PATH];
$paths[WEB_LIBRARY_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_LIBRARY_PATH];
$paths[WEB_AJAX_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_AJAX_PATH];
$is_this_function_initialized = true;
}

Loading…
Cancel
Save