manage_course_tools.php from pointcarre at Krugle
Show manage_course_tools.php syntax highlighted
<?php // $Id: manage_course_tools.php 429 2006-09-22 14:17:35Z evie_em $
/*
==============================================================================
Dokeos - elearning and course management software
Pointcarre - variant of Dokeos
Copyright (c) Evie, Free University of Brussels
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.
http://pointcarre.sourceforge.net/
http://www.dokeos.com/
==============================================================================
*/
/**
==============================================================================
* Script to manage additional course tools
* - add wiki link to courses if not there already
*
* @package dokeos.admin
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
$langFile='admin';
$cidReset=true;
include('../inc/claro_init_global.inc.php');
api_protect_admin_script();
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
require_once('../curriculum/curriculum_database.lib.php');
require_once('../curriculum/curriculum_logic.lib.php');
/*
-----------------------------------------------------------
Constants
-----------------------------------------------------------
*/
define ("ADD_WIKI_TOOL", "add_wiki_tool");
define ("DELETE_WIKI_TOOL", "delete_wiki_tool");
define ("DELETE_BBIMPORT_TOOL", "delete_bbimport_tool");
define ("DELETE_CONFERENCE_TOOL", "delete_conference_tool");
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
$tool_name = get_lang('ManageCourseTools');
$interbredcrump[] = array ("url" => "index.php", "name" => get_lang('AdministrationTools'));
Display::display_header($tool_name);
api_display_tool_title($tool_name);
/*
==============================================================================
LOGIC FUNCTIONS
==============================================================================
*/
function add_wiki_tool($is_simulation)
{
$course_list = CourseManager::get_real_course_list();
foreach ($course_list as $this_course)
{
$tool_table = Database::get_course_table(TOOL_LIST_TABLE, $this_course['db_name']);
$sql_query = "SELECT * FROM $tool_table WHERE link LIKE '%wiki/index.php'";
$sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
if (mysql_num_rows($sql_result) > 0)
{
echo $this_course['code'] . ' -> already has wiki tool<br/>'; //do not add twice
}
else
{
//$url = api_get_path(WEB_CODE_PATH);
$url = "wiki/index.php";
$sql_query = "INSERT INTO $tool_table
( `id` , `name` , `link` , `image` , `visibility` , `admin` , `address` , `added_tool` )
VALUES
('', 'Wiki', '$url', 'wiki.gif', '0', '0', NULL , '')";
if ($is_simulation == true) api_display_debug_info($sql_query); //only show query
else api_sql_query($sql_query, __FILE__, __LINE__); //actually execute query
echo $this_course['code'] . ' -> wiki tool added<br/>';
}
}
}
function remove_wiki_tool()
{
$sql = "DELETE FROM $table_class_user WHERE user_id = '".$user_id."'";
$course_list = CourseManager::get_real_course_list();
foreach ($course_list as $this_course)
{
$tool_table = Database::get_course_table(TOOL_LIST_TABLE, $this_course['db_name']);
$sql_query = "DELETE FROM $tool_table WHERE link LIKE '%wiki/index.php'";
api_sql_query($sql_query, __FILE__, __LINE__);
}
}
function remove_conference_tool()
{
$sql = "DELETE FROM $table_class_user WHERE user_id = '".$user_id."'";
$course_list = CourseManager::get_real_course_list();
foreach ($course_list as $this_course)
{
$tool_table = Database::get_course_table(TOOL_LIST_TABLE, $this_course['db_name']);
$sql_query = "DELETE FROM $tool_table WHERE link LIKE '%online/online.php'";
api_sql_query($sql_query, __FILE__, __LINE__);
}
}
function remove_bbimport_tool()
{
$sql = "DELETE FROM $table_class_user WHERE user_id = '".$user_id."'";
$course_list = CourseManager::get_real_course_list();
foreach ($course_list as $this_course)
{
$tool_table = Database::get_course_table(TOOL_LIST_TABLE, $this_course['db_name']);
$sql_query = "DELETE FROM $tool_table WHERE link LIKE '%plugin/bbimport.php'";
api_sql_query($sql_query, __FILE__, __LINE__);
}
}
/*
==============================================================================
DISPLAY FUNCTIONS
==============================================================================
*/
function display_main_options()
{
echo "The current academic year is set to " . CurriculumLogic::get_current_academic_year() . ".<br/>";
echo 'What do you want to do?';
echo '<ul>';
echo "<li><a href=\"".$_SERVER['PHP_SELF']."?action=".ADD_WIKI_TOOL."\">Voeg wiki tool toe aan elke cursus</a></li>";
echo "<li><a href=\"".$_SERVER['PHP_SELF']."?action=".DELETE_WIKI_TOOL."\">Verwijder de wiki tool uit elke cursus</a></li>";
echo "<li><a href=\"".$_SERVER['PHP_SELF']."?action=".DELETE_BBIMPORT_TOOL."\">Verwijder de bb import tool uit elke cursus</a></li>";
echo "<li><a href=\"".$_SERVER['PHP_SELF']."?action=".DELETE_CONFERENCE_TOOL."\">Verwijder de conference tool uit elke cursus</a></li>";
echo '</ul>';
}
/*
==============================================================================
MAIN CODE
==============================================================================
*/
$action = $_REQUEST['action'];
display_main_options();
if ($action == ADD_WIKI_TOOL)
{
$is_simulation = false;
add_wiki_tool($is_simulation);
}
else if ($action == DELETE_WIKI_TOOL)
{
remove_wiki_tool();
}
else if ($action == DELETE_BBIMPORT_TOOL)
{
remove_bbimport_tool();
}
else if ($action == DELETE_CONFERENCE_TOOL)
{
remove_conference_tool();
}
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
?>
See more files for this project here