@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | require_once 'Resource.class.php'; |
| 5 | 5 | |
| 6 | -define('DOCUMENT','file'); |
|
| 7 | -define('FOLDER','folder'); |
|
| 6 | +define('DOCUMENT', 'file'); |
|
| 7 | +define('FOLDER', 'folder'); |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Class Document |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function __construct($id, $path, $comment, $title, $file_type, $size) |
| 32 | 32 | { |
| 33 | 33 | parent::__construct($id, RESOURCE_DOCUMENT); |
| 34 | - $this->path = 'document' . $path; |
|
| 34 | + $this->path = 'document'.$path; |
|
| 35 | 35 | $this->comment = $comment; |
| 36 | 36 | $this->title = $title; |
| 37 | 37 | $this->file_type = $file_type; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | echo preg_replace('@^document@', '', $this->path); |
| 48 | 48 | if (!empty($this->title)) { |
| 49 | 49 | if (strpos($this->path, $this->title) === false) { |
| 50 | - echo " - " . $this->title; |
|
| 50 | + echo " - ".$this->title; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -47,6 +47,6 @@ |
||
| 47 | 47 | $user_info = api_get_user_info($this->obj->thread_poster_id); |
| 48 | 48 | $extra = $user_info['complete_name'].', '.$extra; |
| 49 | 49 | } |
| 50 | - echo $this->obj->thread_title . ' (' . $extra . ')'; |
|
| 50 | + echo $this->obj->thread_title.' ('.$extra.')'; |
|
| 51 | 51 | } |
| 52 | 52 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $this->course->backup_path, |
| 521 | 521 | $this->course->info['path'] |
| 522 | 522 | ); |
| 523 | - file_put_contents($path.$document->path,$content); |
|
| 523 | + file_put_contents($path.$document->path, $content); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | $params = [ |
@@ -564,14 +564,14 @@ discard block |
||
| 564 | 564 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
| 565 | 565 | $file_exists = file_exists($path.$new_file_name); |
| 566 | 566 | while ($file_exists) { |
| 567 | - $i ++; |
|
| 567 | + $i++; |
|
| 568 | 568 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
| 569 | 569 | $file_exists = file_exists($path.$new_file_name); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | if (!empty($session_id)) { |
| 573 | 573 | |
| 574 | - $document_path = explode('/',$document->path,3); |
|
| 574 | + $document_path = explode('/', $document->path, 3); |
|
| 575 | 575 | $course_path = $path; |
| 576 | 576 | $orig_base_folder = $document_path[1]; |
| 577 | 577 | $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | $folder_exists = file_exists($new_base_path); |
| 591 | 591 | if ($folder_exists) { |
| 592 | - $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
| 592 | + $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
| 593 | 593 | $x = ''; |
| 594 | 594 | while ($folder_exists) { |
| 595 | 595 | $x = $x + 1; |
@@ -609,9 +609,9 @@ discard block |
||
| 609 | 609 | $new_base_path = $_SESSION['new_base_path']; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
| 613 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
| 614 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
| 612 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
| 613 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
| 614 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
| 615 | 615 | |
| 616 | 616 | $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
| 617 | 617 | |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | //Replace old course code with the new destination code see BT#1985 |
| 632 | 632 | if (file_exists($dest_document_path)) { |
| 633 | 633 | $file_info = pathinfo($dest_document_path); |
| 634 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 634 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 635 | 635 | $content = file_get_contents($dest_document_path); |
| 636 | 636 | if (UTF8_CONVERT) { |
| 637 | 637 | $content = utf8_encode($content); |
@@ -687,8 +687,8 @@ discard block |
||
| 687 | 687 | //Replace old course code with the new destination code see BT#1985 |
| 688 | 688 | if (file_exists($path.$new_file_name)) { |
| 689 | 689 | $file_info = pathinfo($path.$new_file_name); |
| 690 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 691 | - $content = file_get_contents($path.$new_file_name); |
|
| 690 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 691 | + $content = file_get_contents($path.$new_file_name); |
|
| 692 | 692 | if (UTF8_CONVERT) { |
| 693 | 693 | $content = utf8_encode($content); |
| 694 | 694 | } |
@@ -741,8 +741,8 @@ discard block |
||
| 741 | 741 | //Replace old course code with the new destination code see BT#1985 |
| 742 | 742 | if (file_exists($path.$new_file_name)) { |
| 743 | 743 | $file_info = pathinfo($path.$new_file_name); |
| 744 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 745 | - $content = file_get_contents($path.$new_file_name); |
|
| 744 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 745 | + $content = file_get_contents($path.$new_file_name); |
|
| 746 | 746 | if (UTF8_CONVERT) { |
| 747 | 747 | $content = utf8_encode($content); |
| 748 | 748 | } |
@@ -805,8 +805,8 @@ discard block |
||
| 805 | 805 | //Replace old course code with the new destination code see BT#1985 |
| 806 | 806 | if (file_exists($path.$document->path)) { |
| 807 | 807 | $file_info = pathinfo($path.$document->path); |
| 808 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 809 | - $content = file_get_contents($path.$document->path); |
|
| 808 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 809 | + $content = file_get_contents($path.$document->path); |
|
| 810 | 810 | if (UTF8_CONVERT) { |
| 811 | 811 | $content = utf8_encode($content); |
| 812 | 812 | } |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | case FILE_OVERWRITE: |
| 897 | 897 | rmdirr($path.$document->path); |
| 898 | 898 | copyDirTo( |
| 899 | - $this->course->backup_path . '/' . $document->path, |
|
| 900 | - $path . dirname($document->path), |
|
| 899 | + $this->course->backup_path.'/'.$document->path, |
|
| 900 | + $path.dirname($document->path), |
|
| 901 | 901 | false |
| 902 | 902 | ); |
| 903 | 903 | break; |
@@ -919,23 +919,23 @@ discard block |
||
| 919 | 919 | $file_exists = file_exists($path.$new_file_name); |
| 920 | 920 | |
| 921 | 921 | while ($file_exists) { |
| 922 | - $i ++; |
|
| 922 | + $i++; |
|
| 923 | 923 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
| 924 | 924 | $file_exists = file_exists($path.$new_file_name); |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | rename( |
| 928 | - $this->course->backup_path . '/' . $document->path, |
|
| 929 | - $this->course->backup_path . '/' . $new_file_name |
|
| 928 | + $this->course->backup_path.'/'.$document->path, |
|
| 929 | + $this->course->backup_path.'/'.$new_file_name |
|
| 930 | 930 | ); |
| 931 | 931 | copyDirTo( |
| 932 | - $this->course->backup_path . '/' . $new_file_name, |
|
| 933 | - $path . dirname($new_file_name), |
|
| 932 | + $this->course->backup_path.'/'.$new_file_name, |
|
| 933 | + $path.dirname($new_file_name), |
|
| 934 | 934 | false |
| 935 | 935 | ); |
| 936 | 936 | rename( |
| 937 | - $this->course->backup_path . '/' . $new_file_name, |
|
| 938 | - $this->course->backup_path . '/' . $document->path |
|
| 937 | + $this->course->backup_path.'/'.$new_file_name, |
|
| 938 | + $this->course->backup_path.'/'.$document->path |
|
| 939 | 939 | ); |
| 940 | 940 | |
| 941 | 941 | break; |
@@ -943,8 +943,8 @@ discard block |
||
| 943 | 943 | } else { |
| 944 | 944 | // end if file exists |
| 945 | 945 | copyDirTo( |
| 946 | - $this->course->backup_path . '/' . $document->path, |
|
| 947 | - $path . dirname($document->path), |
|
| 946 | + $this->course->backup_path.'/'.$document->path, |
|
| 947 | + $path.dirname($document->path), |
|
| 948 | 948 | false |
| 949 | 949 | ); |
| 950 | 950 | } |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | $table_forum = Database::get_course_table(TABLE_FORUM); |
| 963 | 963 | $resources = $this->course->resources; |
| 964 | 964 | foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
| 965 | - $params = (array)$forum->obj; |
|
| 965 | + $params = (array) $forum->obj; |
|
| 966 | 966 | $cat_id = ''; |
| 967 | 967 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
| 968 | 968 | isset($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']])) { |
@@ -1014,13 +1014,13 @@ discard block |
||
| 1014 | 1014 | foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
| 1015 | 1015 | if ($topic->obj->forum_id == $id) { |
| 1016 | 1016 | $this->restore_topic($topic_id, $new_id, $sessionId); |
| 1017 | - $forum_topics ++; |
|
| 1017 | + $forum_topics++; |
|
| 1018 | 1018 | } |
| 1019 | 1019 | } |
| 1020 | 1020 | } |
| 1021 | 1021 | if ($forum_topics > 0) { |
| 1022 | 1022 | $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
| 1023 | - WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
|
| 1023 | + WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int) $new_id; |
|
| 1024 | 1024 | Database::query($sql); |
| 1025 | 1025 | } |
| 1026 | 1026 | } |
@@ -1090,13 +1090,13 @@ discard block |
||
| 1090 | 1090 | $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
| 1091 | 1091 | $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
| 1092 | 1092 | |
| 1093 | - $params = (array)$topic->obj; |
|
| 1093 | + $params = (array) $topic->obj; |
|
| 1094 | 1094 | $params = self::DBUTF8_array($params); |
| 1095 | 1095 | $params['c_id'] = $this->destination_course_id; |
| 1096 | 1096 | $params['forum_id'] = $forum_id; |
| 1097 | 1097 | $params['thread_poster_id'] = $this->first_teacher_id; |
| 1098 | 1098 | $params['thread_date'] = api_get_utc_datetime(); |
| 1099 | - $params['thread_close_date'] = '0000-00-00 00:00:00'; |
|
| 1099 | + $params['thread_close_date'] = '0000-00-00 00:00:00'; |
|
| 1100 | 1100 | $params['thread_last_post'] = 0; |
| 1101 | 1101 | $params['thread_replies'] = 0; |
| 1102 | 1102 | $params['thread_views'] = 0; |
@@ -1202,7 +1202,7 @@ discard block |
||
| 1202 | 1202 | FROM $link_table |
| 1203 | 1203 | WHERE |
| 1204 | 1204 | c_id = ".$this->destination_course_id." AND |
| 1205 | - category_id='" . intval($cat_id). "'"; |
|
| 1205 | + category_id='" . intval($cat_id)."'"; |
|
| 1206 | 1206 | $result = Database::query($sql); |
| 1207 | 1207 | list($max_order) = Database::fetch_array($result); |
| 1208 | 1208 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | $params['description'] = self::DBUTF8($link->description); |
| 1218 | 1218 | $params['category_id'] = $cat_id; |
| 1219 | 1219 | $params['on_homepage'] = $link->on_homepage; |
| 1220 | - $params['display_order'] = $max_order+1; |
|
| 1220 | + $params['display_order'] = $max_order + 1; |
|
| 1221 | 1221 | |
| 1222 | 1222 | $id = Database::insert($link_table, $params); |
| 1223 | 1223 | |
@@ -1261,9 +1261,9 @@ discard block |
||
| 1261 | 1261 | if (is_object($link_cat) && !$link_cat->is_restored()) { |
| 1262 | 1262 | $sql = "SELECT MAX(display_order) FROM $link_cat_table |
| 1263 | 1263 | WHERE c_id = ".$this->destination_course_id." "; |
| 1264 | - $result=Database::query($sql); |
|
| 1265 | - list($orderMax)=Database::fetch_array($result,'NUM'); |
|
| 1266 | - $display_order=$orderMax+1; |
|
| 1264 | + $result = Database::query($sql); |
|
| 1265 | + list($orderMax) = Database::fetch_array($result, 'NUM'); |
|
| 1266 | + $display_order = $orderMax + 1; |
|
| 1267 | 1267 | |
| 1268 | 1268 | $params['c_id'] = $this->destination_course_id; |
| 1269 | 1269 | $params['category_title'] = self::DBUTF8($link_cat->title); |
@@ -1639,9 +1639,9 @@ discard block |
||
| 1639 | 1639 | if (!empty($quiz->sound)) { |
| 1640 | 1640 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
| 1641 | 1641 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
| 1642 | - $sql = "SELECT path FROM " . $table_doc . " |
|
| 1642 | + $sql = "SELECT path FROM ".$table_doc." |
|
| 1643 | 1643 | WHERE |
| 1644 | - c_id = " . $this->destination_course_id . " AND |
|
| 1644 | + c_id = " . $this->destination_course_id." AND |
|
| 1645 | 1645 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
| 1646 | 1646 | $doc = Database::query($sql); |
| 1647 | 1647 | $doc = Database::fetch_object($doc); |
@@ -1675,19 +1675,19 @@ discard block |
||
| 1675 | 1675 | 'random' => $quiz->random, |
| 1676 | 1676 | 'active' => $quiz->active, |
| 1677 | 1677 | 'sound' => self::DBUTF8($doc), |
| 1678 | - 'max_attempt' => (int)$quiz->max_attempt, |
|
| 1679 | - 'results_disabled' => (int)$quiz->results_disabled, |
|
| 1678 | + 'max_attempt' => (int) $quiz->max_attempt, |
|
| 1679 | + 'results_disabled' => (int) $quiz->results_disabled, |
|
| 1680 | 1680 | 'access_condition' => $quiz->access_condition, |
| 1681 | 1681 | 'start_time' => $quiz->start_time, |
| 1682 | 1682 | 'pass_percentage' => $quiz->pass_percentage, |
| 1683 | 1683 | 'end_time' => $quiz->end_time, |
| 1684 | - 'feedback_type' => (int)$quiz->feedback_type, |
|
| 1685 | - 'random_answers' => (int)$quiz->random_answers, |
|
| 1684 | + 'feedback_type' => (int) $quiz->feedback_type, |
|
| 1685 | + 'random_answers' => (int) $quiz->random_answers, |
|
| 1686 | 1686 | 'random_by_category' => $quiz->random_by_category, |
| 1687 | 1687 | 'review_answers' => $quiz->review_answers, |
| 1688 | 1688 | 'propagate_neg' => $quiz->propagate_neg, |
| 1689 | 1689 | 'text_when_finished' => $quiz->text_when_finished, |
| 1690 | - 'expired_time' => (int)$quiz->expired_time, |
|
| 1690 | + 'expired_time' => (int) $quiz->expired_time, |
|
| 1691 | 1691 | ); |
| 1692 | 1692 | |
| 1693 | 1693 | if ($respect_base_content) { |
@@ -1723,9 +1723,9 @@ discard block |
||
| 1723 | 1723 | $qid = $this->restore_quiz_question($question_id); |
| 1724 | 1724 | $question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order; |
| 1725 | 1725 | $sql = "INSERT IGNORE INTO $table_rel SET |
| 1726 | - c_id = " . $this->destination_course_id . ", |
|
| 1727 | - question_id = " . $qid . ", |
|
| 1728 | - exercice_id = " . $new_id . ", |
|
| 1726 | + c_id = ".$this->destination_course_id.", |
|
| 1727 | + question_id = " . $qid.", |
|
| 1728 | + exercice_id = " . $new_id.", |
|
| 1729 | 1729 | question_order = " . $question_order; |
| 1730 | 1730 | Database::query($sql); |
| 1731 | 1731 | } |
@@ -1800,7 +1800,7 @@ discard block |
||
| 1800 | 1800 | $sql = "UPDATE $table_que SET |
| 1801 | 1801 | picture = '$picture_name' |
| 1802 | 1802 | WHERE |
| 1803 | - c_id = " . $this->destination_course_id . " AND |
|
| 1803 | + c_id = ".$this->destination_course_id." AND |
|
| 1804 | 1804 | id = $new_id "; |
| 1805 | 1805 | Database::query($sql); |
| 1806 | 1806 | } |
@@ -1955,7 +1955,7 @@ discard block |
||
| 1955 | 1955 | } |
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | - foreach($correct_answers as $answer_id => $correct_answer) { |
|
| 1958 | + foreach ($correct_answers as $answer_id => $correct_answer) { |
|
| 1959 | 1959 | $params = array(); |
| 1960 | 1960 | $params['correct'] = $new_options[$correct_answer]; |
| 1961 | 1961 | Database::update( |
@@ -1989,7 +1989,7 @@ discard block |
||
| 1989 | 1989 | $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table |
| 1990 | 1990 | if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) { |
| 1991 | 1991 | $resources = $this->course->resources; |
| 1992 | - foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory ) { |
|
| 1992 | + foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory) { |
|
| 1993 | 1993 | $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id; |
| 1994 | 1994 | // check if this test_category already exist in the destination BDD |
| 1995 | 1995 | // do not Database::escape_string $title and $description, it will be done later |
@@ -2135,7 +2135,7 @@ discard block |
||
| 2135 | 2135 | break; |
| 2136 | 2136 | case FILE_RENAME: |
| 2137 | 2137 | $survey_code = $survey->code.'_'; |
| 2138 | - $i=1; |
|
| 2138 | + $i = 1; |
|
| 2139 | 2139 | $temp_survey_code = $survey_code.$i; |
| 2140 | 2140 | while (!$this->is_survey_code_available($temp_survey_code)) { |
| 2141 | 2141 | $temp_survey_code = $survey_code.++$i; |
@@ -2167,15 +2167,15 @@ discard block |
||
| 2167 | 2167 | $sql = "SELECT * FROM $table_sur |
| 2168 | 2168 | WHERE |
| 2169 | 2169 | c_id = ".$this->destination_course_id." AND |
| 2170 | - survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
|
| 2170 | + survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'"; |
|
| 2171 | 2171 | $result = Database::query($sql); |
| 2172 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
| 2172 | + $survey_data = Database::fetch_array($result, 'ASSOC'); |
|
| 2173 | 2173 | |
| 2174 | 2174 | // if the survey is shared => also delete the shared content |
| 2175 | 2175 | if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
| 2176 | - SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
|
| 2176 | + SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id); |
|
| 2177 | 2177 | } |
| 2178 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
| 2178 | + SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id); |
|
| 2179 | 2179 | |
| 2180 | 2180 | // Insert the new source survey |
| 2181 | 2181 | $new_id = Database::insert($table_sur, $params); |
@@ -2251,7 +2251,7 @@ discard block |
||
| 2251 | 2251 | $resources = $this->course->resources; |
| 2252 | 2252 | $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
| 2253 | 2253 | |
| 2254 | - $new_id=0; |
|
| 2254 | + $new_id = 0; |
|
| 2255 | 2255 | |
| 2256 | 2256 | if (is_object($question)) { |
| 2257 | 2257 | if ($question->is_restored()) { |
@@ -2356,14 +2356,14 @@ discard block |
||
| 2356 | 2356 | |
| 2357 | 2357 | // Adding the author's image |
| 2358 | 2358 | if (!empty($lp->preview_image)) { |
| 2359 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
| 2359 | + $new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image)); |
|
| 2360 | 2360 | if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
| 2361 | 2361 | $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
| 2362 | 2362 | //$copy_result = true; |
| 2363 | 2363 | if ($copy_result) { |
| 2364 | 2364 | $lp->preview_image = $new_filename; |
| 2365 | 2365 | } else { |
| 2366 | - $lp->preview_image =''; |
|
| 2366 | + $lp->preview_image = ''; |
|
| 2367 | 2367 | } |
| 2368 | 2368 | } |
| 2369 | 2369 | } |
@@ -2524,20 +2524,20 @@ discard block |
||
| 2524 | 2524 | $next_item_ids[$new_item_id] = $item['next_item_id']; |
| 2525 | 2525 | |
| 2526 | 2526 | if (!empty($item['prerequisite'])) { |
| 2527 | - if ($lp->lp_type =='2') { |
|
| 2527 | + if ($lp->lp_type == '2') { |
|
| 2528 | 2528 | // if is an sco |
| 2529 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
| 2529 | + $old_prerequisite[$new_item_id] = $item['prerequisite']; |
|
| 2530 | 2530 | } else { |
| 2531 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
| 2531 | + $old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']]; |
|
| 2532 | 2532 | } |
| 2533 | 2533 | } |
| 2534 | 2534 | |
| 2535 | 2535 | if (!empty($ref)) { |
| 2536 | - if ($lp->lp_type =='2') { |
|
| 2536 | + if ($lp->lp_type == '2') { |
|
| 2537 | 2537 | // if is an sco |
| 2538 | - $old_refs[$new_item_id]= $ref; |
|
| 2538 | + $old_refs[$new_item_id] = $ref; |
|
| 2539 | 2539 | } else { |
| 2540 | - $old_refs[$new_item_id]= $new_item_ids[$ref]; |
|
| 2540 | + $old_refs[$new_item_id] = $new_item_ids[$ref]; |
|
| 2541 | 2541 | } |
| 2542 | 2542 | } |
| 2543 | 2543 | |
@@ -2546,7 +2546,7 @@ discard block |
||
| 2546 | 2546 | |
| 2547 | 2547 | // Updating prerequisites |
| 2548 | 2548 | foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
| 2549 | - if($my_old_prerequisite != ''){ |
|
| 2549 | + if ($my_old_prerequisite != '') { |
|
| 2550 | 2550 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
| 2551 | 2551 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
| 2552 | 2552 | Database::query($sql); |
@@ -2564,7 +2564,7 @@ discard block |
||
| 2564 | 2564 | |
| 2565 | 2565 | foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
| 2566 | 2566 | $parent_new_id = 0; |
| 2567 | - if($parent_item_old_id != 0){ |
|
| 2567 | + if ($parent_item_old_id != 0) { |
|
| 2568 | 2568 | $parent_new_id = $new_item_ids[$parent_item_old_id]; |
| 2569 | 2569 | } |
| 2570 | 2570 | $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
@@ -2573,7 +2573,7 @@ discard block |
||
| 2573 | 2573 | } |
| 2574 | 2574 | foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
| 2575 | 2575 | $previous_new_id = 0; |
| 2576 | - if($previous_item_old_id != 0){ |
|
| 2576 | + if ($previous_item_old_id != 0) { |
|
| 2577 | 2577 | $previous_new_id = $new_item_ids[$previous_item_old_id]; |
| 2578 | 2578 | } |
| 2579 | 2579 | $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
@@ -2583,7 +2583,7 @@ discard block |
||
| 2583 | 2583 | |
| 2584 | 2584 | foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
| 2585 | 2585 | $next_new_id = 0; |
| 2586 | - if($next_item_old_id != 0){ |
|
| 2586 | + if ($next_item_old_id != 0) { |
|
| 2587 | 2587 | $next_new_id = $new_item_ids[$next_item_old_id]; |
| 2588 | 2588 | } |
| 2589 | 2589 | $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
@@ -2593,7 +2593,7 @@ discard block |
||
| 2593 | 2593 | |
| 2594 | 2594 | foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
| 2595 | 2595 | $prerequisite_new_id = 0; |
| 2596 | - if($prerequisite_old_id != 0){ |
|
| 2596 | + if ($prerequisite_old_id != 0) { |
|
| 2597 | 2597 | $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
| 2598 | 2598 | } |
| 2599 | 2599 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
@@ -2613,9 +2613,9 @@ discard block |
||
| 2613 | 2613 | public function restore_student_publication($sessionId = 0) |
| 2614 | 2614 | { |
| 2615 | 2615 | $sessionId = intval($sessionId); |
| 2616 | - $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
| 2616 | + $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
| 2617 | 2617 | $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
| 2618 | - $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 2618 | + $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 2619 | 2619 | |
| 2620 | 2620 | // Query in student publication |
| 2621 | 2621 | $sql = 'SELECT * FROM '.$work_table.' |
@@ -2693,7 +2693,7 @@ discard block |
||
| 2693 | 2693 | |
| 2694 | 2694 | $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
| 2695 | 2695 | $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
| 2696 | - self::allow_create_all_directory($origin,$destination,false); |
|
| 2696 | + self::allow_create_all_directory($origin, $destination, false); |
|
| 2697 | 2697 | } |
| 2698 | 2698 | |
| 2699 | 2699 | /** |
@@ -2712,16 +2712,16 @@ discard block |
||
| 2712 | 2712 | if ($handle = opendir($source)) { // if the folder exploration is sucsessful, continue |
| 2713 | 2713 | while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue |
| 2714 | 2714 | if ($file != '.' && $file != '..') { |
| 2715 | - $path = $source . '/' . $file; |
|
| 2715 | + $path = $source.'/'.$file; |
|
| 2716 | 2716 | if (is_file($path)) { |
| 2717 | 2717 | /* if (!is_file($dest . '/' . $file) || $overwrite) |
| 2718 | 2718 | if (!@copy($path, $dest . '/' . $file)) { |
| 2719 | 2719 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
| 2720 | 2720 | }*/ |
| 2721 | - } elseif(is_dir($path)) { |
|
| 2722 | - if (!is_dir($dest . '/' . $file)) |
|
| 2723 | - mkdir($dest . '/' . $file); |
|
| 2724 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
| 2721 | + } elseif (is_dir($path)) { |
|
| 2722 | + if (!is_dir($dest.'/'.$file)) |
|
| 2723 | + mkdir($dest.'/'.$file); |
|
| 2724 | + self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite); |
|
| 2725 | 2725 | } |
| 2726 | 2726 | } |
| 2727 | 2727 | } |
@@ -2908,7 +2908,7 @@ discard block |
||
| 2908 | 2908 | $this->course->backup_path, |
| 2909 | 2909 | $this->course->info['path'] |
| 2910 | 2910 | ); |
| 2911 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
| 2911 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
| 2912 | 2912 | unset($thematic->params['id']); |
| 2913 | 2913 | unset($thematic->params['iid']); |
| 2914 | 2914 | |
@@ -2932,7 +2932,7 @@ discard block |
||
| 2932 | 2932 | unset($thematic_advance['iid']); |
| 2933 | 2933 | $thematic_advance['attendance_id'] = 0; |
| 2934 | 2934 | $thematic_advance['thematic_id'] = $last_id; |
| 2935 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 2935 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 2936 | 2936 | $my_id = Database::insert( |
| 2937 | 2937 | $table_thematic_advance, |
| 2938 | 2938 | $thematic_advance, |
@@ -2954,7 +2954,7 @@ discard block |
||
| 2954 | 2954 | } |
| 2955 | 2955 | } |
| 2956 | 2956 | |
| 2957 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
| 2957 | + foreach ($thematic->thematic_plan_list as $thematic_plan) { |
|
| 2958 | 2958 | unset($thematic_plan['id']); |
| 2959 | 2959 | unset($thematic_plan['iid']); |
| 2960 | 2960 | $thematic_plan['thematic_id'] = $last_id; |
@@ -3070,7 +3070,7 @@ discard block |
||
| 3070 | 3070 | // re-create dir |
| 3071 | 3071 | // @todo check security against injection of dir in crafted course backup here! |
| 3072 | 3072 | $path = $obj->params['url']; |
| 3073 | - $path = '/'.str_replace('/','',substr($path,1)); |
|
| 3073 | + $path = '/'.str_replace('/', '', substr($path, 1)); |
|
| 3074 | 3074 | |
| 3075 | 3075 | $workData = array(); |
| 3076 | 3076 | switch ($this->file_option) { |
@@ -3092,9 +3092,9 @@ discard block |
||
| 3092 | 3092 | $obj->params['new_dir'] = $obj->params['title']; |
| 3093 | 3093 | |
| 3094 | 3094 | if (!empty($this->course_origin_id)) { |
| 3095 | - $sql = 'SELECT * FROM ' . $table_work_assignment . ' |
|
| 3095 | + $sql = 'SELECT * FROM '.$table_work_assignment.' |
|
| 3096 | 3096 | WHERE |
| 3097 | - c_id = ' . $this->course_origin_id . ' AND |
|
| 3097 | + c_id = ' . $this->course_origin_id.' AND |
|
| 3098 | 3098 | publication_id = ' . $id_work; |
| 3099 | 3099 | |
| 3100 | 3100 | $result = Database::query($sql); |
@@ -3206,7 +3206,7 @@ discard block |
||
| 3206 | 3206 | public function DBUTF8_array($array) |
| 3207 | 3207 | { |
| 3208 | 3208 | if (UTF8_CONVERT) { |
| 3209 | - foreach ($array as &$item) { |
|
| 3209 | + foreach ($array as &$item) { |
|
| 3210 | 3210 | $item = utf8_encode($item); |
| 3211 | 3211 | } |
| 3212 | 3212 | return $array; |
@@ -512,7 +512,9 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | if (in_array($file_info['extension'], array('html', 'htm'))) { |
| 514 | 514 | $content = file_get_contents($path.$document->path); |
| 515 | - if (UTF8_CONVERT) $content = utf8_encode($content); |
|
| 515 | + if (UTF8_CONVERT) { |
|
| 516 | + $content = utf8_encode($content); |
|
| 517 | + } |
|
| 516 | 518 | $content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 517 | 519 | $content, |
| 518 | 520 | $this->course->code, |
@@ -2240,7 +2242,11 @@ discard block |
||
| 2240 | 2242 | c_id = ".$this->destination_course_id." AND |
| 2241 | 2243 | code='".self::DBUTF8escapestring($survey_code)."'"; |
| 2242 | 2244 | $result = Database::query($sql); |
| 2243 | - if (Database::num_rows($result) > 0) return false; else return true; |
|
| 2245 | + if (Database::num_rows($result) > 0) { |
|
| 2246 | + return false; |
|
| 2247 | + } else { |
|
| 2248 | + return true; |
|
| 2249 | + } |
|
| 2244 | 2250 | } |
| 2245 | 2251 | |
| 2246 | 2252 | /** |
@@ -2719,8 +2725,9 @@ discard block |
||
| 2719 | 2725 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
| 2720 | 2726 | }*/ |
| 2721 | 2727 | } elseif(is_dir($path)) { |
| 2722 | - if (!is_dir($dest . '/' . $file)) |
|
| 2723 | - mkdir($dest . '/' . $file); |
|
| 2728 | + if (!is_dir($dest . '/' . $file)) { |
|
| 2729 | + mkdir($dest . '/' . $file); |
|
| 2730 | + } |
|
| 2724 | 2731 | self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
| 2725 | 2732 | } |
| 2726 | 2733 | } |
@@ -1212,6 +1212,7 @@ |
||
| 1212 | 1212 | * Restore a forum-post |
| 1213 | 1213 | * @TODO Restore tree-structure of posts. For example: attachments to posts. |
| 1214 | 1214 | * @param false|string $topic_id |
| 1215 | + * @param false|string $forum_id |
|
| 1215 | 1216 | */ |
| 1216 | 1217 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
| 1217 | 1218 | { |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class CourseRestorer |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * The course-object |
|
| 41 | - */ |
|
| 39 | + /** |
|
| 40 | + * The course-object |
|
| 41 | + */ |
|
| 42 | 42 | public $course; |
| 43 | 43 | public $destination_course_info; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
| 47 | - * FILE_OVERWRITE) |
|
| 48 | - */ |
|
| 45 | + /** |
|
| 46 | + * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
| 47 | + * FILE_OVERWRITE) |
|
| 48 | + */ |
|
| 49 | 49 | public $file_option; |
| 50 | 50 | public $set_tools_invisible_by_default; |
| 51 | 51 | public $skip_content; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | 'events', |
| 58 | 58 | 'forum_category', |
| 59 | 59 | 'forums', |
| 60 | - // 'forum_topics', |
|
| 60 | + // 'forum_topics', |
|
| 61 | 61 | 'glossary', |
| 62 | 62 | 'quizzes', |
| 63 | 63 | 'test_category', |
@@ -126,15 +126,15 @@ discard block |
||
| 126 | 126 | $this->tool_copy_settings = $array; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Restore a course. |
|
| 129 | + /** |
|
| 130 | + * Restore a course. |
|
| 131 | 131 | * |
| 132 | - * @param string $destination_course_code code of the Chamilo-course in |
|
| 133 | - * @param int $session_id |
|
| 134 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
| 132 | + * @param string $destination_course_code code of the Chamilo-course in |
|
| 133 | + * @param int $session_id |
|
| 134 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
| 135 | 135 | * @param bool $respect_base_content |
| 136 | 136 | * @return false|null |
| 137 | - */ |
|
| 137 | + */ |
|
| 138 | 138 | public function restore( |
| 139 | 139 | $destination_course_code = '', |
| 140 | 140 | $session_id = 0, |
@@ -277,17 +277,17 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - /** |
|
| 281 | - * Restore only harmless course settings: |
|
| 280 | + /** |
|
| 281 | + * Restore only harmless course settings: |
|
| 282 | 282 | * course_language, visibility, department_name,department_url, |
| 283 | 283 | * subscribe, unsubscribe ,category_code |
| 284 | - * |
|
| 285 | - * @param string $destination_course_code |
|
| 286 | - */ |
|
| 284 | + * |
|
| 285 | + * @param string $destination_course_code |
|
| 286 | + */ |
|
| 287 | 287 | public function restore_course_settings($destination_course_code) |
| 288 | 288 | { |
| 289 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
| 290 | - $course_info = $this->course->info; |
|
| 289 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
| 290 | + $course_info = $this->course->info; |
|
| 291 | 291 | $params['course_language'] = $course_info['language']; |
| 292 | 292 | $params['visibility'] = $course_info['visibility']; |
| 293 | 293 | $params['department_name'] = $course_info['department_name']; |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | $params['category_code'] = $course_info['categoryCode']; |
| 297 | 297 | $params['subscribe'] = $course_info['subscribe_allowed']; |
| 298 | 298 | $params['unsubscribe'] = $course_info['unsubscribe']; |
| 299 | - CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
| 300 | - } |
|
| 299 | + CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | 303 | * Restore documents |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | $course_info = api_get_course_info($destination_course_code); |
| 312 | 312 | |
| 313 | 313 | if ($this->course->has_resources(RESOURCE_DOCUMENT)) { |
| 314 | - $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
| 315 | - $resources = $this->course->resources; |
|
| 314 | + $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
| 315 | + $resources = $this->course->resources; |
|
| 316 | 316 | $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
| 317 | 317 | |
| 318 | - foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
| 318 | + foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
| 319 | 319 | |
| 320 | 320 | if (empty($document->item_properties[0]['id_session'])) { |
| 321 | 321 | $my_session_id = 0; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | - } elseif ($document->file_type == DOCUMENT) { |
|
| 388 | + } elseif ($document->file_type == DOCUMENT) { |
|
| 389 | 389 | //Checking if folder exists in the database otherwise we created it |
| 390 | 390 | $dir_to_create = dirname($document->path); |
| 391 | 391 | |
@@ -441,19 +441,19 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if (file_exists($path.$document->path)) { |
|
| 445 | - switch ($this->file_option) { |
|
| 446 | - case FILE_OVERWRITE: |
|
| 444 | + if (file_exists($path.$document->path)) { |
|
| 445 | + switch ($this->file_option) { |
|
| 446 | + case FILE_OVERWRITE: |
|
| 447 | 447 | $origin_path = $this->course->backup_path.'/'.$document->path; |
| 448 | 448 | |
| 449 | - if (file_exists($origin_path)) { |
|
| 450 | - copy($origin_path, $path.$document->path); |
|
| 449 | + if (file_exists($origin_path)) { |
|
| 450 | + copy($origin_path, $path.$document->path); |
|
| 451 | 451 | $sql = "SELECT id FROM $table |
| 452 | 452 | WHERE |
| 453 | 453 | c_id = ".$this->destination_course_id." AND |
| 454 | 454 | path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
| 455 | 455 | |
| 456 | - $res = Database::query($sql); |
|
| 456 | + $res = Database::query($sql); |
|
| 457 | 457 | $count = Database::num_rows($res); |
| 458 | 458 | |
| 459 | 459 | if ($count == 0) { |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | 'session_id' => $my_session_id, |
| 468 | 468 | ]; |
| 469 | 469 | |
| 470 | - $document_id = Database::insert($table, $params); |
|
| 470 | + $document_id = Database::insert($table, $params); |
|
| 471 | 471 | |
| 472 | 472 | if ($document_id) { |
| 473 | 473 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -575,83 +575,83 @@ discard block |
||
| 575 | 575 | ], |
| 576 | 576 | ] |
| 577 | 577 | ); |
| 578 | - } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - break; |
|
| 581 | - case FILE_SKIP: |
|
| 582 | - $sql = "SELECT id FROM $table |
|
| 580 | + break; |
|
| 581 | + case FILE_SKIP: |
|
| 582 | + $sql = "SELECT id FROM $table |
|
| 583 | 583 | WHERE |
| 584 | 584 | c_id = ".$this->destination_course_id." AND |
| 585 | 585 | path='/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
| 586 | - $res = Database::query($sql); |
|
| 587 | - $obj = Database::fetch_object($res); |
|
| 588 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
| 589 | - break; |
|
| 590 | - case FILE_RENAME: |
|
| 591 | - $i = 1; |
|
| 592 | - $ext = explode('.', basename($document->path)); |
|
| 593 | - if (count($ext) > 1) { |
|
| 594 | - $ext = array_pop($ext); |
|
| 595 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
| 596 | - $ext = '.'.$ext; |
|
| 597 | - } else { |
|
| 598 | - $ext = ''; |
|
| 599 | - $file_name_no_ext = $document->path; |
|
| 600 | - } |
|
| 601 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 602 | - $file_exists = file_exists($path.$new_file_name); |
|
| 603 | - while ($file_exists) { |
|
| 604 | - $i ++; |
|
| 605 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 606 | - $file_exists = file_exists($path.$new_file_name); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - if (!empty($session_id)) { |
|
| 610 | - |
|
| 611 | - $document_path = explode('/',$document->path,3); |
|
| 612 | - $course_path = $path; |
|
| 613 | - $orig_base_folder = $document_path[1]; |
|
| 614 | - $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
| 615 | - |
|
| 616 | - if (is_dir($orig_base_path)) { |
|
| 617 | - |
|
| 618 | - $new_base_foldername = $orig_base_folder; |
|
| 619 | - $new_base_path = $orig_base_path; |
|
| 620 | - |
|
| 621 | - if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
| 622 | - unset($_SESSION['new_base_foldername']); |
|
| 623 | - unset($_SESSION['orig_base_foldername']); |
|
| 624 | - unset($_SESSION['new_base_path']); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - $folder_exists = file_exists($new_base_path); |
|
| 628 | - if ($folder_exists) { |
|
| 629 | - $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
| 630 | - $x = ''; |
|
| 631 | - while ($folder_exists) { |
|
| 632 | - $x = $x + 1; |
|
| 633 | - $new_base_foldername = $document_path[1].'_'.$x; |
|
| 634 | - $new_base_path = $orig_base_path.'_'.$x; |
|
| 586 | + $res = Database::query($sql); |
|
| 587 | + $obj = Database::fetch_object($res); |
|
| 588 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
| 589 | + break; |
|
| 590 | + case FILE_RENAME: |
|
| 591 | + $i = 1; |
|
| 592 | + $ext = explode('.', basename($document->path)); |
|
| 593 | + if (count($ext) > 1) { |
|
| 594 | + $ext = array_pop($ext); |
|
| 595 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
| 596 | + $ext = '.'.$ext; |
|
| 597 | + } else { |
|
| 598 | + $ext = ''; |
|
| 599 | + $file_name_no_ext = $document->path; |
|
| 600 | + } |
|
| 601 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 602 | + $file_exists = file_exists($path.$new_file_name); |
|
| 603 | + while ($file_exists) { |
|
| 604 | + $i ++; |
|
| 605 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 606 | + $file_exists = file_exists($path.$new_file_name); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + if (!empty($session_id)) { |
|
| 610 | + |
|
| 611 | + $document_path = explode('/',$document->path,3); |
|
| 612 | + $course_path = $path; |
|
| 613 | + $orig_base_folder = $document_path[1]; |
|
| 614 | + $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
| 615 | + |
|
| 616 | + if (is_dir($orig_base_path)) { |
|
| 617 | + |
|
| 618 | + $new_base_foldername = $orig_base_folder; |
|
| 619 | + $new_base_path = $orig_base_path; |
|
| 620 | + |
|
| 621 | + if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
| 622 | + unset($_SESSION['new_base_foldername']); |
|
| 623 | + unset($_SESSION['orig_base_foldername']); |
|
| 624 | + unset($_SESSION['new_base_path']); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + $folder_exists = file_exists($new_base_path); |
|
| 628 | + if ($folder_exists) { |
|
| 629 | + $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
| 630 | + $x = ''; |
|
| 631 | + while ($folder_exists) { |
|
| 632 | + $x = $x + 1; |
|
| 633 | + $new_base_foldername = $document_path[1].'_'.$x; |
|
| 634 | + $new_base_path = $orig_base_path.'_'.$x; |
|
| 635 | 635 | if ($_SESSION['new_base_foldername'] == $new_base_foldername) { |
| 636 | 636 | break; |
| 637 | 637 | } |
| 638 | - $folder_exists = file_exists($new_base_path); |
|
| 639 | - } |
|
| 640 | - $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
| 641 | - $_SESSION['new_base_path'] = $new_base_path; |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
| 645 | - $new_base_foldername = $_SESSION['new_base_foldername']; |
|
| 646 | - $new_base_path = $_SESSION['new_base_path']; |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
| 650 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
| 651 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
| 652 | - $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
| 653 | - |
|
| 654 | - copy_folder_course_session( |
|
| 638 | + $folder_exists = file_exists($new_base_path); |
|
| 639 | + } |
|
| 640 | + $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
| 641 | + $_SESSION['new_base_path'] = $new_base_path; |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
| 645 | + $new_base_foldername = $_SESSION['new_base_foldername']; |
|
| 646 | + $new_base_path = $_SESSION['new_base_path']; |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
| 650 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
| 651 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
| 652 | + $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
| 653 | + |
|
| 654 | + copy_folder_course_session( |
|
| 655 | 655 | $basedir_dest_path, |
| 656 | 656 | $base_path_document, |
| 657 | 657 | $session_id, |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | 'session_id' => $my_session_id, |
| 694 | 694 | ]; |
| 695 | 695 | |
| 696 | - $document_id = Database::insert($table, $params); |
|
| 696 | + $document_id = Database::insert($table, $params); |
|
| 697 | 697 | |
| 698 | 698 | if ($document_id) { |
| 699 | 699 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -722,10 +722,10 @@ discard block |
||
| 722 | 722 | null, |
| 723 | 723 | $my_session_id |
| 724 | 724 | ); |
| 725 | - } else { |
|
| 726 | - if (file_exists($path.$document->path)) { |
|
| 725 | + } else { |
|
| 726 | + if (file_exists($path.$document->path)) { |
|
| 727 | 727 | copy($path.$document->path, $path.$new_file_name); |
| 728 | - } |
|
| 728 | + } |
|
| 729 | 729 | //Replace old course code with the new destination code see BT#1985 |
| 730 | 730 | if (file_exists($path.$new_file_name)) { |
| 731 | 731 | $file_info = pathinfo($path.$new_file_name); |
@@ -784,10 +784,10 @@ discard block |
||
| 784 | 784 | $my_session_id |
| 785 | 785 | ); |
| 786 | 786 | } |
| 787 | - } |
|
| 788 | - } else { |
|
| 787 | + } |
|
| 788 | + } else { |
|
| 789 | 789 | |
| 790 | - copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
| 790 | + copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
| 791 | 791 | |
| 792 | 792 | //Replace old course code with the new destination code see BT#1985 |
| 793 | 793 | if (file_exists($path.$new_file_name)) { |
@@ -847,20 +847,20 @@ discard block |
||
| 847 | 847 | null, |
| 848 | 848 | $my_session_id |
| 849 | 849 | ); |
| 850 | - } |
|
| 851 | - break; |
|
| 852 | - |
|
| 853 | - } // end switch |
|
| 854 | - } else { |
|
| 855 | - // end if file exists |
|
| 856 | - //make sure the source file actually exists |
|
| 857 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
| 850 | + } |
|
| 851 | + break; |
|
| 852 | + |
|
| 853 | + } // end switch |
|
| 854 | + } else { |
|
| 855 | + // end if file exists |
|
| 856 | + //make sure the source file actually exists |
|
| 857 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
| 858 | 858 | is_readable($this->course->backup_path.'/'.$document->path) && |
| 859 | 859 | is_dir(dirname($path.$document->path)) && |
| 860 | 860 | is_writeable(dirname($path.$document->path)) |
| 861 | 861 | ) { |
| 862 | - //echo 'Copying'; |
|
| 863 | - copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
| 862 | + //echo 'Copying'; |
|
| 863 | + copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
| 864 | 864 | |
| 865 | 865 | //Replace old course code with the new destination code see BT#1985 |
| 866 | 866 | if (file_exists($path.$document->path)) { |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | Database::query($sql); |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
| 901 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
| 902 | 902 | |
| 903 | 903 | $itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : ''; |
| 904 | 904 | $insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id(); |
@@ -920,79 +920,79 @@ discard block |
||
| 920 | 920 | null, |
| 921 | 921 | $my_session_id |
| 922 | 922 | ); |
| 923 | - } else { |
|
| 924 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
| 923 | + } else { |
|
| 924 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
| 925 | 925 | is_readable($this->course->backup_path.'/'.$document->path) |
| 926 | 926 | ) { |
| 927 | - error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
| 928 | - } |
|
| 929 | - if (!is_dir(dirname($path.$document->path))) { |
|
| 930 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
| 931 | - } |
|
| 932 | - if (!is_writeable(dirname($path.$document->path))) { |
|
| 933 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
| 934 | - } |
|
| 935 | - } |
|
| 936 | - } // end file doesn't exist |
|
| 937 | - } |
|
| 938 | - } // end for each |
|
| 939 | - |
|
| 940 | - // Delete sessions for the copy the new folder in session |
|
| 941 | - unset($_SESSION['new_base_foldername']); |
|
| 942 | - unset($_SESSION['orig_base_foldername']); |
|
| 943 | - unset($_SESSION['new_base_path']); |
|
| 944 | - } |
|
| 945 | - } |
|
| 946 | - |
|
| 947 | - /** |
|
| 948 | - * Restore scorm documents |
|
| 949 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
| 927 | + error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
| 928 | + } |
|
| 929 | + if (!is_dir(dirname($path.$document->path))) { |
|
| 930 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
| 931 | + } |
|
| 932 | + if (!is_writeable(dirname($path.$document->path))) { |
|
| 933 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
| 934 | + } |
|
| 935 | + } |
|
| 936 | + } // end file doesn't exist |
|
| 937 | + } |
|
| 938 | + } // end for each |
|
| 939 | + |
|
| 940 | + // Delete sessions for the copy the new folder in session |
|
| 941 | + unset($_SESSION['new_base_foldername']); |
|
| 942 | + unset($_SESSION['orig_base_foldername']); |
|
| 943 | + unset($_SESSION['new_base_path']); |
|
| 944 | + } |
|
| 945 | + } |
|
| 946 | + |
|
| 947 | + /** |
|
| 948 | + * Restore scorm documents |
|
| 949 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
| 950 | 950 | * see #7029 |
| 951 | - */ |
|
| 952 | - public function restore_scorm_documents() |
|
| 951 | + */ |
|
| 952 | + public function restore_scorm_documents() |
|
| 953 | 953 | { |
| 954 | - $perm = api_get_permissions_for_new_directories(); |
|
| 954 | + $perm = api_get_permissions_for_new_directories(); |
|
| 955 | 955 | |
| 956 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
| 957 | - $resources = $this->course->resources; |
|
| 956 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
| 957 | + $resources = $this->course->resources; |
|
| 958 | 958 | |
| 959 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
| 960 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
| 959 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
| 960 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
| 961 | 961 | |
| 962 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
| 962 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
| 963 | 963 | |
| 964 | - if (file_exists($path.$document->path)) { |
|
| 965 | - switch ($this->file_option) { |
|
| 966 | - case FILE_OVERWRITE: |
|
| 967 | - rmdirr($path.$document->path); |
|
| 964 | + if (file_exists($path.$document->path)) { |
|
| 965 | + switch ($this->file_option) { |
|
| 966 | + case FILE_OVERWRITE: |
|
| 967 | + rmdirr($path.$document->path); |
|
| 968 | 968 | copyDirTo( |
| 969 | 969 | $this->course->backup_path . '/' . $document->path, |
| 970 | 970 | $path . dirname($document->path), |
| 971 | 971 | false |
| 972 | 972 | ); |
| 973 | - break; |
|
| 974 | - case FILE_SKIP: |
|
| 975 | - break; |
|
| 973 | + break; |
|
| 974 | + case FILE_SKIP: |
|
| 975 | + break; |
|
| 976 | 976 | case FILE_RENAME: |
| 977 | - $i = 1; |
|
| 978 | - $ext = explode('.', basename($document->path)); |
|
| 979 | - if (count($ext) > 1) { |
|
| 980 | - $ext = array_pop($ext); |
|
| 981 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
| 982 | - $ext = '.'.$ext; |
|
| 983 | - } else { |
|
| 984 | - $ext = ''; |
|
| 985 | - $file_name_no_ext = $document->path; |
|
| 986 | - } |
|
| 987 | - |
|
| 988 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 989 | - $file_exists = file_exists($path.$new_file_name); |
|
| 990 | - |
|
| 991 | - while ($file_exists) { |
|
| 992 | - $i ++; |
|
| 993 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 994 | - $file_exists = file_exists($path.$new_file_name); |
|
| 995 | - } |
|
| 977 | + $i = 1; |
|
| 978 | + $ext = explode('.', basename($document->path)); |
|
| 979 | + if (count($ext) > 1) { |
|
| 980 | + $ext = array_pop($ext); |
|
| 981 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
| 982 | + $ext = '.'.$ext; |
|
| 983 | + } else { |
|
| 984 | + $ext = ''; |
|
| 985 | + $file_name_no_ext = $document->path; |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 989 | + $file_exists = file_exists($path.$new_file_name); |
|
| 990 | + |
|
| 991 | + while ($file_exists) { |
|
| 992 | + $i ++; |
|
| 993 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 994 | + $file_exists = file_exists($path.$new_file_name); |
|
| 995 | + } |
|
| 996 | 996 | |
| 997 | 997 | rename( |
| 998 | 998 | $this->course->backup_path . '/' . $document->path, |
@@ -1008,30 +1008,30 @@ discard block |
||
| 1008 | 1008 | $this->course->backup_path . '/' . $document->path |
| 1009 | 1009 | ); |
| 1010 | 1010 | |
| 1011 | - break; |
|
| 1012 | - } // end switch |
|
| 1013 | - } else { |
|
| 1011 | + break; |
|
| 1012 | + } // end switch |
|
| 1013 | + } else { |
|
| 1014 | 1014 | // end if file exists |
| 1015 | 1015 | copyDirTo( |
| 1016 | 1016 | $this->course->backup_path . '/' . $document->path, |
| 1017 | 1017 | $path . dirname($document->path), |
| 1018 | 1018 | false |
| 1019 | 1019 | ); |
| 1020 | - } |
|
| 1021 | - } // end for each |
|
| 1022 | - } |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * Restore forums |
|
| 1027 | - */ |
|
| 1028 | - public function restore_forums($sessionId = 0) |
|
| 1020 | + } |
|
| 1021 | + } // end for each |
|
| 1022 | + } |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Restore forums |
|
| 1027 | + */ |
|
| 1028 | + public function restore_forums($sessionId = 0) |
|
| 1029 | 1029 | { |
| 1030 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
| 1030 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
| 1031 | 1031 | $sessionId = intval($sessionId); |
| 1032 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
| 1033 | - $resources = $this->course->resources; |
|
| 1034 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
| 1032 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
| 1033 | + $resources = $this->course->resources; |
|
| 1034 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
| 1035 | 1035 | $params = (array)$forum->obj; |
| 1036 | 1036 | $cat_id = ''; |
| 1037 | 1037 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1077,33 +1077,33 @@ discard block |
||
| 1077 | 1077 | Database::query($sql); |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
| 1081 | - |
|
| 1082 | - $forum_topics = 0; |
|
| 1083 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
| 1084 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
| 1085 | - if ($topic->obj->forum_id == $id) { |
|
| 1086 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
| 1087 | - $forum_topics ++; |
|
| 1088 | - } |
|
| 1089 | - } |
|
| 1090 | - } |
|
| 1091 | - if ($forum_topics > 0) { |
|
| 1092 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
| 1080 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
| 1081 | + |
|
| 1082 | + $forum_topics = 0; |
|
| 1083 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
| 1084 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
| 1085 | + if ($topic->obj->forum_id == $id) { |
|
| 1086 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
| 1087 | + $forum_topics ++; |
|
| 1088 | + } |
|
| 1089 | + } |
|
| 1090 | + } |
|
| 1091 | + if ($forum_topics > 0) { |
|
| 1092 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
| 1093 | 1093 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
| 1094 | - Database::query($sql); |
|
| 1095 | - } |
|
| 1096 | - } |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - /** |
|
| 1101 | - * Restore forum-categories |
|
| 1102 | - */ |
|
| 1094 | + Database::query($sql); |
|
| 1095 | + } |
|
| 1096 | + } |
|
| 1097 | + } |
|
| 1098 | + } |
|
| 1099 | + |
|
| 1100 | + /** |
|
| 1101 | + * Restore forum-categories |
|
| 1102 | + */ |
|
| 1103 | 1103 | public function restore_forum_category($my_id = null, $sessionId = 0) |
| 1104 | 1104 | { |
| 1105 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
| 1106 | - $resources = $this->course->resources; |
|
| 1105 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
| 1106 | + $resources = $this->course->resources; |
|
| 1107 | 1107 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
| 1108 | 1108 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
| 1109 | 1109 | if (!empty($my_id)) { |
@@ -1150,16 +1150,16 @@ discard block |
||
| 1150 | 1150 | } |
| 1151 | 1151 | } |
| 1152 | 1152 | } |
| 1153 | - } |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - /** |
|
| 1156 | - * Restore a forum-topic |
|
| 1157 | - * @param false|string $forum_id |
|
| 1158 | - */ |
|
| 1155 | + /** |
|
| 1156 | + * Restore a forum-topic |
|
| 1157 | + * @param false|string $forum_id |
|
| 1158 | + */ |
|
| 1159 | 1159 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
| 1160 | 1160 | { |
| 1161 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 1162 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
| 1161 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 1162 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
| 1163 | 1163 | |
| 1164 | 1164 | $params = (array)$topic->obj; |
| 1165 | 1165 | $params = self::DBUTF8_array($params); |
@@ -1195,28 +1195,28 @@ discard block |
||
| 1195 | 1195 | $sessionId |
| 1196 | 1196 | ); |
| 1197 | 1197 | |
| 1198 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
| 1198 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
| 1199 | 1199 | |
| 1200 | - $topic_replies = -1; |
|
| 1200 | + $topic_replies = -1; |
|
| 1201 | 1201 | |
| 1202 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
| 1203 | - if ($post->obj->thread_id == $thread_id) { |
|
| 1204 | - $topic_replies++; |
|
| 1205 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
| 1206 | - } |
|
| 1207 | - } |
|
| 1208 | - return $new_id; |
|
| 1209 | - } |
|
| 1202 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
| 1203 | + if ($post->obj->thread_id == $thread_id) { |
|
| 1204 | + $topic_replies++; |
|
| 1205 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
| 1206 | + } |
|
| 1207 | + } |
|
| 1208 | + return $new_id; |
|
| 1209 | + } |
|
| 1210 | 1210 | |
| 1211 | - /** |
|
| 1212 | - * Restore a forum-post |
|
| 1213 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
| 1214 | - * @param false|string $topic_id |
|
| 1215 | - */ |
|
| 1211 | + /** |
|
| 1212 | + * Restore a forum-post |
|
| 1213 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
| 1214 | + * @param false|string $topic_id |
|
| 1215 | + */ |
|
| 1216 | 1216 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
| 1217 | 1217 | { |
| 1218 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
| 1219 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
| 1218 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
| 1219 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
| 1220 | 1220 | $params = (array) $post->obj; |
| 1221 | 1221 | $params['c_id'] = $this->destination_course_id; |
| 1222 | 1222 | $params['forum_id'] = $forum_id; |
@@ -1251,37 +1251,37 @@ discard block |
||
| 1251 | 1251 | null, |
| 1252 | 1252 | $sessionId |
| 1253 | 1253 | ); |
| 1254 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
| 1254 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
| 1255 | 1255 | |
| 1256 | - return $new_id; |
|
| 1257 | - } |
|
| 1256 | + return $new_id; |
|
| 1257 | + } |
|
| 1258 | 1258 | |
| 1259 | - /** |
|
| 1260 | - * Restore links |
|
| 1261 | - */ |
|
| 1259 | + /** |
|
| 1260 | + * Restore links |
|
| 1261 | + */ |
|
| 1262 | 1262 | public function restore_links($session_id = 0) |
| 1263 | 1263 | { |
| 1264 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
| 1265 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
| 1266 | - $resources = $this->course->resources; |
|
| 1264 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
| 1265 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
| 1266 | + $resources = $this->course->resources; |
|
| 1267 | 1267 | |
| 1268 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
| 1268 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
| 1269 | 1269 | $cat_id = $this->restore_link_category( |
| 1270 | 1270 | $link->category_id, |
| 1271 | 1271 | $session_id |
| 1272 | 1272 | ); |
| 1273 | - $sql = "SELECT MAX(display_order) |
|
| 1273 | + $sql = "SELECT MAX(display_order) |
|
| 1274 | 1274 | FROM $link_table |
| 1275 | 1275 | WHERE |
| 1276 | 1276 | c_id = ".$this->destination_course_id." AND |
| 1277 | 1277 | category_id='" . intval($cat_id). "'"; |
| 1278 | - $result = Database::query($sql); |
|
| 1279 | - list($max_order) = Database::fetch_array($result); |
|
| 1278 | + $result = Database::query($sql); |
|
| 1279 | + list($max_order) = Database::fetch_array($result); |
|
| 1280 | 1280 | |
| 1281 | 1281 | $params = []; |
| 1282 | - if (!empty($session_id)) { |
|
| 1282 | + if (!empty($session_id)) { |
|
| 1283 | 1283 | $params['session_id'] = $session_id; |
| 1284 | - } |
|
| 1284 | + } |
|
| 1285 | 1285 | |
| 1286 | 1286 | $params['c_id'] = $this->destination_course_id; |
| 1287 | 1287 | $params['url'] = self::DBUTF8($link->url); |
@@ -1310,9 +1310,9 @@ discard block |
||
| 1310 | 1310 | } |
| 1311 | 1311 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
| 1312 | 1312 | } |
| 1313 | - } |
|
| 1314 | - } |
|
| 1315 | - } |
|
| 1313 | + } |
|
| 1314 | + } |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | 1317 | /** |
| 1318 | 1318 | * Restore a link-category |
@@ -1356,21 +1356,21 @@ discard block |
||
| 1356 | 1356 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - /** |
|
| 1360 | - * Restore tool intro |
|
| 1361 | - */ |
|
| 1359 | + /** |
|
| 1360 | + * Restore tool intro |
|
| 1361 | + */ |
|
| 1362 | 1362 | public function restore_tool_intro($sessionId = 0) |
| 1363 | 1363 | { |
| 1364 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
| 1364 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
| 1365 | 1365 | $sessionId = intval($sessionId); |
| 1366 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
| 1367 | - $resources = $this->course->resources; |
|
| 1368 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
| 1369 | - $sql = "DELETE FROM ".$tool_intro_table." |
|
| 1366 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
| 1367 | + $resources = $this->course->resources; |
|
| 1368 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
| 1369 | + $sql = "DELETE FROM ".$tool_intro_table." |
|
| 1370 | 1370 | WHERE |
| 1371 | 1371 | c_id = ".$this->destination_course_id." AND |
| 1372 | 1372 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
| 1373 | - Database::query($sql); |
|
| 1373 | + Database::query($sql); |
|
| 1374 | 1374 | |
| 1375 | 1375 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1376 | 1376 | $tool_intro->intro_text, |
@@ -1398,21 +1398,21 @@ discard block |
||
| 1398 | 1398 | |
| 1399 | 1399 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
| 1400 | 1400 | } |
| 1401 | - } |
|
| 1402 | - } |
|
| 1403 | - } |
|
| 1401 | + } |
|
| 1402 | + } |
|
| 1403 | + } |
|
| 1404 | 1404 | |
| 1405 | - /** |
|
| 1406 | - * Restore events |
|
| 1407 | - */ |
|
| 1405 | + /** |
|
| 1406 | + * Restore events |
|
| 1407 | + */ |
|
| 1408 | 1408 | public function restore_events($sessionId = 0) |
| 1409 | 1409 | { |
| 1410 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
| 1410 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
| 1411 | 1411 | $sessionId = intval($sessionId); |
| 1412 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
| 1413 | - $resources = $this->course->resources; |
|
| 1414 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
| 1415 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1412 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
| 1413 | + $resources = $this->course->resources; |
|
| 1414 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
| 1415 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1416 | 1416 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1417 | 1417 | $event->content, |
| 1418 | 1418 | $this->course->code, |
@@ -1430,7 +1430,7 @@ discard block |
||
| 1430 | 1430 | 'end_date' => $event->end_date, |
| 1431 | 1431 | 'session_id' => $sessionId, |
| 1432 | 1432 | ]; |
| 1433 | - $new_event_id = Database::insert($table, $params); |
|
| 1433 | + $new_event_id = Database::insert($table, $params); |
|
| 1434 | 1434 | |
| 1435 | 1435 | if ($new_event_id) { |
| 1436 | 1436 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1443,30 +1443,30 @@ discard block |
||
| 1443 | 1443 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - // Copy event attachment |
|
| 1446 | + // Copy event attachment |
|
| 1447 | 1447 | |
| 1448 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
| 1449 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
| 1448 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
| 1449 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
| 1450 | 1450 | |
| 1451 | - if (!empty($this->course->orig)) { |
|
| 1451 | + if (!empty($this->course->orig)) { |
|
| 1452 | 1452 | |
| 1453 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1454 | - $sql = 'SELECT path, comment, size, filename |
|
| 1453 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1454 | + $sql = 'SELECT path, comment, size, filename |
|
| 1455 | 1455 | FROM '.$table_attachment.' |
| 1456 | 1456 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
| 1457 | - $attachment_event = Database::query($sql); |
|
| 1458 | - $attachment_event = Database::fetch_object($attachment_event); |
|
| 1457 | + $attachment_event = Database::query($sql); |
|
| 1458 | + $attachment_event = Database::fetch_object($attachment_event); |
|
| 1459 | 1459 | |
| 1460 | - if (file_exists($origin_path.$attachment_event->path) && |
|
| 1460 | + if (file_exists($origin_path.$attachment_event->path) && |
|
| 1461 | 1461 | !is_dir($origin_path.$attachment_event->path) |
| 1462 | 1462 | ) { |
| 1463 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1464 | - $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
| 1465 | - //$copy_result = true; |
|
| 1466 | - if ($copy_result) { |
|
| 1467 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1463 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1464 | + $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
| 1465 | + //$copy_result = true; |
|
| 1466 | + if ($copy_result) { |
|
| 1467 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1468 | 1468 | |
| 1469 | - $params = [ |
|
| 1469 | + $params = [ |
|
| 1470 | 1470 | 'c_id' => $this->destination_course_id, |
| 1471 | 1471 | 'path' => self::DBUTF8($new_filename), |
| 1472 | 1472 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1480,17 +1480,17 @@ discard block |
||
| 1480 | 1480 | Database::query($sql); |
| 1481 | 1481 | } |
| 1482 | 1482 | } |
| 1483 | - } |
|
| 1484 | - } else { |
|
| 1485 | - // get the info of the file |
|
| 1486 | - if (!empty($event->attachment_path) && |
|
| 1483 | + } |
|
| 1484 | + } else { |
|
| 1485 | + // get the info of the file |
|
| 1486 | + if (!empty($event->attachment_path) && |
|
| 1487 | 1487 | is_file($origin_path.$event->attachment_path) && |
| 1488 | 1488 | is_readable($origin_path.$event->attachment_path) |
| 1489 | 1489 | ) { |
| 1490 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1491 | - $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
| 1492 | - if ($copy_result) { |
|
| 1493 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1490 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1491 | + $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
| 1492 | + if ($copy_result) { |
|
| 1493 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1494 | 1494 | |
| 1495 | 1495 | $params = [ |
| 1496 | 1496 | 'c_id' => $this->destination_course_id, |
@@ -1506,29 +1506,29 @@ discard block |
||
| 1506 | 1506 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
| 1507 | 1507 | Database::query($sql); |
| 1508 | 1508 | } |
| 1509 | - } |
|
| 1510 | - } |
|
| 1511 | - } |
|
| 1512 | - } |
|
| 1513 | - } |
|
| 1514 | - } |
|
| 1515 | - |
|
| 1516 | - /** |
|
| 1517 | - * Restore course-description |
|
| 1518 | - */ |
|
| 1509 | + } |
|
| 1510 | + } |
|
| 1511 | + } |
|
| 1512 | + } |
|
| 1513 | + } |
|
| 1514 | + } |
|
| 1515 | + |
|
| 1516 | + /** |
|
| 1517 | + * Restore course-description |
|
| 1518 | + */ |
|
| 1519 | 1519 | public function restore_course_descriptions($session_id = 0) |
| 1520 | 1520 | { |
| 1521 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
| 1522 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
| 1523 | - $resources = $this->course->resources; |
|
| 1524 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
| 1521 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
| 1522 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
| 1523 | + $resources = $this->course->resources; |
|
| 1524 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
| 1525 | 1525 | $courseDescription = (array) $cd; |
| 1526 | 1526 | |
| 1527 | 1527 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
| 1528 | 1528 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
| 1529 | 1529 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
| 1530 | 1530 | |
| 1531 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1531 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1532 | 1532 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1533 | 1533 | $content, |
| 1534 | 1534 | $this->course->code, |
@@ -1556,22 +1556,22 @@ discard block |
||
| 1556 | 1556 | } |
| 1557 | 1557 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
| 1558 | 1558 | } |
| 1559 | - } |
|
| 1560 | - } |
|
| 1561 | - } |
|
| 1559 | + } |
|
| 1560 | + } |
|
| 1561 | + } |
|
| 1562 | 1562 | |
| 1563 | - /** |
|
| 1564 | - * Restore announcements |
|
| 1565 | - */ |
|
| 1563 | + /** |
|
| 1564 | + * Restore announcements |
|
| 1565 | + */ |
|
| 1566 | 1566 | public function restore_announcements($sessionId = 0) |
| 1567 | 1567 | { |
| 1568 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
| 1568 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
| 1569 | 1569 | $sessionId = intval($sessionId); |
| 1570 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
| 1571 | - $resources = $this->course->resources; |
|
| 1572 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
| 1570 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
| 1571 | + $resources = $this->course->resources; |
|
| 1572 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
| 1573 | 1573 | |
| 1574 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1574 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1575 | 1575 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1576 | 1576 | $announcement->content, |
| 1577 | 1577 | $this->course->code, |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | 'session_id' => $sessionId, |
| 1591 | 1591 | ]; |
| 1592 | 1592 | |
| 1593 | - $new_announcement_id = Database::insert($table, $params); |
|
| 1593 | + $new_announcement_id = Database::insert($table, $params); |
|
| 1594 | 1594 | |
| 1595 | 1595 | if ($new_announcement_id) { |
| 1596 | 1596 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1602,32 +1602,32 @@ discard block |
||
| 1602 | 1602 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
| 1606 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
| 1605 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
| 1606 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
| 1607 | 1607 | |
| 1608 | - // Copy announcement attachment file |
|
| 1609 | - if (!empty($this->course->orig)) { |
|
| 1608 | + // Copy announcement attachment file |
|
| 1609 | + if (!empty($this->course->orig)) { |
|
| 1610 | 1610 | |
| 1611 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1612 | - $sql = 'SELECT path, comment, size, filename |
|
| 1611 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1612 | + $sql = 'SELECT path, comment, size, filename |
|
| 1613 | 1613 | FROM '.$table_attachment.' |
| 1614 | 1614 | WHERE |
| 1615 | 1615 | c_id = '.$this->destination_course_id.' AND |
| 1616 | 1616 | announcement_id = '.$id; |
| 1617 | - $attachment_event = Database::query($sql); |
|
| 1618 | - $attachment_event = Database::fetch_object($attachment_event); |
|
| 1617 | + $attachment_event = Database::query($sql); |
|
| 1618 | + $attachment_event = Database::fetch_object($attachment_event); |
|
| 1619 | 1619 | |
| 1620 | - if (file_exists($origin_path.$attachment_event->path) && |
|
| 1620 | + if (file_exists($origin_path.$attachment_event->path) && |
|
| 1621 | 1621 | !is_dir($origin_path.$attachment_event->path) |
| 1622 | 1622 | ) { |
| 1623 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1623 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1624 | 1624 | $copy_result = copy( |
| 1625 | 1625 | $origin_path.$attachment_event->path, |
| 1626 | 1626 | $destination_path.$new_filename |
| 1627 | 1627 | ); |
| 1628 | 1628 | |
| 1629 | - if ($copy_result) { |
|
| 1630 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1629 | + if ($copy_result) { |
|
| 1630 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1631 | 1631 | |
| 1632 | 1632 | $params = [ |
| 1633 | 1633 | 'c_id' => $this->destination_course_id, |
@@ -1644,20 +1644,20 @@ discard block |
||
| 1644 | 1644 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
| 1645 | 1645 | Database::query($sql); |
| 1646 | 1646 | } |
| 1647 | - } |
|
| 1648 | - } |
|
| 1649 | - } else { |
|
| 1650 | - // get the info of the file |
|
| 1651 | - if (!empty($announcement->attachment_path) && |
|
| 1647 | + } |
|
| 1648 | + } |
|
| 1649 | + } else { |
|
| 1650 | + // get the info of the file |
|
| 1651 | + if (!empty($announcement->attachment_path) && |
|
| 1652 | 1652 | is_file($origin_path.$announcement->attachment_path) && |
| 1653 | 1653 | is_readable($origin_path.$announcement->attachment_path) |
| 1654 | 1654 | ) { |
| 1655 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1656 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
| 1655 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1656 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
| 1657 | 1657 | |
| 1658 | - if ($copy_result) { |
|
| 1659 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1660 | - /*$sql = "INSERT INTO ".$table_attachment." SET |
|
| 1658 | + if ($copy_result) { |
|
| 1659 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1660 | + /*$sql = "INSERT INTO ".$table_attachment." SET |
|
| 1661 | 1661 | c_id = ".$this->destination_course_id." , |
| 1662 | 1662 | path = '".self::DBUTF8escapestring($new_filename)."', |
| 1663 | 1663 | comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."', |
@@ -1680,12 +1680,12 @@ discard block |
||
| 1680 | 1680 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
| 1681 | 1681 | Database::query($sql); |
| 1682 | 1682 | } |
| 1683 | - } |
|
| 1684 | - } |
|
| 1685 | - } |
|
| 1686 | - } |
|
| 1687 | - } |
|
| 1688 | - } |
|
| 1683 | + } |
|
| 1684 | + } |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1687 | + } |
|
| 1688 | + } |
|
| 1689 | 1689 | |
| 1690 | 1690 | /** |
| 1691 | 1691 | * Restore Quiz |
@@ -1696,13 +1696,13 @@ discard block |
||
| 1696 | 1696 | $session_id = 0, |
| 1697 | 1697 | $respect_base_content = false |
| 1698 | 1698 | ) { |
| 1699 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
| 1700 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
| 1701 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
| 1702 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
| 1703 | - $resources = $this->course->resources; |
|
| 1699 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
| 1700 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
| 1701 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
| 1702 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
| 1703 | + $resources = $this->course->resources; |
|
| 1704 | 1704 | |
| 1705 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
| 1705 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
| 1706 | 1706 | |
| 1707 | 1707 | if (isset($quiz->obj)) { |
| 1708 | 1708 | //For new imports |
@@ -1712,7 +1712,7 @@ discard block |
||
| 1712 | 1712 | $quiz->obj = $quiz; |
| 1713 | 1713 | } |
| 1714 | 1714 | |
| 1715 | - $doc = ''; |
|
| 1715 | + $doc = ''; |
|
| 1716 | 1716 | if (!empty($quiz->sound)) { |
| 1717 | 1717 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
| 1718 | 1718 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1720,14 +1720,14 @@ discard block |
||
| 1720 | 1720 | WHERE |
| 1721 | 1721 | c_id = " . $this->destination_course_id . " AND |
| 1722 | 1722 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
| 1723 | - $doc = Database::query($sql); |
|
| 1724 | - $doc = Database::fetch_object($doc); |
|
| 1725 | - $doc = str_replace('/audio/', '', $doc->path); |
|
| 1726 | - } |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - if ($id != -1) { |
|
| 1730 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1723 | + $doc = Database::query($sql); |
|
| 1724 | + $doc = Database::fetch_object($doc); |
|
| 1725 | + $doc = str_replace('/audio/', '', $doc->path); |
|
| 1726 | + } |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + if ($id != -1) { |
|
| 1730 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1731 | 1731 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1732 | 1732 | $quiz->description, |
| 1733 | 1733 | $this->course->code, |
@@ -1736,13 +1736,13 @@ discard block |
||
| 1736 | 1736 | $this->course->info['path'] |
| 1737 | 1737 | ); |
| 1738 | 1738 | |
| 1739 | - global $_custom; |
|
| 1740 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
| 1739 | + global $_custom; |
|
| 1740 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
| 1741 | 1741 | $_custom['exercises_clean_dates_when_restoring'] |
| 1742 | 1742 | ) { |
| 1743 | - $quiz->start_time = null; |
|
| 1744 | - $quiz->end_time = null; |
|
| 1745 | - } |
|
| 1743 | + $quiz->start_time = null; |
|
| 1744 | + $quiz->end_time = null; |
|
| 1745 | + } |
|
| 1746 | 1746 | |
| 1747 | 1747 | $params = array( |
| 1748 | 1748 | 'c_id' => $this->destination_course_id, |
@@ -1774,10 +1774,10 @@ discard block |
||
| 1774 | 1774 | } |
| 1775 | 1775 | $params['session_id'] = $my_session_id; |
| 1776 | 1776 | } else { |
| 1777 | - if (!empty($session_id)) { |
|
| 1778 | - $session_id = intval($session_id); |
|
| 1777 | + if (!empty($session_id)) { |
|
| 1778 | + $session_id = intval($session_id); |
|
| 1779 | 1779 | $params['session_id'] = $session_id; |
| 1780 | - } |
|
| 1780 | + } |
|
| 1781 | 1781 | } |
| 1782 | 1782 | $new_id = Database::insert($table_qui, $params); |
| 1783 | 1783 | |
@@ -1786,15 +1786,15 @@ discard block |
||
| 1786 | 1786 | Database::query($sql); |
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | - } else { |
|
| 1790 | - // $id = -1 identifies the fictionary test for collecting |
|
| 1791 | - // orphan questions. We do not store it in the database. |
|
| 1792 | - $new_id = -1; |
|
| 1793 | - } |
|
| 1789 | + } else { |
|
| 1790 | + // $id = -1 identifies the fictionary test for collecting |
|
| 1791 | + // orphan questions. We do not store it in the database. |
|
| 1792 | + $new_id = -1; |
|
| 1793 | + } |
|
| 1794 | 1794 | |
| 1795 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
| 1795 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
| 1796 | 1796 | |
| 1797 | - $order = 0; |
|
| 1797 | + $order = 0; |
|
| 1798 | 1798 | if (!empty($quiz->question_ids)) { |
| 1799 | 1799 | foreach ($quiz->question_ids as $index => $question_id) { |
| 1800 | 1800 | $qid = $this->restore_quiz_question($question_id); |
@@ -1807,30 +1807,30 @@ discard block |
||
| 1807 | 1807 | Database::query($sql); |
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | - } |
|
| 1811 | - } |
|
| 1812 | - } |
|
| 1810 | + } |
|
| 1811 | + } |
|
| 1812 | + } |
|
| 1813 | 1813 | |
| 1814 | - /** |
|
| 1815 | - * Restore quiz-questions |
|
| 1814 | + /** |
|
| 1815 | + * Restore quiz-questions |
|
| 1816 | 1816 | * @params int question id |
| 1817 | - */ |
|
| 1817 | + */ |
|
| 1818 | 1818 | public function restore_quiz_question($id) |
| 1819 | 1819 | { |
| 1820 | - $resources = $this->course->resources; |
|
| 1820 | + $resources = $this->course->resources; |
|
| 1821 | 1821 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
| 1822 | 1822 | |
| 1823 | - $new_id = 0; |
|
| 1823 | + $new_id = 0; |
|
| 1824 | 1824 | |
| 1825 | - if (is_object($question)) { |
|
| 1826 | - if ($question->is_restored()) { |
|
| 1827 | - return $question->destination_id; |
|
| 1828 | - } |
|
| 1829 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
| 1830 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
| 1825 | + if (is_object($question)) { |
|
| 1826 | + if ($question->is_restored()) { |
|
| 1827 | + return $question->destination_id; |
|
| 1828 | + } |
|
| 1829 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
| 1830 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
| 1831 | 1831 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
| 1832 | 1832 | |
| 1833 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1833 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1834 | 1834 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1835 | 1835 | $question->description, |
| 1836 | 1836 | $this->course->code, |
@@ -1851,7 +1851,7 @@ discard block |
||
| 1851 | 1851 | 'extra' => self::DBUTF8($question->extra), |
| 1852 | 1852 | ]; |
| 1853 | 1853 | |
| 1854 | - $new_id = Database::insert($table_que, $params); |
|
| 1854 | + $new_id = Database::insert($table_que, $params); |
|
| 1855 | 1855 | |
| 1856 | 1856 | if ($new_id) { |
| 1857 | 1857 | |
@@ -1892,7 +1892,7 @@ discard block |
||
| 1892 | 1892 | |
| 1893 | 1893 | foreach ($temp as $index => $answer) { |
| 1894 | 1894 | //id = '".$index."', |
| 1895 | - $params = [ |
|
| 1895 | + $params = [ |
|
| 1896 | 1896 | 'c_id' => $this->destination_course_id, |
| 1897 | 1897 | 'question_id' => $new_id, |
| 1898 | 1898 | 'answer' => self::DBUTF8($answer['answer']), |
@@ -1909,12 +1909,12 @@ discard block |
||
| 1909 | 1909 | $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId"; |
| 1910 | 1910 | Database::query($sql); |
| 1911 | 1911 | } |
| 1912 | - } |
|
| 1913 | - } else { |
|
| 1912 | + } |
|
| 1913 | + } else { |
|
| 1914 | 1914 | $correct_answers = array(); |
| 1915 | - foreach ($question->answers as $index => $answer) { |
|
| 1915 | + foreach ($question->answers as $index => $answer) { |
|
| 1916 | 1916 | |
| 1917 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1917 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1918 | 1918 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1919 | 1919 | $answer['answer'], |
| 1920 | 1920 | $this->course->code, |
@@ -1953,8 +1953,8 @@ discard block |
||
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | 1955 | $correct_answers[$answerId] = $answer['correct']; |
| 1956 | - } |
|
| 1957 | - } |
|
| 1956 | + } |
|
| 1957 | + } |
|
| 1958 | 1958 | |
| 1959 | 1959 | //Current course id |
| 1960 | 1960 | $course_id = api_get_course_int_id(); |
@@ -2051,12 +2051,12 @@ discard block |
||
| 2051 | 2051 | } |
| 2052 | 2052 | } |
| 2053 | 2053 | } |
| 2054 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
| 2055 | - } |
|
| 2056 | - return $new_id; |
|
| 2057 | - } |
|
| 2054 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
| 2055 | + } |
|
| 2056 | + return $new_id; |
|
| 2057 | + } |
|
| 2058 | 2058 | |
| 2059 | - /** |
|
| 2059 | + /** |
|
| 2060 | 2060 | * @todo : add session id when used for session |
| 2061 | 2061 | */ |
| 2062 | 2062 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2136,21 +2136,21 @@ discard block |
||
| 2136 | 2136 | $sessionId = intval($sessionId); |
| 2137 | 2137 | |
| 2138 | 2138 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
| 2139 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2140 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2141 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2142 | - $resources = $this->course->resources; |
|
| 2143 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
| 2139 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2140 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2141 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2142 | + $resources = $this->course->resources; |
|
| 2143 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
| 2144 | 2144 | |
| 2145 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
| 2145 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
| 2146 | 2146 | WHERE |
| 2147 | 2147 | c_id = '.$this->destination_course_id.' AND |
| 2148 | 2148 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
| 2149 | 2149 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
| 2150 | 2150 | |
| 2151 | - $result_check = Database::query($sql); |
|
| 2151 | + $result_check = Database::query($sql); |
|
| 2152 | 2152 | |
| 2153 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2153 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2154 | 2154 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2155 | 2155 | $survey->title, |
| 2156 | 2156 | $this->course->code, |
@@ -2204,20 +2204,20 @@ discard block |
||
| 2204 | 2204 | 'session_id' => $sessionId, |
| 2205 | 2205 | ]; |
| 2206 | 2206 | |
| 2207 | - //An existing survey exists with the same code and the same language |
|
| 2208 | - if (Database::num_rows($result_check) == 1) { |
|
| 2209 | - switch ($this->file_option) { |
|
| 2210 | - case FILE_SKIP: |
|
| 2211 | - //Do nothing |
|
| 2212 | - break; |
|
| 2213 | - case FILE_RENAME: |
|
| 2214 | - $survey_code = $survey->code.'_'; |
|
| 2215 | - $i=1; |
|
| 2216 | - $temp_survey_code = $survey_code.$i; |
|
| 2217 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
| 2218 | - $temp_survey_code = $survey_code.++$i; |
|
| 2219 | - } |
|
| 2220 | - $survey_code = $temp_survey_code; |
|
| 2207 | + //An existing survey exists with the same code and the same language |
|
| 2208 | + if (Database::num_rows($result_check) == 1) { |
|
| 2209 | + switch ($this->file_option) { |
|
| 2210 | + case FILE_SKIP: |
|
| 2211 | + //Do nothing |
|
| 2212 | + break; |
|
| 2213 | + case FILE_RENAME: |
|
| 2214 | + $survey_code = $survey->code.'_'; |
|
| 2215 | + $i=1; |
|
| 2216 | + $temp_survey_code = $survey_code.$i; |
|
| 2217 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
| 2218 | + $temp_survey_code = $survey_code.++$i; |
|
| 2219 | + } |
|
| 2220 | + $survey_code = $temp_survey_code; |
|
| 2221 | 2221 | |
| 2222 | 2222 | $params['code'] = $survey_code; |
| 2223 | 2223 | $new_id = Database::insert($table_sur, $params); |
@@ -2236,25 +2236,25 @@ discard block |
||
| 2236 | 2236 | Database::query($sql); |
| 2237 | 2237 | } |
| 2238 | 2238 | } |
| 2239 | - break; |
|
| 2240 | - case FILE_OVERWRITE: |
|
| 2241 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
| 2242 | - // getting the information of the survey (used for when the survey is shared) |
|
| 2239 | + break; |
|
| 2240 | + case FILE_OVERWRITE: |
|
| 2241 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
| 2242 | + // getting the information of the survey (used for when the survey is shared) |
|
| 2243 | 2243 | |
| 2244 | - $sql = "SELECT * FROM $table_sur |
|
| 2244 | + $sql = "SELECT * FROM $table_sur |
|
| 2245 | 2245 | WHERE |
| 2246 | 2246 | c_id = ".$this->destination_course_id." AND |
| 2247 | 2247 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
| 2248 | - $result = Database::query($sql); |
|
| 2249 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
| 2248 | + $result = Database::query($sql); |
|
| 2249 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
| 2250 | 2250 | |
| 2251 | - // if the survey is shared => also delete the shared content |
|
| 2252 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
| 2251 | + // if the survey is shared => also delete the shared content |
|
| 2252 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
| 2253 | 2253 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
| 2254 | - } |
|
| 2255 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
| 2254 | + } |
|
| 2255 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
| 2256 | 2256 | |
| 2257 | - // Insert the new source survey |
|
| 2257 | + // Insert the new source survey |
|
| 2258 | 2258 | $new_id = Database::insert($table_sur, $params); |
| 2259 | 2259 | |
| 2260 | 2260 | if ($new_id) { |
@@ -2275,11 +2275,11 @@ discard block |
||
| 2275 | 2275 | Database::query($sql); |
| 2276 | 2276 | } |
| 2277 | 2277 | } |
| 2278 | - break; |
|
| 2279 | - default: |
|
| 2280 | - break; |
|
| 2281 | - } |
|
| 2282 | - } else { |
|
| 2278 | + break; |
|
| 2279 | + default: |
|
| 2280 | + break; |
|
| 2281 | + } |
|
| 2282 | + } else { |
|
| 2283 | 2283 | // No existing survey with the same language and the same code, we just copy the survey |
| 2284 | 2284 | $new_id = Database::insert($table_sur, $params); |
| 2285 | 2285 | |
@@ -2301,45 +2301,45 @@ discard block |
||
| 2301 | 2301 | Database::query($sql); |
| 2302 | 2302 | } |
| 2303 | 2303 | } |
| 2304 | - } |
|
| 2305 | - } |
|
| 2306 | - } |
|
| 2307 | - } |
|
| 2308 | - |
|
| 2309 | - /** |
|
| 2310 | - * Check availability of a survey code |
|
| 2311 | - * @param string $survey_code |
|
| 2312 | - */ |
|
| 2304 | + } |
|
| 2305 | + } |
|
| 2306 | + } |
|
| 2307 | + } |
|
| 2308 | + |
|
| 2309 | + /** |
|
| 2310 | + * Check availability of a survey code |
|
| 2311 | + * @param string $survey_code |
|
| 2312 | + */ |
|
| 2313 | 2313 | public function is_survey_code_available($survey_code) |
| 2314 | 2314 | { |
| 2315 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2316 | - $sql = "SELECT * FROM $table_sur |
|
| 2315 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2316 | + $sql = "SELECT * FROM $table_sur |
|
| 2317 | 2317 | WHERE |
| 2318 | 2318 | c_id = ".$this->destination_course_id." AND |
| 2319 | 2319 | code='".self::DBUTF8escapestring($survey_code)."'"; |
| 2320 | - $result = Database::query($sql); |
|
| 2321 | - if (Database::num_rows($result) > 0) return false; else return true; |
|
| 2322 | - } |
|
| 2323 | - |
|
| 2324 | - /** |
|
| 2325 | - * Restore survey-questions |
|
| 2326 | - * @param string $survey_id |
|
| 2327 | - */ |
|
| 2320 | + $result = Database::query($sql); |
|
| 2321 | + if (Database::num_rows($result) > 0) return false; else return true; |
|
| 2322 | + } |
|
| 2323 | + |
|
| 2324 | + /** |
|
| 2325 | + * Restore survey-questions |
|
| 2326 | + * @param string $survey_id |
|
| 2327 | + */ |
|
| 2328 | 2328 | public function restore_survey_question($id, $survey_id) |
| 2329 | 2329 | { |
| 2330 | - $resources = $this->course->resources; |
|
| 2331 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
| 2330 | + $resources = $this->course->resources; |
|
| 2331 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
| 2332 | 2332 | |
| 2333 | - $new_id=0; |
|
| 2333 | + $new_id=0; |
|
| 2334 | 2334 | |
| 2335 | - if (is_object($question)) { |
|
| 2336 | - if ($question->is_restored()) { |
|
| 2337 | - return $question->destination_id; |
|
| 2338 | - } |
|
| 2339 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2340 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2335 | + if (is_object($question)) { |
|
| 2336 | + if ($question->is_restored()) { |
|
| 2337 | + return $question->destination_id; |
|
| 2338 | + } |
|
| 2339 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2340 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2341 | 2341 | |
| 2342 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2342 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2343 | 2343 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2344 | 2344 | $question->survey_question, |
| 2345 | 2345 | $this->course->code, |
@@ -2393,10 +2393,10 @@ discard block |
||
| 2393 | 2393 | } |
| 2394 | 2394 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
| 2395 | 2395 | } |
| 2396 | - } |
|
| 2396 | + } |
|
| 2397 | 2397 | |
| 2398 | - return $new_id; |
|
| 2399 | - } |
|
| 2398 | + return $new_id; |
|
| 2399 | + } |
|
| 2400 | 2400 | |
| 2401 | 2401 | /** |
| 2402 | 2402 | * Restoring learning paths |
@@ -2407,20 +2407,20 @@ discard block |
||
| 2407 | 2407 | { |
| 2408 | 2408 | $session_id = intval($session_id); |
| 2409 | 2409 | |
| 2410 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
| 2410 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
| 2411 | 2411 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
| 2412 | 2412 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
| 2413 | 2413 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
| 2414 | 2414 | |
| 2415 | - $resources = $this->course->resources; |
|
| 2415 | + $resources = $this->course->resources; |
|
| 2416 | 2416 | |
| 2417 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
| 2418 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
| 2417 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
| 2418 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
| 2419 | 2419 | |
| 2420 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
| 2420 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
| 2421 | 2421 | |
| 2422 | - $condition_session = ""; |
|
| 2423 | - if (!empty($session_id)) { |
|
| 2422 | + $condition_session = ""; |
|
| 2423 | + if (!empty($session_id)) { |
|
| 2424 | 2424 | if ($respect_base_content) { |
| 2425 | 2425 | $my_session_id = $lp->session_id; |
| 2426 | 2426 | if (!empty($lp->session_id)) { |
@@ -2431,21 +2431,21 @@ discard block |
||
| 2431 | 2431 | $session_id = intval($session_id); |
| 2432 | 2432 | $condition_session = $session_id; |
| 2433 | 2433 | } |
| 2434 | - } |
|
| 2435 | - |
|
| 2436 | - // Adding the author's image |
|
| 2437 | - if (!empty($lp->preview_image)) { |
|
| 2438 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
| 2439 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
| 2440 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
| 2441 | - //$copy_result = true; |
|
| 2442 | - if ($copy_result) { |
|
| 2443 | - $lp->preview_image = $new_filename; |
|
| 2444 | - } else { |
|
| 2445 | - $lp->preview_image =''; |
|
| 2446 | - } |
|
| 2447 | - } |
|
| 2448 | - } |
|
| 2434 | + } |
|
| 2435 | + |
|
| 2436 | + // Adding the author's image |
|
| 2437 | + if (!empty($lp->preview_image)) { |
|
| 2438 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
| 2439 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
| 2440 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
| 2441 | + //$copy_result = true; |
|
| 2442 | + if ($copy_result) { |
|
| 2443 | + $lp->preview_image = $new_filename; |
|
| 2444 | + } else { |
|
| 2445 | + $lp->preview_image =''; |
|
| 2446 | + } |
|
| 2447 | + } |
|
| 2448 | + } |
|
| 2449 | 2449 | |
| 2450 | 2450 | if ($this->add_text_in_items) { |
| 2451 | 2451 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2492,7 +2492,7 @@ discard block |
||
| 2492 | 2492 | $params['session_id'] = $condition_session; |
| 2493 | 2493 | } |
| 2494 | 2494 | |
| 2495 | - $new_lp_id = Database::insert($table_main, $params); |
|
| 2495 | + $new_lp_id = Database::insert($table_main, $params); |
|
| 2496 | 2496 | |
| 2497 | 2497 | if ($new_lp_id) { |
| 2498 | 2498 | |
@@ -2553,13 +2553,13 @@ discard block |
||
| 2553 | 2553 | $old_refs = array(); |
| 2554 | 2554 | $prerequisite_ids = array(); |
| 2555 | 2555 | |
| 2556 | - foreach ($lp->get_items() as $index => $item) { |
|
| 2557 | - // we set the ref code here and then we update in a for loop |
|
| 2558 | - $ref = $item['ref']; |
|
| 2556 | + foreach ($lp->get_items() as $index => $item) { |
|
| 2557 | + // we set the ref code here and then we update in a for loop |
|
| 2558 | + $ref = $item['ref']; |
|
| 2559 | 2559 | |
| 2560 | - // Dealing with path the same way as ref as some data has |
|
| 2560 | + // Dealing with path the same way as ref as some data has |
|
| 2561 | 2561 | // been put into path when it's a local resource |
| 2562 | - // Only fix the path for no scos |
|
| 2562 | + // Only fix the path for no scos |
|
| 2563 | 2563 | if ($item['item_type'] == 'sco') { |
| 2564 | 2564 | $path = $item['path']; |
| 2565 | 2565 | } else { |
@@ -2588,128 +2588,128 @@ discard block |
||
| 2588 | 2588 | 'launch_data' => self::DBUTF8($item['launch_data']), |
| 2589 | 2589 | ]; |
| 2590 | 2590 | |
| 2591 | - $new_item_id = Database::insert($table_item, $params); |
|
| 2591 | + $new_item_id = Database::insert($table_item, $params); |
|
| 2592 | 2592 | |
| 2593 | 2593 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
| 2594 | 2594 | Database::query($sql); |
| 2595 | 2595 | |
| 2596 | - //save a link between old and new item IDs |
|
| 2597 | - $new_item_ids[$item['id']] = $new_item_id; |
|
| 2598 | - //save a reference of items that need a parent_item_id refresh |
|
| 2599 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
| 2600 | - //save a reference of items that need a previous_item_id refresh |
|
| 2601 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
| 2602 | - //save a reference of items that need a next_item_id refresh |
|
| 2603 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
| 2604 | - |
|
| 2605 | - if (!empty($item['prerequisite'])) { |
|
| 2606 | - if ($lp->lp_type =='2') { |
|
| 2607 | - // if is an sco |
|
| 2608 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
| 2609 | - } else { |
|
| 2610 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
| 2611 | - } |
|
| 2612 | - } |
|
| 2613 | - |
|
| 2614 | - if (!empty($ref)) { |
|
| 2615 | - if ($lp->lp_type =='2') { |
|
| 2616 | - // if is an sco |
|
| 2617 | - $old_refs[$new_item_id]= $ref; |
|
| 2618 | - } else { |
|
| 2596 | + //save a link between old and new item IDs |
|
| 2597 | + $new_item_ids[$item['id']] = $new_item_id; |
|
| 2598 | + //save a reference of items that need a parent_item_id refresh |
|
| 2599 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
| 2600 | + //save a reference of items that need a previous_item_id refresh |
|
| 2601 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
| 2602 | + //save a reference of items that need a next_item_id refresh |
|
| 2603 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
| 2604 | + |
|
| 2605 | + if (!empty($item['prerequisite'])) { |
|
| 2606 | + if ($lp->lp_type =='2') { |
|
| 2607 | + // if is an sco |
|
| 2608 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
| 2609 | + } else { |
|
| 2610 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
| 2611 | + } |
|
| 2612 | + } |
|
| 2613 | + |
|
| 2614 | + if (!empty($ref)) { |
|
| 2615 | + if ($lp->lp_type =='2') { |
|
| 2616 | + // if is an sco |
|
| 2617 | + $old_refs[$new_item_id]= $ref; |
|
| 2618 | + } else { |
|
| 2619 | 2619 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
| 2620 | - } |
|
| 2621 | - } |
|
| 2620 | + } |
|
| 2621 | + } |
|
| 2622 | 2622 | |
| 2623 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
| 2624 | - } |
|
| 2623 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
| 2624 | + } |
|
| 2625 | 2625 | |
| 2626 | - // Updating prerequisites |
|
| 2627 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
| 2628 | - if($my_old_prerequisite != ''){ |
|
| 2629 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
| 2626 | + // Updating prerequisites |
|
| 2627 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
| 2628 | + if($my_old_prerequisite != ''){ |
|
| 2629 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
| 2630 | 2630 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
| 2631 | - Database::query($sql); |
|
| 2632 | - } |
|
| 2633 | - } |
|
| 2634 | - |
|
| 2635 | - // Updating refs |
|
| 2636 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
| 2637 | - if ($my_old_ref != '') { |
|
| 2638 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
| 2631 | + Database::query($sql); |
|
| 2632 | + } |
|
| 2633 | + } |
|
| 2634 | + |
|
| 2635 | + // Updating refs |
|
| 2636 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
| 2637 | + if ($my_old_ref != '') { |
|
| 2638 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
| 2639 | 2639 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
| 2640 | - Database::query($sql); |
|
| 2641 | - } |
|
| 2642 | - } |
|
| 2643 | - |
|
| 2644 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
| 2645 | - $parent_new_id = 0; |
|
| 2646 | - if($parent_item_old_id != 0){ |
|
| 2647 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
| 2648 | - } |
|
| 2649 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
| 2640 | + Database::query($sql); |
|
| 2641 | + } |
|
| 2642 | + } |
|
| 2643 | + |
|
| 2644 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
| 2645 | + $parent_new_id = 0; |
|
| 2646 | + if($parent_item_old_id != 0){ |
|
| 2647 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
| 2648 | + } |
|
| 2649 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
| 2650 | 2650 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2651 | - Database::query($sql); |
|
| 2652 | - } |
|
| 2653 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
| 2654 | - $previous_new_id = 0; |
|
| 2655 | - if($previous_item_old_id != 0){ |
|
| 2656 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
| 2657 | - } |
|
| 2658 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
| 2651 | + Database::query($sql); |
|
| 2652 | + } |
|
| 2653 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
| 2654 | + $previous_new_id = 0; |
|
| 2655 | + if($previous_item_old_id != 0){ |
|
| 2656 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
| 2657 | + } |
|
| 2658 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
| 2659 | 2659 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2660 | - Database::query($sql); |
|
| 2661 | - } |
|
| 2662 | - |
|
| 2663 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
| 2664 | - $next_new_id = 0; |
|
| 2665 | - if($next_item_old_id != 0){ |
|
| 2666 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
| 2667 | - } |
|
| 2668 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
| 2660 | + Database::query($sql); |
|
| 2661 | + } |
|
| 2662 | + |
|
| 2663 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
| 2664 | + $next_new_id = 0; |
|
| 2665 | + if($next_item_old_id != 0){ |
|
| 2666 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
| 2667 | + } |
|
| 2668 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
| 2669 | 2669 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2670 | - Database::query($sql); |
|
| 2671 | - } |
|
| 2672 | - |
|
| 2673 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
| 2674 | - $prerequisite_new_id = 0; |
|
| 2675 | - if($prerequisite_old_id != 0){ |
|
| 2676 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
| 2677 | - } |
|
| 2678 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
| 2670 | + Database::query($sql); |
|
| 2671 | + } |
|
| 2672 | + |
|
| 2673 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
| 2674 | + $prerequisite_new_id = 0; |
|
| 2675 | + if($prerequisite_old_id != 0){ |
|
| 2676 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
| 2677 | + } |
|
| 2678 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
| 2679 | 2679 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2680 | - Database::query($sql); |
|
| 2681 | - } |
|
| 2682 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
| 2683 | - } |
|
| 2684 | - } |
|
| 2685 | - } |
|
| 2686 | - |
|
| 2687 | - /** |
|
| 2688 | - * Restore works |
|
| 2680 | + Database::query($sql); |
|
| 2681 | + } |
|
| 2682 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
| 2683 | + } |
|
| 2684 | + } |
|
| 2685 | + } |
|
| 2686 | + |
|
| 2687 | + /** |
|
| 2688 | + * Restore works |
|
| 2689 | 2689 | * @deprecated use restore_works |
| 2690 | 2690 | * |
| 2691 | - */ |
|
| 2692 | - public function restore_student_publication($sessionId = 0) |
|
| 2691 | + */ |
|
| 2692 | + public function restore_student_publication($sessionId = 0) |
|
| 2693 | 2693 | { |
| 2694 | 2694 | $sessionId = intval($sessionId); |
| 2695 | - $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
| 2696 | - $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
| 2697 | - $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 2695 | + $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
| 2696 | + $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
| 2697 | + $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 2698 | 2698 | |
| 2699 | - // Query in student publication |
|
| 2700 | - $sql = 'SELECT * FROM '.$work_table.' |
|
| 2699 | + // Query in student publication |
|
| 2700 | + $sql = 'SELECT * FROM '.$work_table.' |
|
| 2701 | 2701 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
| 2702 | 2702 | |
| 2703 | - $result = Database::query($sql); |
|
| 2704 | - $folders = Database::store_result($result, 'ASSOC'); |
|
| 2703 | + $result = Database::query($sql); |
|
| 2704 | + $folders = Database::store_result($result, 'ASSOC'); |
|
| 2705 | 2705 | |
| 2706 | - foreach ($folders as $folder) { |
|
| 2707 | - $old_id = $folder['id']; |
|
| 2706 | + foreach ($folders as $folder) { |
|
| 2707 | + $old_id = $folder['id']; |
|
| 2708 | 2708 | unset($folder['id']); |
| 2709 | - $folder['c_id'] = $this->destination_course_id; |
|
| 2709 | + $folder['c_id'] = $this->destination_course_id; |
|
| 2710 | 2710 | $folder['parent_id'] = 0; |
| 2711 | 2711 | $folder['session_id'] = $sessionId; |
| 2712 | - $new_id = Database::insert($work_table, $folder); |
|
| 2712 | + $new_id = Database::insert($work_table, $folder); |
|
| 2713 | 2713 | |
| 2714 | 2714 | if ($new_id) { |
| 2715 | 2715 | //query in item property |
@@ -2768,23 +2768,23 @@ discard block |
||
| 2768 | 2768 | } |
| 2769 | 2769 | } |
| 2770 | 2770 | } |
| 2771 | - } |
|
| 2771 | + } |
|
| 2772 | 2772 | |
| 2773 | - $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
|
| 2774 | - $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
|
| 2775 | - self::allow_create_all_directory($origin,$destination,false); |
|
| 2776 | - } |
|
| 2773 | + $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
|
| 2774 | + $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
|
| 2775 | + self::allow_create_all_directory($origin,$destination,false); |
|
| 2776 | + } |
|
| 2777 | 2777 | |
| 2778 | 2778 | /** |
| 2779 | - * copy all directory and sub directory |
|
| 2780 | - * @param string The path origin |
|
| 2781 | - * @param string The path destination |
|
| 2782 | - * @param boolean Option Overwrite |
|
| 2783 | - * @param string $source |
|
| 2784 | - * @param string $dest |
|
| 2785 | - * @return void() |
|
| 2786 | - * @deprecated |
|
| 2787 | - */ |
|
| 2779 | + * copy all directory and sub directory |
|
| 2780 | + * @param string The path origin |
|
| 2781 | + * @param string The path destination |
|
| 2782 | + * @param boolean Option Overwrite |
|
| 2783 | + * @param string $source |
|
| 2784 | + * @param string $dest |
|
| 2785 | + * @return void() |
|
| 2786 | + * @deprecated |
|
| 2787 | + */ |
|
| 2788 | 2788 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
| 2789 | 2789 | { |
| 2790 | 2790 | if (!is_dir($dest)) { |
@@ -2795,14 +2795,14 @@ discard block |
||
| 2795 | 2795 | if ($file != '.' && $file != '..') { |
| 2796 | 2796 | $path = $source . '/' . $file; |
| 2797 | 2797 | if (is_file($path)) { |
| 2798 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
| 2798 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
| 2799 | 2799 | if (!@copy($path, $dest . '/' . $file)) { |
| 2800 | 2800 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
| 2801 | 2801 | }*/ |
| 2802 | 2802 | } elseif(is_dir($path)) { |
| 2803 | 2803 | if (!is_dir($dest . '/' . $file)) |
| 2804 | 2804 | mkdir($dest . '/' . $file); |
| 2805 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
| 2805 | + self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
| 2806 | 2806 | } |
| 2807 | 2807 | } |
| 2808 | 2808 | } |
@@ -2810,12 +2810,12 @@ discard block |
||
| 2810 | 2810 | } |
| 2811 | 2811 | } |
| 2812 | 2812 | |
| 2813 | - /** |
|
| 2814 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
| 2815 | - * @param string Tool name |
|
| 2816 | - * @param integer Old ID |
|
| 2817 | - * @return integer New ID |
|
| 2818 | - */ |
|
| 2813 | + /** |
|
| 2814 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
| 2815 | + * @param string Tool name |
|
| 2816 | + * @param integer Old ID |
|
| 2817 | + * @return integer New ID |
|
| 2818 | + */ |
|
| 2819 | 2819 | public function get_new_id($tool, $ref) |
| 2820 | 2820 | { |
| 2821 | 2821 | // Check if the value exist in the current array. |
@@ -2837,25 +2837,25 @@ discard block |
||
| 2837 | 2837 | } |
| 2838 | 2838 | |
| 2839 | 2839 | return ''; |
| 2840 | - } |
|
| 2840 | + } |
|
| 2841 | 2841 | |
| 2842 | - /** |
|
| 2843 | - * Restore glossary |
|
| 2844 | - */ |
|
| 2842 | + /** |
|
| 2843 | + * Restore glossary |
|
| 2844 | + */ |
|
| 2845 | 2845 | public function restore_glossary($session_id = 0) |
| 2846 | 2846 | { |
| 2847 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
| 2848 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
| 2849 | - $resources = $this->course->resources; |
|
| 2850 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
| 2847 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
| 2848 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
| 2849 | + $resources = $this->course->resources; |
|
| 2850 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
| 2851 | 2851 | |
| 2852 | 2852 | $params = []; |
| 2853 | - if (!empty($session_id)) { |
|
| 2854 | - $session_id = intval($session_id); |
|
| 2853 | + if (!empty($session_id)) { |
|
| 2854 | + $session_id = intval($session_id); |
|
| 2855 | 2855 | $params['session_id'] = $session_id; |
| 2856 | - } |
|
| 2856 | + } |
|
| 2857 | 2857 | |
| 2858 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2858 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2859 | 2859 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2860 | 2860 | $glossary->description, |
| 2861 | 2861 | $this->course->code, |
@@ -2889,27 +2889,27 @@ discard block |
||
| 2889 | 2889 | |
| 2890 | 2890 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
| 2891 | 2891 | } |
| 2892 | - } |
|
| 2893 | - } |
|
| 2894 | - } |
|
| 2892 | + } |
|
| 2893 | + } |
|
| 2894 | + } |
|
| 2895 | 2895 | |
| 2896 | 2896 | /** |
| 2897 | 2897 | * @param int $session_id |
| 2898 | 2898 | */ |
| 2899 | 2899 | public function restore_wiki($session_id = 0) |
| 2900 | 2900 | { |
| 2901 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
| 2902 | - // wiki table of the target course |
|
| 2903 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
| 2904 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
| 2901 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
| 2902 | + // wiki table of the target course |
|
| 2903 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
| 2904 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
| 2905 | 2905 | |
| 2906 | - // storing all the resources that have to be copied in an array |
|
| 2907 | - $resources = $this->course->resources; |
|
| 2906 | + // storing all the resources that have to be copied in an array |
|
| 2907 | + $resources = $this->course->resources; |
|
| 2908 | 2908 | |
| 2909 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
| 2910 | - // the sql statement to insert the groups from the old course to the new course |
|
| 2909 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
| 2910 | + // the sql statement to insert the groups from the old course to the new course |
|
| 2911 | 2911 | |
| 2912 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2912 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2913 | 2913 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2914 | 2914 | $wiki->content, |
| 2915 | 2915 | $this->course->code, |
@@ -2932,7 +2932,7 @@ discard block |
||
| 2932 | 2932 | 'session_id' => !empty($session_id) ? intval($session_id) : 0, |
| 2933 | 2933 | ]; |
| 2934 | 2934 | |
| 2935 | - $new_id = Database::insert($table_wiki, $params); |
|
| 2935 | + $new_id = Database::insert($table_wiki, $params); |
|
| 2936 | 2936 | |
| 2937 | 2937 | if ($new_id) { |
| 2938 | 2938 | |
@@ -2963,9 +2963,9 @@ discard block |
||
| 2963 | 2963 | |
| 2964 | 2964 | Database::insert($table_wiki_conf, $params); |
| 2965 | 2965 | } |
| 2966 | - } |
|
| 2967 | - } |
|
| 2968 | - } |
|
| 2966 | + } |
|
| 2967 | + } |
|
| 2968 | + } |
|
| 2969 | 2969 | |
| 2970 | 2970 | /** |
| 2971 | 2971 | * Restore Thematics |
@@ -2973,15 +2973,15 @@ discard block |
||
| 2973 | 2973 | */ |
| 2974 | 2974 | public function restore_thematic($session_id = 0) |
| 2975 | 2975 | { |
| 2976 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
| 2976 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
| 2977 | 2977 | $table_thematic = Database:: get_course_table(TABLE_THEMATIC); |
| 2978 | 2978 | $table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE); |
| 2979 | 2979 | $table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN); |
| 2980 | 2980 | |
| 2981 | - $resources = $this->course->resources; |
|
| 2982 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
| 2981 | + $resources = $this->course->resources; |
|
| 2982 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
| 2983 | 2983 | |
| 2984 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2984 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2985 | 2985 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2986 | 2986 | $thematic->params['content'], |
| 2987 | 2987 | $this->course->code, |
@@ -2989,13 +2989,13 @@ discard block |
||
| 2989 | 2989 | $this->course->backup_path, |
| 2990 | 2990 | $this->course->info['path'] |
| 2991 | 2991 | ); |
| 2992 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
| 2993 | - unset($thematic->params['id']); |
|
| 2992 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
| 2993 | + unset($thematic->params['id']); |
|
| 2994 | 2994 | unset($thematic->params['iid']); |
| 2995 | 2995 | |
| 2996 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
| 2996 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
| 2997 | 2997 | |
| 2998 | - if ($last_id) { |
|
| 2998 | + if ($last_id) { |
|
| 2999 | 2999 | |
| 3000 | 3000 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
| 3001 | 3001 | Database::query($sql); |
@@ -3008,19 +3008,19 @@ discard block |
||
| 3008 | 3008 | api_get_user_id() |
| 3009 | 3009 | ); |
| 3010 | 3010 | |
| 3011 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
| 3012 | - unset($thematic_advance['id']); |
|
| 3011 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
| 3012 | + unset($thematic_advance['id']); |
|
| 3013 | 3013 | unset($thematic_advance['iid']); |
| 3014 | - $thematic_advance['attendance_id'] = 0; |
|
| 3015 | - $thematic_advance['thematic_id'] = $last_id; |
|
| 3016 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 3014 | + $thematic_advance['attendance_id'] = 0; |
|
| 3015 | + $thematic_advance['thematic_id'] = $last_id; |
|
| 3016 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 3017 | 3017 | $my_id = Database::insert( |
| 3018 | 3018 | $table_thematic_advance, |
| 3019 | 3019 | $thematic_advance, |
| 3020 | 3020 | false |
| 3021 | 3021 | ); |
| 3022 | 3022 | |
| 3023 | - if ($my_id) { |
|
| 3023 | + if ($my_id) { |
|
| 3024 | 3024 | |
| 3025 | 3025 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
| 3026 | 3026 | Database::query($sql); |
@@ -3032,17 +3032,17 @@ discard block |
||
| 3032 | 3032 | "ThematicAdvanceAdded", |
| 3033 | 3033 | api_get_user_id() |
| 3034 | 3034 | ); |
| 3035 | - } |
|
| 3036 | - } |
|
| 3035 | + } |
|
| 3036 | + } |
|
| 3037 | 3037 | |
| 3038 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
| 3039 | - unset($thematic_plan['id']); |
|
| 3038 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
| 3039 | + unset($thematic_plan['id']); |
|
| 3040 | 3040 | unset($thematic_plan['iid']); |
| 3041 | - $thematic_plan['thematic_id'] = $last_id; |
|
| 3042 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
| 3043 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
| 3041 | + $thematic_plan['thematic_id'] = $last_id; |
|
| 3042 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
| 3043 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
| 3044 | 3044 | |
| 3045 | - if ($my_id) { |
|
| 3045 | + if ($my_id) { |
|
| 3046 | 3046 | |
| 3047 | 3047 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
| 3048 | 3048 | Database::query($sql); |
@@ -3054,12 +3054,12 @@ discard block |
||
| 3054 | 3054 | "ThematicPlanAdded", |
| 3055 | 3055 | api_get_user_id() |
| 3056 | 3056 | ); |
| 3057 | - } |
|
| 3058 | - } |
|
| 3059 | - } |
|
| 3060 | - } |
|
| 3061 | - } |
|
| 3062 | - } |
|
| 3057 | + } |
|
| 3058 | + } |
|
| 3059 | + } |
|
| 3060 | + } |
|
| 3061 | + } |
|
| 3062 | + } |
|
| 3063 | 3063 | |
| 3064 | 3064 | /** |
| 3065 | 3065 | * Restore Attendance |
@@ -3067,14 +3067,14 @@ discard block |
||
| 3067 | 3067 | */ |
| 3068 | 3068 | public function restore_attendance($session_id = 0) |
| 3069 | 3069 | { |
| 3070 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
| 3071 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
| 3072 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
| 3070 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
| 3071 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
| 3072 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
| 3073 | 3073 | |
| 3074 | - $resources = $this->course->resources; |
|
| 3075 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
| 3074 | + $resources = $this->course->resources; |
|
| 3075 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
| 3076 | 3076 | |
| 3077 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 3077 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 3078 | 3078 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 3079 | 3079 | $obj->params['description'], |
| 3080 | 3080 | $this->course->code, |
@@ -3086,11 +3086,11 @@ discard block |
||
| 3086 | 3086 | unset($obj->params['id']); |
| 3087 | 3087 | unset($obj->params['iid']); |
| 3088 | 3088 | |
| 3089 | - $obj->params['c_id'] = $this->destination_course_id; |
|
| 3089 | + $obj->params['c_id'] = $this->destination_course_id; |
|
| 3090 | 3090 | |
| 3091 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
| 3091 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
| 3092 | 3092 | |
| 3093 | - if (is_numeric($last_id)) { |
|
| 3093 | + if (is_numeric($last_id)) { |
|
| 3094 | 3094 | |
| 3095 | 3095 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
| 3096 | 3096 | Database::query($sql); |
@@ -3104,11 +3104,11 @@ discard block |
||
| 3104 | 3104 | ); |
| 3105 | 3105 | |
| 3106 | 3106 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
| 3107 | - unset($attendance_calendar['id']); |
|
| 3107 | + unset($attendance_calendar['id']); |
|
| 3108 | 3108 | unset($attendance_calendar['iid']); |
| 3109 | 3109 | |
| 3110 | - $attendance_calendar['attendance_id'] = $last_id; |
|
| 3111 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
| 3110 | + $attendance_calendar['attendance_id'] = $last_id; |
|
| 3111 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
| 3112 | 3112 | $attendanceCalendarId = Database::insert( |
| 3113 | 3113 | $table_attendance_calendar, |
| 3114 | 3114 | $attendance_calendar |
@@ -3116,11 +3116,11 @@ discard block |
||
| 3116 | 3116 | |
| 3117 | 3117 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
| 3118 | 3118 | Database::query($sql); |
| 3119 | - } |
|
| 3120 | - } |
|
| 3121 | - } |
|
| 3122 | - } |
|
| 3123 | - } |
|
| 3119 | + } |
|
| 3120 | + } |
|
| 3121 | + } |
|
| 3122 | + } |
|
| 3123 | + } |
|
| 3124 | 3124 | |
| 3125 | 3125 | /** |
| 3126 | 3126 | * Restore Works |
@@ -3262,11 +3262,11 @@ discard block |
||
| 3262 | 3262 | */ |
| 3263 | 3263 | public function DBUTF8($str) |
| 3264 | 3264 | { |
| 3265 | - if (UTF8_CONVERT) { |
|
| 3265 | + if (UTF8_CONVERT) { |
|
| 3266 | 3266 | $str = utf8_encode($str); |
| 3267 | 3267 | } |
| 3268 | - return $str; |
|
| 3269 | - } |
|
| 3268 | + return $str; |
|
| 3269 | + } |
|
| 3270 | 3270 | |
| 3271 | 3271 | /** |
| 3272 | 3272 | * @param string $str |
@@ -3277,8 +3277,8 @@ discard block |
||
| 3277 | 3277 | if (UTF8_CONVERT) { |
| 3278 | 3278 | $str = utf8_encode($str); |
| 3279 | 3279 | } |
| 3280 | - return Database::escape_string($str); |
|
| 3281 | - } |
|
| 3280 | + return Database::escape_string($str); |
|
| 3281 | + } |
|
| 3282 | 3282 | |
| 3283 | 3283 | /** |
| 3284 | 3284 | * @param array $array |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | $cidReset = true; |
| 13 | 13 | require_once '../inc/global.inc.php'; |
| 14 | -$current_course_tool = TOOL_COURSE_MAINTENANCE; |
|
| 14 | +$current_course_tool = TOOL_COURSE_MAINTENANCE; |
|
| 15 | 15 | |
| 16 | 16 | api_protect_global_admin_script(); |
| 17 | 17 | api_protect_limit_for_session_admin(); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | function display_form() |
| 84 | 84 | { |
| 85 | - $html = ''; |
|
| 85 | + $html = ''; |
|
| 86 | 86 | $sessions = SessionManager::get_sessions_list(array(), array('name', 'ASC')); |
| 87 | 87 | |
| 88 | 88 | // Actions |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | //destination |
| 111 | 111 | $html .= '<div class="form-group">'; |
| 112 | - $html .= '<label class="col-sm-2 control-label">' . get_lang('DestinationCoursesFromSession') . ': </label>'; |
|
| 112 | + $html .= '<label class="col-sm-2 control-label">'.get_lang('DestinationCoursesFromSession').': </label>'; |
|
| 113 | 113 | $html .= '<div class="col-sm-5" id="ajax_sessions_list_destination">'; |
| 114 | 114 | $html .= '<select class="form-control" name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">'; |
| 115 | 115 | $html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div>'; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $html .= '<button class="btn btn-success" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><em class="fa fa-files-o"></em> '.get_lang('CopyCourse').'</button>'; |
| 132 | 132 | |
| 133 | 133 | // Add Security token |
| 134 | - $html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">'; |
|
| 134 | + $html .= '<input type="hidden" value="'.Security::get_token().'" name="sec_token">'; |
|
| 135 | 135 | $html .= '</div></div>'; |
| 136 | 136 | |
| 137 | 137 | $html .= '</form>'; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | /* HTML head extra */ |
| 231 | 231 | |
| 232 | -$htmlHeadXtra[] = $xajax->getJavascript( api_get_path(WEB_LIBRARY_PATH).'xajax/'); |
|
| 232 | +$htmlHeadXtra[] = $xajax->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax/'); |
|
| 233 | 233 | $htmlHeadXtra[] = '<script type="text/javascript"> |
| 234 | 234 | function checkSelected(id_select,id_radio,id_title,id_destination) { |
| 235 | 235 | var num=0; |
@@ -299,22 +299,22 @@ discard block |
||
| 299 | 299 | display_form(); |
| 300 | 300 | } else { |
| 301 | 301 | |
| 302 | - $arr_course_origin = array(); |
|
| 302 | + $arr_course_origin = array(); |
|
| 303 | 303 | $arr_course_destination = array(); |
| 304 | - $destination_session = ''; |
|
| 305 | - $origin_session = ''; |
|
| 304 | + $destination_session = ''; |
|
| 305 | + $origin_session = ''; |
|
| 306 | 306 | |
| 307 | 307 | if (isset($_POST['SessionCoursesListOrigin'])) { |
| 308 | - $arr_course_origin = $_POST['SessionCoursesListOrigin']; |
|
| 308 | + $arr_course_origin = $_POST['SessionCoursesListOrigin']; |
|
| 309 | 309 | } |
| 310 | 310 | if (isset($_POST['SessionCoursesListDestination'])) { |
| 311 | 311 | $arr_course_destination = $_POST['SessionCoursesListDestination']; |
| 312 | 312 | } |
| 313 | 313 | if (isset($_POST['sessions_list_destination'])) { |
| 314 | - $destination_session = $_POST['sessions_list_destination']; |
|
| 314 | + $destination_session = $_POST['sessions_list_destination']; |
|
| 315 | 315 | } |
| 316 | 316 | if (isset($_POST['sessions_list_origin'])) { |
| 317 | - $origin_session = $_POST['sessions_list_origin']; |
|
| 317 | + $origin_session = $_POST['sessions_list_origin']; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) { |
@@ -354,22 +354,22 @@ discard block |
||
| 354 | 354 | Display::display_normal_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary')); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $arr_course_origin = array(); |
|
| 357 | + $arr_course_origin = array(); |
|
| 358 | 358 | $arr_course_destination = array(); |
| 359 | - $destination_session = ''; |
|
| 360 | - $origin_session = ''; |
|
| 359 | + $destination_session = ''; |
|
| 360 | + $origin_session = ''; |
|
| 361 | 361 | |
| 362 | 362 | if (isset($_POST['SessionCoursesListOrigin'])) { |
| 363 | - $arr_course_origin = $_POST['SessionCoursesListOrigin']; |
|
| 363 | + $arr_course_origin = $_POST['SessionCoursesListOrigin']; |
|
| 364 | 364 | } |
| 365 | 365 | if (isset($_POST['SessionCoursesListDestination'])) { |
| 366 | 366 | $arr_course_destination = $_POST['SessionCoursesListDestination']; |
| 367 | 367 | } |
| 368 | 368 | if (isset($_POST['sessions_list_destination'])) { |
| 369 | - $destination_session = $_POST['sessions_list_destination']; |
|
| 369 | + $destination_session = $_POST['sessions_list_destination']; |
|
| 370 | 370 | } |
| 371 | 371 | if (isset($_POST['sessions_list_origin'])) { |
| 372 | - $origin_session = $_POST['sessions_list_origin']; |
|
| 372 | + $origin_session = $_POST['sessions_list_origin']; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) { |
@@ -378,10 +378,10 @@ discard block |
||
| 378 | 378 | $cb = new CourseBuilder('', $course_origin); |
| 379 | 379 | $course = $cb->build($origin_session, $arr_course_origin[0], $with_base_content); |
| 380 | 380 | //$hiddenFields['same_file_name_option'] = $_POST['same_file_name_option']; |
| 381 | - $hiddenFields['destination_course'] = $arr_course_destination[0]; |
|
| 382 | - $hiddenFields['origin_course'] = $arr_course_origin[0]; |
|
| 383 | - $hiddenFields['destination_session'] = $destination_session; |
|
| 384 | - $hiddenFields['origin_session'] = $origin_session; |
|
| 381 | + $hiddenFields['destination_course'] = $arr_course_destination[0]; |
|
| 382 | + $hiddenFields['origin_course'] = $arr_course_origin[0]; |
|
| 383 | + $hiddenFields['destination_session'] = $destination_session; |
|
| 384 | + $hiddenFields['origin_session'] = $origin_session; |
|
| 385 | 385 | // Add token to Course select form |
| 386 | 386 | $hiddenFields['sec_token'] = Security::get_token(); |
| 387 | 387 | |
@@ -65,6 +65,9 @@ |
||
| 65 | 65 | |
| 66 | 66 | /* FUNCTIONS */ |
| 67 | 67 | |
| 68 | +/** |
|
| 69 | + * @param string $name |
|
| 70 | + */ |
|
| 68 | 71 | function make_select_session_list($name, $sessions, $attr = array()) |
| 69 | 72 | { |
| 70 | 73 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $nameTools = get_lang('CopyCourse'); |
| 49 | 49 | $returnLink = api_get_path( |
| 50 | 50 | WEB_CODE_PATH |
| 51 | - ) . 'course_info/maintenance_coach.php?' . api_get_cidreq(); |
|
| 51 | + ).'course_info/maintenance_coach.php?'.api_get_cidreq(); |
|
| 52 | 52 | $interbreadcrumb[] = array( |
| 53 | 53 | 'url' => $returnLink, |
| 54 | 54 | 'name' => get_lang('Maintenance') |
@@ -71,29 +71,29 @@ discard block |
||
| 71 | 71 | $attrs = ''; |
| 72 | 72 | if (count($attr) > 0) { |
| 73 | 73 | foreach ($attr as $key => $value) { |
| 74 | - $attrs .= ' ' . $key . '="' . $value . '"'; |
|
| 74 | + $attrs .= ' '.$key.'="'.$value.'"'; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | - $output = '<select name="' . $name . '" ' . $attrs . '>'; |
|
| 77 | + $output = '<select name="'.$name.'" '.$attrs.'>'; |
|
| 78 | 78 | |
| 79 | 79 | if (count($sessions) == 0) { |
| 80 | - $output .= '<option value = "0">' . get_lang( |
|
| 80 | + $output .= '<option value = "0">'.get_lang( |
|
| 81 | 81 | 'ThereIsNotStillASession' |
| 82 | - ) . '</option>'; |
|
| 82 | + ).'</option>'; |
|
| 83 | 83 | } else { |
| 84 | - $output .= '<option value = "0">' . get_lang( |
|
| 84 | + $output .= '<option value = "0">'.get_lang( |
|
| 85 | 85 | 'SelectASession' |
| 86 | - ) . '</option>'; |
|
| 86 | + ).'</option>'; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | if (is_array($sessions)) { |
| 90 | 90 | foreach ($sessions as $session) { |
| 91 | 91 | $category_name = ''; |
| 92 | 92 | if (!empty($session['category_name'])) { |
| 93 | - $category_name = ' (' . $session['category_name'] . ')'; |
|
| 93 | + $category_name = ' ('.$session['category_name'].')'; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $output .= '<option value="' . $session['id'] . '">' . $session['name'] . ' ' . $category_name . '</option>'; |
|
| 96 | + $output .= '<option value="'.$session['id'].'">'.$session['name'].' '.$category_name.'</option>'; |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | $output .= '</select>'; |
@@ -118,43 +118,43 @@ discard block |
||
| 118 | 118 | // Actions |
| 119 | 119 | $html .= '<div class="actions">'; |
| 120 | 120 | // Link back to the documents overview |
| 121 | - $html .= '<a href="' . $returnLink . '">' . Display::return_icon( |
|
| 122 | - 'back.png', get_lang('BackTo') . ' ' . get_lang('Maintenance'), '', ICON_SIZE_MEDIUM |
|
| 123 | - ) . '</a>'; |
|
| 121 | + $html .= '<a href="'.$returnLink.'">'.Display::return_icon( |
|
| 122 | + 'back.png', get_lang('BackTo').' '.get_lang('Maintenance'), '', ICON_SIZE_MEDIUM |
|
| 123 | + ).'</a>'; |
|
| 124 | 124 | $html .= '</div>'; |
| 125 | 125 | |
| 126 | 126 | $html .= Display::return_message( |
| 127 | 127 | get_lang('CopyCourseFromSessionToSessionExplanation') |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - $html .= '<form name="formulaire" method="post" action="' . api_get_self( |
|
| 131 | - ) . '?' . api_get_cidreq() . '" >'; |
|
| 130 | + $html .= '<form name="formulaire" method="post" action="'.api_get_self( |
|
| 131 | + ).'?'.api_get_cidreq().'" >'; |
|
| 132 | 132 | $html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">'; |
| 133 | 133 | |
| 134 | 134 | // Source |
| 135 | - $html .= '<tr><td width="15%"><b>' . get_lang( |
|
| 135 | + $html .= '<tr><td width="15%"><b>'.get_lang( |
|
| 136 | 136 | 'OriginCoursesFromSession' |
| 137 | - ) . ':</b></td>'; |
|
| 138 | - $html .= '<td width="10%" align="left">' . api_get_session_name( |
|
| 137 | + ).':</b></td>'; |
|
| 138 | + $html .= '<td width="10%" align="left">'.api_get_session_name( |
|
| 139 | 139 | $sessionId |
| 140 | - ) . '</td>'; |
|
| 140 | + ).'</td>'; |
|
| 141 | 141 | $html .= '<td width="50%">'; |
| 142 | - $html .= "{$courseInfo['title']} ({$courseInfo['code']})" . '</td></tr>'; |
|
| 142 | + $html .= "{$courseInfo['title']} ({$courseInfo['code']})".'</td></tr>'; |
|
| 143 | 143 | |
| 144 | 144 | // Destination |
| 145 | - $html .= '<tr><td width="15%"><b>' . get_lang( |
|
| 145 | + $html .= '<tr><td width="15%"><b>'.get_lang( |
|
| 146 | 146 | 'DestinationCoursesFromSession' |
| 147 | - ) . ':</b></td>'; |
|
| 147 | + ).':</b></td>'; |
|
| 148 | 148 | $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">'; |
| 149 | 149 | $html .= '<select name="sessions_list_destination" onchange="javascript: xajax_searchCourses(this.value,\'destination\');">'; |
| 150 | 150 | if (empty($sessions)) { |
| 151 | - $html .= '<option value = "0">' . get_lang( |
|
| 151 | + $html .= '<option value = "0">'.get_lang( |
|
| 152 | 152 | 'ThereIsNotStillASession' |
| 153 | - ) . '</option>'; |
|
| 153 | + ).'</option>'; |
|
| 154 | 154 | } else { |
| 155 | - $html .= '<option value = "0">' . get_lang( |
|
| 155 | + $html .= '<option value = "0">'.get_lang( |
|
| 156 | 156 | 'SelectASession' |
| 157 | - ) . '</option>'; |
|
| 157 | + ).'</option>'; |
|
| 158 | 158 | foreach ($sessions as $session) { |
| 159 | 159 | if ($session['id'] == $sessionId) { |
| 160 | 160 | continue; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | continue; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $html .= '<option value="' . $session['id'] . '">' . $session['name'] . '</option>'; |
|
| 167 | + $html .= '<option value="'.$session['id'].'">'.$session['name'].'</option>'; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | $html .= '</tr></table>'; |
| 177 | 177 | |
| 178 | 178 | $html .= "<fieldset>"; |
| 179 | - $html .= '<legend>' . get_lang('TypeOfCopy') . ' <small>(' . get_lang('CopyOnlySessionItems') . ')</small></legend>'; |
|
| 179 | + $html .= '<legend>'.get_lang('TypeOfCopy').' <small>('.get_lang('CopyOnlySessionItems').')</small></legend>'; |
|
| 180 | 180 | $html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>'; |
| 181 | - $html .= get_lang('FullCopy') . '</label>'; |
|
| 181 | + $html .= get_lang('FullCopy').'</label>'; |
|
| 182 | 182 | $html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items"/>'; |
| 183 | - $html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>'; |
|
| 183 | + $html .= ' '.get_lang('LetMeSelectItems').'</label><br/>'; |
|
| 184 | 184 | |
| 185 | 185 | $html .= "</fieldset>"; |
| 186 | 186 | |
| 187 | - $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes( |
|
| 187 | + $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes( |
|
| 188 | 188 | api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES) |
| 189 | - ) . "'" . ')) return false;">' . get_lang('CopyCourse') . '</button>'; |
|
| 189 | + )."'".')) return false;">'.get_lang('CopyCourse').'</button>'; |
|
| 190 | 190 | $html .= '</form>'; |
| 191 | 191 | echo $html; |
| 192 | 192 | } |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $courseTitle = str_replace("'", "\'", $course['title']); |
| 214 | 214 | |
| 215 | - $return .= '<option value="' . $course['code'] . '" title="' . @htmlspecialchars( |
|
| 216 | - $course['title'] . ' (' . $course['visual_code'] . ')', ENT_QUOTES, api_get_system_encoding() |
|
| 217 | - ) . '">' . |
|
| 218 | - $course['title'] . ' (' . $course['visual_code'] . ')</option>'; |
|
| 215 | + $return .= '<option value="'.$course['code'].'" title="'.@htmlspecialchars( |
|
| 216 | + $course['title'].' ('.$course['visual_code'].')', ENT_QUOTES, api_get_system_encoding() |
|
| 217 | + ).'">'. |
|
| 218 | + $course['title'].' ('.$course['visual_code'].')</option>'; |
|
| 219 | 219 | } |
| 220 | 220 | $return .= '</select>'; |
| 221 | 221 | $_SESSION['course_list_destination'] = $course_list_destination; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | /* HTML head extra */ |
| 234 | 234 | |
| 235 | 235 | $htmlHeadXtra[] = $xajax->getJavascript( |
| 236 | - api_get_path(WEB_LIBRARY_PATH) . 'xajax/' |
|
| 236 | + api_get_path(WEB_LIBRARY_PATH).'xajax/' |
|
| 237 | 237 | ); |
| 238 | 238 | $htmlHeadXtra[] = '<script> |
| 239 | 239 | function checkSelected(id_select,id_radio,id_title,id_destination) { |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | CourseSelectForm :: display_form($course, $hiddenFields, true); |
| 380 | 380 | |
| 381 | - echo '<div style="float:right"><a href="javascript:window.history.go(-1);">' . |
|
| 381 | + echo '<div style="float:right"><a href="javascript:window.history.go(-1);">'. |
|
| 382 | 382 | Display::return_icon( |
| 383 | - 'back.png', get_lang('Back') . ' ' . get_lang('To') . ' ' . get_lang( |
|
| 383 | + 'back.png', get_lang('Back').' '.get_lang('To').' '.get_lang( |
|
| 384 | 384 | 'PlatformAdmin' |
| 385 | 385 | ), array('style' => 'vertical-align:middle') |
| 386 | - ) . |
|
| 387 | - get_lang('Back') . '</a></div>'; |
|
| 386 | + ). |
|
| 387 | + get_lang('Back').'</a></div>'; |
|
| 388 | 388 | } else { |
| 389 | 389 | Display::display_error_message( |
| 390 | 390 | get_lang('You must select a course from original session and select a destination session') |
@@ -98,21 +98,21 @@ discard block |
||
| 98 | 98 | $cr->set_file_option($_POST['same_file_name_option']); |
| 99 | 99 | $cr->restore(); |
| 100 | 100 | Display::display_normal_message(get_lang('ImportFinished')); |
| 101 | - echo '<a class="btn btn-default" href="' . api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/index.php">' . get_lang('CourseHomepage') . '</a>'; |
|
| 101 | + echo '<a class="btn btn-default" href="'.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php">'.get_lang('CourseHomepage').'</a>'; |
|
| 102 | 102 | } else { |
| 103 | 103 | if (!$error) { |
| 104 | 104 | Display::display_warning_message(get_lang('NoResourcesInBackupFile')); |
| 105 | - echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>'; |
|
| 105 | + echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>'; |
|
| 106 | 106 | } elseif ($filename === false) { |
| 107 | 107 | Display::display_error_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin')); |
| 108 | - echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>'; |
|
| 108 | + echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>'; |
|
| 109 | 109 | } else { |
| 110 | 110 | if ($filename == '') { |
| 111 | 111 | Display::display_error_message(get_lang('SelectBackupFile')); |
| 112 | - echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>'; |
|
| 112 | + echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>'; |
|
| 113 | 113 | } else { |
| 114 | 114 | Display::display_error_message(get_lang('UploadError')); |
| 115 | - echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>'; |
|
| 115 | + echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>'; |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | CourseSelectForm::display_form($course, $hiddenFields); |
| 143 | 143 | } elseif ($filename === false) { |
| 144 | 144 | Display::display_error_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin')); |
| 145 | - echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>'; |
|
| 145 | + echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>'; |
|
| 146 | 146 | } else { |
| 147 | 147 | Display::display_warning_message(get_lang('NoResourcesInBackupFile')); |
| 148 | - echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>'; |
|
| 148 | + echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>'; |
|
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | 151 | $user = api_get_user_info(); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $form = new FormValidator( |
| 158 | 158 | 'import_backup_form', |
| 159 | 159 | 'post', |
| 160 | - api_get_path(WEB_CODE_PATH) . 'coursecopy/import_backup.php?' . api_get_cidreq(), |
|
| 160 | + api_get_path(WEB_CODE_PATH).'coursecopy/import_backup.php?'.api_get_cidreq(), |
|
| 161 | 161 | '', |
| 162 | 162 | array('enctype' => 'multipart/form-data') |
| 163 | 163 | ); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | ); |
| 190 | 190 | $options['null'] = '-'; |
| 191 | 191 | foreach ($backups as $index => $backup) { |
| 192 | - $options[$backup['file']] = $backup['course_code'] . ' (' . $backup['date'] . ')'; |
|
| 192 | + $options[$backup['file']] = $backup['course_code'].' ('.$backup['date'].')'; |
|
| 193 | 193 | } |
| 194 | 194 | $form->addElement( |
| 195 | 195 | 'select', |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | 'radio', |
| 208 | 208 | '', |
| 209 | 209 | '', |
| 210 | - '<i>' . get_lang('NoBackupsAvailable') . '</i>', |
|
| 210 | + '<i>'.get_lang('NoBackupsAvailable').'</i>', |
|
| 211 | 211 | '', |
| 212 | 212 | 'disabled="true"' |
| 213 | 213 | ); |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | $this_section = SECTION_COURSES; |
| 11 | 11 | |
| 12 | 12 | if (extension_loaded('xapian')) { |
| 13 | - require '../newscorm/lp_list_search.php'; |
|
| 13 | + require '../newscorm/lp_list_search.php'; |
|
| 14 | 14 | } else { |
| 15 | 15 | Display::display_header(get_lang('Search')); |
| 16 | 16 | Display::display_error_message(get_lang('SearchXapianModuleNotInstalled')); |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | require_once '../inc/global.inc.php'; |
| 10 | -$this_section = SECTION_COURSES; |
|
| 10 | +$this_section = SECTION_COURSES; |
|
| 11 | 11 | |
| 12 | 12 | if (extension_loaded('xapian')) { |
| 13 | 13 | require '../newscorm/lp_list_search.php'; |
@@ -104,6 +104,8 @@ |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $q = strtolower($_GET["q"]); |
| 107 | -if (!$q) return; |
|
| 107 | +if (!$q) { |
|
| 108 | + return; |
|
| 109 | +} |
|
| 108 | 110 | //echo $q . "| value\n"; |
| 109 | 111 | get_suggestions_from_search_engine($q); |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package chamilo.search |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -require_once dirname(__FILE__) . '/../inc/global.inc.php'; |
|
| 9 | +require_once dirname(__FILE__).'/../inc/global.inc.php'; |
|
| 10 | 10 | |
| 11 | 11 | function get_suggestions_from_search_engine($q) |
| 12 | 12 | { |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | global $charset; |
| 15 | 15 | |
| 16 | 16 | $json = []; |
| 17 | - $table_sfv = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 17 | + $table_sfv = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES); |
|
| 18 | 18 | $q = Database::escape_string($q); |
| 19 | 19 | $cid = api_get_course_id(); |
| 20 | 20 | $sql_add = ''; |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | $i = 0; |
| 29 | 29 | while ($row = Database::fetch_array($sql_result)) { |
| 30 | 30 | $json[] = [ |
| 31 | - 'id' => api_convert_encoding($row['value'],'UTF-8',$charset), |
|
| 32 | - 'value' => api_convert_encoding($row['value'],'UTF-8',$charset), |
|
| 33 | - 'label' => api_convert_encoding($row['value'],'UTF-8',$charset) |
|
| 31 | + 'id' => api_convert_encoding($row['value'], 'UTF-8', $charset), |
|
| 32 | + 'value' => api_convert_encoding($row['value'], 'UTF-8', $charset), |
|
| 33 | + 'label' => api_convert_encoding($row['value'], 'UTF-8', $charset) |
|
| 34 | 34 | ]; |
| 35 | 35 | |
| 36 | - if ($i<20) { |
|
| 37 | - $data[ $row['course_code'] ] [ $row['tool_id'] ] [ $row['ref_id'] ] = 1; |
|
| 36 | + if ($i < 20) { |
|
| 37 | + $data[$row['course_code']] [$row['tool_id']] [$row['ref_id']] = 1; |
|
| 38 | 38 | } |
| 39 | 39 | $i++; |
| 40 | 40 | } |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | // will create a copy as Yannick - Car - Speed |
| 79 | 79 | // in $output[3] |
| 80 | 80 | $c = count($output); |
| 81 | - for ($i=0;$i<$c; $i++) { |
|
| 82 | - $output[($c+$i)] = $current_field_val; |
|
| 81 | + for ($i = 0; $i < $c; $i++) { |
|
| 82 | + $output[($c + $i)] = $current_field_val; |
|
| 83 | 83 | } |
| 84 | 84 | } else { |
| 85 | 85 | //no identical field id, continue as usual |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | foreach ($output as $i=>$out) { |
| 99 | - if (api_stristr($out,$q) === false) {continue;} |
|
| 99 | + if (api_stristr($out, $q) === false) {continue; } |
|
| 100 | 100 | $s = api_convert_encoding(substr($out, 0, -3), 'UTF-8', $charset); |
| 101 | - if (!in_array($s,$more_sugg)) { |
|
| 101 | + if (!in_array($s, $more_sugg)) { |
|
| 102 | 102 | $more_sugg[] = $s; |
| 103 | 103 | $json[] = [ |
| 104 | 104 | 'id' => $s, |
@@ -101,8 +101,8 @@ |
||
| 101 | 101 | $group_url = "group_view.php?id=$id"; |
| 102 | 102 | |
| 103 | 103 | $result['name'] = '<div class="group-name">'.Display::url( |
| 104 | - api_ucwords(cut($result['name'], 40, true)), $group_url) |
|
| 105 | - .'</div><div class="count-username">'. |
|
| 104 | + api_ucwords(cut($result['name'], 40, true)), $group_url) |
|
| 105 | + .'</div><div class="count-username">'. |
|
| 106 | 106 | Display::returnFontAwesomeIcon('user').$result['count'].'</div>'; |
| 107 | 107 | |
| 108 | 108 | $picture = $userGroup->get_picture_group( |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | api_block_anonymous_users(); |
| 21 | 21 | |
| 22 | 22 | if (api_get_setting('allow_social_tool') != 'true') { |
| 23 | - $url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; |
|
| 24 | - header('Location: ' . $url); |
|
| 23 | + $url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; |
|
| 24 | + header('Location: '.$url); |
|
| 25 | 25 | exit; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | $allowed_picture_types = api_get_supported_image_extensions(); |
| 46 | 46 | $form->addRule( |
| 47 | 47 | 'picture', |
| 48 | - get_lang('OnlyImagesAllowed') . ' (' . implode( |
|
| 48 | + get_lang('OnlyImagesAllowed').' ('.implode( |
|
| 49 | 49 | ',', |
| 50 | 50 | $allowed_picture_types |
| 51 | - ) . ')', |
|
| 51 | + ).')', |
|
| 52 | 52 | 'filetype', |
| 53 | 53 | $allowed_picture_types |
| 54 | 54 | ); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
| 68 | 68 | |
| 69 | 69 | $sql = "UPDATE $table_user |
| 70 | - SET picture_uri = '$new_picture' WHERE user_id = " . api_get_user_id(); |
|
| 70 | + SET picture_uri = '$new_picture' WHERE user_id = ".api_get_user_id(); |
|
| 71 | 71 | |
| 72 | 72 | $result = Database::query($sql); |
| 73 | 73 | } |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | $result['name'] = Security::remove_XSS($result['name'], STUDENT, true); |
| 94 | 94 | |
| 95 | 95 | if ($result['count'] == 1) { |
| 96 | - $result['count'] = '1 ' . get_lang('Member'); |
|
| 96 | + $result['count'] = '1 '.get_lang('Member'); |
|
| 97 | 97 | } else { |
| 98 | - $result['count'] = $result['count'] . ' ' . get_lang('Members'); |
|
| 98 | + $result['count'] = $result['count'].' '.get_lang('Members'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $group_url = "group_view.php?id=$id"; |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | 80 |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - $result['picture'] = '<img class="group-image" src="' . $picture['file'] . '" />'; |
|
| 115 | - $group_actions = '<div class="group-more"><a href="groups.php?#tab_browse-2">' . get_lang('SeeMore') . '</a></div>'; |
|
| 116 | - $group_info= '<div class="description"><p>' . cut($result['description'], 120, true) . "</p></div>"; |
|
| 114 | + $result['picture'] = '<img class="group-image" src="'.$picture['file'].'" />'; |
|
| 115 | + $group_actions = '<div class="group-more"><a href="groups.php?#tab_browse-2">'.get_lang('SeeMore').'</a></div>'; |
|
| 116 | + $group_info = '<div class="description"><p>'.cut($result['description'], 120, true)."</p></div>"; |
|
| 117 | 117 | $groups_newest[] = array( |
| 118 | 118 | Display::url( |
| 119 | 119 | $result['picture'], |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | $group_url = "group_view.php?id=$id"; |
| 141 | 141 | |
| 142 | 142 | if ($result['count'] == 1) { |
| 143 | - $result['count'] = '1 ' . get_lang('Member'); |
|
| 143 | + $result['count'] = '1 '.get_lang('Member'); |
|
| 144 | 144 | } else { |
| 145 | - $result['count'] = $result['count'] . ' ' . get_lang('Members'); |
|
| 145 | + $result['count'] = $result['count'].' '.get_lang('Members'); |
|
| 146 | 146 | } |
| 147 | 147 | $result['name'] = '<div class="group-name">'.Display::url( |
| 148 | - api_ucwords(cut($result['name'], 40, true)),$group_url) |
|
| 148 | + api_ucwords(cut($result['name'], 40, true)), $group_url) |
|
| 149 | 149 | .'</div><div class="count-username">'.Display::returnFontAwesomeIcon('user').$result['count'].'</div>'; |
| 150 | 150 | |
| 151 | 151 | $picture = $userGroup->get_picture_group( |
@@ -153,42 +153,42 @@ discard block |
||
| 153 | 153 | $result['picture'], |
| 154 | 154 | 80 |
| 155 | 155 | ); |
| 156 | - $result['picture_uri'] = '<img class="group-image" src="' . $picture['file'] . '" />'; |
|
| 157 | - $group_actions = '<div class="group-more" ><a href="groups.php?#tab_browse-3">' . get_lang('SeeMore') . '</a></div>'; |
|
| 158 | - $group_info= '<div class="description"><p>' . cut($result['description'], 120, true) . "</p></div>"; |
|
| 156 | + $result['picture_uri'] = '<img class="group-image" src="'.$picture['file'].'" />'; |
|
| 157 | + $group_actions = '<div class="group-more" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>'; |
|
| 158 | + $group_info = '<div class="description"><p>'.cut($result['description'], 120, true)."</p></div>"; |
|
| 159 | 159 | $groups_pop[] = array( |
| 160 | 160 | Display::url($result['picture_uri'], $group_url), |
| 161 | - $result['name'],$group_info. $group_actions |
|
| 161 | + $result['name'], $group_info.$group_actions |
|
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | -$list=count($groups_newest); |
|
| 165 | +$list = count($groups_newest); |
|
| 166 | 166 | $social_group_block = null; |
| 167 | 167 | if ($list > 0) { |
| 168 | 168 | $social_group_block .= '<div class="list-group-newest">'; |
| 169 | - $social_group_block .= '<div class="group-title">' . get_lang('Newest') . '</div>'; |
|
| 170 | - for($i = 0;$i < $list; $i++){ |
|
| 171 | - $social_group_block.='<div class="row">'; |
|
| 172 | - $social_group_block.='<div class="col-md-2">' . $groups_newest[$i][0] . '</div>'; |
|
| 173 | - $social_group_block.='<div class="col-md-10">' . $groups_newest[$i][1]; |
|
| 174 | - $social_group_block.= $groups_newest[$i][2] . '</div>'; |
|
| 175 | - $social_group_block.="</div>"; |
|
| 169 | + $social_group_block .= '<div class="group-title">'.get_lang('Newest').'</div>'; |
|
| 170 | + for ($i = 0; $i < $list; $i++) { |
|
| 171 | + $social_group_block .= '<div class="row">'; |
|
| 172 | + $social_group_block .= '<div class="col-md-2">'.$groups_newest[$i][0].'</div>'; |
|
| 173 | + $social_group_block .= '<div class="col-md-10">'.$groups_newest[$i][1]; |
|
| 174 | + $social_group_block .= $groups_newest[$i][2].'</div>'; |
|
| 175 | + $social_group_block .= "</div>"; |
|
| 176 | 176 | } |
| 177 | - $social_group_block.= "</div>"; |
|
| 177 | + $social_group_block .= "</div>"; |
|
| 178 | 178 | } |
| 179 | -$list=count($groups_pop); |
|
| 179 | +$list = count($groups_pop); |
|
| 180 | 180 | if ($list > 0) { |
| 181 | 181 | $social_group_block .= '<div class="list-group-newest">'; |
| 182 | - $social_group_block .= '<div class="group-title">' . get_lang('Popular') . '</div>'; |
|
| 183 | - |
|
| 184 | - for($i = 0;$i < $list; $i++){ |
|
| 185 | - $social_group_block.='<div class="row">'; |
|
| 186 | - $social_group_block.='<div class="col-md-2">' . $groups_pop[$i][0] . '</div>'; |
|
| 187 | - $social_group_block.='<div class="col-md-10">' . $groups_pop[$i][1]; |
|
| 188 | - $social_group_block.= $groups_pop[$i][2] . '</div>'; |
|
| 189 | - $social_group_block.="</div>"; |
|
| 182 | + $social_group_block .= '<div class="group-title">'.get_lang('Popular').'</div>'; |
|
| 183 | + |
|
| 184 | + for ($i = 0; $i < $list; $i++) { |
|
| 185 | + $social_group_block .= '<div class="row">'; |
|
| 186 | + $social_group_block .= '<div class="col-md-2">'.$groups_pop[$i][0].'</div>'; |
|
| 187 | + $social_group_block .= '<div class="col-md-10">'.$groups_pop[$i][1]; |
|
| 188 | + $social_group_block .= $groups_pop[$i][2].'</div>'; |
|
| 189 | + $social_group_block .= "</div>"; |
|
| 190 | 190 | } |
| 191 | - $social_group_block.= "</div>"; |
|
| 191 | + $social_group_block .= "</div>"; |
|
| 192 | 192 | } |
| 193 | 193 | // My friends |
| 194 | 194 | $friend_html = SocialManager::listMyFriendsBlock( |