Minor: Format code

pull/5960/head
Angel Fernando Quiroz Campos 8 months ago
parent 489bcdc703
commit 0fb79998f2
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 48
      assets/vue/views/documents/DocumentsList.vue
  2. 45
      assets/vue/views/links/LinksList.vue
  3. 3
      src/CoreBundle/Command/LpProgressReminderCommand.php
  4. 10
      src/CoreBundle/Form/ProfileType.php
  5. 12
      src/CoreBundle/Migrations/Schema/V200/Version20230913162700.php
  6. 4
      src/CoreBundle/Migrations/Schema/V200/Version20241230175100.php
  7. 11
      src/CoreBundle/Repository/Node/UserRepository.php

@ -133,15 +133,15 @@
field="resourceNode.title"
>
<template #body="slotProps">
<div style="display: flex; align-items: center;">
<div style="display: flex; align-items: center">
<DocumentEntry
v-if="slotProps.data"
:data="slotProps.data"
/>
<BaseIcon
v-if="isAllowedToEdit && isSessionDocument(slotProps.data)"
icon="session-star"
class="mr-8"
icon="session-star"
/>
</div>
</template>
@ -176,17 +176,17 @@
<div class="flex flex-row justify-end gap-2">
<BaseButton
v-if="canEdit(slotProps.data)"
:title="t('Move')"
icon="folder-move"
size="small"
type="secondary"
:title="t('Move')"
@click="openMoveDialog(slotProps.data)"
/>
<BaseButton
:title="t('Information')"
icon="information"
size="small"
type="primary"
:title="t('Information')"
@click="btnShowInformationOnClick(slotProps.data)"
/>
@ -199,44 +199,46 @@
? 'eye-off'
: ''
"
:title="t('Visibility')"
size="small"
type="secondary"
:title="t('Visibility')"
@click="btnChangeVisibilityOnClick(slotProps.data)"
/>
<BaseButton
v-if="canEdit(slotProps.data)"
:title="t('Edit')"
icon="edit"
size="small"
type="secondary"
:title="t('Edit')"
@click="btnEditOnClick(slotProps.data)"
/>
<BaseButton
v-if="canEdit(slotProps.data)"
:title="t('Delete')"
icon="delete"
size="small"
type="danger"
:title="t('Delete')"
@click="confirmDeleteItem(slotProps.data)"
/>
<BaseButton
v-if="isCertificateMode && canEdit(slotProps.data)"
:class="{ selected: slotProps.data.iid === defaultCertificateId }"
:icon="slotProps.data.iid === defaultCertificateId ? 'certificate-selected' : 'certificate-not-selected'"
:title="t('Set as default certificate')"
size="small"
type="slotProps.data.iid === defaultCertificateId ? 'success' : 'black'"
:title="t('Set as default certificate')"
@click="selectAsDefaultCertificate(slotProps.data)"
/>
<BaseButton
v-if="securityStore.isAuthenticated && isCurrentTeacher && isHtmlFile(slotProps.data) && canEdit(slotProps.data)"
v-if="
securityStore.isAuthenticated && isCurrentTeacher && isHtmlFile(slotProps.data) && canEdit(slotProps.data)
"
:icon="getTemplateIcon(slotProps.data.iid)"
:title="t('Template options')"
size="small"
type="secondary"
:title="t('Template options')"
@click="openTemplateForm(slotProps.data.iid)"
/>
</div>
@ -279,9 +281,9 @@
<Dropdown
v-model="selectedFolder"
:options="folders"
:placeholder="t('Select a folder')"
optionLabel="label"
optionValue="value"
:placeholder="t('Select a folder')"
/>
</BaseDialogConfirmCancel>
@ -505,17 +507,14 @@ const isCurrentTeacher = computed(() => securityStore.isCurrentTeacher)
const canEdit = (item) => {
const resourceLink = item.resourceLinkListFromEntity[0]
const isSessionDocument = resourceLink.session && resourceLink.session['@id'] === `/api/sessions/${sid}`
const isSessionDocument = resourceLink.session && resourceLink.session["@id"] === `/api/sessions/${sid}`
const isBaseCourse = !resourceLink.session
return (
(isSessionDocument && isAllowedToEdit.value) ||
(isBaseCourse && !sid && isCurrentTeacher.value)
)
return (isSessionDocument && isAllowedToEdit.value) || (isBaseCourse && !sid && isCurrentTeacher.value)
}
const isSessionDocument = (item) => {
const resourceLink = item.resourceLinkListFromEntity[0]
return resourceLink.session && resourceLink.session['@id'] === `/api/sessions/${sid}`
return resourceLink.session && resourceLink.session["@id"] === `/api/sessions/${sid}`
}
const isHtmlFile = (fileData) => isHtml(fileData)
@ -785,11 +784,13 @@ function openMoveDialog(document) {
isMoveDialogVisible.value = true
}
async function fetchFolders(nodeId = null, parentPath = '') {
const foldersList = [{
label: 'Root',
value: nodeId || route.params.node || route.query.node || 'root-node-id',
}]
async function fetchFolders(nodeId = null, parentPath = "") {
const foldersList = [
{
label: "Root",
value: nodeId || route.params.node || route.query.node || "root-node-id",
},
]
try {
let nodesToFetch = [{ id: nodeId || route.params.node || route.query.node, path: parentPath }]
@ -808,7 +809,7 @@ async function fetchFolders(nodeId = null, parentPath = '') {
},
})
response.data["hydra:member"].forEach(folder => {
response.data["hydra:member"].forEach((folder) => {
const fullPath = `${currentNode.path}/${folder.title}`
foldersList.push({
@ -837,7 +838,6 @@ async function loadAllFolders() {
async function moveDocument() {
try {
const response = await axios.put(`/api/documents/${item.value.iid}/move`, {
parentResourceNodeId: selectedFolder.value,
})

@ -49,9 +49,12 @@
class="flex flex-col gap-4"
>
<!-- Render the list of links without a category -->
<LinkCategoryCard v-if="linksWithoutCategory.length > 0" :showHeader="false">
<LinkCategoryCard
v-if="linksWithoutCategory.length > 0"
:showHeader="false"
>
<template #header>
<h5>{{ t('General') }}</h5>
<h5>{{ t("General") }}</h5>
</template>
<ul>
@ -61,8 +64,8 @@
class="mb-4"
>
<LinkItem
:link="link"
:isLinkValid="linkValidationResults[link.iid]"
:link="link"
@check="checkLink(link.iid, link.url)"
@delete="confirmDeleteLink(link)"
@edit="editLink"
@ -90,7 +93,10 @@
/>
<h5>{{ category.info.title }}</h5>
</div>
<div class="flex gap-2" v-if="securityStore.isAuthenticated && isCurrentTeacher">
<div
v-if="securityStore.isAuthenticated && isCurrentTeacher"
class="flex gap-2"
>
<BaseButton
:label="t('Edit')"
icon="edit"
@ -123,8 +129,8 @@
:key="link.id"
>
<LinkItem
:link="link"
:isLinkValid="linkValidationResults[link.iid]"
:link="link"
@check="checkLink(link.iid, link.url)"
@delete="confirmDeleteLink(link)"
@edit="editLink"
@ -135,7 +141,7 @@
</li>
</ul>
<p v-if="!category.links || category.links.length === 0">
{{ t('There are no links in this category') }}
{{ t("There are no links in this category") }}
</p>
</LinkCategoryCard>
</div>
@ -153,9 +159,7 @@
>
<div v-if="categoryToDelete">
<p class="mb-2 font-semibold">{{ categoryToDelete.info.title }}</p>
<p>
{{ t('With links') }}: {{ (categoryToDelete.links || []).map((l) => l.title).join(', ') }}
</p>
<p>{{ t("With links") }}: {{ (categoryToDelete.links || []).map((l) => l.title).join(", ") }}</p>
</div>
</BaseDialogDelete>
</div>
@ -178,14 +182,13 @@ import Skeleton from "primevue/skeleton"
import { isVisible, toggleVisibilityProperty, visibilityFromBoolean } from "../../components/links/linkVisibility"
import { useSecurityStore } from "../../store/securityStore"
import { useCidReq } from "../../composables/cidReq"
import { checkIsAllowedToEdit } from "../../composables/userPermissions";
import { checkIsAllowedToEdit } from "../../composables/userPermissions"
const route = useRoute()
const router = useRouter()
const securityStore = useSecurityStore()
const { cid, sid, gid } = useCidReq()
const isAllowedToEdit = ref(false);
const isAllowedToEdit = ref(false)
const { t } = useI18n()
@ -216,7 +219,7 @@ const isLoading = ref(true)
const linkValidationResults = ref({})
onMounted(async () => {
isAllowedToEdit.value = await checkIsAllowedToEdit(true, true, true);
isAllowedToEdit.value = await checkIsAllowedToEdit(true, true, true)
linksWithoutCategory.value = []
categories.value = []
await fetchLinks()
@ -257,7 +260,7 @@ async function checkLink(id, url) {
console.error("Error checking link:", error)
linkValidationResults.value = {
...linkValidationResults.value,
[id]: { isValid: false, message: error.message || "Link validation failed" }
[id]: { isValid: false, message: error.message || "Link validation failed" },
}
}
}
@ -265,7 +268,7 @@ async function checkLink(id, url) {
async function toggleVisibility(link) {
try {
const visibility = toggleVisibilityProperty(!link.linkVisible)
let newLink = await linkService.toggleLinkVisibility(link.iid, isVisible(visibility))
let newLink = await linkService.toggleLinkVisibility(link.iid, isVisible(visibility), cid, sid)
notifications.showSuccessNotification(t("Link visibility updated"))
Object.values(categories.value)
.map((c) => c.links)
@ -377,14 +380,14 @@ async function fetchLinks() {
}
try {
const data = await linkService.getLinks(params);
linksWithoutCategory.value = data.linksWithoutCategory || [];
categories.value = data.categories || [];
const data = await linkService.getLinks(params)
linksWithoutCategory.value = data.linksWithoutCategory || []
categories.value = data.categories || []
} catch (error) {
console.error("Error fetching links:", error);
notifications.showErrorNotification(t("Could not retrieve links"));
console.error("Error fetching links:", error)
notifications.showErrorNotification(t("Could not retrieve links"))
} finally {
isLoading.value = false;
isLoading.value = false
}
}
</script>

@ -26,6 +26,9 @@ use Twig\Environment;
class LpProgressReminderCommand extends Command
{
/**
* @var string|null
*/
protected static $defaultName = 'app:lp-progress-reminder';
private const NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION = 3;

@ -46,7 +46,7 @@ class ProfileType extends AbstractType
'field' => 'illustration',
'type' => IllustrationType::class,
'label' => 'Picture',
'mapped' => false
'mapped' => false,
],
'login' => ['field' => 'login', 'type' => TextType::class, 'label' => 'Login'],
'password' => ['field' => 'password', 'type' => TextType::class, 'label' => 'Password'],
@ -61,8 +61,8 @@ class ProfileType extends AbstractType
];
foreach ($fieldsMap as $key => $fieldConfig) {
if (in_array($key, $visibleOptions)) {
$isEditable = in_array($key, $changeableOptions);
if (\in_array($key, $visibleOptions)) {
$isEditable = \in_array($key, $changeableOptions);
$builder->add(
$fieldConfig['field'],
$fieldConfig['type'],
@ -78,14 +78,14 @@ class ProfileType extends AbstractType
}
}
if ('true' === $this->settingsManager->getSetting('use_users_timezone') && in_array('timezone', $visibleOptions)) {
if ('true' === $this->settingsManager->getSetting('use_users_timezone') && \in_array('timezone', $visibleOptions)) {
$builder->add(
'timezone',
TimezoneType::class,
[
'label' => 'Timezone',
'required' => true,
'attr' => !in_array('timezone', $changeableOptions) ? ['readonly' => true] : [],
'attr' => !\in_array('timezone', $changeableOptions) ? ['readonly' => true] : [],
]
);
}

@ -103,7 +103,7 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$items = $result->fetchAllAssociative();
foreach ($items as $item) {
if ((int)$item['c_id'] !== (int)$courseId) {
if ((int) $item['c_id'] !== (int) $courseId) {
continue;
}
@ -138,7 +138,7 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$documentRepo->update($document);
}
} catch (Exception $e) {
error_log("[ERROR] Processing file $filePath failed for IID={$item['iid']} in Course ID={$item['c_id']}: " . $e->getMessage());
error_log("[ERROR] Processing file $filePath failed for IID={$item['iid']} in Course ID={$item['c_id']}: ".$e->getMessage());
}
}
}
@ -159,7 +159,7 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$videoPath = preg_replace("/^\\/courses\\/$actualCourseDirectory\\//i", "/courses/$courseDirectory/", $videoPath);
}
$sql = "SELECT iid, title, resource_node_id FROM c_document WHERE title = :title AND c_id = :courseId";
$sql = 'SELECT iid, title, resource_node_id FROM c_document WHERE title = :title AND c_id = :courseId';
$result = $this->connection->executeQuery($sql, ['title' => $fileName, 'courseId' => $courseId]);
$documents = $result->fetchAllAssociative();
@ -213,7 +213,7 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$appCourseOldPath = $rootPath.'/app'.$videoPath;
$title = basename($appCourseOldPath);
$sql = "SELECT * FROM c_document WHERE title = :title AND c_id = :courseId";
$sql = 'SELECT * FROM c_document WHERE title = :title AND c_id = :courseId';
$stmt = $this->connection->prepare($sql);
$result = $stmt->executeQuery(['title' => $title, 'courseId' => $courseId]);
$existingDocument = $result->fetchAssociative();
@ -222,9 +222,9 @@ final class Version20230913162700 extends AbstractMigrationChamilo
$document = $documentRepo->find($existingDocument['iid']);
if ($document) {
return $document;
} else {
throw new Exception("ResourceNode not found for resource_node_id " . $existingDocument['resource_node_id']);
}
throw new Exception('ResourceNode not found for resource_node_id '.$existingDocument['resource_node_id']);
}
if (file_exists($appCourseOldPath) && !is_dir($appCourseOldPath)) {

@ -51,13 +51,13 @@ final class Version20241230175100 extends AbstractMigrationChamilo
private function getForeignKeyName(string $tableName, string $columnName): ?string
{
$query = "
$query = '
SELECT CONSTRAINT_NAME
FROM information_schema.KEY_COLUMN_USAGE
WHERE TABLE_NAME = :tableName
AND COLUMN_NAME = :columnName
AND TABLE_SCHEMA = DATABASE()
";
';
$result = $this->connection->fetchOne($query, [
'tableName' => $tableName,

@ -188,12 +188,15 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
$connection->commit();
} catch (Exception $e) {
$connection->rollBack();
throw $e;
}
}
/**
* Reassigns resources and related data from a deleted user to a fallback user in the database.
*
* @param mixed $connection
*/
protected function reassignUserResourcesToFallbackSQL(User $userToDelete, User $fallbackUser, $connection): void
{
@ -220,12 +223,12 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
$field = $relation['field'];
$action = $relation['action'];
if ($action === 'delete') {
if ('delete' === $action) {
$connection->executeStatement(
"DELETE FROM $table WHERE $field = :userId",
['userId' => $userToDelete->getId()]
);
} elseif ($action === 'update') {
} elseif ('update' === $action) {
$connection->executeStatement(
"UPDATE $table SET $field = :fallbackUserId WHERE $field = :userId",
[
@ -353,8 +356,8 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
$em = $this->getEntityManager();
$connection = $em->getConnection();
$currentDate = (new \DateTime())->format('Y-m-d H:i:s');
$updatedContent = sprintf(
$currentDate = (new Datetime())->format('Y-m-d H:i:s');
$updatedContent = \sprintf(
$this->translator->trans('This message was deleted when the user was removed from the platform on %s'),
$currentDate
);

Loading…
Cancel
Save