Adding c_id when copy a course session into another course session see #3910

skala
Julio Montoya 13 years ago
parent 2da70aaa81
commit cf13a78c74
  1. 13
      main/coursecopy/classes/CourseRestorer.class.php
  2. 25
      main/coursecopy/classes/CourseSelectForm.class.php
  3. 2
      main/coursecopy/copy_course.php
  4. 10
      main/coursecopy/copy_course_session.php
  5. 10
      main/inc/lib/main_api.lib.php

@ -294,7 +294,7 @@ class CourseRestorer
foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
$dirs = explode('/', dirname($document->path));
//$dirs = explode('/', dirname($document->path));
if (empty($document->item_properties[0]['id_session'])) {
$my_session_id = 0;
@ -326,10 +326,7 @@ class CourseRestorer
if (!is_dir($path.dirname($document->path))) {
continue;
//echo '! is dir'; var_dump($path.dirname($document->path));
$visibility = $document->item_properties[0]['visibility'];
//$new = $path.dirname($document->path);
//$new = substr($new, 8);
$visibility = $document->item_properties[0]['visibility'];
$new = substr($document->path, 8);
if (!empty($document->title)) {
$title = $document->title;
@ -433,12 +430,12 @@ class CourseRestorer
$dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
$basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
$dest_filename = basename($dest_document_path); // e.g: "collaborative.png"
//$dest_filename = basename($dest_document_path); // e.g: "collaborative.png"
$base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document"
$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
copy_folder_course_session($basedir_dest_path, $base_path_document, $session_id, $course_info, $document);
copy_folder_course_session($basedir_dest_path, $base_path_document, $session_id, $course_info, $document, $this->course_origin_id);
if (file_exists($course_path.$document->path)) {
copy($course_path.$document->path, $dest_document_path);
@ -450,7 +447,7 @@ class CourseRestorer
if (in_array($file_info['extension'], array('html','htm'))) {
$content = file_get_contents($dest_document_path);
if (UTF8_CONVERT) $content = utf8_encode($content);
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course($content ,$this->course->code,$this->course->destination_path);
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course($content, $this->course->code, $this->course->destination_path);
$result = file_put_contents($dest_document_path,$content);
}
}

@ -18,21 +18,21 @@ class CourseSelectForm
*/
function display_form($course, $hidden_fields = null, $avoid_serialize=false) {
global $charset;
$resource_titles[RESOURCE_EVENT] = get_lang('Events');
$resource_titles[RESOURCE_EVENT] = get_lang('Events');
$resource_titles[RESOURCE_ANNOUNCEMENT] = get_lang('Announcements');
$resource_titles[RESOURCE_DOCUMENT] = get_lang('Documents');
$resource_titles[RESOURCE_LINK] = get_lang('Links');
$resource_titles[RESOURCE_COURSEDESCRIPTION] = get_lang('CourseDescription');
$resource_titles[RESOURCE_FORUM] = get_lang('Forums');
$resource_titles[RESOURCE_FORUM] = get_lang('Forums');
$resource_titles[RESOURCE_QUIZ] = get_lang('Tests');
$resource_titles[RESOURCE_LEARNPATH] = get_lang('Learnpaths');
$resource_titles[RESOURCE_SCORM] = 'SCORM';
$resource_titles[RESOURCE_TOOL_INTRO] = get_lang('ToolIntro');
$resource_titles[RESOURCE_SURVEY] = get_lang('Survey');
$resource_titles[RESOURCE_LEARNPATH] = get_lang('Learnpaths');
$resource_titles[RESOURCE_SCORM] = 'SCORM';
$resource_titles[RESOURCE_TOOL_INTRO] = get_lang('ToolIntro');
$resource_titles[RESOURCE_SURVEY] = get_lang('Survey');
$resource_titles[RESOURCE_GLOSSARY] = get_lang('Glossary');
$resource_titles[RESOURCE_WIKI] = get_lang('Wiki');
$resource_titles[RESOURCE_THEMATIC] = get_lang('Thematic');
$resource_titles[RESOURCE_ATTENDANCE] = get_lang('Attendance');
$resource_titles[RESOURCE_WIKI] = get_lang('Wiki');
$resource_titles[RESOURCE_THEMATIC] = get_lang('Thematic');
$resource_titles[RESOURCE_ATTENDANCE] = get_lang('Attendance');
?>
<script type="text/javascript">
@ -133,11 +133,10 @@ class CourseSelectForm
echo "[<a href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a> | <a href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>]";
echo '<br />';
foreach ($resources as $id => $resource) {
echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />';
echo ' <label for="resource['.$type.']['.$id.']">';
echo ' <label class="checkbox">';
echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />';
$resource->show();
echo '</label>';
echo '<br />';
echo '</label>';
}
echo '</blockquote>';
echo '</div>';

@ -115,4 +115,4 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
}
/* FOOTER */
Display::display_footer();
Display::display_footer();

@ -114,12 +114,12 @@ function display_form() {
$html .= '</tr></table>';
$html .= '<h3>'.get_lang('TypeOfCopy').'</h3>';
$html .= '<input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= '<label for="copy_option_1"> '.get_lang('FullCopy').'</label><br/>';
$html .= '<input type="radio" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
$html .= '<label for="copy_option_2"><span id="title_option2" style="color:#aaa"> '.get_lang('LetMeSelectItems').'</span></label><br/>';
$html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= get_lang('FullCopy').'</label><br/>';
$html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
$html .= ' '.get_lang('LetMeSelectItems').'</label><br/>';
$html .= '<input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" /><label for="copy_base_content_id">'.get_lang('CopyOnlySessionItems').'</label><br /><br/>';
$html .= '<label class="checkbox"><input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" />'.get_lang('CopyOnlySessionItems').'</label><br /><br/>';
$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;">'.get_lang('CopyCourse').'</button>';
$html .= '</form>';

@ -2783,10 +2783,10 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
}
$course_id = $_course['real_id'];
$filter = "c_id = $course_id AND tool='$tool' AND ref='$item_id' $condition_session ";
$filter = " c_id = $course_id AND tool='$tool' AND ref='$item_id' $condition_session ";
if ($item_id == '*') {
$filter = "c_id = $course_id AND tool='$tool' AND visibility<>'2' $condition_session"; // For all (not deleted) items of the tool
$filter = " c_id = $course_id AND tool='$tool' AND visibility<>'2' $condition_session"; // For all (not deleted) items of the tool
}
// Check whether $to_user_id and $to_group_id are passed in the function call.
// If both are not passed (both are null) then it is a message for everybody and $to_group_id should be 0 !
@ -3629,9 +3629,11 @@ function copyr($source, $dest, $exclude = array(), $copied_files = array()) {
}
// TODO: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach. Documentation header to be added here.
function copy_folder_course_session($pathname, $base_path_document, $session_id, $course_info, $document) {
function copy_folder_course_session($pathname, $base_path_document, $session_id, $course_info, $document, $source_course_id) {
$table = Database :: get_course_table(TABLE_DOCUMENT);
$session_id = intval($session_id);
$source_course_id = intval($source_course_id);
// Check whether directory already exists.
if (is_dir($pathname) || empty($pathname)) {
return true;
@ -3657,7 +3659,7 @@ function copy_folder_course_session($pathname, $base_path_document, $session_id,
if (!file_exists($new_pathname)) {
$path = Database::escape_string($path);
$sql = "SELECT * FROM $table WHERE path = '$path' AND filetype = 'folder' AND session_id = '$session_id'";
$sql = "SELECT * FROM $table WHERE c_id = $source_course_id AND path = '$path' AND filetype = 'folder' AND session_id = '$session_id'";
$rs1 = Database::query($sql);
$num_rows = Database::num_rows($rs1);

Loading…
Cancel
Save