mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°2039 - Send news only to Person with at least 1 active user which has access to the backoffice
This commit is contained in:
@@ -9,11 +9,17 @@ class PortalDispatcher
|
||||
$this->sPortalid = $sPortalId;
|
||||
$this->aData = PortalDispatcherData::GetData($sPortalId);
|
||||
}
|
||||
|
||||
public function IsUserAllowed()
|
||||
|
||||
/**
|
||||
* @param \User|null $oUser
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0 N°2039 Add $oUser parameter
|
||||
*/
|
||||
public function IsUserAllowed(?User $oUser = null)
|
||||
{
|
||||
$bRet = true;
|
||||
$aProfiles = UserRights::ListProfiles();
|
||||
$aProfiles = UserRights::ListProfiles($oUser);
|
||||
|
||||
foreach($this->aData['deny'] as $sDeniedProfile)
|
||||
{
|
||||
|
||||
@@ -287,6 +287,29 @@
|
||||
if ($oRecipient instanceof Person && UserRights::GetUserFromPerson($oRecipient, false) === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip recipient that have no user with access to the backoffice
|
||||
$oRecipientUsersSearch = DBObjectSearch::FromOQL("SELECT User WHERE contactid = " . $oRecipient->GetKey() . " AND status = 'enabled'");
|
||||
$oRecipientUsersSearch->AllowAllData();
|
||||
$oRecipientUsersSet = new DBObjectSet($oRecipientUsersSearch);
|
||||
$oPortalDispatcher = new PortalDispatcher('backoffice');
|
||||
// - Check if the user has access to the backoffice
|
||||
$bHasAccessToBackoffice = false;
|
||||
while ($oRecipientUser = $oRecipientUsersSet->Fetch()) {
|
||||
// Skip recipients with user that don't have access to the backoffice
|
||||
if (false === $oPortalDispatcher->IsUserAllowed($oRecipientUser)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bHasAccessToBackoffice = true;
|
||||
break;
|
||||
}
|
||||
// - Skip it if necessary
|
||||
if (false === $bHasAccessToBackoffice) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip recipients that have unsubscribed
|
||||
if (!\Combodo\iTop\Service\Notification\NotificationsService::GetInstance()->IsSubscribed($oTrigger, $this, $oRecipient)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user