Source for file CourseRecycler.class.php
Documentation is available at CourseRecycler.class.php
// $Id: CourseRecycler.class.php 12117 2007-04-24 22:06:36Z pcool $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Bart Mollet (bart.mollet@hogent.be)
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
==============================================================================
require_once ('Course.class.php');
require_once ('rmdirr.php');
* Class to delete items from a Dokeos-course
* @author Bart Mollet <bart.mollet@hogent.be>
* A course-object with the items to delete
* Create a new CourseRecycler
* @param course $course The course-object which contains the items to
* Delete all items from the course.
* This deletes all items in the course-object from the current Dokeos-
foreach ($this->course->resources as $type => $resources)
foreach ($resources as $id => $resource)
$sql = "DELETE FROM ". $table_linked_resources. " WHERE (source_type = '". $type. "' AND source_id = '". $id. "') OR (resource_type = '". $type. "' AND resource_id = '". $id. "') ";
$sql = "DELETE FROM ". $table_item_properties. " WHERE tool ='". $resource->get_tool(). "' AND ref=". $id;
//$this->recycle_forums();
//$this->recycle_forum_categories();
$sql = "DELETE FROM ". $table. " WHERE id IN(". $ids. ")";
$sql = "DELETE FROM ". $table. " WHERE id IN(". $ids. ")";
$sql = "DELETE FROM ". $table_post. " WHERE forum_id IN(". $forum_ids. ")";
$sql = "DELETE FROM ". $table_thread. " WHERE forum_id IN(". $forum_ids. ")";
$sql = "DELETE FROM ". $table_forum. " WHERE forum_id IN(". $forum_ids. ")";
* Delete forum-categories
* Deletes all forum-categories from current course without forums
$sql = "SELECT fc.cat_id FROM ". $table_forumcat. " fc LEFT JOIN ". $table_forum. " f ON fc.cat_id=f.forum_category WHERE f.forum_id IS NULL";
$sql = "DELETE FROM ". $table_forumcat. " WHERE cat_id = ". $obj->cat_id;
* Deletes all empty link-categories (=without links) from current course
$sql = "SELECT lc.id FROM ". $link_cat_table. " lc LEFT JOIN ". $link_table. " l ON lc.id=l.category_id WHERE l.id IS NULL";
$sql = "DELETE FROM ". $link_cat_table. " WHERE id = ". $obj->id;
$sql = "DELETE FROM ". $table. " WHERE id IN(". $ids. ")";
$sql = "DELETE FROM ". $table. " WHERE id IN(". $ids. ")";
* Recycle quizzes - doesn't remove the questions and their answers, as they might still be used later
//$table_qui_que = Database :: get_course_table(TABLE_QUIZ_QUESTION);
//$table_qui_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
$sql = "DELETE FROM ". $table_qui. " WHERE id IN(". $ids. ")";
$sql = "DELETE FROM ". $table_rel. " WHERE exercice_id IN(". $ids. ")";
* Recycle surveys - removes everything
$sql = "DELETE FROM ". $table_survey_i. " ";
$sql = "DELETE FROM ". $table_survey_a. " WHERE survey_id IN(". $ids. ")";
$sql = "DELETE FROM ". $table_survey_q_o. " WHERE survey_id IN(". $ids. ")";
$sql = "DELETE FROM ". $table_survey_q. " WHERE survey_id IN(". $ids. ")";
$sql = "DELETE FROM ". $table_survey. " WHERE survey_id IN(". $ids. ")";
//remove links from course homepage
$sql = "DELETE FROM $table_tool WHERE link LIKE '%lp_controller.php%lp_id=$id%' AND image='scormbuilder.gif'";
//remove elements from lp_* tables (from bottom-up) by removing interactions, then item_view, then views and items, then paths
$sql_items = "SELECT id FROM $table_item WHERE lp_id=$id";
$sql_iv = "SELECT id FROM $table_iv WHERE lp_item_id=". $row_item['id'];
$sql_iv_int_del = "DELETE FROM $table_iv_int WHERE lp_iv_id = ". $row_iv['id'];
$res_iv_int_del = api_sql_query($sql_iv_int_del,__FILE__ ,__LINE__ );
$sql_iv_del = "DELETE FROM $table_iv WHERE lp_item_id=". $row_item['id'];
$sql_items_del = "DELETE FROM $table_item WHERE lp_id=$id";
$res_items_del = api_sql_query($sql_items_del,__FILE__ ,__LINE__ );
$sql_views_del = "DELETE FROM $table_view WHERE lp_id=$id";
$res_views_del = api_sql_query($sql_views_del,__FILE__ ,__LINE__ );
$sql_del = "DELETE FROM $table_main WHERE id = $id";
* Delete course description
$sql = "DELETE FROM ". $table. " WHERE id IN(". $ids. ")";
|