public static function canComment($documentId, $email = '')
	{
		
		$canViewDocument = JUDownloadFrontHelperPermission::userCanDoDocument($documentId, true);
		if ($canViewDocument == false)
		{
			return false;
		}

		
		$userIdPassed = self::checkBlackListUserId();
		if (!$userIdPassed)
		{
			return false;
		}

		
		$userIpPassed = self::checkBlackListUserIP();
		if (!$userIpPassed)
		{
			return false;
		}

		
		$params = JUDownloadHelper::getParams(null, $documentId);
		$user   = JFactory::getUser();

		$isDocumentOwner           = JUDownloadFrontHelperPermission::isDocumentOwner($documentId);
		$ownerCanCommentOnDocument = $params->get('document_owner_can_comment', 0);
		
		if ($isDocumentOwner && $ownerCanCommentOnDocument)
		{
			
			$ownerCanCommentManyTimes = $params->get('document_owner_can_comment_many_times', 0);
			if ($ownerCanCommentManyTimes)
			{
				return true;
			}
			else
			{
				$totalCommentsOnDoc = JUDownloadFrontHelperComment::getTotalCommentsOnDocumentOfUser($documentId, $user->id);
				if ($totalCommentsOnDoc == 0)
				{
					return true;
				}
			}
		}

		$asset = 'com_judownload.document.' . $documentId;

		if ($user->authorise('judl.comment.create', $asset) || (JUDownloadFrontHelperPermission::canDownloadDocument($documentId) && $params->get('can_download_can_comment', 0)))
		{
			
			if ($user->authorise('judl.comment.create.many_times', $asset))
			{
				return true;
			}
			else
			{
				if (!$user->get('guest'))
				{
					$totalCommentsOnDoc = JUDownloadFrontHelperComment::getTotalCommentsOnDocumentOfUser($documentId, $user->id);
					if ($totalCommentsOnDoc == 0)
					{
						return true;
					}
				}
				else
				{
					if ($email != '')
					{
						$totalCommentsPerOneDocumentForGuest = JUDownloadFrontHelperComment::getTotalCommentsOnDocumentForGuest($documentId, $email);
						if ($totalCommentsPerOneDocumentForGuest == 0)
						{
							return true;
						}
					}
					else
					{
						return true;
					}
				}
			}
		}

		return false;
	}