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


PHP JComments::sendNotification方法代码示例

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


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

示例1: saveComment

 public static function saveComment($values = array())
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $db = JCommentsFactory::getDBO();
     $config = JCommentsFactory::getConfig();
     $response = JCommentsFactory::getAjaxResponse();
     $values = self::prepareValues($_POST);
     $comment = new JCommentsTableComment($db);
     $id = (int) $values['id'];
     if ($comment->load($id)) {
         $acl = JCommentsFactory::getACL();
         if ($acl->canEdit($comment)) {
             if ($values['comment'] == '') {
                 self::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
             } else {
                 if ($config->getInt('comment_maxlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) > $config->getInt('comment_maxlength')) {
                     self::showErrorMessage(JText::_('ERROR_TOO_LONG_COMMENT'), 'comment');
                 } else {
                     if ($config->getInt('comment_minlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) < $config->getInt('comment_minlength')) {
                         self::showErrorMessage(JText::_('ERROR_YOUR_COMMENT_IS_TOO_SHORT'), 'comment');
                     } else {
                         $bbcode = JCommentsFactory::getBBCode();
                         $comment->comment = $values['comment'];
                         $comment->comment = $bbcode->filter($comment->comment);
                         $comment->published = $acl->check('autopublish');
                         if ($config->getInt('comment_title') != 0 && isset($values['title'])) {
                             $comment->title = stripslashes((string) $values['title']);
                         }
                         if ($config->getInt('author_homepage') == 1 && isset($values['homepage'])) {
                             $comment->homepage = JCommentsText::url($values['homepage']);
                         } else {
                             $comment->homepage = '';
                         }
                         $result = JCommentsEvent::trigger('onJCommentsCommentBeforeChange', array(&$comment));
                         if (in_array(false, $result, true)) {
                             return $response;
                         }
                         $comment->store();
                         $comment->checkin();
                         JCommentsEvent::trigger('onJCommentsCommentAfterChange', array(&$comment));
                         if ($config->getInt('enable_notification') == 1) {
                             if ($config->check('notification_type', 1) == true) {
                                 JComments::sendNotification($comment, false);
                             }
                         }
                         $html = JCommentsText::jsEscape(JComments::getCommentItem($comment));
                         $response->addScript("jcomments.updateComment(" . $comment->id . ", '{$html}');");
                     }
                 }
             }
         } else {
             $response->addAlert(JText::_('ERROR_CANT_EDIT'));
         }
     }
     return $response;
 }
开发者ID:sergy444,项目名称:joomla,代码行数:58,代码来源:jcomments.ajax.php

示例2: saveComment

 function saveComment($values = array())
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $db =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     $response =& JCommentsFactory::getAjaxResponse();
     $values = JCommentsAJAX::prepareValues($_POST);
     $comment = new JCommentsDB($db);
     $id = (int) $values['id'];
     if ($comment->load($id)) {
         $acl =& JCommentsFactory::getACL();
         if ($acl->canEdit($comment)) {
             if ($values['comment'] == '') {
                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
             } else {
                 if ($config->getInt('comment_maxlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) > $config->getInt('comment_maxlength')) {
                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_TOO_LONG_COMMENT'), 'comment');
                 } else {
                     if ($config->getInt('comment_minlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) < $config->getInt('comment_minlength')) {
                         JCommentsAJAX::showErrorMessage(JText::_('Your comment is too short'), 'comment');
                     } else {
                         $bbcode =& JCommentsFactory::getBBCode();
                         $comment->comment = $values['comment'];
                         $comment->comment = $bbcode->filter($comment->comment);
                         $comment->published = $acl->check('autopublish');
                         if ($config->getInt('comment_title') != 0 && isset($values['title'])) {
                             $comment->title = stripslashes((string) $values['title']);
                         }
                         if ($config->getInt('author_homepage') == 1 && isset($values['homepage'])) {
                             $comment->homepage = JCommentsText::url($values['homepage']);
                         } else {
                             $comment->homepage = '';
                         }
                         $allowed = true;
                         if ($config->getInt('enable_mambots') == 1) {
                             require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                             JCommentsPluginHelper::importPlugin('jcomments');
                             JCommentsPluginHelper::trigger('onBeforeCommentChanged', array(&$comment, &$response, &$allowed));
                         }
                         if ($allowed == false) {
                             return $response;
                         }
                         $comment->store();
                         $comment->checkin();
                         $comment->datetime = $comment->date;
                         if ($config->getInt('enable_mambots') == 1) {
                             JCommentsPluginHelper::importPlugin('jcomments');
                             JCommentsPluginHelper::trigger('onAfterCommentChanged', array(&$comment, &$response));
                         }
                         if ($config->getInt('enable_notification') == 1) {
                             if ($config->check('notification_type', 1) == true) {
                                 JComments::sendNotification($comment, false);
                             }
                         }
                         JComments::prepareComment($comment);
                         $tmpl =& JCommentsFactory::getTemplate();
                         $tmpl->load('tpl_comment');
                         $tmpl->addVar('tpl_comment', 'get_comment_body', 1);
                         $tmpl->addObject('tpl_comment', 'comment', $comment);
                         $html = $tmpl->renderTemplate('tpl_comment');
                         $html = JCommentsText::jsEscape($html);
                         $response->addScript("jcomments.updateComment(" . $comment->id . ", '{$html}');");
                     }
                 }
             }
         } else {
             $response->addAlert(JText::_('ERROR_CANT_EDIT'));
         }
     }
     unset($comment);
     return $response;
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:74,代码来源:jcomments.ajax.php

示例3: onJCommentsCommentBeforeAdd

 /**
  * onJCommentsCommentBeforeAdd trigger
  * @access public
  * @param JCommentsDB $comment
  * @return bolean true
  * @since 1.5
  */
 public function onJCommentsCommentBeforeAdd(&$comment)
 {
     $config = $this->getCTConfig();
     $session = JFactory::getSession();
     $submit_time = $this->submit_time_test();
     // set new time because onJCommentsFormAfterDisplay worked only once
     // and formtime in session need to be renewed between ajax posts
     $session->set($this->form_load_label, time());
     $checkjs = $this->get_ct_checkjs(true);
     $sender_info = $this->get_sender_info();
     $sender_info = json_encode($sender_info);
     if ($sender_info === false) {
         $sender_info = '';
     }
     $post_info['comment_type'] = 'jcomments_comment';
     $post_info['post_url'] = $session->get($this->current_page);
     $post_info = json_encode($post_info);
     if ($post_info === false) {
         $post_info = '';
     }
     $plugin_groups = array();
     $param_groups = $this->params->get('groups');
     if (is_array($param_groups)) {
         foreach ($param_groups as $group) {
             array_push($plugin_groups, (int) $group);
         }
     } else {
         array_push($plugin_groups, (int) $param_groups);
     }
     $user = JFactory::getUser();
     if (method_exists($user, 'getAuthorisedGroups')) {
         // 1.6+
         $user_groups = $user->getAuthorisedGroups();
     } else {
         // 1.5
         $user_groups = array();
         if ($user->guest) {
             array_push($user_groups, 29);
         } else {
             array_push($user_groups, $user->gid);
         }
     }
     foreach ($user_groups as $group) {
         if (in_array($group, $plugin_groups)) {
             $example = null;
             if ($config['relevance_test'] !== '') {
                 switch ($comment->object_group) {
                     case 'com_content':
                         $article = JTable::getInstance('content');
                         $article->load($comment->object_id);
                         $baseText = $article->introtext . '<br>' . $article->fulltext;
                         break;
                     default:
                         $baseText = '';
                 }
                 $db = JCommentsFactory::getDBO();
                 $query = "SELECT comment " . "\nFROM #__jcomments " . "\nWHERE published = 1 " . "\n  AND object_group = '" . $db->getEscaped($comment->object_group) . "'" . "\n  AND object_id = " . $comment->object_id . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . " ORDER BY id DESC " . " LIMIT 10 ";
                 $db->setQuery($query);
                 $prevComments = $db->loadResultArray();
                 $prevComments = $prevComments == NULL ? '' : implode("\n\n", $prevComments);
                 $example = $baseText . "\n\n\n\n" . $prevComments;
             }
             self::getCleantalk();
             $ctResponse = self::ctSendRequest('check_message', array('example' => $example, 'message' => $comment->comment, 'sender_nickname' => $comment->name, 'sender_email' => $comment->email, 'sender_ip' => self::$CT->ct_session_ip($_SERVER['REMOTE_ADDR']), 'js_on' => $checkjs, 'submit_time' => $submit_time, 'sender_info' => $sender_info, 'post_info' => $post_info));
             if (!empty($ctResponse) && is_array($ctResponse)) {
                 if ($ctResponse['stop_queue'] == 1) {
                     JCommentsAJAX::showErrorMessage($ctResponse['comment'], 'comment');
                     return false;
                 } else {
                     if ($ctResponse['allow'] == 0) {
                         $comment->published = false;
                         // Send notification to administrator
                         if ($config['jcomments_unpublished_nofications'] != '') {
                             JComments::sendNotification($comment, true);
                         }
                     }
                 }
             }
             return true;
         }
         //if(in_array($group, $plugin_groups))
     }
     //foreach
 }
开发者ID:VladCleantalk,项目名称:joomla25-3x-antispam,代码行数:91,代码来源:antispambycleantalk.php


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