Feature #347 - Course settings and Course creation, Documents, Dropbox tool: Removing the parameters __FILE__ and __LINE__ in the Database::query() calls.

skala
Ivan Tcholakov 15 years ago
parent d7374d430e
commit bc60747b1b
  1. 6
      main/calendar/agenda.inc.php
  2. 30
      main/course_info/infocours.php
  3. 2
      main/course_info/postpone.php
  4. 60
      main/coursecopy/classes/CourseBuilder.class.php
  5. 98
      main/coursecopy/classes/CourseRecycler.class.php
  6. 172
      main/coursecopy/classes/CourseRestorer.class.php
  7. 50
      main/coursecopy/classes/CourseSelectForm.class.php
  8. 2
      main/coursecopy/copy_course.php
  9. 10
      main/coursecopy/copy_course_session.php
  10. 2
      main/create_course/add_course.php
  11. 2
      main/document/create_document.php
  12. 32
      main/document/document.inc.php
  13. 2
      main/document/document.php
  14. 8
      main/document/downloadfolder.inc.php
  15. 10
      main/document/edit_document.php
  16. 30
      main/document/slideshow.php
  17. 22
      main/document/upload.php
  18. 28
      main/dropbox/dropbox_class.inc.php
  19. 2
      main/dropbox/dropbox_download.php
  20. 48
      main/dropbox/dropbox_functions.inc.php
  21. 11
      main/dropbox/dropbox_submit.php

