示例#1
0
	public static function canAutoApprovalComment($documentId)
	{
		$params = JUDownloadHelper::getParams(null, $documentId);

		
		$isDocumentOwner                      = JUDownloadFrontHelperPermission::isDocumentOwner($documentId);
		$autoApprovalWhenDocumentOwnerComment = $params->get('document_owner_auto_approval_when_comment', 0);

		if ($isDocumentOwner && $autoApprovalWhenDocumentOwnerComment)
		{
			return true;
		}

		
		$user  = JFactory::getUser();
		$asset = 'com_judownload.document.' . $documentId;
		if ($user->authorise('judl.comment.auto_approval', $asset))
		{
			return true;
		}

		
		
		if (!$user->get('guest'))
		{
			$autoApprovalCommentThreshold = (int) $params->get('auto_approval_comment_threshold', 0);
			if ($autoApprovalCommentThreshold > 0)
			{
				$totalApprovedCommentsOfUser = JUDownloadFrontHelperComment::getTotalApprovedCommentsOfUser($user->id);
				if ($totalApprovedCommentsOfUser >= $autoApprovalCommentThreshold)
				{
					return true;
				}
			}
		}

		return false;
	}