1. Leonid
  2. Wishlist
  3. Tuesday, 16 June 2009
  4.  Subscribe via email
Well, my solution is quite dirty and hardcoded. On post inserted event onCommentAutoPublishing triggered. Each event handler return true if message is published otherwise false. Message autopublished if no false values was returned by plugins.

Plugin parameters:
[size=1]Just small amount of context data passed. Maybe we should pass $this reference instead?[/size]
[ol][li]comment (BB-tagged text message)[/li][li]ip[/li][li]email[/li][li]website[/li][/ol]
Plugin result:
[ul][li]true (message published)[/li][li]false (message is not published)[/li][/ul]

diff --git a/joscomment/comment.class.php b/joscomment/comment.class.php
index bb04ded..d98a760 100644
--- a/joscomment/comment.class.php
+++ b/joscomment/comment.class.php
@@ -976,6 +976,16 @@ class JOSC_board extends JOSC_visual {
return JOSC_utils::censorText($text,$this->_censorship_enable,$this->_censorship_words,$this->_censorship_case_sensitive);
}

+ private function _isPublished($ip, $email, $website, $comment)
+ {
+ $dispatcher = JDispatcher::getInstance();
+ $result = $dispatcher->trigger('onCommentAutoPublishing', array('comment' => $comment, 'ip' => $ip, 'email' => $email, 'website' => $website));
+ $custom_filters = true;
+ foreach ($result as $row) {
+ $custom_filters = $custom_filters && $row;
+ }
+ return ($this->_autopublish && $custom_filters) || JOSC_utils::isModerator($this->_moderator);
+ }
function insertNewPost($ajax = false)
{
$ip = $_SERVER['REMOTE_ADDR'];
@@ -997,7 +1007,7 @@ class JOSC_board extends JOSC_visual {
$title = $this->censorText(JOSC_utils::mysql_escape_string(strip_tags($this->_ttitle)));
$comment = $this->censorText(JOSC_utils::mysql_escape_string(strip_tags($this->_tcomment)));
if (!$comment) $comment = _JOOMLACOMMENT_EMPTYCOMMENT;
- $published = $this->_autopublish || JOSC_utils::isModerator($this->_moderator);
+ $published = $this->_isPublished($ip, $email, $website, $comment);
$parent_id = $this->_parent_id;
$database->SetQuery("
INSERT INTO jos_comment


And here sample plugin, discontinuing comments with hyperlinks inside:
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.plugin.plugin');

class plgSystemJocom_Nolink extends JPlugin
{
public function onCommentAutoPublishing($comment, $ip, $email, $website)
{
return stripos($comment, '[url') === false;
}
}
Responses (1)


There are %s replies to this question. If you want to see them you need a valid subscription.
If you have a valid subscription, please login now.
Visit store now

Last questions

Veranstaltung im Frontend sichtbar obwohl nicht ve
Hallo, folgendes Problem stellt sich mir: Wenn ich eine Veranstaltung dupl...
4 Replies
Posted on Friday, 09 February 2024
Suche bei der Matukio - Fehler Ö Ä Ü..
Hallo, evtl. könnt ihr mir weiterhelfen. Bei mir funktioniert die suche bei ...
3 Replies
Posted on Wednesday, 15 May 2024
  • New
  • When is CComment compatible with Joomla 5?
    When is CComment compatible with Joomla 5?...
    4 Replies
    Posted on Tuesday, 05 December 2023
    • #CComment
    • #Joomla 5
    _MATUKIO_NO_EVENTS appears in the frontend if no e
    Hello, there ist still the problem, that on the frontpage appears COM_MATUKIO...
    2 Replies
    Posted on Sunday, 12 May 2024
  • New
  • verschiedene URL's für Kursübersicht einer Kategor
    Hallo, ich habe eine Frage in Bezug auf SEO: ein externer Spezialist macht die...
    3 Replies
    Posted on Monday, 29 April 2024