Skip to content

Commit

Permalink
Ticket #4842 - Antispam: PHP error when Lasso Moderation is enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Nov 14, 2024
1 parent f1c3940 commit c157b21
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions modules/boonex/antispam/classes/BxAntispamModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,44 +282,43 @@ public function serviceOnFormSubmitted($sModule, $iEntry, $sAction, &$oForm)
if($this->_oConfig->getAntispamOption('lm_enable') == 'on' && (bx_srv('system', 'is_module_content', [$sModule]) || bx_srv('system', 'is_module_context', [$sModule]) || in_array($sModule, ['bx_timeline'])) && ($oModule = BxDolModule::getInstance($sModule)) !== null) {
$CNF = &$oModule->_oConfig->CNF;

$iAuthorId = bx_get_logged_profile_id();
$iAuthorName = BxDolProfile::getInstance()->getDisplayName();

$iDataAdded = time();

$sText = '';
if(isset($CNF['FIELD_TEXT'], $oForm->aInputs[$CNF['FIELD_TEXT']]))
$sText = $oForm->getCleanValue($CNF['FIELD_TEXT']);
if(empty($sText) && isset($oForm->aInputs['text']))
$sText = $oForm->getCleanValue('text');

$aMedias = [
'images' => ['fields' => ['FIELD_PHOTO', 'FIELD_PICTURE', 'FIELD_COVER'], 'data' => []],
'videos' => ['fields' => ['FIELD_VIDEO'], 'data' => []]
];
foreach($aMedias as $sName => $aMedia)
foreach($aMedia['fields'] as $sField) {
if(!isset($CNF[$sField], $oForm->aInputs[$CNF[$sField]]))
continue;

$oStorage = BxDolStorage::getObjectInstance($oForm->aInputs[$CNF[$sField]]['storage_object']);
if(!$oStorage)
continue;

$aGhosts = $oStorage->getGhosts($iAuthorId, $sAction == 'insert' ? 0 : $iEntry);
foreach($aGhosts as $aGhost)
$aMedias[$sName]['data'][] = $oStorage->getFileUrlById($aGhost['id']);
}

$oLassoModeration = bx_instance('BxAntispamLassoModeration', [], $this->getName());
$oLassoModeration->addContent($sModule, $iEntry, [
'author_id' => $iAuthorId,
'author_name' => $iAuthorName,
'date_added' => $iDataAdded,
'text' => $sText,
'images' => $aMedias['images']['data'],
'videos' => $aMedias['videos']['data']
]);
if(($iAuthorId = bx_get_logged_profile_id()) !== false && ($oAuthor = BxDolProfile::getInstance()) !== false) {
$iDataAdded = time();

$sText = '';
if(isset($CNF['FIELD_TEXT'], $oForm->aInputs[$CNF['FIELD_TEXT']]))
$sText = $oForm->getCleanValue($CNF['FIELD_TEXT']);
if(empty($sText) && isset($oForm->aInputs['text']))
$sText = $oForm->getCleanValue('text');

$aMedias = [
'images' => ['fields' => ['FIELD_PHOTO', 'FIELD_PICTURE', 'FIELD_COVER'], 'data' => []],
'videos' => ['fields' => ['FIELD_VIDEO'], 'data' => []]
];
foreach($aMedias as $sName => $aMedia)
foreach($aMedia['fields'] as $sField) {
if(!isset($CNF[$sField], $oForm->aInputs[$CNF[$sField]]))
continue;

$oStorage = BxDolStorage::getObjectInstance($oForm->aInputs[$CNF[$sField]]['storage_object']);
if(!$oStorage)
continue;

$aGhosts = $oStorage->getGhosts($iAuthorId, $sAction == 'insert' ? 0 : $iEntry);
foreach($aGhosts as $aGhost)
$aMedias[$sName]['data'][] = $oStorage->getFileUrlById($aGhost['id']);
}

$oLassoModeration = bx_instance('BxAntispamLassoModeration', [], $this->getName());
$oLassoModeration->addContent($sModule, $iEntry, [
'author_id' => $iAuthorId,
'author_name' => $oAuthor->getDisplayName(),
'date_added' => $iDataAdded,
'text' => $sText,
'images' => $aMedias['images']['data'],
'videos' => $aMedias['videos']['data']
]);
}
}
}

Expand Down

0 comments on commit c157b21

Please sign in to comment.