|
|
|
@ -757,35 +757,36 @@ class CourseRestorer |
|
|
|
|
*/ |
|
|
|
|
function restore_forum_category($my_id = null) { |
|
|
|
|
$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
|
|
|
$resources = $this->course->resources; |
|
|
|
|
//$forum_cat = $resources[RESOURCE_FORUMCATEGORY][$id]; |
|
|
|
|
foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
|
|
|
|
if (!empty($my_id)) { |
|
|
|
|
if ($my_id != $id) { |
|
|
|
|
continue; |
|
|
|
|
$resources = $this->course->resources; |
|
|
|
|
if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
|
|
|
|
foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
|
|
|
|
if (!empty($my_id)) { |
|
|
|
|
if ($my_id != $id) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($forum_cat && !$forum_cat->is_restored()) { |
|
|
|
|
$title = $forum_cat->obj->cat_title; |
|
|
|
|
if (!empty($title)) { |
|
|
|
|
if (!preg_match('/.*\((.+)\)$/', $title, $matches)) { |
|
|
|
|
// This is for avoiding repetitive adding of training code after several backup/restore cycles. |
|
|
|
|
if ($matches[1] != $this->course->code) { |
|
|
|
|
$title = $title.' ('.$this->course->code.')'; |
|
|
|
|
if ($forum_cat && !$forum_cat->is_restored()) { |
|
|
|
|
$title = $forum_cat->obj->cat_title; |
|
|
|
|
if (!empty($title)) { |
|
|
|
|
if (!preg_match('/.*\((.+)\)$/', $title, $matches)) { |
|
|
|
|
// This is for avoiding repetitive adding of training code after several backup/restore cycles. |
|
|
|
|
if ($matches[1] != $this->course->code) { |
|
|
|
|
$title = $title.' ('.$this->course->code.')'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$params = (array) $forum_cat->obj; |
|
|
|
|
$params['c_id'] = $this->destination_course_id; |
|
|
|
|
$params['cat_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['cat_comment'], $this->course->code, $this->course->destination_path); |
|
|
|
|
unset($params['cat_id']); |
|
|
|
|
self::DBUTF8_array($params); |
|
|
|
|
$new_id = Database::insert($forum_cat_table, $params); |
|
|
|
|
$this->course->resources[RESOURCE_FORUMCATEGORY][$id]->destination_id = $new_id; |
|
|
|
|
if (!empty($my_id)) { |
|
|
|
|
return $new_id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$params = (array) $forum_cat->obj; |
|
|
|
|
$params['c_id'] = $this->destination_course_id; |
|
|
|
|
$params['cat_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['cat_comment'], $this->course->code, $this->course->destination_path); |
|
|
|
|
unset($params['cat_id']); |
|
|
|
|
self::DBUTF8_array($params); |
|
|
|
|
$new_id = Database::insert($forum_cat_table, $params); |
|
|
|
|
$this->course->resources[RESOURCE_FORUMCATEGORY][$id]->destination_id = $new_id; |
|
|
|
|
if (!empty($my_id)) { |
|
|
|
|
return $new_id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|