Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
:to="tabTo('CMImportBackup')"
class="cm-tab"
active-class="cm-tab--active"
@click="goToTab('CMImportBackup', $event)"
>
<i class="mdi mdi-tray-arrow-down cm-tab__icon"></i>
<span>{{ t("Import backup") }}</span>
Expand All @@ -46,6 +47,7 @@
:to="tabTo('CMCreateBackup')"
class="cm-tab"
active-class="cm-tab--active"
@click="goToTab('CMCreateBackup', $event)"
>
<i class="mdi mdi-content-save cm-tab__icon"></i>
<span>{{ t("Create backup") }}</span>
Expand All @@ -56,6 +58,7 @@
:to="tabTo('CMCopyCourse')"
class="cm-tab"
active-class="cm-tab--active"
@click="goToTab('CMCopyCourse', $event)"
>
<i class="mdi mdi-content-copy cm-tab__icon"></i>
<span>{{ t("Copy course") }}</span>
Expand All @@ -66,6 +69,7 @@
:to="tabTo('CMCc13')"
class="cm-tab"
active-class="cm-tab--active"
@click="goToTab('CMCc13', $event)"
>
<i class="mdi mdi-layers cm-tab__icon"></i>
<span>{{ t("IMS CC 1.3") }}</span>
Expand All @@ -76,7 +80,7 @@
:to="tabTo('CMRecycle')"
class="cm-tab"
active-class="cm-tab--active"
@click.prevent="refreshRecycleTab"
@click="goToTab('CMRecycle', $event)"
>
<i class="mdi mdi-recycle cm-tab__icon"></i>
<span>{{ t("Recycle course") }}</span>
Expand All @@ -87,6 +91,7 @@
:to="tabTo('CMDelete')"
class="cm-tab cm-tab--danger"
active-class="cm-tab--active"
@click="goToTab('CMDelete', $event)"
>
<i class="mdi mdi-trash-can-outline cm-tab__icon"></i>
<span>{{ t("Delete course") }}</span>
Expand Down Expand Up @@ -128,9 +133,11 @@ function tabTo(name) {
}
}

function refreshRecycleTab() {
function goToTab(name, evt) {
if (route.name !== name) return
evt?.preventDefault?.()
router.push({
name: "CMRecycle",
name,
params: { node },
query: { ...route.query, _r: Date.now().toString() },
})
Expand Down
21 changes: 19 additions & 2 deletions assets/vue/views/coursemaintenance/ImportBackup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
@change="onLocalFile"
class="w-full rounded border border-gray-25 p-2 text-sm"
/>
<div
v-if="backupType === 'local' && localFile"
class="mt-1 text-tiny text-gray-50"
>
{{ localFile.name }}
</div>

<!-- Server archive -->
<label class="mt-4 flex items-center gap-2">
Expand Down Expand Up @@ -159,7 +165,7 @@
<button
class="btn-primary"
@click="nextFromStep1"
:disabled="loading"
:disabled="loading || !canContinueFromStep1"
>
<i class="mdi mdi-arrow-right"></i> {{ t("Continue") }}
</button>
Expand Down Expand Up @@ -243,7 +249,7 @@
</template>

<script setup>
import { ref, onMounted, watch } from "vue"
import { ref, onMounted, watch, computed } from "vue"
import { useRoute, useRouter } from "vue-router"
import { useI18n } from "vue-i18n"
import svc from "../../services/courseMaintenance"
Expand Down Expand Up @@ -273,6 +279,17 @@ const tree = ref([]) // groups as returned by backend
const notices = ref([])
const selections = ref({}) // { [type]: { [id]: 1 } }

const canContinueFromStep1 = computed(() => {
if (backupType.value === "local") return !!localFile.value
if (backupType.value === "server") return !!serverFilename.value
return false
})

watch(backupType, (v) => {
if (v === "local") serverFilename.value = ""
else localFile.value = null
})

/* Lifecycle */
onMounted(bootstrap)
watch(
Expand Down
38 changes: 37 additions & 1 deletion src/CourseBundle/Component/CourseCopy/CourseRestorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ public function restore_documents($session_id = 0, $respect_base_content = false
}
}

// scan del directorio oficial de backups del archiver
$scanBase = $this->getCourseBackupsBase();
if (is_dir($scanBase)) {
$cands = glob($scanBase.'/CourseArchiver_*', GLOB_ONLYDIR) ?: [];
Expand Down Expand Up @@ -785,6 +784,20 @@ public function restore_documents($session_id = 0, $respect_base_content = false
$isHtml = $isHtmlFile($srcPath, $rawTitle);
$rel = '/'.ltrim(substr($item->path, 8), '/'); // remove "document" prefix
$parentRel = rtrim(\dirname($rel), '/');

if (!empty($item->destination_id) && !$isHtml) {
$maybeExisting = $docRepo->find((int) $item->destination_id);
if ($maybeExisting) {
$this->dlog('restore_documents: already mapped asset, skipping', [
'src' => $item->path ?? null,
'dst_iid' => (int) $item->destination_id,
]);
continue;
} else {
$item->destination_id = 0;
}
}

$parentId = $folders[$parentRel] ?? 0;
if (!$parentId) {
$parentId = $ensureFolder($parentRel);
Expand Down Expand Up @@ -1023,6 +1036,15 @@ public function restore_forums(int $sessionId = 0): void
if (!\is_object($forumRes) || !\is_object($forumRes->obj)) {
continue;
}

if ((int) ($forumRes->destination_id ?? 0) > 0) {
$this->dlog('restore_forums: already mapped, skipping', [
'src_forum_id' => (int) $srcForumId,
'dst_forum_iid' => (int) $forumRes->destination_id,
]);
continue;
}

$p = (array) $forumRes->obj;

$dstCategory = null;
Expand Down Expand Up @@ -1500,6 +1522,16 @@ public function restore_links($session_id = 0): void
};

foreach ($resources[RESOURCE_LINK] as $oldLinkId => $link) {

$mapped = (int) ($this->course->resources[RESOURCE_LINK][$oldLinkId]->destination_id ?? 0);
if ($mapped > 0) {
$this->dlog('restore_links: already mapped, skipping', [
'src_link_id' => (int) $oldLinkId,
'dst_link_id' => $mapped,
]);
continue;
}

$rawUrl = (string) ($link->url ?? ($link->extra['url'] ?? ''));
$rawTitle = (string) ($link->title ?? ($link->extra['title'] ?? ''));
$rawDesc = (string) ($link->description ?? ($link->extra['description'] ?? ''));
Expand Down Expand Up @@ -2753,6 +2785,10 @@ public function restore_quizzes($session_id = 0, $respect_base_content = false):
}

foreach ($resources[RESOURCE_QUIZ] as $id => $quizWrap) {
if ((int) ($this->course->resources[RESOURCE_QUIZ][$id]->destination_id ?? 0) > 0) {
$this->dlog('RESTORE_QUIZ: already mapped, skipping', ['src_quiz_id' => (int) $id]);
continue;
}
$quiz = isset($quizWrap->obj) ? $quizWrap->obj : $quizWrap;

// Rewrite HTML-bearing fields
Expand Down
Loading