Skip to content

Commit 8b746cc

Browse files
committed
Merge branch 'master' of github.com:chamilo/chamilo-lms
2 parents c72139d + 779b066 commit 8b746cc

File tree

16 files changed

+200
-72
lines changed

16 files changed

+200
-72
lines changed

.env.dist

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ DATABASE_PASSWORD='{{DATABASE_PASSWORD}}'
1616
###< doctrine/doctrine-bundle ###
1717

1818
###> symfony/framework-bundle ###
19-
APP_ENV='{{APP_ENV}}'
19+
APP_ENV='dev'
2020
APP_SECRET='{{APP_SECRET}}'
21-
APP_DEBUG='{{APP_DEBUG}}'
21+
APP_DEBUG='1'
2222
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
2323
#TRUSTED_HOSTS='^(localhost|example\.com)$'
2424
###< symfony/framework-bundle ###
@@ -29,28 +29,31 @@ APP_INSTALLED='{{APP_INSTALLED}}'
2929
## Encrypt method bcrypt/sha1/md5
3030
APP_ENCRYPT_METHOD='{{APP_ENCRYPT_METHOD}}'
3131

32-
APP_LOCALE='{{APP_LOCALE}}'
32+
APP_LOCALE='en_US'
3333

34-
APP_CUSTOM_VUE_TEMPLATE='{{APP_CUSTOM_VUE_TEMPLATE}}'
34+
APP_CUSTOM_VUE_TEMPLATE='0'
3535

36-
GOOGLE_MAPS_API_KEY='{{GOOGLE_MAPS_API_KEY}}'
36+
GOOGLE_MAPS_API_KEY=''
37+
38+
# Enable the entryponint /api for API docs
39+
APP_ENABLE_API_ENTRYPOINT=false
3740

3841
#APP_API_PLATFORM_URL='http://localhost/api/' #deprecated
3942

4043
###< chamilo ###
4144

4245
###> symfony/mailer ###
43-
MAILER_DSN='{{MAILER_DSN}}'
46+
MAILER_DSN=sendmail://default
4447
###< symfony/mailer ###
4548

4649
###> nelmio/cors-bundle ###
47-
CORS_ALLOW_ORIGIN='{{CORS_ALLOW_ORIGIN}}'
50+
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
4851
###< nelmio/cors-bundle ###
4952

5053
###> lexik/jwt-authentication-bundle ###
51-
JWT_SECRET_KEY='{{JWT_SECRET_KEY}}'
52-
JWT_PUBLIC_KEY='{{JWT_PUBLIC_KEY}}'
53-
JWT_PASSPHRASE='{{JWT_PASSPHRASE}}'
54+
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
55+
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
56+
JWT_PASSPHRASE=your_secret_passphrase
5457
###< lexik/jwt-authentication-bundle ###
5558

5659
###> symfony/messenger ###
@@ -59,12 +62,3 @@ JWT_PASSPHRASE='{{JWT_PASSPHRASE}}'
5962
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
6063
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
6164
###< symfony/messenger ###
62-
63-
###> additional settings ###
64-
DB_MANAGER_ENABLED='{{DB_MANAGER_ENABLED}}'
65-
SECURITY_KEY='{{SECURITY_KEY}}'
66-
SOFTWARE_NAME='{{SOFTWARE_NAME}}'
67-
SOFTWARE_URL='{{SOFTWARE_URL}}'
68-
DENY_DELETE_USERS='{{DENY_DELETE_USERS}}'
69-
HOSTING_TOTAL_SIZE_LIMIT='{{HOSTING_TOTAL_SIZE_LIMIT}}'
70-
###< additional settings ###

