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. 42
      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: assets:
uri_prefix: '' uri_prefix: ''
upload_destination: oneup_flysystem.asset_filesystem upload_destination: oneup_flysystem.asset_filesystem
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer namer: Chamilo\CoreBundle\Component\Utils\AssetFileNameNamer
directory_namer: directory_namer:
service: Chamilo\CoreBundle\Component\Utils\AssetDirectoryNamer service: Chamilo\CoreBundle\Component\Utils\AssetDirectoryNamer
options: {property: 'category'} options: {property: 'category'}

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

@ -67,32 +67,30 @@ switch ($action) {
} }
$courseList = []; $courseList = [];
if (!empty($list)) { foreach ($list as $course) {
foreach ($list as $course) { $courseInfo = api_get_course_info_by_id($course['real_id']);
$courseInfo = api_get_course_info_by_id($course['real_id']); $sessionId = 0;
$sessionId = 0; if (!empty($course['session_id'])) {
if (isset($course['session_id']) && !empty($course['session_id'])) { $sessionId = $course['session_id'];
$sessionId = $course['session_id']; }
}
$sessionName = '';
if (isset($course['session_name']) && !empty($course['session_name'])) {
$sessionName = ' ('.$course['session_name'].')';
}
// Skip current course/course session $sessionName = '';
if ($currentCourseId == $courseInfo['real_id'] && $sessionId == $currentSessionId) { if (!empty($course['session_name'])) {
continue; $sessionName = ' ('.$course['session_name'].')';
} }
$courseList['items'][] = [ // Skip current course/course session
'id' => $courseInfo['real_id'].'_'.$sessionId, if ($currentCourseId == $courseInfo['real_id'] && $sessionId == $currentSessionId) {
'text' => $courseInfo['title'].$sessionName, continue;
];
} }
echo json_encode($courseList); $courseList['items'][] = [
'id' => $courseInfo['real_id'].'_'.$sessionId,
'text' => $courseInfo['title'].$sessionName,
];
} }
echo json_encode($courseList);
} }
break; break;
case 'search_category': case 'search_category':
@ -125,7 +123,7 @@ switch ($action) {
break; break;
case 'search_course': case 'search_course':
if (api_is_teacher() || api_is_platform_admin()) { 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 //if session is defined, lets find only courses of this session
$courseList = SessionManager::get_course_list_by_session_id( $courseList = SessionManager::get_course_list_by_session_id(
$_GET['session_id'], $_GET['session_id'],

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

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

@ -7,7 +7,9 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Component\Utils; namespace Chamilo\CoreBundle\Component\Utils;
use Chamilo\CoreBundle\Entity\Asset; use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Repository\AssetRepository;
use InvalidArgumentException; use InvalidArgumentException;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Vich\UploaderBundle\Mapping\PropertyMapping; use Vich\UploaderBundle\Mapping\PropertyMapping;
@ -17,13 +19,17 @@ use Vich\UploaderBundle\Naming\DirectoryNamerInterface;
class AssetDirectoryNamer implements DirectoryNamerInterface, ConfigurableInterface class AssetDirectoryNamer implements DirectoryNamerInterface, ConfigurableInterface
{ {
protected PropertyAccessorInterface $propertyAccessor; protected PropertyAccessorInterface $propertyAccessor;
private ?AssetRepository $assetRepository = null;
private ?RequestStack $requestStack = null;
private string $propertyPath; private string $propertyPath;
private int $charsPerDir = 2; private int $charsPerDir = 2;
private int $dirs = 1; 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->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
$this->assetRepository = $assetRepository;
$this->requestStack = $requestStack;
} }
/** /**
@ -53,6 +59,13 @@ class AssetDirectoryNamer implements DirectoryNamerInterface, ConfigurableInterf
$fileName = $mapping->getFileName($object); $fileName = $mapping->getFileName($object);
$category = $this->propertyAccessor->getValue($object, $this->propertyPath); $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; $parts[] = $category;
if (Asset::EXTRA_FIELD === $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: Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor:
arguments: ['@translator', '@router'] 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\CreateDefaultPages: ~
Chamilo\CoreBundle\Component\Utils\NameConvention: ~ Chamilo\CoreBundle\Component\Utils\NameConvention: ~
Chamilo\CoreBundle\Component\Utils\Glide: Chamilo\CoreBundle\Component\Utils\Glide:

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

Loading…
Cancel
Save