Merge remote-tracking branch 'origin/master'

pull/5206/head
Angel Fernando Quiroz Campos 2 years ago
commit 260a6aecd9
  1. 2
      config/packages/vich_uploader.yaml
  2. 4
      public/main/gradebook/certificate_report.php
  3. 8
      public/main/inc/ajax/course.ajax.php
  4. 2
      public/main/inc/lib/course.lib.php
  5. 14
      public/main/user/user.php
  6. 15
      src/CoreBundle/Component/Utils/AssetDirectoryNamer.php
  7. 59
      src/CoreBundle/Component/Utils/AssetFileNameNamer.php
  8. 14
      src/CoreBundle/Resources/config/services.yml
  9. 16
      tailwind.config.js

@ -16,7 +16,7 @@ vich_uploader:
assets:
uri_prefix: ''
upload_destination: oneup_flysystem.asset_filesystem
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
namer: Chamilo\CoreBundle\Component\Utils\AssetFileNameNamer
directory_namer:
service: Chamilo\CoreBundle\Component\Utils\AssetDirectoryNamer
options: {property: 'category'}

@ -47,7 +47,7 @@ if (api_is_student_boss()) {
}
foreach ($sessionsList as $session) {
$sessions[$session['id']] = $session['name'];
$sessions[$session['id']] = $session['title'];
}
$selfUrl = api_get_self();
@ -233,7 +233,7 @@ if ($searchSessionAndCourse || $searchCourseOnly) {
}
if (!is_null($gradebook)) {
$sessionName = $session['name'];
$sessionName = $session['title'];
$courseName = $sessionCourse['title'];
$certificateStudent = [

@ -67,16 +67,15 @@ switch ($action) {
}
$courseList = [];
if (!empty($list)) {
foreach ($list as $course) {
$courseInfo = api_get_course_info_by_id($course['real_id']);
$sessionId = 0;
if (isset($course['session_id']) && !empty($course['session_id'])) {
if (!empty($course['session_id'])) {
$sessionId = $course['session_id'];
}
$sessionName = '';
if (isset($course['session_name']) && !empty($course['session_name'])) {
if (!empty($course['session_name'])) {
$sessionName = ' ('.$course['session_name'].')';
}
@ -93,7 +92,6 @@ switch ($action) {
echo json_encode($courseList);
}
}
break;
case 'search_category':
if (api_is_platform_admin() || api_is_allowed_to_create_course()) {
@ -125,7 +123,7 @@ switch ($action) {
break;
case 'search_course':
if (api_is_teacher() || api_is_platform_admin()) {
if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
if (!empty($_GET['session_id'])) {
//if session is defined, lets find only courses of this session
$courseList = SessionManager::get_course_list_by_session_id(
$_GET['session_id'],

@ -1253,7 +1253,7 @@ class CourseManager
* @param array $extra_field
* @param array $courseCodeList
* @param array $userIdList
* @param string $filterByActive
* @param bool $filterByActive
* @param array $sessionIdList
* @param string $searchByKeyword
*

@ -673,6 +673,11 @@ function get_number_of_users()
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
$active = isset($_GET['active']) ? $_GET['active'] : null;
if ($active) {
$active = true;
} else {
$active = false;
}
$type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : STUDENT;
if (empty($sessionId)) {
@ -821,6 +826,13 @@ function get_user_data($from, $number_of_items, $column, $direction)
}
$active = $_GET['active'] ?? null;
if (isset($active)) {
if ($active) {
$active = true;
} else {
$active = false;
}
}
if (empty($sessionId)) {
$status = $type;
@ -840,7 +852,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
null,
false,
false,
null,
[],
[],
[],
$active

@ -7,7 +7,9 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Component\Utils;
use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Repository\AssetRepository;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Vich\UploaderBundle\Mapping\PropertyMapping;
@ -17,13 +19,17 @@ use Vich\UploaderBundle\Naming\DirectoryNamerInterface;
class AssetDirectoryNamer implements DirectoryNamerInterface, ConfigurableInterface
{
protected PropertyAccessorInterface $propertyAccessor;
private ?AssetRepository $assetRepository = null;
private ?RequestStack $requestStack = null;
private string $propertyPath;
private int $charsPerDir = 2;
private int $dirs = 1;
public function __construct(?PropertyAccessorInterface $propertyAccessor)
public function __construct(?PropertyAccessorInterface $propertyAccessor, ?AssetRepository $assetRepository = null, ?RequestStack $requestStack = null)
{
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
$this->assetRepository = $assetRepository;
$this->requestStack = $requestStack;
}
/**
@ -53,6 +59,13 @@ class AssetDirectoryNamer implements DirectoryNamerInterface, ConfigurableInterf
$fileName = $mapping->getFileName($object);
$category = $this->propertyAccessor->getValue($object, $this->propertyPath);
if (Asset::SYSTEM_TEMPLATE === $object->getCategory()) {
return 'system_templates';
}
if (Asset::TEMPLATE === $object->getCategory()) {
return 'doc_templates';
}
$parts[] = $category;
if (Asset::EXTRA_FIELD === $category) {

@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Component\Utils;
use Chamilo\CoreBundle\Entity\Asset;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Translation\TranslatorInterface;
use Vich\UploaderBundle\Mapping\PropertyMapping;
use Vich\UploaderBundle\Naming\NamerInterface;
use const PATHINFO_EXTENSION;
/**
* @implements NamerInterface<Asset>
*/
class AssetFileNameNamer implements NamerInterface
{
private RequestStack $requestStack;
private TranslatorInterface $translator;
public function __construct(RequestStack $requestStack, TranslatorInterface $translator)
{
$this->requestStack = $requestStack;
$this->translator = $translator;
}
public function name($object, PropertyMapping $mapping): string
{
if (!$object instanceof Asset) {
throw new InvalidArgumentException('Expected object of type Asset.');
}
$category = $object->getCategory();
if (\in_array($category, [Asset::TEMPLATE, Asset::SYSTEM_TEMPLATE])) {
$request = $this->requestStack->getCurrentRequest();
if ($request) {
$templateId = $object->getId();
$templateTitle = $request->get('title', 'default-title');
$titleSlug = $this->slugify($templateTitle);
$extension = pathinfo($mapping->getFileName($object), PATHINFO_EXTENSION);
return sprintf('%s-%s.%s', $templateId, $titleSlug, $extension);
}
}
return $mapping->getFileName($object);
}
private function slugify(string $text): string
{
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $text), '-'));
}
}

@ -45,7 +45,19 @@ services:
Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor:
arguments: ['@translator', '@router']
Chamilo\CoreBundle\Component\Utils\AssetDirectoryNamer: ~
Chamilo\CoreBundle\Component\Utils\AssetDirectoryNamer:
arguments:
- '@property_accessor'
- '@Chamilo\CoreBundle\Repository\AssetRepository'
- '@request_stack'
Chamilo\CoreBundle\Component\Utils\AssetFileNameNamer:
arguments:
- '@request_stack'
- '@translator'
tags:
- { name: vich_uploader.namer, mapping: assets }
Chamilo\CoreBundle\Component\Utils\CreateDefaultPages: ~
Chamilo\CoreBundle\Component\Utils\NameConvention: ~
Chamilo\CoreBundle\Component\Utils\Glide:

@ -36,14 +36,14 @@ module.exports = {
gradient: colorWithOpacity("--color-tertiary-gradient"),
},
gray: {
5: "#fcfcfc",
10: "#fafafa",
15: "#f7f8f9",
20: "#edf0f2",
25: "#e4e9ed",
30: "rgba(0, 0, 0, 0.12)",
50: "#a2a6b0",
90: "#333333",
5: "#ccc",
10: "#bbb",
15: "#aaa",
20: "#999",
25: "#888",
30: "#777",
50: "#555",
90: "#444",
},
support: {
1: "rgba(46, 117, 163, 0.08)",

Loading…
Cancel
Save