本文整理汇总了PHP中EnmasseHelper::checkSpammer方法的典型用法代码示例。如果您正苦于以下问题:PHP EnmasseHelper::checkSpammer方法的具体用法?PHP EnmasseHelper::checkSpammer怎么用?PHP EnmasseHelper::checkSpammer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnmasseHelper
的用法示例。
在下文中一共展示了EnmasseHelper::checkSpammer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit_review
function submit_review()
{
$nDealId = JRequest::getVar('nDealId');
$nRating = JRequest::getVar('nRating');
$sReviewBody = JRequest::getVar('sReviewBody');
// Be sure this is a valid deal id
if ($nDealId > 0) {
// Check for a valid rating number and review content
// User has to select his/her rating (the number is from 1 to 5)
// and has enter his/her review
if ($nRating <= 0 || $nRating > 5) {
$sMessage = JText::_('PLEASE_RATE');
$sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
} elseif ($sReviewBody == '') {
$sMessage = JText::_('PLEASE_ENTER_REVIEW');
$sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
} else {
if (EnmasseHelper::checkSpammer(JFactory::getUser()->get('id'))) {
// If this user is a spammer, lie to him/her that the review is submitted but actually we store nothing
$sMessage = JText::_('REVIEW_SUBMITTED_SUCCESSFULLY');
$sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
} else {
$aComment = array();
$aComment['deal_id'] = $nDealId;
$aComment['user_id'] = JFactory::getUser()->get('id');
$aComment['comment'] = $sReviewBody;
$aComment['rating'] = $nRating;
$aComment['created_at'] = DatetimeWrapper::getDatetimeOfNow();
$aComment['status'] = 0;
$oRow = JModel::getInstance('comment', 'enmasseModel')->store($aComment);
if ($oRow->success) {
$sMessage = JText::_('REVIEW_SUBMITTED_SUCCESSFULLY');
} else {
$sMessage = JText::_('SAVE_REVIEW_FAILED');
}
$sRedirectUrl = JRoute::_('index.php?option=com_enmasse&controller=deal&task=comment&id=' . $nDealId, false);
}
}
} else {
$sMessage = JText::_('SAVE_REVIEW_FAILED');
$sRedirectUrl = JRoute::_('index.php?option=com_enmasse&view=dealtoday', false);
}
$this->setRedirect($sRedirectUrl, $sMessage);
}
示例2: markUserAsSpammer
public static function markUserAsSpammer($nCommentId)
{
$comment = JModel::getInstance('Comment', 'EnmasseModel')->getCommentById($nCommentId);
$user = JFactory::getUser($comment->user_id);
if (EnmasseHelper::checkSpammer($comment->user_id)) {
$sMessage = JText::sprintf('COMMENT_USER_ALREADY_SPAMMER', $user->name);
} else {
$db = JFactory::getDBO();
$query = "SELECT id FROM #__enmasse_comment WHERE user_id = " . $comment->user_id;
$db->setQuery($query);
$aIDs = $db->loadResultArray();
$sCommentIds = implode(',', $aIDs);
$bResult = JModel::getInstance('Comment', 'EnmasseModel')->changeCommentStatus($sCommentIds, 3);
if ($bResult) {
$sMessage = JText::_('COMMENT_SPAMMED_SUCCESSFULLY');
} else {
$sMessage = JText::_('COMMENT_SPAMMED_FAILED');
}
$query = "INSERT INTO #__enmasse_comment_spammer VALUES ('', {$comment->user_id}) ";
$db->setQuery($query);
$db->query();
if ($db->getErrorNum()) {
$sMessage = JText::sprintf('COMMENT_USER_SPAMMED_FAILED', $user->name);
JJFactory::getApplication()->redirect('index.php?option=com_enmasse&controller=comment', $sMessage, 'error');
}
$sMessage = JText::sprintf('COMMENT_MARK_SPAMMER_SUCCESSFULLY', $user->name);
}
JFactory::getApplication()->redirect('index.php?option=com_enmasse&controller=comment', $sMessage);
}