[svn r22084] logic changes-allow hide and show tools - (partial FS#4403)

skala
Isaac Flores 16 years ago
parent bec729b392
commit 4ba9cf4260
  1. 98
      main/course_home/activity.php
  2. 83
      main/course_home/course_home.php

@ -36,9 +36,7 @@
* @package dokeos.course_home
==============================================================================
*/
require_once '../../main/inc/global.inc.php';
/*
==============================================================================
FUNCTIONS
@ -226,7 +224,7 @@ function show_tools_category($course_tool_category)
if($toolsRow['visibility'] == '1' && $toolsRow['admin'] !='1')
{
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'));
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
@ -234,7 +232,7 @@ function show_tools_category($course_tool_category)
if($toolsRow['visibility'] == '0' && $toolsRow['admin'] !='1')
{
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'));
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
}
@ -263,7 +261,9 @@ function show_tools_category($course_tool_category)
{
if(empty($toolsRow['adminlink']))
{
echo "<a href=\"" .api_get_self(). "?".api_get_cidreq()."&amp;id=" . $toolsRow["id"] . "&amp;" . $this_link['cmd'] . "\">" . $this_link['name'] . "</a>";
//echo "<a 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>";
}
}
}
@ -311,8 +311,12 @@ function show_tools_category($course_tool_category)
{
if (count(explode('type=classroom',$toolsRow['link']))==2 || count(explode('type=conference',$toolsRow['link']))==2) {
$toollink = "\t" . '<a ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
$my_tool_link = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . $toolsRow['link'] . '" target="_blank">';
} else {
$toollink = "\t" . '<a ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
$my_tool_link = "\t" . '<a id="tooldesc_'.$toolsRow["id"].'" ' . $class . ' href="' . htmlspecialchars($toolsRow['link']) . '" target="' . $toolsRow['target'] . '">';
}
}
@ -332,10 +336,10 @@ function show_tools_category($course_tool_category)
{
$tool_name = get_lang(ucfirst($toolsRow['name']));
}
Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon'));
Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon','id'=>'toolimage_'.$toolsRow["id"]));
echo '</a> ';
echo $toollink;
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']));
*/
@ -371,29 +375,64 @@ function show_tools_category($course_tool_category)
Work with data post askable by admin of course (franglais, clean this)
-----------------------------------------------------------
*/
if(api_is_allowed_to_edit())
{
/*
-----------------------------------------------------------
HIDE
-----------------------------------------------------------
*/
if(!empty($_GET['hide'])) // visibility 1 -> 0
{
api_sql_query("UPDATE $tool_table SET visibility=0 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
if(api_is_allowed_to_edit()) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
/*
-----------------------------------------------------------
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='".$_GET["id"]."'";
api_sql_query($sql,__FILE__,__LINE__);
echo 'ToolIsNowHidden';
}
}
/*
-----------------------------------------------------------
REACTIVATE
-----------------------------------------------------------
*/
elseif(isset($_GET['visibility'])&& $_GET['visibility']==1) // visibility 0,2 -> 1
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
api_sql_query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
echo 'ToolIsNowVisible';
}
}
exit;
}
/*
-----------------------------------------------------------
REACTIVATE
-----------------------------------------------------------
*/
elseif(!empty($_GET['restore'])) // visibility 0,2 -> 1
{
api_sql_query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
} else {
if(api_is_allowed_to_edit()) {
/*
-----------------------------------------------------------
HIDE
-----------------------------------------------------------
*/
if(!empty($_GET['hide'])) // visibility 1 -> 0
{
api_sql_query("UPDATE $tool_table SET visibility=0 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
}
/*
-----------------------------------------------------------
REACTIVATE
-----------------------------------------------------------
*/
elseif(!empty($_GET['restore'])) // visibility 0,2 -> 1
{
api_sql_query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
}
}
}
// work with data post askable by admin of course
@ -436,6 +475,7 @@ if(api_is_platform_admin())
if(api_is_allowed_to_edit())
{
?>
<div id="id_content_message"></div>
<div class="courseadminview">
<span class="viewcaption"><?php echo get_lang("Authoring") ?></span>
<table width="100%">

@ -1,4 +1,4 @@
<?php // $Id: course_home.php 21932 2009-07-09 05:07:14Z ivantcholakov $
<?php // $Id: course_home.php 22084 2009-07-14 19:29:34Z iflorespaz $
/*
==============================================================================
@ -63,7 +63,88 @@ $language_file[] = "course_home";
$use_anonymous = true;
// inlcuding the global file
include('../../main/inc/global.inc.php');
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] ='<script type="text/javascript">
$(document).ready(function() {
$("td .make_visible_and_invisible > img").click(function () {
make_visible="visible.gif";
make_invisible="invisible.gif";
path_name=$(this).attr("src");
list_path_name=path_name.split("/");
image_link=list_path_name[list_path_name.length-1];
tool_id=$(this).attr("id");
tool_info=tool_id.split("_");
my_tool_id=tool_info[1];
current_tool_image=$("#toolimage_"+my_tool_id).attr("src");
list_current_tool_image=current_tool_image.split("/");
image_for_replace=list_current_tool_image[list_current_tool_image.length-1];
list_new_image=image_for_replace.split(".");
if (image_for_replace.split("_na").length==2){
list_image_na=image_for_replace.split("_na");
list_image_na=list_image_na[0]+".gif";
new_current_tool_image=current_tool_image.replace(image_for_replace,list_image_na);
$("#tooldesc_"+my_tool_id).attr("class","");
} else {
new_image_to_replace=list_new_image[0]+"_na.gif";
new_current_tool_image=current_tool_image.replace(image_for_replace,new_image_to_replace);
$("#tooldesc_"+my_tool_id).attr("class","invisible");
}
$("#toolimage_"+my_tool_id).attr("src",new_current_tool_image);
if (image_link=="visible.gif") {
mew_path_name=path_name.replace(make_visible,make_invisible);
my_visibility=0;
} else {
mew_path_name=path_name.replace(make_invisible,make_visible);
my_visibility=1;
}
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
$("#id_content_message").html("<div class=\"normal-message\"><img src=\'/main/inc/lib/javascript/indicator.gif\' /></div>");
},
type: "GET",
url: "/main/course_home/activity.php",
data: "id="+my_tool_id+"&visibility="+my_visibility+"&sent_http_request=1",
success: function(datos) {
$("#"+tool_id).attr("src",mew_path_name);
if (image_link=="visible.gif") {
$("#"+tool_id).attr("alt","'.get_lang('Activate').'");
$("#"+tool_id).attr("title","'.get_lang('Activate').'");
} else {
$("#"+tool_id).attr("alt","'.get_lang('Deactivate').'");
$("#"+tool_id).attr("title","'.get_lang('Deactivate').'");
}
//$("#id_content_message").html(datos);
if (datos=="ToolIsNowVisible") {
$("#id_content_message").html("<div class=\"confirmation-message\">'.get_lang('ToolIsNowVisible').'</div>");
} else {
$("#id_content_message").html("<div class=\"confirmation-message\">'.get_lang('ToolIsNowHidden').'</div>");
}
} });
});
});
</script>';
if(!isset($cidReq))
{
$cidReq = api_get_course_id(); // to provide compatibility. with previous system

Loading…
Cancel
Save