当前位置: 首页>>代码示例>>PHP>>正文


PHP JComments::getLastComment方法代码示例

本文整理汇总了PHP中JComments::getLastComment方法的典型用法代码示例。如果您正苦于以下问题:PHP JComments::getLastComment方法的具体用法?PHP JComments::getLastComment怎么用?PHP JComments::getLastComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JComments的用法示例。


在下文中一共展示了JComments::getLastComment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addComment


//.........这里部分代码省略.........
                                 $comment->published = $acl->check('autopublish');
                                 if (JCOMMENTS_JVERSION == '1.5') {
                                     $dateNow =& JFactory::getDate();
                                     $comment->date = $dateNow->toMySQL();
                                 } else {
                                     $comment->date = date('Y-m-d H:i:s', time() + $mainframe->getCfg('offset') * 60 * 60);
                                 }
                                 $query = "SELECT COUNT(*) " . "\nFROM #__jcomments " . "\nWHERE comment = '" . $db->getEscaped($comment->comment) . "'" . "\n  AND ip = '" . $db->getEscaped($comment->ip) . "'" . "\n  AND name = '" . $db->getEscaped($comment->name) . "'" . "\n  AND userid = '" . $comment->userid . "'" . "\n  AND object_id = " . $comment->object_id . "\n  AND parent = " . $comment->parent . "\n  AND object_group = '" . $db->getEscaped($comment->object_group) . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "");
                                 $db->setQuery($query);
                                 $found = $db->loadResult();
                                 // if duplicates is not found
                                 if ($found == 0) {
                                     // trigger onBeforeCommentAdded event
                                     $allowed = true;
                                     if ($config->getInt('enable_mambots') == 1) {
                                         require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                                         JCommentsPluginHelper::importPlugin('jcomments');
                                         JCommentsPluginHelper::trigger('onBeforeCommentAdded', array(&$comment, &$response, &$allowed));
                                     }
                                     if ($allowed === false) {
                                         return $response;
                                     }
                                     // save comments subscription
                                     if ($values['subscribe']) {
                                         require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php';
                                         $manager =& JCommentsSubscriptionManager::getInstance();
                                         $manager->subscribe($comment->object_id, $comment->object_group, $comment->userid, $comment->email, $comment->name, $comment->lang);
                                     }
                                     $merged = false;
                                     $merge_time = $config->getInt('merge_time', 0);
                                     // merge comments from same author
                                     if ($my->id && $merge_time > 0) {
                                         // load previous comment for same object and group
                                         $prevComment = JComments::getLastComment($comment->object_id, $comment->object_group, $comment->parent);
                                         if ($prevComment != null) {
                                             // if previous comment from same author and it currently not edited
                                             // by any user - we'll update comment, else - insert new record to database
                                             if ($prevComment->userid == $comment->userid && $prevComment->parent == $comment->parent && !$acl->isLocked($prevComment)) {
                                                 $newText = $prevComment->comment . '<br /><br />' . $comment->comment;
                                                 $timeDiff = strtotime($comment->date) - strtotime($prevComment->datetime);
                                                 if ($timeDiff < $merge_time) {
                                                     $maxlength = $config->getInt('comment_maxlength');
                                                     $needcheck = $acl->check('enable_comment_length_check');
                                                     // validate new comment text length and if it longer than specified -
                                                     // disable union current comment with previous
                                                     if ($needcheck == 0 || $needcheck == 1 && $maxlength != 0 && JCommentsText::strlen($newText) <= $maxlength) {
                                                         $comment->id = $prevComment->id;
                                                         $comment->comment = $newText;
                                                         $merged = true;
                                                     }
                                                 }
                                             }
                                             unset($prevComment);
                                         }
                                     }
                                     if ($comment->parent > 0) {
                                         $parent = new JCommentsDB($db);
                                         if ($parent->load($comment->parent)) {
                                             if ($config->getInt('comment_title') == 1 && $comment->title == '') {
                                                 if (!empty($parent->title)) {
                                                     $comment->title = JText::_('Re') . ' ' . $parent->title;
                                                 }
                                             }
                                             $comment->level = $parent->level + 1;
                                             $comment->path = $parent->path . ',' . $parent->id;
                                         }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:67,代码来源:jcomments.ajax.php


注:本文中的JComments::getLastComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。