本文整理汇总了PHP中JCommentsFactory::getACL方法的典型用法代码示例。如果您正苦于以下问题:PHP JCommentsFactory::getACL方法的具体用法?PHP JCommentsFactory::getACL怎么用?PHP JCommentsFactory::getACL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCommentsFactory
的用法示例。
在下文中一共展示了JCommentsFactory::getACL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getCommentsQuery
function _getCommentsQuery(&$options)
{
$acl =& JCommentsFactory::getACL();
$db =& JCommentsFactory::getDBO();
$object_id = @$options['object_id'];
$object_group = @$options['object_group'];
$parent = @$options['parent'];
$published = @$options['published'];
$orderBy = @$options['orderBy'];
$limitStart = @$options['limitStart'];
$limit = @$options['limit'];
$where = array();
if ($object_id) {
$where[] = "c.object_id = " . $object_id;
}
if ($object_group != '') {
$where[] = "c.object_group = '" . $db->getEscaped($object_group) . "'";
}
if ($parent !== null) {
$where[] = "c.parent = " . $parent;
}
if ($published !== null) {
$where[] = "c.published = " . $published;
}
if (JCommentsMultilingual::isEnabled()) {
$where[] = "c.lang = '" . JCommentsMultilingual::getLanguage() . "'";
}
$query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n, c.email, c.homepage, c.date as datetime, c.ip, c.published, c.checked_out, c.checked_out_time" . "\n, c.isgood, c.ispoor" . "\n, v.value as voted" . "\n, case when c.userid = 0 then 'guest' else replace(lower(u.usertype), ' ', '-') end as usertype" . "\nFROM #__jcomments AS c" . "\nLEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($acl->getUserId() ? " AND v.userid = " . $acl->getUserId() : " AND v.userid = 0 AND v.ip = '" . $acl->getUserIP() . "'") . "\nLEFT JOIN #__users AS u ON c.userid = u.id" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY " . $orderBy . ($limit > 0 ? "\nLIMIT {$limitStart}, {$limit}" : "");
return $query;
}
示例2: getCategoryNewTree
function getCategoryNewTree($object_id, $object_group = 'com_content')
{
global $my;
$object_id = (int) $object_id;
$object_group = trim($object_group);
$acl =& JCommentsFactory::getACL();
$config =& JCommentsFactory::getConfig();
$canPublish = $acl->canPublish();
$canComment = $acl->canComment();
}
示例3: getCommentsCount
public static function getCommentsCount($object_id, $object_group = 'com_content', $filter = '')
{
$acl = JCommentsFactory::getACL();
$options = array();
$options['object_id'] = (int) $object_id;
$options['object_group'] = trim($object_group);
$options['published'] = $acl->canPublish() || $acl->canPublishForObject($object_id, $object_group) ? null : 1;
$options['filter'] = $filter;
return JCommentsModel::getCommentsCount($options);
}
示例4: onContentSearch
/**
* Comments Search method
*
* @param string $text Target search string
* @param string $phrase mathcing option, exact|any|all
* @param string $ordering ordering option, newest|oldest|popular|alpha|category
* @param mixed $areas An array if the search it to be restricted to areas, null if search all
* @return array
*/
function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$text = JString::strtolower(trim($text));
$result = array();
if ($text == '' || !defined('JCOMMENTS_JVERSION')) {
return $result;
}
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return $result;
}
}
if (file_exists(JCOMMENTS_BASE . '/jcomments.php')) {
require_once JCOMMENTS_BASE . '/jcomments.php';
$db = JFactory::getDBO();
$limit = $this->params->def('search_limit', 50);
switch ($phrase) {
case 'exact':
$text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
$wheres2[] = "LOWER(c.name) LIKE " . $text;
$wheres2[] = "LOWER(c.comment) LIKE " . $text;
$wheres2[] = "LOWER(c.title) LIKE " . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = "LOWER(c.name) LIKE " . $word;
$wheres2[] = "LOWER(c.comment) LIKE " . $word;
$wheres2[] = "LOWER(c.title) LIKE " . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
break;
}
switch ($ordering) {
case 'oldest':
$order = 'date ASC';
break;
case 'newest':
default:
$order = 'date DESC';
break;
}
$acl = JCommentsFactory::getACL();
$access = $acl->getUserAccess();
if (is_array($access)) {
$accessCondition = "AND jo.access IN (" . implode(',', $access) . ")";
} else {
$accessCondition = "AND jo.access <= " . (int) $access;
}
$query = "SELECT " . " c.comment AS text" . ", c.date AS created" . ", '2' AS browsernav" . ", '" . JText::_('PLG_SEARCH_JCOMMENTS_COMMENTS') . "' AS section" . ", '' AS href" . ", c.id" . ", jo.title AS object_title, jo.link AS object_link" . " FROM #__jcomments AS c" . " INNER JOIN #__jcomments_objects AS jo ON jo.object_id = c.object_id AND jo.object_group = c.object_group and jo.lang=c.lang" . " WHERE c.published=1" . " AND c.deleted=0" . " AND jo.link <> ''" . (JCommentsMultilingual::isEnabled() ? " AND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . " AND ({$where}) " . $accessCondition . " ORDER BY c.object_id, {$order}";
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
$cnt = count($rows);
if ($cnt > 0) {
$config = JCommentsFactory::getConfig();
$enableCensor = $acl->check('enable_autocensor');
$word_maxlength = $config->getInt('word_maxlength');
for ($i = 0; $i < $cnt; $i++) {
$text = JCommentsText::cleanText($rows[$i]->text);
if ($enableCensor) {
$text = JCommentsText::censor($text);
}
if ($word_maxlength > 0) {
$text = JCommentsText::fixLongWords($text, $word_maxlength);
}
if ($text != '') {
$rows[$i]->title = $rows[$i]->object_title;
$rows[$i]->text = $text;
$rows[$i]->href = $rows[$i]->object_link . '#comment-' . $rows[$i]->id;
$result[] = $rows[$i];
}
}
}
unset($rows);
}
return $result;
}
示例5: _getCommentsQuery
protected static function _getCommentsQuery(&$options)
{
$acl = JCommentsFactory::getACL();
$db = JFactory::getDbo();
$object_id = @$options['object_id'];
$object_group = @$options['object_group'];
$parent = @$options['parent'];
$level = @$options['level'];
$published = @$options['published'];
$userid = @$options['userid'];
$filter = @$options['filter'];
$orderBy = @$options['orderBy'];
$limitStart = isset($options['limitStart']) ? $options['limitStart'] : 0;
$limit = @$options['limit'];
$votes = isset($options['votes']) ? $options['votes'] : true;
$objectinfo = isset($options['objectinfo']) ? $options['objectinfo'] : false;
$where = array();
if (!empty($object_id)) {
$where[] = "c.object_id = " . $object_id;
}
if (!empty($object_group)) {
if (is_array($object_group)) {
$where[] = "(c.object_group = '" . implode("' OR c.object_group = '", $object_group) . "')";
} else {
$where[] = "c.object_group = " . $db->Quote($object_group);
}
}
if ($parent !== null) {
$where[] = "c.parent = " . $parent;
}
if ($level !== null) {
$where[] = "c.level = " . (int) $level;
}
if ($published !== null) {
$where[] = "c.published = " . $published;
}
if ($userid !== null) {
$where[] = "c.userid = " . $userid;
}
if (JCommentsMultilingual::isEnabled()) {
$language = isset($options['lang']) ? $options['lang'] : JCommentsMultilingual::getLanguage();
$where[] = "c.lang = " . $db->Quote($language);
}
if ($objectinfo && isset($options['access'])) {
if (is_array($options['access'])) {
$access = implode(',', $options['access']);
$where[] = "jo.access IN (" . $access . ")";
} else {
$where[] = "jo.access <= " . (int) $options['access'];
}
}
if ($filter != "") {
$where[] = $filter;
}
$query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n, c.email, c.homepage, c.date, c.date as datetime, c.ip, c.published, c.deleted, c.checked_out, c.checked_out_time" . "\n, c.isgood, c.ispoor" . ($votes ? "\n, v.value as voted" : "\n, 1 as voted") . "\n, case when c.parent = 0 then unix_timestamp(c.date) else 0 end as threaddate" . ($objectinfo ? "\n, jo.title AS object_title, jo.link AS object_link, jo.access AS object_access" : ", '' AS object_title, '' AS object_link, 0 AS object_access, 0 AS object_owner") . "\nFROM #__jcomments AS c" . ($votes ? "\nLEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($acl->getUserId() ? " AND v.userid = " . $acl->getUserId() : " AND v.userid = 0 AND v.ip = '" . $acl->getUserIP() . "'") : "") . ($objectinfo ? "\n LEFT JOIN #__jcomments_objects AS jo ON jo.object_id = c.object_id AND jo.object_group = c.object_group AND jo.lang=c.lang" : "") . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY " . $orderBy . ($limit > 0 ? "\nLIMIT {$limitStart}, {$limit}" : "");
return $query;
}
示例6: registerCode
function registerCode($str)
{
$acl = JCommentsFactory::getACL();
$this->_codes[$str] = $acl->check('enable_bbcode_' . $str);
}
示例7: onPrepareContent
//.........这里部分代码省略.........
if ($readmore_register == 1) {
$readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE');
} else if (isset($params) && $readmore = $params->get('readmore')) {
$readmore_text = $readmore;
} else {
$readmore_text = JText::_('LINK_READ_MORE');
}
$tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
$tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
$tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
$tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
}
$commentsDisabled = false;
if ($config->getInt('comments_off', 0) == 1) {
$commentsDisabled = true;
} else if ($config->getInt('comments_on', 0) == 1) {
$commentsDisabled = false;
}
$tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled));
$count = 0;
// do not query comments count if comments disabled and link hidden
if (!$commentsDisabled) {
require_once (JCOMMENTS_MODELS . '/jcomments.php');
$anchor = "";
if ($this->params->get('comments_count', 1) != 0) {
$acl = JCommentsFactory::getACL();
$options = array();
$options['object_id'] = (int) $article->id;
$options['object_group'] = 'com_content';
$options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1;
$count = JCommentsModel::getCommentsCount($options);
$tmpl->addVar('tpl_links', 'comments-count', $count);
$anchor = $count == 0 ? '#addcomment' : '#comments';
if ($count == 0) {
$link_text = JText::_('LINK_ADD_COMMENT');
} else {
if (JCOMMENTS_JVERSION == '1.5') {
require_once (JCOMMENTS_LIBRARIES.'/joomlatune/language.tools.php');
$lang = JFactory::getLanguage();
$suffix = JoomlaTuneLanguageTools::getPluralSuffix($lang->getTag(), $count);
$string = 'LINK_READ_COMMENTS';
$key = $string . '_' . $suffix;
if (!$lang->hasKey($key)) {
$key = $string;
}
$link_text = JText::sprintf($key, $count);
} else {
$link_text = JText::plural('LINK_READ_COMMENTS', $count);
}
}
} else {
$link_text = JText::_('LINK_ADD_COMMENT');
}
示例8: getCommentsTree
function getCommentsTree($object_id, $object_group = 'com_content', $search_text = '')
{
global $my;
$object_id = (int) $object_id;
$object_group = trim($object_group);
$acl =& JCommentsFactory::getACL();
$dbo =& JCommentsFactory::getDBO();
$config =& JCommentsFactory::getConfig();
$canPublish = $acl->canPublish();
$canComment = $acl->canComment();
$where = '';
if ($search_text) {
$words = explode(' ', $search_text);
$wheres = array();
foreach ($words as $word) {
$wheres2 = array();
$wheres2[] = "LOWER(name) LIKE '%{$word}%'";
$wheres2[] = "LOWER(comment) LIKE '%{$word}%'";
}
if (isset($wheres2) && count($wheres2)) {
$where .= ' AND (';
$where .= implode(' OR ', $wheres2);
$where .= ' )';
}
}
if ($canComment == 0) {
$total = JLMS_JComments::getCommentsCount($object_id, $object_group, $where);
if ($total == 0) {
return '';
}
}
$query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n , c.email, c.homepage, c.date as datetime, c.ip, c.published, c.checked_out, c.checked_out_time" . "\n , c.isgood, c.ispoor" . "\n , v.value as voted" . "\n FROM #__jcomments AS c" . "\n LEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($my->id ? " AND v.userid = " . $my->id : " AND v.ip = '" . $acl->getUserIP() . "'") . "\n WHERE c.object_id = " . $object_id . "\n AND c.object_group = '" . $object_group . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . ($canPublish == 0 ? "\nAND c.published = 1" : "") . $where . "\n ORDER BY c.parent, c.date ASC";
$dbo->setQuery($query);
$rows = $dbo->loadObjectList();
$tmpl =& JCommentsFactory::getTemplate($object_id, $object_group);
$tmpl->load('tpl_tree');
$tmpl->load('tpl_comment');
if (count($rows)) {
$isLocked = $config->getInt('object_locked', 0) == 1;
$tmpl->addVar('tpl_tree', 'comments-refresh', intval(!$isLocked));
$tmpl->addVar('tpl_tree', 'comments-rss', intval($config->getInt('enable_rss') && !$isLocked));
$tmpl->addVar('tpl_tree', 'comments-can-subscribe', intval($my->id && $acl->check('enable_subscribe') && !$isLocked));
if ($my->id && $acl->check('enable_subscribe')) {
require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php';
$manager =& JCommentsSubscriptionManager::getInstance();
$isSubscribed = $manager->isSubscribed($object_id, $object_group, $my->id);
$tmpl->addVar('tpl_tree', 'comments-user-subscribed', $isSubscribed);
}
$i = 1;
if ($config->getInt('enable_mambots') == 1) {
require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
JCommentsPluginHelper::importPlugin('jcomments');
JCommentsPluginHelper::trigger('onBeforeDisplayCommentsList', array(&$rows));
if ($acl->check('enable_gravatar')) {
JCommentsPluginHelper::trigger('onPrepareAvatars', array(&$rows));
}
}
require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'tree.php';
$tree = new JoomlaTuneTree($rows);
$items = $tree->get();
foreach ($rows as $row) {
if ($config->getInt('enable_mambots') == 1) {
JCommentsPluginHelper::trigger('onBeforeDisplayComment', array(&$row));
}
// run autocensor, replace quotes, smiles and other pre-view processing
JComments::prepareComment($row);
// setup toolbar
if (!$acl->canModerate($row)) {
$tmpl->addVar('tpl_comment', 'comments-panel-visible', 0);
} else {
$tmpl->addVar('tpl_comment', 'comments-panel-visible', 1);
$tmpl->addVar('tpl_comment', 'button-edit', $acl->canEdit($row));
$tmpl->addVar('tpl_comment', 'button-delete', $acl->canDelete($row));
$tmpl->addVar('tpl_comment', 'button-publish', $acl->canPublish($row));
$tmpl->addVar('tpl_comment', 'button-ip', $acl->canViewIP($row));
}
$tmpl->addVar('tpl_comment', 'comment-show-vote', $config->getInt('enable_voting'));
$tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail($row));
$tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage($row));
$tmpl->addVar('tpl_comment', 'comment-show-title', $config->getInt('comment_title'));
$tmpl->addVar('tpl_comment', 'button-vote', $acl->canVote($row));
$tmpl->addVar('tpl_comment', 'button-quote', $acl->canQuote($row));
$tmpl->addVar('tpl_comment', 'button-reply', $acl->canReply($row));
$tmpl->addVar('tpl_comment', 'avatar', $acl->check('enable_gravatar'));
if (isset($items[$row->id])) {
$tmpl->addVar('tpl_comment', 'comment-number', '');
$tmpl->addObject('tpl_comment', 'comment', $row);
$items[$row->id]->html = $tmpl->renderTemplate('tpl_comment');
$i++;
}
}
$tmpl->addObject('tpl_tree', 'comments-items', $items);
unset($rows);
}
return $tmpl->renderTemplate('tpl_tree');
}
示例9: getList
//.........这里部分代码省略.........
if (count($source) == 1 && $source[0] == 'com_content') {
$joins[] = 'JOIN #__content AS cc ON cc.id = o.object_id';
$joins[] = 'LEFT JOIN #__categories AS ct ON ct.id = cc.catid';
$where[] = "c.object_group = " . $db->Quote($source[0]);
$where[] = "(cc.publish_up = '0000-00-00 00:00:00' OR cc.publish_up <= '{$now}')";
$where[] = "(cc.publish_down = '0000-00-00 00:00:00' OR cc.publish_down >= '{$now}')";
$categories = $params->get('catid', array());
if (!is_array($categories)) {
$categories = explode(',', $categories);
}
JArrayHelper::toInteger($categories);
$categories = implode(',', $categories);
if (!empty($categories)) {
$where[] = "cc.catid IN (" . $categories . ")";
}
} else {
if (count($source)) {
$where[] = "c.object_group in ('" . implode("','", $source) . "')";
}
}
$query = "SELECT c.id, c.userid, c.comment, c.title, c.name, c.username, c.email, c.date, c.object_id, c.object_group, '' as avatar" . ", o.title AS object_title, o.link AS object_link, o.access AS object_access, o.userid AS object_owner" . " FROM #__jcomments AS c" . " JOIN #__jcomments_objects AS o ON c.object_id = o.object_id AND c.object_group = o.object_group AND c.lang = o.lang" . (count($joins) ? ' ' . implode(' ', $joins) : '') . (count($where) ? ' WHERE ' . implode(' AND ', $where) : '') . " ORDER BY " . $orderBy;
$db->setQuery($query, 0, $params->get('count'));
$list = $db->loadObjectList();
if (!is_array($list)) {
$list = array();
}
if (count($list)) {
$show_date = $params->get('show_comment_date', 0);
$date_type = $params->get('date_type', '');
$date_format = $params->get('date_format', 'd.m.Y H:i');
$show_author = $params->get('show_comment_author', 0);
$show_object_title = $params->get('show_object_title', 0);
$show_comment_title = $params->get('show_comment_title', 0);
$show_smiles = $params->get('show_smiles', 0);
$show_avatar = $params->get('show_avatar', 0);
$limit_comment_text = (int) $params->get('limit_comment_text', 0);
$config = JCommentsFactory::getConfig();
$bbcode = JCommentsFactory::getBBCode();
$smiles = JCommentsFactory::getSmiles();
$acl = JCommentsFactory::getACL();
if ($show_avatar) {
JPluginHelper::importPlugin('jcomments');
if (version_compare(JVERSION, '3.0', 'ge')) {
$dispatcher = JEventDispatcher::getInstance();
} else {
$dispatcher = JDispatcher::getInstance();
}
$dispatcher->trigger('onPrepareAvatars', array(&$list));
}
foreach ($list as &$item) {
$item->displayDate = '';
if ($show_date) {
if ($date_type == 'relative') {
$item->displayDate = modJCommentsLatestHelper::getRelativeDate($item->date);
} else {
$item->displayDate = JHTML::_('date', $item->date, $date_format);
}
}
$item->displayAuthorName = '';
if ($show_author) {
$item->displayAuthorName = JComments::getCommentAuthorName($item);
}
$item->displayObjectTitle = '';
if ($show_object_title) {
$item->displayObjectTitle = $item->object_title;
}
$item->displayCommentTitle = '';
if ($show_comment_title) {
$item->displayCommentTitle = $item->title;
}
$item->displayCommentLink = $item->object_link . '#comment-' . $item->id;
$text = JCommentsText::censor($item->comment);
$text = preg_replace('#\\[quote[^\\]]*?\\](((?R)|.)*?)\\[\\/quote\\]#ismu', '', $text);
$text = $bbcode->filter($text, true);
$text = JCommentsText::fixLongWords($text, $config->getInt('word_maxlength'), ' ');
if ($acl->check('autolinkurls')) {
$text = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $text);
}
$text = JCommentsText::cleanText($text);
if ($limit_comment_text && JString::strlen($text) > $limit_comment_text) {
$text = self::truncateText($text, $limit_comment_text - 1);
}
switch ($show_smiles) {
case 1:
$text = $smiles->replace($text);
break;
case 2:
$text = $smiles->strip($text);
break;
}
$item->displayCommentText = $text;
if ($show_avatar && empty($item->avatar)) {
$gravatar = md5(strtolower($item->email));
$item->avatar = '<img src="http://www.gravatar.com/avatar.php?gravatar_id=' . $gravatar . '&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars(JComments::getCommentAuthorName($item)) . '" />';
}
$item->readmoreText = JText::_('MOD_JCOMMENTS_LATEST_READMORE');
}
}
return $list;
}
示例10: BanIP
public static function BanIP($id)
{
if (JCommentsSecurity::badRequest() == 1) {
JCommentsSecurity::notAuth();
}
$acl = JCommentsFactory::getACL();
$response = JCommentsFactory::getAjaxResponse();
if ($acl->canBan()) {
$config = JCommentsFactory::getConfig();
if ($config->getInt('enable_blacklist') == 1) {
$id = (int) $id;
$db = JCommentsFactory::getDBO();
$comment = new JCommentsTableComment($db);
if ($comment->load($id)) {
// we will not ban own IP ;)
if ($comment->ip != $acl->getUserIP()) {
$options = array();
$options['ip'] = $comment->ip;
// check if this IP already banned
if (JCommentsSecurity::checkBlacklist($options)) {
$result = JCommentsEvent::trigger('onJCommentsUserBeforeBan', array(&$comment, &$options));
if (!in_array(false, $result, true)) {
require_once JCOMMENTS_TABLES . '/blacklist.php';
$blacklist = new JCommentsTableBlacklist($db);
$blacklist->ip = $comment->ip;
$blacklist->created = JCommentsFactory::getDate();
$blacklist->created_by = $acl->getUserId();
if ($blacklist->store()) {
JCommentsEvent::trigger('onJCommentsUserAfterBan', array(&$comment, $options));
self::showInfoMessage(JText::_('SUCCESSFULLY_BANNED'), 'comment-item-' . $id);
}
}
} else {
self::showErrorMessage(JText::_('ERROR_IP_ALREADY_BANNED'), '', 'comment-item-' . $id);
}
} else {
self::showErrorMessage(JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP'), '', 'comment-item-' . $id);
}
}
}
}
return $response;
}
示例11: showUserComments
public static function showUserComments()
{
$config = JCommentsFactory::getConfig();
if ($config->get('enable_rss') == '1') {
$app = JFactory::getApplication('site');
$acl = JCommentsFactory::getACL();
$userid = $app->input->getInt('userid', 0);
$limit = $app->input->getInt('limit', $config->getInt('feed_limit', 100));
$user = JFactory::getUser($userid);
if (!isset($user->id)) {
self::showNotFound();
return;
}
$lm = $limit != $config->getInt('feed_limit') ? '&limit=' . $limit : '';
if (JCommentsMultilingual::isEnabled()) {
$language = JCommentsMultilingual::getLanguage();
$lp = '&lang=' . $language;
} else {
$language = null;
$lp = '';
}
$liveSite = trim(str_replace(JURI::root(true), '', str_replace('/administrator', '', JURI::root())), '/');
$syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&tmpl=raw');
$user->userid = $user->id;
$username = JComments::getCommentAuthorName($user);
$rss = new JoomlaTuneFeed();
$rss->title = JText::sprintf('USER_FEED_TITLE', $username);
$rss->link = str_replace('/administrator', '', JURI::root());
$rss->syndicationURL = $syndicationURL;
$rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username);
$options = array();
$options['lang'] = $language;
$options['userid'] = $userid;
$options['published'] = 1;
$options['filter'] = 'c.deleted = 0';
$options['orderBy'] = 'c.date DESC';
$options['votes'] = false;
$options['limit'] = $limit;
$options['limitStart'] = 0;
$options['objectinfo'] = true;
$options['access'] = $acl->getUserAccess();
$rows = JCommentsModel::getCommentsList($options);
$word_maxlength = $config->getInt('word_maxlength');
foreach ($rows as $row) {
$comment = JCommentsText::cleanText($row->comment);
if ($comment != '') {
// getting object's information (title and link)
$object_title = $row->object_title;
$object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $row->object_link));
// apply censor filter
$object_title = JCommentsText::censor($object_title);
$comment = JCommentsText::censor($comment);
// fix long words problem
if ($word_maxlength > 0) {
$comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' ');
if ($object_title != '') {
$object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' ');
}
}
$author = JComments::getCommentAuthorName($row);
$item = new JoomlaTuneFeedItem();
$item->title = $object_title;
$item->link = $object_link . '#comment-' . $row->id;
$item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment);
$item->source = $object_link;
$item->pubDate = $row->date;
$item->author = $author;
$rss->addItem($item);
}
}
$rss->display();
unset($rows, $rss);
exit;
}
}
示例12: showUserComments
public static function showUserComments()
{
$config = JCommentsFactory::getConfig();
if ($config->get('enable_rss') == '1') {
$app = JCommentsFactory::getApplication('site');
$acl = JCommentsFactory::getACL();
$userid = (int) JCommentsInput::getVar('userid', 0);
$limit = (int) JCommentsInput::getVar('limit', $config->getInt('feed_limit', 100));
$user = JCommentsFactory::getUser($userid);
if (!isset($user->id)) {
self::showNotFound();
return;
}
if (JCOMMENTS_JVERSION == '1.0') {
$offset = $app->getCfg('offset') + date('O') / 100;
} else {
$offset = $app->getCfg('offset');
}
$lm = $limit != $config->getInt('feed_limit') ? '&limit=' . $limit : '';
if (JCommentsMultilingual::isEnabled()) {
$language = JCommentsMultilingual::getLanguage();
$lp = '&lang=' . $language;
} else {
$language = null;
$lp = '';
}
if (JCOMMENTS_JVERSION == '1.0') {
$syndicationURL = $app->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&no_html=1';
} else {
$liveSite = str_replace(JURI::root(true), '', $app->getCfg('live_site'));
$syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&tmpl=raw');
}
$user->userid = $user->id;
$username = JComments::getCommentAuthorName($user);
$rss = new JoomlaTuneFeed();
$rss->setOffset($offset);
$rss->encoding = JCOMMENTS_ENCODING;
$rss->title = JText::sprintf('USER_FEED_TITLE', $username);
$rss->link = $app->getCfg('live_site');
$rss->syndicationURL = $syndicationURL;
$rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username);
$options = array();
$options['lang'] = $language;
$options['userid'] = $userid;
$options['published'] = 1;
$options['filter'] = 'c.deleted = 0';
$options['orderBy'] = 'c.date DESC';
$options['votes'] = false;
$options['limit'] = $limit;
$options['limitStart'] = 0;
$options['objectinfo'] = true;
$options['access'] = $acl->getUserAccess();
$rows = JCommentsModel::getCommentsList($options);
$word_maxlength = $config->getInt('word_maxlength');
$lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null;
foreach ($rows as $row) {
$comment = JCommentsText::cleanText($row->comment);
if ($comment != '') {
// getting object's information (title and link)
$object_title = empty($row->object_title) ? JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang) : $row->object_title;
$object_link = empty($row->object_link) ? JCommentsObjectHelper::getLink($row->object_id, $row->object_group, $lang) : $row->object_link;
$object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $object_link));
// apply censor filter
$object_title = JCommentsText::censor($object_title);
$comment = JCommentsText::censor($comment);
// fix long words problem
if ($word_maxlength > 0) {
$comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' ');
if ($object_title != '') {
$object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' ');
}
}
$author = JComments::getCommentAuthorName($row);
$item = new JoomlaTuneFeedItem();
$item->title = $object_title;
$item->link = $object_link . '#comment-' . $row->id;
$item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment);
$item->source = $object_link;
if (JCOMMENTS_JVERSION == '1.0') {
$date = strtotime((string) $row->date) - $offset * 3600;
$item->pubDate = date('Y-m-d H:i:s', $date);
} else {
$item->pubDate = $row->date;
}
$item->author = $author;
$rss->addItem($item);
}
}
$rss->display();
unset($rows, $rss);
exit;
}
}
示例13: executeCmd
function executeCmd()
{
global $mainframe;
$cmd = strtolower(JCommentsInput::getVar('cmd', ''));
$hash = JCommentsInput::getVar('hash', '');
$id = (int) JCommentsInput::getVar('id', 0);
$error = '';
$link = $mainframe->getCfg('live_site') . '/index.php';
$checkHash = JCommentsFactory::getCmdHash($cmd, $id);
if ($hash == $checkHash) {
$config =& JCommentsFactory::getConfig();
if ($config->getInt('enable_quick_moderation') == 1) {
$dbo =& JCommentsFactory::getDBO();
$comment = new JCommentsDB($dbo);
if ($comment->load($id)) {
$link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group);
$link = str_replace('&', '&', $link);
switch ($cmd) {
case 'publish':
$comment->published = 1;
$comment->store();
$link .= '#comment-' . $comment->id;
break;
case 'unpublish':
$comment->published = 0;
$comment->store();
$acl =& JCommentsFactory::getACL();
if ($acl->canPublish()) {
$link .= '#comment-' . $comment->id;
} else {
$link .= '#comments';
}
break;
case 'delete':
$comment->delete();
$link .= '#comments';
break;
}
}
} else {
$error = JText::_('Quick moderation function is disabled by administrator!');
}
} else {
$error = JText::_('Incorrect hash for this operation!');
}
JCommentsRedirect($link, $error);
}
示例14: onPrepareContent
//.........这里部分代码省略.........
}
if ($this->params->get('readmore_link', 1) == 0) {
$readmoreDisabled = true;
}
$tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled));
// don't fill any readmore variable if it disabled
if (!$readmoreDisabled) {
if ($readmore_register == 1) {
$readmore_text = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
} else {
if (isset($params) && ($readmore = $params->get('readmore'))) {
$readmore_text = $readmore;
} else {
if ($alternative_readmore = $article->alternative_readmore) {
$readmore_text = trim($alternative_readmore);
if ($params->get('show_readmore_title', 0) != 0) {
$readmore_text .= ' ' . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit'));
}
} else {
$readmore_text = JText::_('COM_CONTENT_READ_MORE_TITLE');
if ($params->get('show_readmore_title', 0) == 1) {
$readmore_text = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit'));
}
}
}
}
$tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
$tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
$tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
$tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
}
$commentsDisabled = false;
if ($config->getInt('comments_off', 0) == 1) {
$commentsDisabled = true;
} else {
if ($config->getInt('comments_on', 0) == 1) {
$commentsDisabled = false;
}
}
$tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled));
$count = 0;
// do not query comments count if comments disabled and link hidden
if (!$commentsDisabled) {
require_once JPATH_ROOT . '/components/com_jcomments/models/jcomments.php';
$anchor = "";
if ($this->params->get('comments_count', 1) != 0) {
$acl = JCommentsFactory::getACL();
$options = array();
$options['object_id'] = (int) $article->id;
$options['object_group'] = 'com_content';
$options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1;
$count = JCommentsModel::getCommentsCount($options);
$tmpl->addVar('tpl_links', 'comments-count', $count);
$anchor = $count == 0 ? '#addcomments' : '#comments';
if ($count == 0) {
$link_text = JText::_('LINK_ADD_COMMENT');
} else {
$link_text = JText::plural('LINK_READ_COMMENTS', $count);
}
} else {
$link_text = JText::_('LINK_ADD_COMMENT');
}
$tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor);
$tmpl->addVar('tpl_links', 'link-comment-text', $link_text);
$tmpl->addVar('tpl_links', 'link-comments-class', $this->params->get('comments_css_class', 'comments-link'));
}
JCommentsContentPluginHelper::clear($article, true);
// hide comments link if comments enabled but link disabled in plugin params
if (($this->params->get('comments_count', 1) == 0 || $count == 0 && $this->params->get('add_comments', 1) == 0 || $count == 0 && $readmore_register == 1) && !$commentsDisabled) {
$tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
}
//links_position
if ($this->params->get('links_position', 1) == 1) {
$article->text .= $tmpl->renderTemplate('tpl_links');
} else {
$article->text = $tmpl->renderTemplate('tpl_links') . $article->text;
}
$tmpl->freeTemplate('tpl_links');
if ($this->params->get('readmore_link', 1) == 1) {
$article->readmore = 0;
$article->readmore_link = '';
$article->readmore_register = false;
}
} else {
if ($this->params->get('show_comments_event') == 'onPrepareContent') {
$isEnabled = $config->getInt('comments_on', 0) == 1 && $config->getInt('comments_off', 0) == 0;
if ($isEnabled && $view == 'article') {
require_once JPATH_ROOT . '/components/com_jcomments/jcomments.php';
$comments = JComments::show($article->id, 'com_content', $article->title);
if (strpos($article->text, '{jcomments}') !== false) {
$article->text = str_replace('{jcomments}', $comments, $article->text);
} else {
$article->text .= $comments;
}
}
}
JCommentsContentPluginHelper::clear($article, true);
}
return '';
}
示例15: 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;
}