assets/css/app.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ form .field {
698698
.permissions-table {
699699
width: 100%;
700700
border-collapse: collapse;
701+
table-layout: auto;
701702
th, td {
702703
border: 1px solid #ccc;
703704
padding: 8px;
@@ -713,8 +714,12 @@ form .field {
713714
background-color: #e9e9e9;
714715
}
715716
th, td {
716-
border: 1px solid #ddd;
717-
padding: 8px;
717+
padding: 5px;
718+
font-size: 0.9em;
719+
white-space: normal;
720+
word-wrap: break-word;
721+
min-width: 100px;
722+
vertical-align: top;
718723
}
719724
th {
720725
padding-top: 12px;
@@ -741,6 +746,10 @@ form .field {
741746
.save-button:hover {
742747
background-color: #45a049;
743748
}
749+
input[type="checkbox"] {
750+
transform: scale(1);
751+
margin: 0 auto;
752+
}
744753
}
745754

746755
.files-info-page {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
api_platform:
22
enable_docs: true
3-
enable_entrypoint: false
3+
enable_entrypoint: '%env(bool:APP_ENABLE_API_ENTRYPOINT)%'

public/main/auth/inscription.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@
174174
$exercise_redirect = isset($_REQUEST['e']) && !empty($_REQUEST['e']) ? $_REQUEST['e'] : null;
175175

176176
if (!empty($course_code_redirect)) {
177+
if (!api_is_anonymous()) {
178+
$course_info = api_get_course_info($course_code_redirect);
179+
$subscribed = CourseManager::autoSubscribeToCourse($course_code_redirect);
180+
if ($subscribed) {
181+
header('Location: ' . api_get_path(WEB_PATH) . 'course/'.$course_info['real_id'].'/home?sid=0');
182+
} else {
183+
header('Location: ' . api_get_path(WEB_PATH) . 'course/'.$course_info['real_id'].'/about');
184+
}
185+
exit;
186+
}
177187
Session::write('course_redirect', $course_code_redirect);
178188
Session::write('exercise_redirect', $exercise_redirect);
179189
}

public/main/forum/editpost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function setFocus() {
124124
$sessionEntity = api_get_session_entity();
125125

126126
$forumIsVisible = $forum->isVisible($courseEntity);
127-
$categoryIsVisible = $category->isVisible($courseEntity);
127+
$categoryIsVisible = $category->isVisible($courseEntity) && !api_get_session_id();
128128

129129
if (empty($post)) {
130130
api_not_allowed(true);

public/main/forum/editthread.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function setFocus() {
9595
//$forumIsVisible = $forum->isVisible($courseEntity, $sessionEntity);
9696

9797
$category = $forum->getForumCategory();
98-
$categoryIsVisible = $category->isVisible($courseEntity);
98+
$categoryIsVisible = $category->isVisible($courseEntity) && !api_get_session_id();
9999

100100
if (api_is_in_gradebook()) {
101101
$interbreadcrumb[] = [

public/main/forum/newthread.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function setFocus() {
125125
(
126126
($current_forum_category && false == $current_forum_category->isVisible($courseEntity)) ||
127127
false == $current_forum_category->isVisible($courseEntity)
128-
)
128+
) && !api_get_session_id()
129129
) {
130130
api_not_allowed(true);
131131
}

public/main/forum/viewforum.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,19 @@ function setFocus() {
110110
(
111111
($category && false == $category->isVisible($courseEntity)) ||
112112
!$category->isVisible($courseEntity)
113-
)
113+
) &&
114+
!$sessionId
114115
) {
115-
api_not_allowed(true);
116+
// api_not_allowed(true);
116117
}
117118
} else {
118119
// Course
119120
if (!api_is_allowed_to_create_course() && //is a student
120121
(
121122
($category && false == $category->isVisible($courseEntity)) ||
122123
!$category->isVisible($courseEntity)
123-
)
124+
) &&
125+
!$sessionId
124126
) {
125127
api_not_allowed(true);
126128
}

public/main/inc/lib/course.lib.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,82 @@ public static function autoSubscribeToCourse($courseCode, $status = STUDENT)
684684
return self::subscribeUser($userId, $course->getId(), $status, 0);
685685
}
686686

687+
/**
688+
* Checks if the current user can subscribe to a given course.
689+
*/
690+
public static function canUserSubscribeToCourse(string $courseCode): bool
691+
{
692+
if (api_is_anonymous()) {
693+
return false;
694+
}
695+
696+
$course = Container::getCourseRepository()->findOneBy(['code' => $courseCode]);
697+
698+
if (null === $course) {
699+
return false;
700+
}
701+
702+
$visibility = (int) $course->getVisibility();
703+
704+
if (in_array($visibility, [
705+
Course::CLOSED,
706+
Course::HIDDEN,
707+
])) {
708+
return false;
709+
}
710+
711+
if (Course::REGISTERED === $visibility && false === $course->getSubscribe()) {
712+
return false;
713+
}
714+
715+
$userId = api_get_user_id();
716+
717+
$sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
718+
WHERE
719+
user_id = $userId AND
720+
relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND
721+
c_id = ".$course->getId();
722+
if (Database::num_rows(Database::query($sql)) > 0) {
723+
return false;
724+
}
725+
726+
if (SUBSCRIBE_NOT_ALLOWED === (int) $course->getSubscribe()) {
727+
return false;
728+
}
729+
730+
$extraFieldValue = new ExtraFieldValue('course');
731+
$value = $extraFieldValue->get_values_by_handler_and_field_variable(
732+
$course->getId(),
733+
'max_subscribed_students'
734+
);
735+
if (!empty($value) && isset($value['value']) && '' !== $value['value']) {
736+
$maxStudents = (int) $value['value'];
737+
$count = CourseManager::get_user_list_from_course_code(
738+
$courseCode,
739+
0,
740+
null,
741+
null,
742+
STUDENT,
743+
true,
744+
false
745+
);
746+
747+
if ($count >= $maxStudents) {
748+
return false;
749+
}
750+
}
751+
752+
if ('true' === api_get_setting('session.catalog_course_subscription_in_user_s_session')) {
753+
$user = api_get_user_entity($userId);
754+
$sessions = $user->getCurrentlyAccessibleSessions();
755+
if (empty($sessions) && $user->getSessionsAsStudent()) {
756+
return false;
757+
}
758+
}
759+
760+
return true;
761+
}
762+
687763
/**
688764
* Subscribe a user to a course. No checks are performed here to see if
689765
* course subscription is allowed.

public/main/my_space/myStudents.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@
508508
$em->persist($message);
509509
$em->flush();
510510

511+
$senderName = UserManager::formatUserFullName($currentUser);
512+
$emailAdmin = api_get_setting('admin.administrator_email');
513+
511514
// Send also message to all student bosses
512515
$bossList = UserManager::getStudentBossList($studentId);
513516

@@ -517,20 +520,29 @@
517520

518521
foreach ($bossList as $boss) {
519522
$studentFullName = UserManager::formatUserFullName($student);
520-
$content = sprintf(
523+
$contentBoss = sprintf(
521524
get_lang('Hi,<br/><br/>User %s sent a follow up message about student %s.<br/><br/>The message can be seen here %s'),
522525
UserManager::formatUserFullName($currentUser),
523526
$studentFullName,
524527
$link
525528
);
526-
$message = (new Message())
529+
$messageBoss = (new Message())
527530
->setTitle(sprintf(get_lang('Follow up message about student %s'), $studentFullName))
528-
->setContent($content)
531+
->setContent($contentBoss)
529532
->setSender(api_get_user_entity())
530533
->addReceiverTo(api_get_user_entity($boss['boss_id']))
531534
->setMsgType(Message::MESSAGE_TYPE_INBOX)
532535
;
533-
$em->persist($message);
536+
$em->persist($messageBoss);
537+
538+
api_mail_html(
539+
UserManager::formatUserFullName(api_get_user_entity($boss['boss_id'])),
540+
api_get_user_entity($boss['boss_id'])->getEmail(),
541+
sprintf(get_lang('Follow up message about student %s'), $studentFullName),
542+
$contentBoss,
543+
$senderName,
544+
$emailAdmin
545+
);
534546
}
535547

536548
$em->flush();

0 commit comments

Comments
 (0)