";
if (is_array($lnk))
{
foreach ($lnk as $thisLnk)
{
if ($toolsRow['adminlink'])
{
$cell_content .= '
'.Display::return_icon('edit.gif', get_lang('Edit')).'';
//echo "edit link:".$properties['adminlink'];
}
else
{
$cell_content .= "
".$thisLnk['name']."";
}
}
}
// 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 .= "
".get_lang("Edit")."";
}
}
$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:
$condition_display_tools = ' WHERE visibility = 1 ';
if (api_is_coach()) {
$condition_display_tools = ' WHERE visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'") ';
}
$result = Database::query("SELECT * FROM $course_tool_table $condition_display_tools ORDER BY id");
$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");
$colLink ="##808080";
break;
case TOOL_COURSE_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE admin=1 AND visibility != 2 ORDER BY id");
$colLink ="##003399";
break;
case TOOL_PLATFORM_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = 2 ORDER BY id");
$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);
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 "
\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)?'?':'&');
$toolsRow['link'] = $toolsRow['link'];
echo '';
if(strpos($toolsRow['name'],'visio_')!==false)
{
echo '';
}
else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
{
/*
echo '';
*/
echo '';
}
else
{
echo '';
}
/*
echo Display::return_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name']))),' ', ($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'])),'';
*/
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),' ', $tool_name,'';
// 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' || $toolsRow['name'] == TOOL_TRACKING)
{
$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 ''.Display::return_icon('edit.gif', get_lang('Edit')).'';
//echo "edit link:".$properties['adminlink'];
}
}
if ( api_is_platform_admin() && !api_is_coach())
{
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 "" . $this_link['name'] . "";
}
}
}
// 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 "". get_lang("Edit"). "";
echo " | \n";
if($i%2)
{
echo "
\n";
}
$i++;
}
}
if($i%2)
{
echo "
| \n",
"\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:
$condition_display_tools = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction") ';
if (api_is_coach()) {
$condition_display_tools = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction")) OR (name = "'.TOOL_TRACKING.'") ';
}
$sql = "SELECT * FROM $course_tool_table $condition_display_tools $condition_session ORDER BY id";
$result = Database::query($sql);
$colLink ="##003399";
break;
case TOOL_AUTHORING:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'authoring' $condition_session ORDER BY id";
$result = Database::query($sql);
$colLink ="##003399";
break;
case TOOL_INTERACTION:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'interaction' $condition_session ORDER BY id";
$result = Database::query($sql);
$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);
$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);
$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'");
$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);
$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);
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 "
\n";
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
echo '' . "\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 ''.Display::return_icon('edit.gif', get_lang('Edit')).'';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($toolsRow['admin'] !='1') {
$link['cmd'] = "hide=yes";
}
}
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($toolsRow['adminlink'])) {
echo '" . $this_link['name'] . "";
}
}
} else { echo ' ';}
// 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) ? '?' : '&');
//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" . '';
*/
$toollink = "\t" . '';
$my_tool_link = "\t" . '';
} elseif (strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true) {
/*
$toollink = "\t" . '';
*/
$toollink = "\t" . '';
$my_tool_link="\t" . '';
} else {
if (count(explode('type=classroom',$toolsRow['link']))==2 || count(explode('type=conference',$toolsRow['link']))==2) {
//$toollink = "\t" . '';
$toollink = "\t" . '';
$my_tool_link = "\t" . '';
} else {
//$toollink = "\t" . '';
$toollink = "\t" . '';
$my_tool_link = "\t" . '';
}
}
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 ' ';
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" . '';
echo ' | ';
if ($i%2) {
echo "
";
}
$i++;
}
}
if ($i%2) {
echo "
| \n",
"\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);
$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);
$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 .= '
'. get_lang('SessionCategory') . ': ' . '' . $session_category .' |
';
}
$output .= '
'. get_lang('SessionName') . ': ' . '' . $session['name'] .' | '. get_lang('GeneralCoach') . ': ' . '' . $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' .' |
';
$output .= '
'. get_lang('SessionIdentifier') . ': '. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) .' | '. get_lang('Date') . ': ' . '' . $msg_date .' |
';
return $output;
}
}
?>