Code Search for Developers
 
 
  

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

pointcarre

Pointcarre - a learning management system based on the Dokeos community releases. No fork, but containing locally developed extensions, features not (yet) in the standard release, integrated plugins...

Project homepage: http://sourceforge.net/projects/pointcarre
Programming language(s): PHP
License: other

  nightly_update/
    nightly_update.php
  class_add.php
  class_edit.php
  class_information.php
  class_list.php
  configure_homepage.php
  course_add.php
  course_category.php
  course_create_content.php
  course_edit.php
  course_information.php
  course_list.php
  course_virtual.php
  curriculum_complete_update.php
  exemple.csv
  exemple.xml
  index.php
  languages.php
  manage_course_tools.php
  manage_official_classes.php
  manage_official_communities.php
  manage_official_personnel.php
  manage_official_students.php
  manage_official_teachers.php
  manage_special_options.php
  official_update_titles_teachers.php
  settings.php
  statistics.php
  subscribe_class2course.php
  subscribe_user2class.php
  subscribe_user2course.php
  system_announcements.php
  user_add.php
  user_edit.php
  user_export.php
  user_import.php
  user_information.php
  user_list.php
  veco_manage_official_data.php