本文整理汇总了PHP中JComments::sendReport方法的典型用法代码示例。如果您正苦于以下问题:PHP JComments::sendReport方法的具体用法?PHP JComments::sendReport怎么用?PHP JComments::sendReport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JComments
的用法示例。
在下文中一共展示了JComments::sendReport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reportComment
function reportComment()
{
if (JCommentsSecurity::badRequest() == 1) {
JCommentsSecurity::notAuth();
}
$acl =& JCommentsFactory::getACL();
$db =& JCommentsFactory::getDBO();
$config =& JCommentsFactory::getConfig();
$response =& JCommentsFactory::getAjaxResponse();
$values = JCommentsAJAX::prepareValues($_POST);
$id = (int) $values['commentid'];
$reason = trim(strip_tags($values['reason']));
$name = trim(strip_tags($values['name']));
$ip = $acl->getUserIP();
if ($reason == '') {
JCommentsAJAX::showErrorMessage(JText::_('Please enter the reason for your report!'), '', 'comments-report-form');
return $response;
}
$query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id;
if ($acl->getUserId()) {
$query .= ' AND userid = ' . $acl->getUserId();
} else {
$query .= ' AND ip = "' . $ip . '"';
}
$db->setQuery($query);
$reported = $db->loadResult();
if (!$reported) {
$query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id;
$db->setQuery($query);
$reported = $db->loadResult();
if (!$reported) {
$comment = new JCommentsDB($db);
if ($comment->load($id)) {
if ($acl->canReport($comment)) {
$allowed = true;
if ($config->getInt('enable_mambots') == 1) {
require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
JCommentsPluginHelper::importPlugin('jcomments');
JCommentsPluginHelper::trigger('onReportComment', array(&$comment, &$response, &$allowed, &$value));
}
if ($allowed !== false) {
if ($acl->getUserId()) {
$user = JCommentsFactory::getUser();
$name = $user->name;
} else {
if ($name == '') {
$name = JText::_('Guest');
}
}
$query = "INSERT INTO `#__jcomments_reports`(`commentid`,`userid`, `name`,`ip`,`date`,`reason`)" . "VALUES('" . $comment->id . "', '" . $acl->getUserId() . "', '" . $db->getEscaped($name) . "', '" . $db->getEscaped($ip) . "', now(), '" . $db->getEscaped($reason) . "')";
$db->setQuery($query);
$db->query();
if ($config->getInt('enable_notification') == 1) {
if ($config->check('notification_type', 2)) {
$comment->datetime = $comment->date;
if (is_string($comment->datetime)) {
$comment->datetime = strtotime($comment->datetime);
}
JComments::sendReport($comment, $name, $reason);
}
}
$html = JText::_('Report successfully sent!');
$html = str_replace("\n", '\\n', $html);
$html = str_replace('\\n', '<br />', $html);
$html = JCommentsText::jsEscape($html);
$response->addScript("jcomments.closeReport('{$html}');");
}
} else {
JCommentsAJAX::showErrorMessage(JText::_('You have no rights to report comment!'), '', 'comments-report-form');
}
} else {
$response->addAlert(JText::_('ERROR_NOT_FOUND'));
}
unset($comment);
} else {
JCommentsAJAX::showErrorMessage(JText::_('Comment already reported to the site administrator'), '', 'comments-report-form');
}
} else {
JCommentsAJAX::showErrorMessage(JText::_('You can\'t report the same comment more than once!'), '', 'comments-report-form');
}
return $response;
}
示例2: reportComment
public static function reportComment()
{
if (JCommentsSecurity::badRequest() == 1) {
JCommentsSecurity::notAuth();
}
$acl = JCommentsFactory::getACL();
$db = JCommentsFactory::getDBO();
$config = JCommentsFactory::getConfig();
$response = JCommentsFactory::getAjaxResponse();
$values = self::prepareValues($_POST);
$id = (int) $values['commentid'];
$reason = trim(strip_tags($values['reason']));
$name = trim(strip_tags($values['name']));
$ip = $acl->getUserIP();
if (empty($reason)) {
if ($config->getInt('report_reason_required') == 1) {
self::showErrorMessage(JText::_('ERROR_NO_REASON_FOR_REPORT'), '', 'comments-report-form');
return $response;
} else {
$reason = JText::_('REPORT_REASON_UNKNOWN_REASON');
}
}
$query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id;
if ($acl->getUserId()) {
$query .= ' AND userid = ' . $acl->getUserId();
} else {
$query .= ' AND userid = 0 AND ip = "' . $ip . '"';
}
$db->setQuery($query);
$reported = $db->loadResult();
if (!$reported) {
$maxReportsPerComment = $config->getInt('reports_per_comment', 1);
$maxReportsBeforeUnpublish = $config->getInt('reports_before_unpublish', 0);
$db->setQuery('SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id);
$reported = $db->loadResult();
if ($reported < $maxReportsPerComment || $maxReportsPerComment == 0) {
$comment = new JCommentsTableComment($db);
if ($comment->load($id)) {
if ($acl->canReport($comment)) {
if ($acl->getUserId()) {
$user = JCommentsFactory::getUser();
$name = $user->name;
} else {
if (empty($name)) {
$name = 'Guest';
// JText::_('Guest');
}
}
require_once JCOMMENTS_TABLES . '/report.php';
$report = new JCommentsTableReport($db);
$report->commentid = $comment->id;
$report->date = JCommentsFactory::getDate();
$report->userid = $acl->getUserId();
$report->ip = $ip;
$report->name = $name;
$report->reason = $reason;
$html = '';
$result = JCommentsEvent::trigger('onJCommentsCommentBeforeReport', array(&$comment, &$report));
if (!in_array(false, $result, true)) {
if ($report->store()) {
JCommentsEvent::trigger('onJCommentsCommentAfterReport', array(&$comment, $report));
if ($config->getInt('enable_notification') == 1) {
if ($config->check('notification_type', 2)) {
JComments::sendReport($comment, $name, $reason);
}
}
// unpublish comment if reports count is enough
if ($maxReportsBeforeUnpublish > 0 && $reported >= $maxReportsBeforeUnpublish) {
$comment->published = 0;
$comment->store();
}
$html = JText::_('REPORT_SUCCESSFULLY_SENT');
$html = str_replace("\n", '\\n', $html);
$html = str_replace('\\n', '<br />', $html);
$html = JCommentsText::jsEscape($html);
}
}
$response->addScript("jcomments.closeReport('{$html}');");
} else {
self::showErrorMessage(JText::_('ERROR_YOU_HAVE_NO_RIGHTS_TO_REPORT'), '', 'comments-report-form');
}
} else {
$response->addAlert(JText::_('ERROR_NOT_FOUND'));
}
} else {
self::showErrorMessage(JText::_('ERROR_COMMENT_ALREADY_REPORTED'), '', 'comments-report-form');
}
} else {
self::showErrorMessage(JText::_('ERROR_YOU_CAN_NOT_REPORT_THE_SAME_COMMENT_MORE_THAN_ONCE'), '', 'comments-report-form');
}
return $response;
}