@ -4449,7 +4449,7 @@ function delete_attachment_file($id_attach) {
$id_attach=Database::escape_string($id_attach);
$sql="DELETE FROM $agenda_table_attachment WHERE id = ".(int)$id_attach;
$result=Database::query($sql, __LINE__, __FILE__);
$result=Database::query($sql);
$last_id_file=Database::insert_id();
// update item_property
api_item_property_update($_course, 'calendar_event_attachment', $id_attach ,'AgendaAttachmentDeleted', api_get_user_id());
@ -4497,7 +4497,7 @@ function add_agenda_attachment_file($file_comment,$last_id) {
if ($result) {
$sql='INSERT INTO '.$agenda_table_attachment.'(filename,comment, path,agenda_id,size) '.
"VALUES ( '".$safe_file_name."', '".$safe_file_comment."', '".$safe_new_file_name."' , '".$last_id."', '".$_FILES['user_upload']['size']."' )";
$result=Database::query($sql, __LINE__, __FILE__);
$result=Database::query($sql);
$message.=' / '.get_lang('FileUploadSucces').'<br />';
$last_id_file=Database::insert_id();
@ -4548,7 +4548,7 @@ function edit_agenda_attachment_file($file_comment,$agenda_id,$id_attach) {
if ($result) {
$sql="UPDATE $agenda_table_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', agenda_id = '$safe_agenda_id', size ='".$_FILES['user_upload']['size']."'
WHERE id = '$safe_id_attach'";
$result=Database::query($sql, __LINE__, __FILE__);
$result=Database::query($sql);
api_item_property_update($_course, 'calendar_event_attachment', $safe_id_attach ,'AgendaAttachmentUpdated', api_get_user_id());

@ -107,19 +107,19 @@ $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
// Get all course categories
$sql = "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE' OR code = '".Database::escape_string($_course['categoryCode'])."' ORDER BY tree_pos";
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
$s_select_course_tutor_name="SELECT tutor_name FROM $tbl_course WHERE code='$course_code'";
$q_tutor=Database::query($s_select_course_tutor_name, __FILE__, __LINE__);
$q_tutor=Database::query($s_select_course_tutor_name);
$s_tutor=Database::result($q_tutor,0,"tutor_name");
$s_sql_course_titular="SELECT DISTINCT username, lastname, firstname FROM $tbl_user as user, $tbl_course_user as course_rel_user WHERE (course_rel_user.status='1') AND user.user_id=course_rel_user.user_id AND course_code='".$course_code."'";
$q_result_titulars=Database::query($s_sql_course_titular, __FILE__, __LINE__);
$q_result_titulars=Database::query($s_sql_course_titular);
$target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
if(Database::num_rows($q_result_titulars)==0){
$sql="SELECT username, lastname, firstname FROM $tbl_user as user, $tbl_admin as admin WHERE admin.user_id=user.user_id ORDER BY ".$target_name." ASC";
$q_result_titulars=Database::query($sql, __FILE__, __LINE__);
$q_result_titulars=Database::query($sql);
}
$a_profs[0] = '-- '.get_lang('NoManager').' --';
@ -336,49 +336,49 @@ if ($form->validate() && is_settings_editable()) {
tutor_name = '".$update_values['tutor_name']."',
registration_code = '".$update_values['course_registration_password']."'
WHERE code = '".$course_code."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
//update course_settings table - this assumes those records exist, otherwise triggers an error
$table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING);
if($update_values['email_alert_to_teacher_on_new_user_in_course'] != $values['email_alert_to_teacher_on_new_user_in_course']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_to_teacher_on_new_user_in_course']." WHERE variable = 'email_alert_to_teacher_on_new_user_in_course' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['email_alert_manager_on_new_doc'] != $values['email_alert_manager_on_new_doc']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_doc']." WHERE variable = 'email_alert_manager_on_new_doc' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['email_alert_on_new_doc_dropbox'] != $values['email_alert_on_new_doc_dropbox']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_on_new_doc_dropbox']." WHERE variable = 'email_alert_on_new_doc_dropbox' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['email_alert_manager_on_new_quiz'] != $values['email_alert_manager_on_new_quiz']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_quiz']." WHERE variable = 'email_alert_manager_on_new_quiz' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['allow_user_edit_agenda'] != $values['allow_user_edit_agenda']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_agenda']." WHERE variable = 'allow_user_edit_agenda' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['allow_user_edit_announcement'] != $values['allow_user_edit_announcement']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_announcement']." WHERE variable = 'allow_user_edit_announcement' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['allow_user_image_forum'] != $values['allow_user_image_forum']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_image_forum']." WHERE variable = 'allow_user_image_forum' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['allow_open_chat_window'] != $values['allow_open_chat_window']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_open_chat_window']." WHERE variable = 'allow_open_chat_window' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['course_theme'] != $values['course_theme']){
$sql = "UPDATE $table_course_setting SET value = '".$update_values['course_theme']."' WHERE variable = 'course_theme' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
if($update_values['allow_learningpath_theme'] != $values['allow_learning_path_theme']){
$sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_learning_path_theme']." WHERE variable = 'allow_learning_path_theme' ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}

@ -76,7 +76,7 @@ $currentCourseRepository = $_course["path"];
$sqlCourseExtention = "SELECT last_visit, last_edit, creation_date, expiration_date FROM ".$TABLECOURSE." WHERE code = '".$_cid."'";
$resultCourseExtention = Database::query($sqlCourseExtention,__FILE__,__LINE__);
$resultCourseExtention = Database::query($sqlCourseExtention);
$currentCourseExtentionData = Database::fetch_array($resultCourseExtention);
$currentCourseLastVisit = $currentCourseExtentionData["last_visit"];
$currentCourseLastEdit = $currentCourseExtentionData["last_edit"];

@ -97,7 +97,7 @@ class CourseBuilder
foreach ($this->course->resources as $type => $resources) {
foreach ($resources as $id => $resource) {
$sql = "SELECT * FROM ".$table_link." WHERE source_type = '".$resource->get_type()."' AND source_id = '".$resource->get_id()."'";
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
while ($link = Database::fetch_object($res)) {
$this->course->resources[$type][$id]->add_linked_resource($link->resource_type, $link->resource_id);
}
@ -112,7 +112,7 @@ class CourseBuilder
if ($tool != null)
{
$sql = "SELECT * FROM $table_properties WHERE TOOL = '".$tool."' AND ref='".$resource->get_id()."'";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
$all_properties = array ();
while ($item_property = Database::fetch_array($res))
{
@ -143,7 +143,7 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND session_id = '.$session_id.' ORDER BY path';
}
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
@ -159,7 +159,7 @@ class CourseBuilder
else
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND d.session_id = 0 ORDER BY path';
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
@ -176,7 +176,7 @@ class CourseBuilder
{
$table = Database :: get_course_table(TABLE_FORUM);
$sql = 'SELECT * FROM '.$table;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$forum = new Forum($obj->forum_id, $obj->forum_title, $obj->forum_comment, $obj->forum_category, $obj->forum_last_post, $obj->forum_threads, $obj->forum_posts, $obj->allow_anonymous, $obj->allow_edit, $obj->approval_direct_post, $obj->allow_attachements, $obj->allow_new_threads, $obj->default_view, $obj->forum_of_group, $obj->forum_group_public_private, $obj->forum_order, $obj->locked, $obj->session_id, $obj->forum_image);
@ -193,7 +193,7 @@ class CourseBuilder
{
$table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
$sql = 'SELECT * FROM '.$table.' WHERE cat_id = '.$id;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$forum_category = new ForumCategory($obj->cat_id, $obj->cat_title, $obj->cat_comment, $obj->cat_order, $obj->locked, $obj->session_id);
@ -207,7 +207,7 @@ class CourseBuilder
{
$table = Database :: get_course_table(TABLE_FORUM_THREAD);
$sql = 'SELECT * FROM '.$table;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$forum_topic = new ForumTopic($obj->thread_id, $obj->thread_title, $obj->thread_date, $obj->thread_poster_id, $obj->thread_poster_name, $obj->forum_id, $obj->thread_last_post, $obj->thread_replies, $obj->thread_views, $obj->thread_sticky, $obj->locked, $obj->thread_close_date, $obj->thread_weight, $obj->thread_title_qualify, $obj->thread_qualify_max);
@ -222,7 +222,7 @@ class CourseBuilder
{
$table_post = Database :: get_course_table(TABLE_FORUM_POST);
$sql = 'SELECT * FROM '.$table_post;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$forum_post = new ForumPost($obj->post_id, $obj->post_title, $obj->post_text, $obj->post_date, $obj->poster_id, $obj->poster_name, $obj->post_notification, $obj->post_parent_id, $obj->thread_id, $obj->forum_id, $obj->visible);
@ -247,7 +247,7 @@ class CourseBuilder
$sql = "SELECT * FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 AND l.session_id = 0 ORDER BY l.display_order";
}
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$link = new Link($obj->id, $obj->title, $obj->url, $obj->description, $obj->category_id, $obj->on_homepage);
@ -272,7 +272,7 @@ class CourseBuilder
{
$table = Database :: get_course_table(TABLE_TOOL_INTRO);
$sql = 'SELECT * FROM '.$table;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$tool_intro = new ToolIntro($obj->id, $obj->intro_text);
@ -292,7 +292,7 @@ class CourseBuilder
}
$sql = 'SELECT * FROM '.$link_cat_table.' WHERE id = '.$id;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$link_category = new LinkCategory($obj->id, $obj->category_title, $obj->description, $obj->display_order);
@ -320,7 +320,7 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table_qui.' WHERE active >=0 AND session_id = 0'; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
}
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
if (strlen($obj->sound) > 0)
@ -330,7 +330,7 @@ class CourseBuilder
}
$quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound, $obj->max_attempt, $obj->results_disabled, $obj->access_condition, $obj->start_time, $obj->end_time, $obj->feedback_type, $obj->random_answers, $obj->expired_time);
$sql = 'SELECT * FROM '.$table_rel.' WHERE exercice_id = '.$obj->id;
$db_result2 = Database::query($sql, __FILE__, __LINE__);
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
$quiz->add_question($obj2->question_id, $obj2->question_order);
@ -367,12 +367,12 @@ class CourseBuilder
// Building normal tests.
$sql = 'SELECT * FROM '.$table_que;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id;
$db_result2 = Database::query($sql, __FILE__, __LINE__);
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
@ -385,7 +385,7 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table_que.
' as questions LEFT JOIN '.$table_rel.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.
' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1'; // active = -1 means "deleted" test.
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
if (Database::num_rows($db_result) > 0)
{
$build_orphan_questions = true;
@ -393,7 +393,7 @@ class CourseBuilder
{
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.(int)$obj->id;
$db_result2 = Database::query($sql, __FILE__, __LINE__);
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
@ -419,7 +419,7 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table_que.
' as questions LEFT JOIN '.$table_rel.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.
' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1';
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
if (Database::num_rows($db_result) > 0)
{
$orphan_questions = new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0); // Tjis is the fictional test for collecting orphan questions.
@ -428,7 +428,7 @@ class CourseBuilder
{
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id;
$db_result2 = Database::query($sql, __FILE__, __LINE__);
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
@ -445,7 +445,7 @@ class CourseBuilder
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$sql = 'SELECT * FROM '.$table_survey.' WHERE session_id = 0 ';
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$survey = new Survey($obj->survey_id, $obj->code,$obj->title,
@ -455,7 +455,7 @@ class CourseBuilder
$obj->creation_date, $obj->invited, $obj->answered,
$obj->invite_mail, $obj->reminder_mail);
$sql = 'SELECT * FROM '.$table_question.' WHERE survey_id = '.$obj->survey_id;
$db_result2 = Database::query($sql, __FILE__, __LINE__);
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
$survey->add_question($obj2->question_id);
@ -472,7 +472,7 @@ class CourseBuilder
$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_opt = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$sql = 'SELECT * FROM '.$table_que;
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$question = new SurveyQuestion($obj->question_id, $obj->survey_id,
@ -480,7 +480,7 @@ class CourseBuilder
$obj->type, $obj->display, $obj->sort,
$obj->shared_question_id, $obj->max_value);
$sql = 'SELECT * FROM '.$table_opt.' WHERE question_id = '."'".$obj->question_id."'";
$db_result2 = Database::query($sql, __FILE__, __LINE__);
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
$question->add_answer($obj2->option_text, $obj2->sort);
@ -495,7 +495,7 @@ class CourseBuilder
{
$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
$sql = 'SELECT * FROM '.$table.' WHERE session_id = 0';
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$announcement = new Announcement($obj->id, $obj->title, $obj->content, $obj->end_date,$obj->display_order,$obj->email_sent);
@ -509,7 +509,7 @@ class CourseBuilder
{
$table = Database :: get_course_table(TABLE_AGENDA);
$sql = 'SELECT * FROM '.$table.' WHERE session_id = 0';
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$event = new Event($obj->id, $obj->title, $obj->content, $obj->start_date, $obj->end_date);
@ -531,7 +531,7 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table. ' WHERE session_id = 0';
}
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$cd = new CourseDescription($obj->id, $obj->title, $obj->content, $obj->description_type);
@ -559,7 +559,7 @@ class CourseBuilder
$sql = 'SELECT * FROM '.$table_main.' WHERE session_id = 0';
}
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
@ -661,7 +661,7 @@ class CourseBuilder
}
}
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$doc = new Glossary($obj->glossary_id, $obj->name, $obj->description, $obj->display_order);
@ -688,7 +688,7 @@ class CourseBuilder
$sql_session = "SELECT id, name, course_code FROM $tbl_session_course
INNER JOIN $tbl_session ON id_session = id
WHERE course_code = '$code_course' ";
$query_session = Database::query($sql_session, __FILE__, __LINE__);
$query_session = Database::query($sql_session);
while ($rows_session = Database::fetch_assoc($query_session)) {
$session = new CourseSession($rows_session['id'], $rows_session['name']);
$this->course->add_resource($session);
@ -709,7 +709,7 @@ class CourseBuilder
$tbl_wiki = Database::get_course_table(TABLE_WIKI);
$sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE session_id = 0';
}
$db_result = api_sql_query($sql, __FILE__, __LINE__);
$db_result = api_sql_query($sql);
while ($obj = Database::fetch_object($db_result))
{
$wiki = new Wiki($obj->id, $obj->page_id, $obj->reflink, $obj->title, $obj->content, $obj->user_id, $obj->group_id, $obj->dtime, $obj->progress, $obj->version);

@ -61,16 +61,16 @@ class CourseRecycler
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."') ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
if(is_numeric($id))
{
$sql = "DELETE FROM ".$table_item_properties." WHERE tool ='".$resource->get_tool()."' AND ref=".$id;
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
elseif ($type == RESOURCE_TOOL_INTRO)
{
$sql = "DELETE FROM $table_tool_intro WHERE id='$id'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
}
@ -102,10 +102,10 @@ class CourseRecycler
}
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_DOCUMENT])));
$sql = "DELETE FROM ".$table." WHERE id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
* Delete wiki
*/
@ -118,18 +118,18 @@ class CourseRecycler
$pages = array();
foreach ($this->course->resources[RESOURCE_WIKI] as $resource) {
$pages[] = $resource->page_id;
$pages[] = $resource->page_id;
}
$wiki_ids = implode(',', (array_keys($this->course->resources[RESOURCE_WIKI])));
$page_ids = implode(',', $pages);
$sql = "DELETE FROM ".$table_wiki." WHERE id IN(".$wiki_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_wiki_conf." WHERE page_id IN(".$page_ids.")";
Database::query($sql,__FILE__,__LINE__);
}
Database::query($sql);
}
}
/**
* Delete glossary
*/
@ -138,10 +138,10 @@ class CourseRecycler
$table_glossary = Database::get_course_table(TABLE_GLOSSARY);
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_GLOSSARY])));
$sql = "DELETE FROM ".$table_glossary." WHERE glossary_id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
* Delete links
*/
@ -152,7 +152,7 @@ class CourseRecycler
$table = Database :: get_course_table(TABLE_LINK);
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_LINK])));
$sql = "DELETE FROM ".$table." WHERE id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -178,44 +178,44 @@ class CourseRecycler
" USING ".$table_attachment." INNER JOIN ".$table_post.
" WHERE ".$table_attachment.".post_id = ".$table_post.".post_id".
" AND ".$table_post.".forum_id IN(".$forum_ids.");";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_mail_queue.
" USING ".$table_mail_queue." INNER JOIN ".$table_post.
" WHERE ".$table_mail_queue.".post_id = ".$table_post.".post_id".
" AND ".$table_post.".forum_id IN(".$forum_ids.");";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
// Just in case, deleting in the same table using thread_id as record-linker.
$sql = "DELETE FROM ".$table_mail_queue.
" USING ".$table_mail_queue." INNER JOIN ".$table_thread.
" WHERE ".$table_mail_queue.".thread_id = ".$table_thread.".thread_id".
" AND ".$table_thread.".forum_id IN(".$forum_ids.");";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_thread_qualify.
" USING ".$table_thread_qualify." INNER JOIN ".$table_thread.
" WHERE ".$table_thread_qualify.".thread_id = ".$table_thread.".thread_id".
" AND ".$table_thread.".forum_id IN(".$forum_ids.");";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_thread_qualify_log.
" USING ".$table_thread_qualify_log." INNER JOIN ".$table_thread.
" WHERE ".$table_thread_qualify_log.".thread_id = ".$table_thread.".thread_id".
" AND ".$table_thread.".forum_id IN(".$forum_ids.");";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_notification." WHERE forum_id IN(".$forum_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_post." WHERE forum_id IN(".$forum_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_thread." WHERE forum_id IN(".$forum_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_forum." WHERE forum_id IN(".$forum_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -227,11 +227,11 @@ class CourseRecycler
$table_forum = Database :: get_course_table(TABLE_FORUM);
$table_forumcat = Database :: get_course_table(TABLE_FORUM_CATEGORY);
$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";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
while ($obj = Database::fetch_object($res))
{
$sql = "DELETE FROM ".$table_forumcat." WHERE cat_id = ".$obj->cat_id;
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -243,11 +243,11 @@ class CourseRecycler
$link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY);
$link_table = Database :: get_course_table(TABLE_LINK);
$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";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
while ($obj = Database::fetch_object($res))
{
$sql = "DELETE FROM ".$link_cat_table." WHERE id = ".$obj->id;
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -260,7 +260,7 @@ class CourseRecycler
$table = Database :: get_course_table(TABLE_AGENDA);
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_EVENT])));
$sql = "DELETE FROM ".$table." WHERE id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -273,7 +273,7 @@ class CourseRecycler
$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_ANNOUNCEMENT])));
$sql = "DELETE FROM ".$table." WHERE id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -294,9 +294,9 @@ class CourseRecycler
// Deletion of the normal tests, questions in them are not deleted, they become orphan at this moment.
$sql = "DELETE FROM ".$table_qui." WHERE id <> -1 AND id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_rel." WHERE exercice_id <> -1 AND exercice_id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
// Identifying again and deletion of the orphan questions, if it was desired.
if ($delete_orphan_questions)
@ -304,7 +304,7 @@ class CourseRecycler
$sql = 'SELECT questions.id FROM '.$table_qui_que.
' as questions LEFT JOIN '.$table_rel.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.
' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1'; // active = -1 means "deleted" test.
$db_result = Database::query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql);
if (Database::num_rows($db_result) > 0)
{
$orphan_ids = array();
@ -314,18 +314,18 @@ class CourseRecycler
}
$orphan_ids = implode(',', $orphan_ids);
$sql = "DELETE FROM ".$table_rel." WHERE question_id IN(".$orphan_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_qui_ans." WHERE question_id IN(".$orphan_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_qui_que." WHERE id IN(".$orphan_ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
}
// Purge "deleted" tests (active = -1).
$sql = "DELETE FROM ".$table_qui." WHERE active = -1";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
/**
* Recycle surveys - removes everything
@ -341,15 +341,15 @@ class CourseRecycler
$table_survey_i = Database :: get_course_table(TABLE_SURVEY_INVITATION);
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_SURVEY])));
$sql = "DELETE FROM ".$table_survey_i." ";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_survey_a." WHERE survey_id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_survey_q_o." WHERE survey_id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_survey_q." WHERE survey_id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$sql = "DELETE FROM ".$table_survey." WHERE survey_id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
/**
@ -369,34 +369,34 @@ class CourseRecycler
{
//remove links from course homepage
$sql = "DELETE FROM $table_tool WHERE link LIKE '%lp_controller.php%lp_id=$id%' AND image='scormbuilder.gif'";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
//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";
$res_items = Database::query($sql_items,__FILE__,__LINE__);
$res_items = Database::query($sql_items);
while ($row_item = Database::fetch_array($res_items))
{
//get item views
$sql_iv = "SELECT id FROM $table_iv WHERE lp_item_id=".$row_item['id'];
$res_iv = Database::query($sql_iv,__FILE__,__LINE__);
$res_iv = Database::query($sql_iv);
while ($row_iv = Database::fetch_array($res_iv))
{
//delete interactions
$sql_iv_int_del = "DELETE FROM $table_iv_int WHERE lp_iv_id = ".$row_iv['id'];
$res_iv_int_del = Database::query($sql_iv_int_del,__FILE__,__LINE__);
$res_iv_int_del = Database::query($sql_iv_int_del);
}
//delete item views
$sql_iv_del = "DELETE FROM $table_iv WHERE lp_item_id=".$row_item['id'];
$res_iv_del = Database::query($sql_iv_del,__FILE__,__LINE__);
$res_iv_del = Database::query($sql_iv_del);
}
//delete items
$sql_items_del = "DELETE FROM $table_item WHERE lp_id=$id";
$res_items_del = Database::query($sql_items_del,__FILE__,__LINE__);
$res_items_del = Database::query($sql_items_del);
//delete views
$sql_views_del = "DELETE FROM $table_view WHERE lp_id=$id";
$res_views_del = Database::query($sql_views_del,__FILE__,__LINE__);
$res_views_del = Database::query($sql_views_del);
//delete lps
$sql_del = "DELETE FROM $table_main WHERE id = $id";
$res_del = Database::query($sql_del,__FILE__,__LINE__);
$res_del = Database::query($sql_del);
}
}
}
@ -410,7 +410,7 @@ class CourseRecycler
$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
$ids = implode(',', (array_keys($this->course->resources[RESOURCE_COURSEDESCRIPTION])));
$sql = "DELETE FROM ".$table." WHERE id IN(".$ids.")";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
}

@ -158,7 +158,7 @@ class CourseRestorer
// First check if there isn't allready a record for this resource
$sql = "SELECT * FROM $table WHERE tool = '".$property['tool']."' AND ref = '".$resource->destination_id."'";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
if( Database::num_rows($res) == 0) {
// The to_group_id and to_user_id are set to default values as users/groups possibly not exist in the target course
$sql = "INSERT INTO $table SET
@ -175,7 +175,7 @@ class CourseRestorer
to_user_id = '".Database::escape_string($property['to_user_id'])."',
to_group_id = '0' $condition_session" ;
;
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
}
@ -195,7 +195,7 @@ class CourseRestorer
{
$to_resource = $this->course->resources[$to_type][$to_id];
$sql = "INSERT INTO ".$table." SET source_type = '".$type."', source_id = '".$resource->destination_id."', resource_type='".$to_type."', resource_id='".$to_resource->destination_id."' ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
}
@ -225,7 +225,7 @@ class CourseRestorer
$new = substr($document->path, 8);
if (!is_dir($path.'document/'.$new)) {
$sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string($new)."'";
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
$num_result = Database::num_rows($res);
if ($num_result==0) {
$created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new),$visibility);
@ -241,7 +241,7 @@ class CourseRestorer
$my_temp .= $dirs[$i];
if (!is_dir($path.'document/'.$my_temp)) {
$sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string($my_temp)."'";
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
$num_result = Database::num_rows($res);
if ($num_result==0) {
$created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document','/'.$my_temp,basename($my_temp));
@ -271,15 +271,15 @@ class CourseRestorer
copy($origin_path, $path.$document->path);
}
$sql = "SELECT id FROM ".$table." WHERE path='/".substr($document->path, 9)."'";
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
$obj = Database::fetch_object($res);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
$sql = "UPDATE ".$table." SET comment = '".Database::escape_string($document->comment)."', title='".Database::escape_string($document->title)."', size='".$document->size."' WHERE id = '".$obj->id."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
break;
case FILE_SKIP :
$sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string(substr($document->path, 9))."'";
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
$obj = Database::fetch_object($res);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
break;
@ -353,20 +353,20 @@ class CourseRestorer
copy($course_path.$document->path, $dest_document_path);
$sql = "INSERT INTO $table SET path = '$path_title', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string(basename($path_title))."' ,filetype='".$document->file_type."', size= '".$document->size."', session_id = '$session_id'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::insert_id();
} else {
copy($path.$document->path, $path.$new_file_name);
$sql = "INSERT INTO ".$table." SET path = '/".Database::escape_string(substr($new_file_name, 9))."', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string($document->title)."' ,filetype='".$document->file_type."', size= '".$document->size."', session_id = '$session_id'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::insert_id();
}
} else {
copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
$sql = "INSERT INTO ".$table." SET path = '/".Database::escape_string(substr($new_file_name, 9))."', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string($document->title)."' ,filetype='".$document->file_type."', size= '".$document->size."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::insert_id();
}
break;
@ -381,7 +381,7 @@ class CourseRestorer
{
copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
$sql = "INSERT INTO ".$table." SET path = '/".substr($document->path, 9)."', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string($document->title)."' ,filetype='".$document->file_type."', size= '".$document->size."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::insert_id();
}
else
@ -404,7 +404,7 @@ class CourseRestorer
else
{
/*$sql = "SELECT id FROM ".$table." WHERE path = '/".Database::escape_string(substr($document->path, 9))."'";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
if( Database::num_rows($res)> 0)
{
$obj = Database::fetch_object($res);
@ -413,7 +413,7 @@ class CourseRestorer
else
{
$sql = "INSERT INTO ".$table." SET path = '/".Database::escape_string(substr($document->path, 9))."', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string($document->title)."' ,filetype='".$document->file_type."', size= '".$document->size."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::insert_id();
}*/
} // end folder
@ -532,7 +532,7 @@ class CourseRestorer
", locked = ".(int)Database::escape_string($forum->locked).
", session_id = ".(int)Database::escape_string($forum->session_id).
", forum_image = '".Database::escape_string($forum->image)."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
$forum_topics = 0;
@ -551,7 +551,7 @@ class CourseRestorer
{
$last_post = $this->course->resources[RESOURCE_FORUMPOST][$forum->last_post];
$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics.", forum_last_post = ".(int)$last_post->destination_id." WHERE forum_id = ".(int)$new_id;
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
}
@ -580,7 +580,7 @@ class CourseRestorer
"', cat_order = ".(int)Database::escape_string($forum_cat->order).
", locked = ".(int)Database::escape_string($forum_cat->locked).
", session_id = ".(int)Database::escape_string($forum_cat->session_id);
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_FORUMCATEGORY][$id]->destination_id = $new_id;
return $new_id;
@ -608,7 +608,7 @@ class CourseRestorer
"', thread_weight = ".(float)Database::escape_string($topic->weight).
", thread_title_qualify = '".Database::escape_string($topic->title_qualify).
"', thread_qualify_max = ".(float)Database::escape_string($topic->qualify_max);
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_FORUMTOPIC][$id]->destination_id = $new_id;
$topic_replies = -1;
@ -624,12 +624,12 @@ class CourseRestorer
if (is_object($last_post))
{
$sql = "UPDATE ".$table." SET thread_last_post = ".(int)$last_post->destination_id;
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
if ($topic_replies >= 0)
{
$sql = "UPDATE ".$table." SET thread_replies = ".$topic_replies;
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
return $new_id;
}
@ -653,7 +653,7 @@ class CourseRestorer
"', post_notification = ".(int)Database::escape_string($post->topic_notify).
", post_parent_id = ".(int)Database::escape_string($post->parent_post_id).
", visible = ".(int)Database::escape_string($post->visible);
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
return $new_id;
@ -671,7 +671,7 @@ class CourseRestorer
{
$cat_id = $this->restore_link_category($link->category_id,$session_id);
$sql = "SELECT MAX(display_order) FROM $link_table WHERE category_id='" . Database::escape_string($cat_id). "'";
$result = Database::query($sql, __FILE__, __LINE__);
$result = Database::query($sql);
list($max_order) = Database::fetch_array($result);
$condition_session = "";
@ -681,7 +681,7 @@ class CourseRestorer
$sql = "INSERT INTO ".$link_table." SET url = '".Database::escape_string($link->url)."', title = '".Database::escape_string($link->title)."', description = '".Database::escape_string($link->description)."', category_id='".$cat_id."', on_homepage = '".$link->on_homepage."', display_order='".($max_order+1)."' $condition_session";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_LINK][$id]->destination_id = Database::insert_id();
}
}
@ -698,10 +698,10 @@ class CourseRestorer
foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro)
{
$sql = "DELETE FROM ".$tool_intro_table." WHERE id='".Database::escape_string($tool_intro->id)."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$sql = "INSERT INTO ".$tool_intro_table." SET id='".Database::escape_string($tool_intro->id)."', intro_text = '".Database::escape_string($tool_intro->intro_text)."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = Database::insert_id();
}
@ -726,11 +726,11 @@ class CourseRestorer
if (is_object($link_cat) && !$link_cat->is_restored())
{
$sql = "SELECT MAX(display_order) FROM $link_cat_table";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
list($orderMax)=Database::fetch_array($result,'NUM');
$display_order=$orderMax+1;
$sql = "INSERT INTO ".$link_cat_table." SET category_title = '".Database::escape_string($link_cat->title)."', description='".Database::escape_string($link_cat->description)."', display_order='".$display_order."' $condition_session ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id = $new_id;
return $new_id;
@ -748,11 +748,11 @@ class CourseRestorer
$resources = $this->course->resources;
foreach ($resources[RESOURCE_EVENT] as $id => $event)
{
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course($event->content, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table." SET title = '".Database::escape_string($event->title)."', content = '".Database::escape_string($event->content)."', start_date = '".$event->start_date."', end_date = '".$event->end_date."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_EVENT][$id]->destination_id = Database::insert_id();
}
}
@ -776,7 +776,7 @@ class CourseRestorer
$course_destination=$this->course->destination_path;
}
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course($cd->content, $this->course->code, $this->course->destination_path);
$condition_session = "";
@ -785,7 +785,7 @@ class CourseRestorer
$condition_session = " , session_id = '$session_id' ";
}
$sql = "INSERT INTO ".$table." SET description_type = '".Database::escape_string($cd->description_type)."',title = '".Database::escape_string($cd->title)."', content = '".Database::escape_string($description_content)."' $condition_session";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = Database::insert_id();
}
}
@ -801,17 +801,17 @@ class CourseRestorer
$resources = $this->course->resources;
foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement)
{
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course($announcement->content, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table." " .
"SET title = '".Database::escape_string($announcement->title)."'," .
"content = '".Database::escape_string($announcement->content)."', " .
"end_date = '".$announcement->date."', " .
"display_order = '".$announcement->display_order."', " .
"email_sent = '".$announcement->email_sent."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = Database::insert_id();
}
}
@ -835,7 +835,7 @@ class CourseRestorer
if ($this->course->resources[RESOURCE_DOCUMENT][$quiz->media]->is_restored())
{
$sql = "SELECT path FROM ".$table_doc." WHERE id = ".$resources[RESOURCE_DOCUMENT][$quiz->media]->destination_id;
$doc = Database::query($sql, __FILE__, __LINE__);
$doc = Database::query($sql);
$doc = Database::fetch_object($doc);
$doc = str_replace('/audio/', '', $doc->path);
}
@ -849,7 +849,7 @@ class CourseRestorer
$condition_session = " , session_id = '$session_id' ";
}
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($quiz->description, $this->course->code, $this->course->destination_path);
// Normal tests are stored in the database.
@ -869,7 +869,7 @@ class CourseRestorer
", random_answers = ".(int)$quiz->random_answers.
", expired_time = ".(int)$quiz->expired_time.
$condition_session;
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
} else {
// $id = -1 identifies the fictionary test for collecting orphan questions. We do not store it in the database.
@ -879,7 +879,7 @@ class CourseRestorer
foreach ($quiz->question_ids as $index => $question_id) {
$qid = $this->restore_quiz_question($question_id);
$sql = "INSERT IGNORE INTO ".$table_rel." SET question_id = ".$qid.", exercice_id = ".$new_id.", question_order = ".$quiz->question_orders[$index]."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
}
@ -902,29 +902,29 @@ class CourseRestorer
}
$table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION, $this->course->destination_db);
$table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER, $this->course->destination_db);
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($question->description, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_que." SET question = '".addslashes($question->question)."', description = '".addslashes($question->description)."', ponderation = '".addslashes($question->ponderation)."', position = '".addslashes($question->position)."', type='".addslashes($question->quiz_type)."', picture='".addslashes($question->picture)."', level='".addslashes($question->level)."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
if ($question->quiz_type == 4) { // for answer type matching
foreach ($question->answers as $index => $answer) {
$sql = "INSERT INTO ".$table_ans." SET id= '".$answer['id']."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
} else {
foreach ($question->answers as $index => $answer) {
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($answer['answer'], $this->course->code, $this->course->destination_path);
$answer['comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($answer['comment'], $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_ans." SET id= '". ($index +1)."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
@ -950,9 +950,9 @@ class CourseRestorer
AND lang="'.Database::escape_string($survey->lang).'"
';
$result_check = Database::query($sql_check, __FILE__, __LINE__);
$result_check = Database::query($sql_check);
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course($survey->title, $this->course->code, $this->course->destination_path);
$survey->subtitle = DocumentManager::replace_urls_inside_content_html_from_copy_course($survey->subtitle, $this->course->code, $this->course->destination_path);
$survey->intro = DocumentManager::replace_urls_inside_content_html_from_copy_course($survey->intro, $this->course->code, $this->course->destination_path);
@ -1017,7 +1017,7 @@ class CourseRestorer
"reminder_mail = '".Database::escape_string($survey->reminder_mail)."'";
//Insert the new source survey
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
@ -1027,11 +1027,11 @@ class CourseRestorer
$sql = "UPDATE ".$table_que." " .
"SET survey_id = ".$new_id." WHERE " .
"question_id = ".$qid."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$sql = "UPDATE ".$table_ans." ".
"SET survey_id = ".$new_id." WHERE " .
"question_id = ".$qid."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
break;
@ -1044,7 +1044,7 @@ class CourseRestorer
require_once(api_get_path(SYS_CODE_PATH).'survey/survey.lib.php');
$sql_select_existing_survey = "SELECT * FROM $table_sur WHERE survey_id='".Database::escape_string(Database::result($result_check,0,0))."'";
$result = Database::query($sql_select_existing_survey, __FILE__, __LINE__);
$result = Database::query($sql_select_existing_survey);
$survey_data = Database::fetch_array($result,'ASSOC');
// if the survey is shared => also delete the shared content
@ -1055,7 +1055,7 @@ class CourseRestorer
$return = survey_manager :: delete_survey($survey_data['survey_id'],false,$this->course->destination_db);
//Insert the new source survey
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
@ -1065,11 +1065,11 @@ class CourseRestorer
$sql = "UPDATE ".$table_que." " .
"SET survey_id = ".$new_id." WHERE " .
"question_id = ".$qid."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$sql = "UPDATE ".$table_ans." ".
"SET survey_id = ".$new_id." WHERE " .
"question_id = ".$qid."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
break;
@ -1083,7 +1083,7 @@ class CourseRestorer
//No existing survey with the same language and the same code, we just copy the survey
else
{
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
foreach ($survey->question_ids as $index => $question_id)
@ -1092,11 +1092,11 @@ class CourseRestorer
$sql = "UPDATE ".$table_que." " .
"SET survey_id = ".$new_id." WHERE " .
"question_id = ".$qid."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$sql = "UPDATE ".$table_ans." ".
"SET survey_id = ".$new_id." WHERE " .
"question_id = ".$qid."";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
@ -1111,7 +1111,7 @@ class CourseRestorer
{
$table_sur = Database :: get_course_table(TABLE_SURVEY, $this->course->destination_db);
$sql = "SELECT * FROM $table_sur WHERE code='".Database::escape_string($survey_code)."'";
$result = Database::query($sql, __FILE__, __LINE__);
$result = Database::query($sql);
if(Database::num_rows($result) > 0) return false; else return true;
}
@ -1135,7 +1135,7 @@ class CourseRestorer
$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION, $this->course->destination_db);
$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION, $this->course->destination_db);
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course($question->survey_question, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_que." " .
@ -1147,14 +1147,14 @@ class CourseRestorer
"sort = '".Database::escape_string($question->sort)."', " .
"shared_question_id = '".Database::escape_string($question->shared_question_id)."', " .
"max_value = '".Database::escape_string($question->max_value)."' ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_id = Database::insert_id();
foreach ($question->answers as $index => $answer) {
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$answer['option_text'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($answer['option_text'], $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_ans." " .
"SET " .
"question_id = '".Database::escape_string($new_id)."', " .
@ -1162,7 +1162,7 @@ class CourseRestorer
"sort = '".Database::escape_string($answer['sort'])."', " .
"survey_id = '".Database::escape_string($question->survey_id)."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
$this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
}
@ -1205,13 +1205,13 @@ class CourseRestorer
"js_lib= '".Database::escape_string($lp->js_lib)."', " .
"content_license= '".Database::escape_string($lp->content_license)."', " .
"debug= '".Database::escape_string($lp->debug)."' $condition_session ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_lp_id = Database::insert_id();
if($lp->visibility) {
$sql = "INSERT INTO $table_tool SET name='".Database::escape_string($lp->name)."', link='newscorm/lp_controller.php?action=view&lp_id=$new_lp_id', image='scormbuilder.gif', visibility='1', admin='0', address='squaregrey.gif'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
$new_item_ids = array();
@ -1272,7 +1272,7 @@ class CourseRestorer
"parameters='".Database::escape_string($item['parameters'])."', " .
"launch_data = '".Database::escape_string($item['launch_dataprereq_type'])."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$new_item_id = Database::insert_id();
//save a link between old and new item IDs
$new_item_ids[$item['id']] = $new_item_id;
@ -1308,7 +1308,7 @@ class CourseRestorer
foreach ($old_prerequisite as $key=>$my_old_prerequisite) {
if($my_old_prerequisite != ''){
$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' WHERE id = '".$key."' ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
@ -1316,7 +1316,7 @@ class CourseRestorer
foreach ($old_refs as $key=>$my_old_ref) {
if ($my_old_ref != '') {
$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' WHERE id = '".$key."' ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
}
@ -1326,7 +1326,7 @@ class CourseRestorer
$parent_new_id = $new_item_ids[$parent_item_old_id];
}
$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' WHERE id = '".$new_item_id."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
$previous_new_id = 0;
@ -1334,7 +1334,7 @@ class CourseRestorer
$previous_new_id = $new_item_ids[$previous_item_old_id];
}
$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' WHERE id = '".$new_item_id."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
@ -1343,7 +1343,7 @@ class CourseRestorer
$next_new_id = $new_item_ids[$next_item_old_id];
}
$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' WHERE id = '".$new_item_id."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id)
@ -1353,7 +1353,7 @@ class CourseRestorer
$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
}
$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' WHERE id = '".$new_item_id."'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
}
$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
@ -1417,9 +1417,9 @@ class CourseRestorer
$query_sql_ip = $query_sql_fin_ip.$query_sql_ini_ip;
$query_sql_sa = $query_sql_fin_sa.$query_sql_ini_sa;
Database::query($query_sql_sp,__FILE__,__LINE__);
Database::query($query_sql_ip,__FILE__,__LINE__);
Database::query($query_sql_sa,__FILE__,__LINE__);
Database::query($query_sql_sp);
Database::query($query_sql_ip);
Database::query($query_sql_sa);
}
@ -1488,11 +1488,11 @@ class CourseRestorer
$condition_session = " , session_id = '$session_id' ";
}
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($glossary->description, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_glossary." SET name = '".Database::escape_string($glossary->name)."', description = '".Database::escape_string($glossary->description)."', display_order='".Database::escape_string($glossary->display_order)."' $condition_session ";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
$this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = Database::insert_id();
}
@ -1515,7 +1515,7 @@ class CourseRestorer
//$wiki = new Wiki($obj->page_id, $obj->reflink, $obj->title, $obj->content, $obj->user_id, $obj->group_id, $obj->dtime);
// the sql statement to insert the groups from the old course to the new course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course($wiki->content, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO $table_wiki (page_id, reflink, title, content, user_id, group_id, dtime, progress, version, session_id)
@ -1530,18 +1530,18 @@ class CourseRestorer
'".Database::escape_string($wiki->progress)."',
'".intval($wiki->version)."',
'".(!empty($session_id)?intval($session_id):0)."')";
$rs2 = Database::query($sql, __FILE__, __LINE__);
$rs2 = Database::query($sql);
$new_id = Database::insert_id();
$this->course->resources[RESOURCE_WIKI][$id]->destination_id = $new_id;
$sql = "UPDATE $table_wiki set page_id = '$new_id' WHERE id = '$new_id'";
Database::query($sql, __FILE__, __LINE__);
Database::query($sql);
// we also add an entry in wiki_conf
$sql = "INSERT INTO $table_wiki_conf
(page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_size, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit)
VALUES
('".intval($new_id)."', '', '', '', '', '', '', '', NULL, 0, 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0)";
$rs1 = Database::query($sql, __FILE__, __LINE__);
$rs1 = Database::query($sql);
}
}
}

