Merge branch 'master' of github.com:chamilo/chamilo-lms

pull/4002/head
Yannick Warnier 3 years ago
commit 39af799e08
  1. 8
      assets/vue/views/documents/List.vue
  2. 12
      public/main/mySpace/index.php
  3. 4
      src/CoreBundle/Migrations/AbstractMigrationChamilo.php
  4. 8
      src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php
  5. 21
      tests/CourseBundle/Repository/CDocumentRepositoryTest.php

@ -211,8 +211,8 @@
</Button>
<Button v-if="isAuthenticated && isCurrentTeacher" class="btn btn-primary" @click="changeVisibilityHandler(slotProps.data, slotProps)">
<v-icon v-if="slotProps.data.resourceLinkListFromEntity[0].visibility == 2" icon="mdi-eye"/>
<v-icon v-if="slotProps.data.resourceLinkListFromEntity[0].visibility == 0" icon="mdi-eye-off"/>
<v-icon v-if="RESOURCE_LINK_PUBLISHED === slotProps.data.resourceLinkListFromEntity[0].visibility" icon="mdi-eye"/>
<v-icon v-if="RESOURCE_LINK_DRAFT === slotProps.data.resourceLinkListFromEntity[0].visibility" icon="mdi-eye-off"/>
</Button>
<Button v-if="isAuthenticated && isCurrentTeacher" class="btn btn-primary p-mr-2" @click="editHandler(slotProps.data)">
@ -329,7 +329,7 @@ import ResourceFileIcon from '../../components/documents/ResourceFileIcon.vue';
import ResourceFileLink from '../../components/documents/ResourceFileLink.vue';
import DataFilter from '../../components/DataFilter';
import DocumentsFilterForm from '../../components/documents/Filter';
import {RESOURCE_LINK_PUBLISHED} from "../../components/resource_links/visibility";
import {RESOURCE_LINK_PUBLISHED, RESOURCE_LINK_DRAFT} from "../../components/resource_links/visibility";
export default {
name: 'DocumentsList',
@ -344,6 +344,8 @@ export default {
mixins: [ListMixin],
data() {
return {
RESOURCE_LINK_PUBLISHED: RESOURCE_LINK_PUBLISHED,
RESOURCE_LINK_DRAFT: RESOURCE_LINK_DRAFT,
sortBy: 'title',
sortDesc: false,
// columnsQua: [

@ -73,12 +73,12 @@ if ($is_platform_admin) {
Display::return_icon('statistics.png', get_lang('Current courses report'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php'
);
/*
$menu_items[] = Display::url(
Display::return_icon('dashboard.png', get_lang('Dashboard'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'dashboard/index.php'
);
*/
/*
$menu_items[] = Display::url(
Display::return_icon('dashboard.png', get_lang('Dashboard'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'dashboard/index.php'
);
*/
} else {
$menu_items[] = Display::url(
Display::return_icon(

@ -258,11 +258,11 @@ abstract class AbstractMigrationChamilo extends AbstractMigration implements Con
$sessionId = $item['session_id'] ?? 0;
$groupId = $item['to_group_id'] ?? 0;
$newVisibility = ResourceLink::VISIBILITY_PENDING;
$newVisibility = ResourceLink::VISIBILITY_DRAFT;
// Old visibility (item property) is based in this switch:
switch ($visibility) {
case 0:
$newVisibility = ResourceLink::VISIBILITY_PENDING;
$newVisibility = ResourceLink::VISIBILITY_DRAFT;
break;
case 1:

@ -37,18 +37,20 @@ final class Version20200821224242 extends AbstractMigrationChamilo
$this->addSql('UPDATE message SET parent_id = NULL WHERE parent_id = 0');
$sql = 'SELECT id, parent_id FROM message WHERE parent_id IS NOT NULL';
$sql = 'SELECT id, parent_id FROM message WHERE parent_id IS NOT NULL AND parent_id <> 0';
$result = $connection->executeQuery($sql);
$items = $result->fetchAllAssociative();
foreach ($items as $item) {
$id = $item['id'];
$parentId = $item['parent_id'];
$parentId = (int) $item['parent_id'];
$sql = "SELECT id FROM message WHERE id = $parentId";
$result = $connection->executeQuery($sql);
$subItem = $result->fetchAllAssociative();
if (empty($subItem)) {
$sql = "DELETE FROM message WHERE id = $id";
$connection->executeQuery($sql);
$this->addSql($sql);
}
}

@ -16,6 +16,7 @@ use Chamilo\CourseBundle\Entity\CGroup;
use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
use LogicException;
use Symfony\Component\HttpFoundation\Request;
class CDocumentRepositoryTest extends AbstractApiTest
@ -816,18 +817,33 @@ class CDocumentRepositoryTest extends AbstractApiTest
;
$documentRepo->create($document);
$documentRepo->setVisibilityPublished($document);
$link = $document->getFirstResourceLink();
$this->expectException(LogicException::class);
$link->setVisibility(888);
$link->setUserGroup(null);
$this->assertFalse($link->hasGroup());
$this->assertFalse($link->hasSession());
$this->assertTrue($link->isPublished());
$this->assertFalse($link->isDraft());
$this->assertFalse($link->isPending());
$this->assertSame(ResourceLink::VISIBILITY_PUBLISHED, $link->getVisibility());
$this->assertSame('Published', $link->getVisibilityName());
$documentRepo->setVisibilityDraft($document);
$link = $document->getFirstResourceLink();
$this->assertSame(ResourceLink::VISIBILITY_DRAFT, $link->getVisibility());
$this->assertSame('Draft', $link->getVisibilityName());
$documentRepo->toggleVisibilityPublishedDraft($document);
$link = $document->getFirstResourceLink();
$this->assertSame(ResourceLink::VISIBILITY_PUBLISHED, $link->getVisibility());
$this->assertSame('Published', $link->getVisibilityName());
$documentRepo->toggleVisibilityPublishedDraft($document);
$link = $document->getFirstResourceLink();
@ -836,14 +852,17 @@ class CDocumentRepositoryTest extends AbstractApiTest
$documentRepo->setVisibilityPending($document);
$link = $document->getFirstResourceLink();
$this->assertSame(ResourceLink::VISIBILITY_PENDING, $link->getVisibility());
$this->assertSame('Pending', $link->getVisibilityName());
$documentRepo->setVisibilityDeleted($document);
$link = $document->getFirstResourceLink();
$this->assertSame(ResourceLink::VISIBILITY_DELETED, $link->getVisibility());
$this->assertSame('Deleted', $link->getVisibilityName());
$documentRepo->softDelete($document);
$link = $document->getFirstResourceLink();
$this->assertSame(ResourceLink::VISIBILITY_DELETED, $link->getVisibility());
$this->assertSame('Deleted', $link->getVisibilityName());
}
public function testGetTotalSpaceByCourse(): void

Loading…
Cancel
Save