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. 16
      main/lp/lp_subscribe_users.php

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

Loading…
Cancel
Save