@ -53,7 +53,7 @@ class CourseSelectForm
$resource_titles[RESOURCE_SURVEY] = get_lang('Survey');
$resource_titles[RESOURCE_GLOSSARY] = get_lang('Glossary');
$resource_titles[RESOURCE_WIKI] = get_lang('Wiki');
?>
<script language="JavaScript" type="text/javascript">
function exp(item) {
@ -113,7 +113,7 @@ class CourseSelectForm
echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
if (!empty($hidden_fields['destination_course']) && !empty($hidden_fields['origin_course']) && !empty($hidden_fields['destination_session']) && !empty($hidden_fields['origin_session']) ) {
echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>';
echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['origin_course'].'"/>';
@ -169,11 +169,11 @@ class CourseSelectForm
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
}
}
if (!empty($hidden_fields['destination_session'])) {
echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;" >'.get_lang('Ok').'</button>';
} else {
echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
}
CourseSelectForm :: display_hidden_quiz_questions($course);
@ -194,7 +194,7 @@ class CourseSelectForm
echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.'] id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
}
break;
}
}
}
@ -230,36 +230,36 @@ class CourseSelectForm
//Create the resource DOCUMENT objects
//Loading the results from the checkboxes of the javascript
$resource = $_POST['resource'][RESOURCE_DOCUMENT];
if (!empty($course_code)) {
$course_info = api_get_course_info($course_code);
$table_doc = Database :: get_course_table(TABLE_DOCUMENT,$course_info['dbName']);
$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
} else {
$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);
}
// Searching the documents resource that have been set to null because $avoid_serialize is true in the display_form() function
if ($from=='copy_course') {
if (is_array($resource)) {
$resource = array_keys($resource);
foreach ($resource as $resource_item) {
foreach ($resource as $resource_item) {
$condition_session = '';
if (!empty($session_id)) {
$session_id = intval($session_id);
$condition_session = ' AND d.session_id ='.$session_id;
$condition_session = ' AND d.session_id ='.$session_id;
}
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND id = '.$resource_item.$condition_session.' ORDER BY path';
$db_result = Database::query($sql, __FILE__, __LINE__);
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND id = '.$resource_item.$condition_session.' ORDER BY path';
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
$course->add_resource($doc);
// adding item property
$sql = "SELECT * FROM $table_prop WHERE TOOL = '".RESOURCE_DOCUMENT."' AND ref='".$resource_item."'";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
$all_properties = array ();
while ($item_property = Database::fetch_array($res,'ASSOC')) {
$all_properties[] = $item_property;
@ -339,19 +339,19 @@ class CourseSelectForm
unset ($course->resources[$type][$id]);
}
}
}
}
}
}
}
return $course;
return $course;
}
/**
* Display the form session export
* @param array $hidden_fiels Hidden fields to add to the form.
* @param boolean the document array will be serialize. This is used in the course_copy.php file
*/
function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize=false) {
function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize=false) {
?>
<script language="JavaScript" type="text/javascript">
function exp(item) {
@ -388,10 +388,10 @@ class CourseSelectForm
break;
}
}
}
}
}
}
</script>
</script>
<?php
//get destination course title
@ -402,20 +402,20 @@ class CourseSelectForm
echo get_lang('DestinationCourse').' : '.$course_infos['title'];
echo '</h3>';
}
echo '<script language="javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
foreach($list_course as $course){
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
if (count($resources) > 0) {
echo '<img id="img_'.$course->code.'" src="../img/1.gif" onclick="javascript:exp('."'$course->code'".');" />';
echo '<b onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />';
echo '<div id="div_'.$course->code.'">';
echo '<blockquote>';
echo "[<a href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a> - <a href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>]";
echo '<br />';
echo '<br />';
foreach ($resources as $id => $resource) {
echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
echo ' <label for="resource['.$course->code.']['.$id.']">';
@ -434,7 +434,7 @@ class CourseSelectForm
//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
// this is a known issue of serialize
$course->resources['document']= null;
}
}
echo '<input type="hidden" name="course" value="'.base64_encode(serialize($course)).'"/>';
if (is_array($hidden_fields)) {
foreach ($hidden_fields as $key => $value) {

@ -76,7 +76,7 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
$sql .= ' AND cu.status=1 ';
}
$sql .= ' AND target_course_code IS NULL AND cu.user_id = '.$user_info['user_id'].' AND c.code != '."'".$course_info['sysCode']."'".' ORDER BY title ASC';
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
if( Database::num_rows($res) == 0) {
Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));
} else {

@ -90,7 +90,7 @@ function display_form() {
$html .= '<a href="../admin/index.php">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('PlatformAdmin'),array('style'=>'vertical-align:middle')).get_lang('BackTo').' '.get_lang('PlatformAdmin').'</a>';
$html .= '</div>';
$html .= '<div class="row"><div class="form_header">'.get_lang('CopyCourse').'</div></div>';
$html .= '<div class="row"><div class="form_header">'.get_lang('CopyCourse').'</div></div>';
$html .= '<form name="formulaire" method="post" action="'.api_get_self().'" >';
$html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">';
@ -145,7 +145,7 @@ function search_courses($id_session,$type) {
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
AND src.id_session = '".$id_session."'";
$rs = Database::query($sql, __FILE__, __LINE__);
$rs = Database::query($sql);
$course_list = array();
@ -171,7 +171,7 @@ function search_courses($id_session,$type) {
FROM $session_table s , $session_category_table sc
WHERE s.session_category_id = sc.id AND s.id NOT IN('$id_session')";
$rs_select_destination = Database::query($sql, __FILE__, __LINE__);
$rs_select_destination = Database::query($sql);
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$select_destination .= '<option value = "0">'.get_lang('SelectASession').'</option>';
@ -206,7 +206,7 @@ function search_courses($id_session,$type) {
WHERE src.course_code = c.code
AND src.id_session = '".intval($id_session)."'
AND c.code IN ($list_courses_origin)";
$rs = Database::query($sql, __FILE__, __LINE__);
$rs = Database::query($sql);
$course_list_destination = array();
$return .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;" onmouseover="this.disabled=true;" onmouseout="this.disabled=false;">';
@ -226,7 +226,7 @@ function search_courses($id_session,$type) {
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
AND src.id_session = '".intval($session_origin)."'";
$result = Database::query($sql, __FILE__, __LINE__);
$result = Database::query($sql);
$return_option_disabled = '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\')">';
while($cours = Database :: fetch_array($result)) {

@ -122,7 +122,7 @@ if ($form->validate()) {
$keys = define_course_keys($wanted_code, "", $_configuration['db_prefix']);
$sql_check = sprintf('SELECT * FROM '.$table_course.' WHERE visual_code = "%s"',Database :: escape_string($wanted_code));
$result_check = Database::query($sql_check,__FILE__,__LINE__); //I don't know why this api function doesn't work...
$result_check = Database::query($sql_check); //I don't know why this api function doesn't work... Ivan, 12-FEB-2010: What do you mean?
if ( Database::num_rows($result_check)<1 ) {
if (sizeof($keys)) {
$visual_code = $keys["currentCourseCode"];

@ -500,7 +500,7 @@ if ($form->validate()) {
$ct .= ", comment='$new_comment'";
if ($new_title)
$ct .= ", title='$new_title'";
Database::query("UPDATE $TABLE_DOCUMENT SET".substr($ct, 1)." WHERE id = '$document_id'", __FILE__, __LINE__);
Database::query("UPDATE $TABLE_DOCUMENT SET".substr($ct, 1)." WHERE id = '$document_id'");
}
$dir= substr($dir,0,-1);
header('Location: document.php?curdirpath='.urlencode($dir));

@ -56,7 +56,7 @@ function build_directory_selector($folders,$curdirpath,$group_dir='',$changeRend
$folder_sql = implode("','",$escaped_folders);
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$sql = "SELECT * FROM $doc_table WHERE filetype='folder' AND path IN ('".$folder_sql."')";
$res = Database::query($sql,__FILE__,__LINE__);
$res = Database::query($sql);
$folder_titles = array();
while($obj = Database::fetch_object($res))
{
@ -165,7 +165,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
if (!$show_as_icon)
{
//build download link (icon)
$forcedownload_link=($filetype=='folder')?api_get_self().'?'.api_get_cidreq().'&action=downloadfolder&amp;path='.$url_path.$req_gid:api_get_self().'?'.api_get_cidreq().'&amp;action=download&amp;id='.$url_path.$req_gid;
//folder download or file download?
$forcedownload_icon=($filetype=='folder')?'folder_zip.gif':'filesave.gif';
@ -222,7 +222,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
if (!$show_as_icon)
{
if($filetype=="folder")
{
{
if(api_is_allowed_to_edit() || api_is_platform_admin() || api_get_setting('students_download_folders') == 'true')
{
$force_download_html = ($size==0)?'':'<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'),array('height'=>'16', 'width' => '16')).'</a>';
@ -232,7 +232,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
{
$force_download_html = ($size==0)?'':'<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'),array('height'=>'16', 'width' => '16')).'</a>';
}
return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" target="'.$target.'"'.$visibility_class.' style="float:left">'.$title.'</a>'.$force_download_html;
}
else
@ -253,9 +253,9 @@ function build_document_icon_tag($type, $path)
$basename = basename($path);
$current_session_id = api_get_session_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
if ($type == 'file')
{
@ -348,27 +348,27 @@ function build_edit_icons($curdirpath,$type,$path,$visibility,$id,$is_template,$
$modify_icons = '';
$cur_ses = api_get_session_id();
// if document is read only *or* we're in a session and the document
// if document is read only *or* we're in a session and the document
// is from a non-session context, hide the edition capabilities
if ($is_read_only /*or ($session_id!=$cur_ses)*/)
{
$modify_icons = Display::return_icon('edit_na.gif', get_lang('Modify'));
{
$modify_icons = Display::return_icon('edit_na.gif', get_lang('Modify'));
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif', get_lang('Delete'));
$modify_icons .= '&nbsp;'.Display::return_icon('deplacer_fichier_na.gif', get_lang('Move'));
$modify_icons .= '&nbsp;'.Display::return_icon('deplacer_fichier_na.gif', get_lang('Move'));
$modify_icons .= '&nbsp;'.Display::return_icon($visibility_icon.'_na.gif', get_lang('VisibilityCannotBeChanged'));
}
else
{
{
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
if (strcmp($path,'/audio')===0 or strcmp($path,'/flash')===0 or strcmp($path,'/images')===0 or strcmp($path,'/shared_folder')===0 or strcmp($path,'/video')===0 or strcmp($path,'/chat_files')===0) {
if (strcmp($path,'/audio')===0 or strcmp($path,'/flash')===0 or strcmp($path,'/images')===0 or strcmp($path,'/shared_folder')===0 or strcmp($path,'/video')===0 or strcmp($path,'/chat_files')===0) {
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif',get_lang('ThisFolderCannotBeDeleted'));
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
}
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
}
}
if($type == 'file' && pathinfo($path,PATHINFO_EXTENSION)=='html')
{
if($is_template==0)
@ -491,7 +491,7 @@ function get_titles_of_path($path)
else
{
$sql = 'SELECT title FROM '.Database::get_course_table(TABLE_DOCUMENT).' WHERE path LIKE BINARY "'.$tmp_path.'"';
$rs = Database::query($sql,__FILE__,__LINE__);
$rs = Database::query($sql);
$tmp_title = '/'.Database::result($rs,0,0);
$path_displayed .= $tmp_title;
$tmp_folders_titles[$tmp_path] = $tmp_title;
@ -556,7 +556,7 @@ function is_my_shared_folder($user_id, $path)
{
if('/shared_folder/sf_user_'.$user_id==Security::remove_XSS($path))
{
return true;
return true;
}
return false;
}

@ -94,7 +94,7 @@ if(isset($_GET['id_session'])) {
// Check whether the tool is actually visible
$table_course_tool = Database::get_course_table(TABLE_TOOL_LIST, $_course['dbName']);
$tool_sql = 'SELECT visibility FROM ' . $table_course_tool . ' WHERE name = "'. TOOL_DOCUMENT .'" LIMIT 1';
$tool_result = Database::query($tool_sql,__FILE__,__LINE__);
$tool_result = Database::query($tool_sql);
$tool_row = Database::fetch_array($tool_result);
$tool_visibility = $tool_row['visibility'];
if ($tool_visibility == '0' && $to_group_id == '0' && !($is_allowed_to_edit || $group_member_with_upload_rights))

@ -80,7 +80,7 @@ if (is_allowed_to_edit())
$querypath=$path;
}
//search for all files that are not deleted => visibility != 2
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$querypath."/%' AND `docs`.`filetype`='file' AND `props`.`visibility`<>'2' AND `props`.`to_group_id`=".$to_group_id."",__FILE__,__LINE__);
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$querypath."/%' AND `docs`.`filetype`='file' AND `props`.`visibility`<>'2' AND `props`.`to_group_id`=".$to_group_id."");
//add tem to the zip file
while ($not_deleted_file = Database::fetch_assoc($query))
{
@ -102,7 +102,7 @@ else
//big problem: visible files that are in a hidden folder are included when we do a query for visiblity='v'!!!
//so... I do it in a couple of steps:
//1st: get all files that are visible in the given path
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$querypath."/%' AND `props`.`visibility`='1' AND `docs`.`filetype`='file' AND `props`.`to_group_id`=".$to_group_id,__FILE__,__LINE__);
$query = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$querypath."/%' AND `props`.`visibility`='1' AND `docs`.`filetype`='file' AND `props`.`to_group_id`=".$to_group_id);
//add them to an array
while ($all_visible_files = Database::fetch_assoc($query))
{
@ -113,7 +113,7 @@ else
//print_r($all_visible_files_path);
//echo('</pre>');
//2nd: get all folders that are invisible in the given path
$query2 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$querypath."/%' AND `props`.`visibility`<>'1' AND `docs`.`filetype`='folder'",__FILE__,__LINE__);
$query2 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$querypath."/%' AND `props`.`visibility`<>'1' AND `docs`.`filetype`='folder'");
//if we get invisible folders, we have to filter out these results from all visible files we found
if(Database::num_rows($query2)>0)
{
@ -122,7 +122,7 @@ else
{
//3rd: get all files that are in the found invisible folder (these are "invisible" too)
//echo "<br><br>invisible folders: ".$sys_course_path.$_course['path']."/document".$invisible_folders['path']."<br>";
$query3 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$invisible_folders['path']."/%' AND `docs`.`filetype`='file' AND `props`.`visibility`='1'",__FILE__,__LINE__);
$query3 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props WHERE `props`.`tool`='".TOOL_DOCUMENT."' AND `docs`.`id`=`props`.`ref` AND `docs`.`path` LIKE '".$invisible_folders['path']."/%' AND `docs`.`filetype`='file' AND `props`.`visibility`='1'");
//add tem to an array
while ($files_in_invisible_folder = Database::fetch_assoc($query3))
{

@ -328,7 +328,7 @@ if (isset($_POST['newComment']))
$newComment = trim(Database::escape_string(Security::remove_XSS($_POST['newComment']))); // remove spaces
$newTitle = trim(Database::escape_string(Security::remove_XSS($_POST['newTitle']))); // remove spaces
// Check if there is already a record for this file in the DB
$result = Database::query ("SELECT * FROM $dbTable WHERE path LIKE BINARY '".$commentPath."'",__FILE__,__LINE__);
$result = Database::query ("SELECT * FROM $dbTable WHERE path LIKE BINARY '".$commentPath."'");
while($row = Database::fetch_array($result, 'ASSOC'))
{
$attribute['path' ] = $row['path' ];
@ -340,7 +340,7 @@ if (isset($_POST['newComment']))
SET comment='".$newComment."', title='".$newTitle."'
WHERE path
LIKE BINARY '".$commentPath."'";
Database::query($query,__FILE__,__LINE__);
Database::query($query);
$oldComment = $newComment;
$oldTitle = $newTitle;
$comments_updated = get_lang('ComMod');
@ -370,7 +370,7 @@ if (isset($_POST['renameTo']))
/** TODO check if this code is still used **/
/* Search the old comment */ // RH: metadata: added 'id,'
$result = Database::query("SELECT id,comment,title FROM $dbTable WHERE path LIKE BINARY '$dir$doc'",__FILE__,__LINE__);
$result = Database::query("SELECT id,comment,title FROM $dbTable WHERE path LIKE BINARY '$dir$doc'");
$message = "<i>Debug info</i><br>directory = $dir<br>";
$message .= "document = $file_name<br>";
@ -608,7 +608,7 @@ if( isset($info_message))
// readonly
$sql = 'SELECT id, readonly FROM '.$dbTable.' WHERE path LIKE BINARY "'.$dir.$doc.'"';
$rs = Database::query($sql, __FILE__, __LINE__);
$rs = Database::query($sql);
$readonly = Database::result($rs,0,'readonly');
$doc_id = Database::result($rs,0,'id');
@ -616,7 +616,7 @@ $doc_id = Database::result($rs,0,'id');
$sql = 'SELECT insert_user_id FROM '.Database::get_course_table(TABLE_ITEM_PROPERTY).'
WHERE tool LIKE "document"
AND ref='.intval($doc_id);
$rs = Database::query($sql, __FILE__, __LINE__);
$rs = Database::query($sql);
$owner_id = Database::result($rs,0,'insert_user_id');

@ -229,22 +229,22 @@ if ($slide_id !== "all") {
$pathpart=$path.'/';
}
$sql = "SELECT * FROM $tbl_documents WHERE path='".Database::escape_string($pathpart.$image_files_only[$slide])."'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
$row = Database::fetch_array($result);
echo '<table align="center" border="0" cellspacing="10">';
echo '<tr>';
echo '<td align="center" style="font-size: xx-large; font-weight: bold;">';
echo '<td align="center" style="font-size: xx-large; font-weight: bold;">';
echo $row['title'];
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="center">';
echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'><img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags."></a>";
echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'><img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags."></a>";
echo '</td>';
echo '</tr>';
echo '</tr>';
echo '<tr>';
echo '<td style="border:1px solid; border-color: #CCCCCC">';
echo '<td style="border:1px solid; border-color: #CCCCCC">';
echo $row['comment'];
echo '</td>';
echo '</tr>';
@ -254,11 +254,11 @@ if ($slide_id !== "all") {
{
echo '<tr>';
echo '<td align="center">';
echo '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$pathurl.'&amp;origin=slideshow&amp;origin_opt='.$slide_id.'&amp;file='.urlencode($path).'/'.$image_files_only[$slide].'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="'.get_lang('Modify').'" /></a><br />';
echo '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$pathurl.'&amp;origin=slideshow&amp;origin_opt='.$slide_id.'&amp;file='.urlencode($path).'/'.$image_files_only[$slide].'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="'.get_lang('Modify').'" /></a><br />';
$aux= explode(".", htmlspecialchars($image_files_only[$slide]));
$ext= $aux[count($aux)-1];
echo $image_files_only[$slide].' <br />';
list($width, $high) = getimagesize($image);
echo $image_files_only[$slide].' <br />';
list($width, $high) = getimagesize($image);
echo $width.' x '.$high.' <br />';
echo round((filesize($image)/1024),2).' KB';
echo ' - '.$ext;
@ -278,19 +278,19 @@ if ($slide_id !== "all") {
}
echo $resize_info;
echo $resize_widht;
echo $resize_height;
echo $resize_height;
echo '</td>';
echo '</tr>';
}
echo '</table>';
echo '<br/>';
// back forward buttons
echo '<table align="center" border="0">';
echo '<tr>';
echo '<td align="center" >';
// first slide
echo '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'slide_first.png" title="'.get_lang('FirstSlide').'" alt="'.get_lang('FirstSlide').'">&nbsp;&nbsp;</a>';
// previous slide
@ -308,7 +308,7 @@ if ($slide_id !== "all") {
// next slide
if ($slide < $total_slides -1 and $slide_id <> "all") {
echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
}
echo '<img src="'.api_get_path(WEB_IMG_PATH).'slide_next.png" title="'.get_lang('Next').'" alt="'.get_lang('Next').'">';
if ($slide > 0) {
@ -318,8 +318,8 @@ if ($slide_id !== "all") {
echo '&nbsp;&nbsp;<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'slide_last.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'"></a>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</table>';
} else {
Display::display_warning_message(get_lang('FileNotFound'));
}

@ -48,7 +48,7 @@ require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php
require_once 'document.inc.php';
// adding extra javascript to the form
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<script type="text/javascript">
function check_unzip() {
@ -62,7 +62,7 @@ function check_unzip() {
document.upload.if_exists[2].disabled=false;
}
}
function advanced_parameters() {
if(document.getElementById(\'options\').style.display == \'none\') {
document.getElementById(\'options\').style.display = \'block\';
@ -72,7 +72,7 @@ function advanced_parameters() {
document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
}
}
function setFocus(){
$("#title_file").focus();
}
@ -162,7 +162,7 @@ function get_text_content($doc_path, $doc_mime) {
}
// variables
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
@ -268,7 +268,7 @@ if(isset($_FILES['user_upload'])) {
if($upload_ok) {
//file got on the server without problems, now process it
$new_path = handle_uploaded_document($_course, $_FILES['user_upload'],$base_work_dir,$_POST['curdirpath'],$_user['user_id'],$to_group_id,$to_user_id,$max_filled_space,$_POST['unzip'],$_POST['if_exists']);
$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
@ -280,7 +280,7 @@ if(isset($_FILES['user_upload'])) {
if ($new_comment) $ct .= ", comment='$new_comment'";
if ($new_title) $ct .= ", title='$new_title'";
Database::query("UPDATE $table_document SET" . substr($ct, 1) .
" WHERE id = '$docid'", __FILE__, __LINE__);
" WHERE id = '$docid'");
}
//showing message when sending zip files
if ($new_path === true && $_POST['unzip'] == 1) {
@ -289,7 +289,7 @@ if(isset($_FILES['user_upload'])) {
if ( (api_get_setting('search_enabled')=='true') && ($docid = DocumentManager::get_document_id($_course, $new_path))) {
$table_document = Database::get_course_table(TABLE_DOCUMENT);
$result = Database::query("SELECT * FROM $table_document WHERE id = '$docid' LIMIT 1", __FILE__, __LINE__);
$result = Database::query("SELECT * FROM $table_document WHERE id = '$docid' LIMIT 1");
if (Database::num_rows($result) == 1) {
$row = Database::fetch_array($result);
$doc_path = api_get_path(SYS_COURSE_PATH) . $courseDir. $row['path'];
@ -357,7 +357,7 @@ if(isset($_FILES['user_upload'])) {
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $courseid, TOOL_DOCUMENT, $docid);
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$se_ref = Database::fetch_array($res);
@ -388,7 +388,7 @@ if(isset($_FILES['user_upload'])) {
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'UPDATE %s SET search_did=%d WHERE id=%d LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, (int)$did, (int)$se_ref['id']);
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
@ -420,7 +420,7 @@ if(isset($_FILES['user_upload'])) {
$sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, search_did)
VALUES (NULL , \'%s\', \'%s\', %s, %s)';
$sql = sprintf($sql, $tbl_se_ref, $courseid, TOOL_DOCUMENT, $docid, $did);
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
}
}
}
@ -496,7 +496,7 @@ if(isset($_GET['createdir']))
$new_folder_text .= '</form>';
//show the form
//Display::display_normal_message($new_folder_text, false);
echo create_dir_form();
}

@ -113,7 +113,7 @@ class Dropbox_Work {
$sql="SELECT id, upload_date
FROM ".$dropbox_cnf["tbl_file"]."
WHERE filename = '".addslashes($this->filename)."'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
$res = Database::fetch_array($result);
if ($res != FALSE) {
$this->isOldWork = TRUE;
@ -129,7 +129,7 @@ class Dropbox_Work {
, author = '".addslashes($this->author)."'
, last_upload_date = '".addslashes($this->last_upload_date)."'
WHERE id='".addslashes($this->id)."'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
} else {
$this->upload_date = $this->last_upload_date;
$sql="INSERT INTO ".$dropbox_cnf["tbl_file"]."
@ -145,7 +145,7 @@ class Dropbox_Work {
, ".intval($_SESSION['id_session'])."
)";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
$this->id = Database::insert_id(); //get automatically inserted id
}
@ -173,7 +173,7 @@ class Dropbox_Work {
$sql="SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
FROM ".$dropbox_cnf["tbl_file"]."
WHERE id='".addslashes($id)."'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
$res = Database::fetch_array($result, 'ASSOC');
// Check if uploader is still in Dokeos system
@ -203,7 +203,7 @@ class Dropbox_Work {
if ($_GET['action']=='viewfeedback' AND $this->id==$_GET['id']) {
$feedback2=array();
$sql_feedback = "SELECT * FROM ".$dropbox_cnf["tbl_feedback"]." WHERE file_id='".$id."' ORDER BY feedback_id ASC";
$result = Database::query($sql_feedback, __FILE__, __LINE__);
$result = Database::query($sql_feedback);
while ($row_feedback=Database::fetch_array($result)) {
$row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
$feedback2[]=$row_feedback;
@ -214,7 +214,7 @@ class Dropbox_Work {
// RH: Feedback
$result = Database::query("SELECT feedback_date, feedback, cat_id FROM ".
dropbox_cnf("tbl_post")." WHERE dest_user_id='".$_user['user_id'].
"' AND file_id='".$id."'",__FILE__,__LINE__);
"' AND file_id='".$id."'");
if ($res = Database::fetch_array($result))
{
$this->feedback_date = $res["feedback_date"];
@ -334,7 +334,7 @@ class Dropbox_SentWork extends Dropbox_Work
$sql="SELECT dest_user_id, feedback_date, feedback
FROM ".$dropbox_cnf["tbl_post"]."
WHERE file_id='".addslashes($id)."'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
while ($res = Database::fetch_array($result)) {
// check for deleted users
$dest_user_id = $res["dest_user_id"];
@ -393,7 +393,7 @@ class Dropbox_Person
//if (intval($_SESSION['id_session']>0)) { $sql .= " AND r.session_id = ".intval($_SESSION['id_session']); }
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
while ($res = Database::fetch_array($result)) {
$temp = new Dropbox_Work($res["file_id"]);
$temp -> category = $res['cat_id'];
@ -409,7 +409,7 @@ class Dropbox_Person
//if(intval($_SESSION['id_session']>0)) { $sql .= " AND f.session_id = ".intval($_SESSION['id_session']); }
$result =Database::query($sql,__FILE__,__LINE__);
$result =Database::query($sql);
while ($res = Database::fetch_array($result)) {
$this->sentWork[] = new Dropbox_SentWork($res["id"]);
}
@ -518,7 +518,7 @@ class Dropbox_Person
global $dropbox_cnf;
//delete entries in person table concerning received works
foreach ($this->receivedWork as $w) {
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'",__FILE__,__LINE__);
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'");
}
removeUnusedFiles(); //check for unused files
@ -558,7 +558,7 @@ class Dropbox_Person
}
}
//delete entries in person table concerning received works
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$id."'",__FILE__,__LINE__);
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$id."'");
removeUnusedFiles(); //check for unused files
}
@ -569,7 +569,7 @@ class Dropbox_Person
global $dropbox_cnf;
//delete entries in person table concerning sent works
foreach ($this->sentWork as $w) {
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'",__FILE__,__LINE__);
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'");
removeMoreIfMailing($w->id); // RH: Mailing: see init1
}
removeUnusedFiles(); //check for unused files
@ -597,7 +597,7 @@ class Dropbox_Person
}
//$file_id = $this->sentWork[$index]->id; // RH: Mailing
//delete entries in person table concerning sent works
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$id."'",__FILE__,__LINE__);
Database::query("DELETE FROM ".$dropbox_cnf["tbl_person"]." WHERE user_id='".$this->userId."' AND file_id='".$id."'");
removeMoreIfMailing($id); // RH: Mailing: see init1
removeUnusedFiles(); //check for unused files
}
@ -630,7 +630,7 @@ class Dropbox_Person
Database::query("UPDATE ".$dropbox_cnf["tbl_post"]." SET feedback_date='".
addslashes($feedback_date)."', feedback='".addslashes($text).
"' WHERE dest_user_id='".$this->userId."' AND file_id='".$id."'",__FILE__,__LINE__);
"' WHERE dest_user_id='".$this->userId."' AND file_id='".$id."'");
//update item_property (previously last_tooledit) table

@ -57,7 +57,7 @@ if ( isset($_GET['cat_id']) AND is_numeric($_GET['cat_id']) AND $_GET['action']=
AND post.file_id=file.id
" ;
}
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
while ($row=Database::fetch_array($result))
{
$files_to_download[]=$row['id'];

@ -154,11 +154,11 @@ function delete_category($action, $id)
// step 1: delete the category
$sql="DELETE FROM ".$dropbox_cnf['tbl_category']." WHERE cat_id='".Database::escape_string($id)."' AND $sentreceived='1'";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
// step 2: delete all the documents in this category
$sql="SELECT * FROM ".$entries_table." WHERE cat_id='".Database::escape_string($id)."'";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
while ($row=Database::fetch_array($result))
{
@ -244,7 +244,7 @@ function store_move($id, $target, $part)
WHERE dest_user_id='".Database::escape_string($_user['user_id'])."'
AND file_id='".Database::escape_string($id)."'
";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$return_message=get_lang('ReceivedFileMoved');
}
if ($part=='sent')
@ -253,7 +253,7 @@ function store_move($id, $target, $part)
WHERE uploader_id='".Database::escape_string($_user['user_id'])."'
AND id='".Database::escape_string($id)."'
";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
$return_message=get_lang('SentFileMoved');
}
}
@ -343,7 +343,7 @@ function get_dropbox_categories($filter='')
$sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE user_id='".$_user['user_id']."' $condition_session";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
while ($row=Database::fetch_array($result))
{
if(($filter=='sent' AND $row['sent']==1) OR ($filter=='received' AND $row['received']==1) OR $filter=='')
@ -401,7 +401,7 @@ function store_addcategory()
$session_id = api_get_session_id();
// step 3a, we check if the category doesn't already exist
$sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE user_id='".$_user['user_id']."' AND cat_name='".Database::escape_string(Security::remove_XSS($_POST['category_name']))."' AND received='".$received."' AND sent='$sent' AND session_id='$session_id'";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
// step 3b, we add the category if it does not exist yet.
@ -409,7 +409,7 @@ function store_addcategory()
{
$sql="INSERT INTO ".$dropbox_cnf['tbl_category']." (cat_name, received, sent, user_id, session_id)
VALUES ('".Database::escape_string(Security::remove_XSS($_POST['category_name']))."', '".Database::escape_string($received)."', '".Database::escape_string($sent)."', '".Database::escape_string($_user['user_id'])."',$session_id)";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
return array('type' => 'confirmation', 'message'=>get_lang('CategoryStored'));
}
else
@ -422,7 +422,7 @@ function store_addcategory()
$sql="UPDATE ".$dropbox_cnf['tbl_category']." SET cat_name='".Database::escape_string(Security::remove_XSS($_POST['category_name']))."', received='".Database::escape_string($received)."' , sent='".Database::escape_string($sent)."'
WHERE user_id='".Database::escape_string($_user['user_id'])."'
AND cat_id='".Database::escape_string(Security::remove_XSS($_POST['edit_id']))."'";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
return array('type' => 'confirmation', 'message'=>get_lang('CategoryModified'));
}
}
@ -446,7 +446,7 @@ function display_addcategory_form($category_name='', $id='',$action)
{
// retrieve the category we are editing
$sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE cat_id='".Database::escape_string($id)."'";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
$row=Database::fetch_array($result);
if ($category_name=='') // after an edit with an error we do not want to return to the original name but the name we already modified. (happens when createinrecievedfiles AND createinsentfiles are not checked)
@ -717,7 +717,7 @@ function getUserNameFromId ( $id) // RH: Mailing: return 'Mailing ' + id
$sql = "SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ', lastname)" : "CONCAT(lastname,' ', firstname)")." AS name
FROM " . $dropbox_cnf["tbl_user"] . "
WHERE user_id='$id'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
$res = Database::fetch_array( $result);
if ( $res == FALSE) return FALSE;
@ -734,7 +734,7 @@ function getLoginFromId ( $id)
$sql = "SELECT username
FROM " . dropbox_cnf("tbl_user") . "
WHERE user_id='$id'";
$result =Database::query($sql,__FILE__,__LINE__);
$result =Database::query($sql);
$res = Database::fetch_array( $result);
if ( $res == FALSE) return FALSE;
return stripslashes( $res["username"]);
@ -764,14 +764,14 @@ function removeUnusedFiles( )
FROM " . dropbox_cnf("tbl_file") . " f
LEFT JOIN " . dropbox_cnf("tbl_person") . " p ON f.id = p.file_id
WHERE p.user_id IS NULL";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
while ( $res = Database::fetch_array( $result))
{
//delete the selected files from the post and file tables
$sql = "DELETE FROM " . dropbox_cnf("tbl_post") . " WHERE file_id='" . $res['id'] . "'";
$result1 = Database::query($sql,__FILE__,__LINE__);
$result1 = Database::query($sql);
$sql = "DELETE FROM " . dropbox_cnf("tbl_file") . " WHERE id='" . $res['id'] . "'";
$result1 = Database::query($sql,__FILE__,__LINE__);
$result1 = Database::query($sql);
//delete file from server
@unlink( dropbox_cnf("sysPath") . "/" . $res["filename"]);
@ -799,7 +799,7 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
FROM " . $dropbox_cnf["tbl_file"] . " f
LEFT JOIN " . $dropbox_cnf["tbl_post"] . " p ON f.id = p.file_id
WHERE p.dest_user_id = '" . $mailingPseudoId . "'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
if (!($res = Database::fetch_array($result)))
die(dropbox_lang("generalError")." (code 901)");
@ -826,7 +826,7 @@ function removeMoreIfMailing($file_id)
$sql = "SELECT p.dest_user_id
FROM " . $dropbox_cnf["tbl_post"] . " p
WHERE p.file_id = '" . $file_id . "'";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
if ( $res = Database::fetch_array( $result))
{
@ -834,11 +834,11 @@ function removeMoreIfMailing($file_id)
if ( $mailingPseudoId > dropbox_cnf("mailingIdBase"))
{
$sql = "DELETE FROM " . dropbox_cnf("tbl_person") . " WHERE user_id='" . $mailingPseudoId . "'";
$result1 = Database::query($sql,__FILE__,__LINE__);
$result1 = Database::query($sql);
$sql = "UPDATE " . dropbox_cnf("tbl_file") .
" SET uploader_id='" . api_get_user_id() . "' WHERE uploader_id='" . $mailingPseudoId . "'";
$result1 = Database::query($sql,__FILE__,__LINE__);
$result1 = Database::query($sql);
}
}
}
@ -1083,7 +1083,7 @@ function display_user_link($user_id, $name='')
{
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql="SELECT * FROM $table_user WHERE user_id='".Database::escape_string($user_id)."'";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
$row=Database::fetch_array($result);
return "<a href=\"../user/userInfo.php?uInfo=".$row['user_id']."\">".api_get_person_name($row['firstname'], $row['lastname'])."</a>";
}
@ -1151,7 +1151,7 @@ function feedback_form()
// we now check if the other users have not delete this document yet. If this is the case then it is useless to see the
// add feedback since the other users will never get to see the feedback.
$sql="SELECT * FROM ".$dropbox_cnf["tbl_person"]." WHERE file_id='".Database::escape_string($_GET['id'])."'";
$result=Database::query($sql,__LINE__, __FILE__);
$result=Database::query($sql);
$number_users_who_see_file=Database::num_rows($result);
if ($number_users_who_see_file>1)
{
@ -1192,7 +1192,7 @@ function store_feedback()
{
$sql="INSERT INTO ".$dropbox_cnf['tbl_feedback']." (file_id, author_user_id, feedback, feedback_date) VALUES
('".Database::escape_string($_GET['id'])."','".Database::escape_string($_user['user_id'])."','".Database::escape_string($_POST['feedback'])."',NOW())";
Database::query($sql,__FILE__,__LINE__);
Database::query($sql);
return get_lang('DropboxFeedbackStored');
}
}
@ -1238,7 +1238,7 @@ function zip_download ($array)
WHERE file.id IN (".implode(', ',$array).")
AND file.id=person.file_id
AND person.user_id='".$_user['user_id']."'";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
while ($row=Database::fetch_array($result))
{
$files[$row['filename']]=array('filename'=>$row['filename'],'title'=>$row['title'], 'author'=>$row['author'], 'description'=>$row['description']);
@ -1486,7 +1486,7 @@ function get_total_number_feedback($file_id='')
global $dropbox_cnf;
$sql="SELECT COUNT(feedback_id) AS total, file_id FROM ".$dropbox_cnf['tbl_feedback']." GROUP BY file_id";
$result=Database::query($sql, __FILE__, __LINE__);
$result=Database::query($sql);
while ($row=Database::fetch_array($result))
{
$return[$row['file_id']]=$row['total'];
@ -1553,7 +1553,7 @@ function get_last_tool_access($tool, $course_code='', $user_id='')
AND access_tool='".Database::escape_string($tool)."'
ORDER BY access_date DESC
LIMIT 1";
$result=Database::query($sql,__FILE__,__LINE__);
$result=Database::query($sql);
$row=Database::fetch_array($result);
return $row['access_date'];
}

@ -1,7 +1,6 @@
<?php //$id: $
/* For licensing terms, see /dokeos_license.txt */
/*
* ========================================
* PREVENT RESUBMITING
@ -338,7 +337,7 @@ if ( isset( $_GET['mailingIndex'])) // examine or send
unset($students);
}
$result = Database::query($sel . $thisRecip . "'",__FILE__,__LINE__);
$result = Database::query($sel . $thisRecip . "'");
while ( ($res = Database::fetch_array($result))) {$students[] = $res;}
Database::free_result($result);
@ -482,7 +481,7 @@ if ( isset( $_GET['mailingIndex'])) // examine or send
ON cu.user_id = u.user_id AND cu.course_code = '".$_course['sysCode']."'
WHERE cu.status = 5
AND u.user_id NOT IN ('" . implode("', '" , $students) . "')";
$result = Database::query($sql,__FILE__,__LINE__);
$result = Database::query($sql);
if ( Database::num_rows($result) > 0)
{
@ -521,11 +520,11 @@ if ( isset( $_GET['mailingIndex'])) // examine or send
SET filesize = '0'
, upload_date = '".$sendDT."', last_upload_date = '".$sendDT."'
WHERE id='".addslashes($mailing_item->id)."'";
$result =Database::query($sql,__FILE__,__LINE__);
$result =Database::query($sql);
}
elseif ( $mailing_item->filesize != 0)
elseif ($mailing_item->filesize != 0)
{
$errormsg .= '<br>' . dropbox_lang("mailingNotYetSent") . '<br>';
$errormsg .= '<br />' . dropbox_lang("mailingNotYetSent") . '<br />';
}
}
}

Loading…
Cancel
Save