Skip to content

Commit a8b4e48

Browse files
committed
Try group iid if group.id doesn't work see BT#14145
1 parent 1517b20 commit a8b4e48

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

main/inc/lib/AnnouncementManager.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,6 @@ public static function edit_announcement(
769769
$courseId = api_get_course_int_id();
770770
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
771771
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
772-
773772
$id = intval($id);
774773

775774
$params = [
@@ -825,14 +824,20 @@ public static function edit_announcement(
825824
if (is_array($send_to['groups'])) {
826825
foreach ($send_to['groups'] as $group) {
827826
$groupInfo = GroupManager::get_group_properties($group);
828-
api_item_property_update(
829-
$courseInfo,
830-
TOOL_ANNOUNCEMENT,
831-
$id,
832-
'AnnouncementUpdated',
833-
api_get_user_id(),
834-
$groupInfo
835-
);
827+
if (empty($groupInfo)) {
828+
// Probably the group id and iid are different try checking the iid
829+
$groupInfo = GroupManager::get_group_properties($group, true);
830+
}
831+
if ($groupInfo) {
832+
api_item_property_update(
833+
$courseInfo,
834+
TOOL_ANNOUNCEMENT,
835+
$id,
836+
'AnnouncementUpdated',
837+
api_get_user_id(),
838+
$groupInfo
839+
);
840+
}
836841
}
837842
}
838843

@@ -1068,7 +1073,7 @@ public static function load_edit_users($tool, $id)
10681073
{
10691074
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
10701075
$tool = Database::escape_string($tool);
1071-
$id = intval($id);
1076+
$id = (int) $id;
10721077
$courseId = api_get_course_int_id();
10731078

10741079
$sql = "SELECT * FROM $table
@@ -1087,7 +1092,7 @@ public static function load_edit_users($tool, $id)
10871092
return 'everyone';
10881093
break;
10891094
default:
1090-
$to[] = "GROUP:".$row['to_group_id'];
1095+
$to[] = "GROUP:".$toGroup;
10911096
}
10921097
}
10931098

0 commit comments

Comments
 (0)