public static function canComment($listingId, $email = '') { $canViewListing = JUDirectoryFrontHelperPermission::userCanDoListing($listingId, true); if ($canViewListing == false) { return false; } $userIdPassed = self::checkBlackListUserId(); if (!$userIdPassed) { return false; } $userIpPassed = self::checkBlackListUserIP(); if (!$userIpPassed) { return false; } $params = JUDirectoryHelper::getParams(null, $listingId); $user = JFactory::getUser(); $isListingOwner = JUDirectoryFrontHelperPermission::isListingOwner($listingId); $ownerCanCommentOnListing = $params->get('listing_owner_can_comment', 0); if ($isListingOwner && $ownerCanCommentOnListing) { $ownerCanCommentManyTimes = $params->get('listing_owner_can_comment_many_times', 0); if ($ownerCanCommentManyTimes) { return true; } else { $totalCommentsOnListing = JUDirectoryFrontHelperComment::getTotalCommentsOnListingOfUser($listingId, $user->id); if ($totalCommentsOnListing == 0) { return true; } } } $asset = 'com_judirectory.listing.' . $listingId; if ($user->authorise('judir.comment.create', $asset)) { if ($user->authorise('judir.comment.create.many_times', $asset)) { return true; } else { if (!$user->get('guest')) { $totalCommentsOnListing = JUDirectoryFrontHelperComment::getTotalCommentsOnListingOfUser($listingId, $user->id); if ($totalCommentsOnListing == 0) { return true; } } else { if ($email != '') { $totalCommentsPerOneListingForGuest = JUDirectoryFrontHelperComment::getTotalCommentsOnListingForGuest($listingId, $email); if ($totalCommentsPerOneListingForGuest == 0) { return true; } } else { return true; } } } } return false; }