Improving queries, fixing PHP warnings, updating docs.

1.9.x
Julio Montoya 11 years ago
parent 27cc5484bc
commit bb2e6043bf
  1. 66
      main/coursecopy/classes/CourseBuilder.class.php

@ -26,6 +26,8 @@ require_once 'Thematic.class.php';
require_once 'Attendance.class.php'; require_once 'Attendance.class.php';
require_once 'Work.class.php'; require_once 'Work.class.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php';
/** /**
* Class which can build a course-object from a Chamilo-course. * Class which can build a course-object from a Chamilo-course.
* @author Bart Mollet <bart.mollet@hogent.be> * @author Bart Mollet <bart.mollet@hogent.be>
@ -178,14 +180,18 @@ class CourseBuilder
/** /**
* Build the documents * Build the documents
* @param int $session_id
* @param string $course_code
* @param bool $with_base_content
* @param array $id_list
*/ */
public function build_documents($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) public function build_documents($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
{ {
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
$table_doc = Database::get_course_table(TABLE_DOCUMENT); $table_doc = Database::get_course_table(TABLE_DOCUMENT);
$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
//Remove chat_files and shared_folder files //Remove chat_files and shared_folder files
$avoid_paths = " path NOT LIKE '/shared_folder%' AND $avoid_paths = " path NOT LIKE '/shared_folder%' AND
@ -200,14 +206,14 @@ class CourseBuilder
$session_condition = api_get_session_condition($session_id, true); $session_condition = api_get_session_condition($session_id, true);
} }
if (!empty($this->course->type) && $this->course->type=='partial') { if (!empty($this->course->type) && $this->course->type == 'partial') {
$sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM $table_doc d, $table_prop p FROM $table_doc d INNER JOIN $table_prop p
ON (p.ref = d.id AND d.c_id = p.c_id)
WHERE WHERE
d.c_id = $course_id AND d.c_id = $course_id AND
p.c_id = $course_id AND p.c_id = $course_id AND
tool = '".TOOL_DOCUMENT."' AND tool = '".TOOL_DOCUMENT."' AND
p.ref = d.id AND
p.visibility != 2 AND p.visibility != 2 AND
path NOT LIKE '/images/gallery%' AND path NOT LIKE '/images/gallery%' AND
$avoid_paths $avoid_paths
@ -215,50 +221,50 @@ class CourseBuilder
ORDER BY path"; ORDER BY path";
} else { } else {
$sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM $table_doc d, $table_prop p FROM $table_doc d INNER JOIN $table_prop p
ON (p.ref = d.id AND d.c_id = p.c_id)
WHERE WHERE
d.c_id = $course_id AND d.c_id = $course_id AND
p.c_id = $course_id AND p.c_id = $course_id AND
tool = '".TOOL_DOCUMENT."' AND tool = '".TOOL_DOCUMENT."' AND
$avoid_paths AND $avoid_paths AND
p.ref = d.id AND
p.visibility != 2 $session_condition p.visibility != 2 $session_condition
ORDER BY path"; ORDER BY path";
} }
$db_result = Database::query($sql); $db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) { while ($obj = Database::fetch_object($db_result)) {
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size); $doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
$this->course->add_resource($doc); $this->course->add_resource($doc);
} }
} else { } else {
if (!empty($this->course->type) && $this->course->type=='partial') {
if (!empty($this->course->type) && $this->course->type=='partial') $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d INNER JOIN $table_prop p
FROM '.$table_doc.' d, '.$table_prop.' p ON (p.ref = d.id AND d.c_id = p.c_id)
WHERE WHERE
d.c_id = '.$course_id.' AND d.c_id = $course_id AND
p.c_id = '.$course_id.' AND p.c_id = $course_id AND
tool = \''.TOOL_DOCUMENT.'\' AND tool = '".TOOL_DOCUMENT."' AND
p.ref = d.id AND
p.visibility != 2 AND p.visibility != 2 AND
path NOT LIKE \'/images/gallery%\' AND path NOT LIKE '/images/gallery%' AND
'.$avoid_paths.'AND $avoid_paths AND
d.session_id = 0 d.session_id = 0
ORDER BY path'; ORDER BY path";
else var_dump($sql);
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size } else {
FROM '.$table_doc.' d, '.$table_prop.' p $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM $table_doc d INNER JOIN $table_prop p
ON (p.ref = d.id AND d.c_id = p.c_id)
WHERE WHERE
d.c_id = '.$course_id.' AND d.c_id = $course_id AND
p.c_id = '.$course_id.' AND p.c_id = $course_id AND
tool = \''.TOOL_DOCUMENT.'\' AND tool = '".TOOL_DOCUMENT."' AND
p.ref = d.id AND
p.visibility != 2 AND p.visibility != 2 AND
'.$avoid_paths.' AND $avoid_paths AND
d.session_id = 0 d.session_id = 0
ORDER BY path'; ORDER BY path";
}
$db_result = Database::query($sql); $db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) { while ($obj = Database::fetch_object($db_result)) {

Loading…
Cancel
Save