Learnpath: Add sanity checks in the lp-specific user subscription configuration page to avoir null errors - refs BT#17726

pull/3547/head
Yannick Warnier 5 years ago
parent a013c164d4
commit c97b8dcdd1
  1. 22
      main/lp/lp_subscribe_users.php

@ -94,8 +94,15 @@ $subscribedUsersInLp = $itemRepo->getUsersSubscribedToItem(
);
$selectedChoices = [];
foreach ($subscribedUsersInLp as $itemProperty) {
$selectedChoices[] = $itemProperty->getToUser()->getId();
if (!empty($subscribedUsersInLp)) {
foreach ($subscribedUsersInLp as $itemProperty) {
if (!empty($itemProperty)) {
$getToUser = $itemProperty->getToUser();
if (!empty($getToUser)) {
$selectedChoices[] = $getToUser->getId();
}
}
}
}
//Building the form for Users
@ -140,8 +147,15 @@ $subscribedGroupsInLp = $itemRepo->getGroupsSubscribedToItem(
$selectedGroupChoices = [];
/** @var CItemProperty $itemProperty */
foreach ($subscribedGroupsInLp as $itemProperty) {
$selectedGroupChoices[] = $itemProperty->getGroup()->getId();
if (!empty($subscribedGroupsInLp)) {
foreach ($subscribedGroupsInLp as $itemProperty) {
if (!empty($itemProperty)) {
$getGroup = $itemProperty->getGroup();
if (!empty($getGroup)) {
$selectedGroupChoices[] = $itemProperty->getGroup()->getId();
}
}
}
}
$groupMultiSelect = $form->addElement(

Loading…
Cancel
Save