Fix empty user group select when editing an announcement see BT#14824

pull/2688/head
Julio Montoya 7 years ago
parent 260549e93c
commit a1e7082fec
  1. 3
      main/announcements/announcements.php
  2. 15
      main/inc/lib/course.lib.php

@ -450,7 +450,7 @@ switch ($action) {
);
// when we want to remind the users who have never been active
// then we have a different subject and content for the announcement
if ($_GET['since'] == 'never') {
if ($_GET['since'] === 'never') {
$title_to_modify = sprintf(
get_lang('RemindInactiveLearnersMailSubject'),
api_get_setting('siteName')
@ -475,6 +475,7 @@ switch ($action) {
$announcementInfo = AnnouncementManager::get_by_id($courseId, $id);
if (isset($announcementInfo) && !empty($announcementInfo)) {
$to = AnnouncementManager::load_edit_users('announcement', $id);
$defaults = [
'title' => $announcementInfo['title'],
'content' => $announcementInfo['content'],

@ -6051,7 +6051,7 @@ class CourseManager
public static function addGroupMultiSelect($form, $groupInfo, $to = [])
{
$group_users = GroupManager::get_subscribed_users($groupInfo);
$array = self::buildSelectOptions(null, $group_users, $to);
$array = self::buildSelectOptions([$groupInfo], $group_users, $to);
$result = [];
foreach ($array as $content) {
@ -6089,14 +6089,19 @@ class CourseManager
"GROUP:".$groupId,
$alreadySelected
)
) { // $alreadySelected is the array containing the groups (and users) that are already selected
$user_label = ($thisGroup['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser');
$user_disabled = ($thisGroup['userNb'] > 0) ? "" : "disabled=disabled";
) {
$userCount = isset($thisGroup['userNb']) ? $thisGroup['userNb'] : 0;
if (empty($userCount)) {
$userCount = isset($thisGroup['count_users']) ? $thisGroup['count_users'] : 0;
}
// $alreadySelected is the array containing the groups (and users) that are already selected
$user_label = ($userCount > 0) ? get_lang('Users') : get_lang('LowerCaseUser');
$user_disabled = ($userCount > 0) ? "" : "disabled=disabled";
$result[] = [
'disabled' => $user_disabled,
'value' => "GROUP:".$groupId,
// The space before "G" is needed in order to advmultiselect.php js puts groups first
'content' => " G: ".$thisGroup['name']." - ".$thisGroup['userNb']." ".$user_label,
'content' => " G: ".$thisGroup['name']." - ".$userCount." ".$user_label,
];
}
}

Loading…
Cancel
Save