Dotclear

Changeset 2305


Ignore:
Timestamp:
06/06/10 01:00:49 (13 years ago)
Author:
JcDenis
Message:

dcFilterDuplicate 0.3

  • Switched to DC 2.2
Location:
plugins/dcFilterDuplicate
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcFilterDuplicate/_define.php

    r1981 r2305  
    33# This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 
    44#  
    5 # Copyright (c) 2009 JC Denis and contributors 
     5# Copyright (c) 2009-2010 JC Denis and contributors 
    66# jcdenis@gdwd.com 
    77#  
     
    1717     /* Description*/              "Antispam for duplicate comments on multiblog", 
    1818     /* Author */             "JC Denis", 
    19      /* Version */            '0.2', 
     19     /* Version */            '0.3', 
    2020     /* Permissions */             'admin', 
    2121     /* Priority */           200 
    2222); 
    23      /* date */          #20091213 
     23     /* date */          #20100605 
    2424?> 
  • plugins/dcFilterDuplicate/_install.php

    r1981 r2305  
    33# This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 
    44#  
    5 # Copyright (c) 2009 JC Denis and contributors 
     5# Copyright (c) 2009-2010 JC Denis and contributors 
    66# jcdenis@gdwd.com 
    77#  
     
    1616$new_version = $core->plugins->moduleInfo('dcFilterDuplicate','version'); 
    1717$old_version = $core->getVersion('dcFilterDuplicate'); 
     18 
    1819# Compare versions 
    1920if (version_compare($old_version,$new_version,'>=')) {return;} 
     21 
    2022# Install or update 
    21 try { 
    22      # Check DC version (dev on) 
    23      if (!version_compare(DC_VERSION,'2.1.5','>=')) { 
    24           throw new Exception('Plugin called dcFilterDuplicate requires Dotclear 2.1.5 or higher.'); 
     23try 
     24{ 
     25     # Check version 
     26     if (version_compare(DC_VERSION,'2.2-beta','<')) 
     27     { 
     28          throw new Exception('dcFilterDuplicate requires Dotclear 2.2'); 
    2529     } 
    26      # Check DC version (new settings) 
    27      if (version_compare(DC_VERSION,'2.2','>=')) { 
    28           throw new Exception('Plugin called dcFilterDuplicate requires Dotclear up to 2.2.'); 
    29      } 
     30      
    3031     # Settings 
    31      $s = null; 
    32      $s =& $core->blog->settings; 
    33      $s->setNameSpace('dcFilterDuplicate'); 
    34      $s->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true); 
    35      $s->setNameSpace('system'); 
     32     $core->blog->settings->addNamespace('dcFilterDuplicate'); 
     33     $core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true); 
     34 
    3635     # Version 
    3736     $core->setVersion('dcFilterDuplicate',$new_version); 
    38      # All right baby 
     37 
    3938     return true; 
    4039} 
    41 catch (Exception $e) { 
     40catch (Exception $e) 
     41{ 
    4242     $core->error->add($e->getMessage()); 
    4343     return false; 
  • plugins/dcFilterDuplicate/_prepend.php

    r1560 r2305  
    33# This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 
    44#  
    5 # Copyright (c) 2009 JC Denis and contributors 
     5# Copyright (c) 2009-2010 JC Denis and contributors 
    66# jcdenis@gdwd.com 
    77#  
  • plugins/dcFilterDuplicate/_uninstall.php

    r1981 r2305  
    33# This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 
    44#  
    5 # Copyright (c) 2009 JC Denis and contributors 
     5# Copyright (c) 2009-2010 JC Denis and contributors 
    66# jcdenis@gdwd.com 
    77#  
  • plugins/dcFilterDuplicate/inc/class.filter.duplicate.php

    r1981 r2305  
    33# This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 
    44#  
    5 # Copyright (c) 2009 JC Denis and contributors 
     5# Copyright (c) 2009-2010 JC Denis and contributors 
    66# jcdenis@gdwd.com 
    77#  
     
    1717     public $name = 'Duplicate comment filter'; 
    1818     public $has_gui = true; 
    19   
     19      
    2020     protected function setInfo() 
    2121     { 
    2222          $this->description = __('Same comments on others blogs of a multiblog.'); 
    2323     } 
    24  
     24      
    2525     public function isSpam($type,$author,$email,$site,$ip,$content,$post_id,&$status) 
    2626     { 
    2727          if ($type != 'comment') return null; 
    28  
    29           $minlen = abs((integer) $this->core->blog->settings->dcfilterduplicate_minlen); 
     28           
     29          $this->core->blog->settings->addNamespace('dcFilterDuplicate'); 
     30          $minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen); 
    3031          if (strlen($content) < $minlen) return null; 
    31  
     32           
    3233          try 
    3334          { 
     
    4344               } 
    4445          } 
    45           catch (Exception $e) { throw new Exception($e->getMessage()); } 
     46          catch (Exception $e) 
     47          { 
     48               throw new Exception($e->getMessage()); 
     49          } 
    4650     } 
    47  
     51      
    4852     public function isDuplicate($content,$ip) 
    4953     { 
     
    5862          return !$rs->isEmpty(); 
    5963     } 
    60  
     64      
    6165     public function markDuplicate($content,$ip) 
    6266     { 
    6367          $cur = $this->core->con->openCursor($this->core->prefix.'comment'); 
    6468          $this->core->con->writeLock($this->core->prefix.'comment'); 
    65  
     69           
    6670          $cur->comment_status = -2; 
    6771          $cur->comment_spam_status = 'Duplicate on other blog'; 
    6872          $cur->comment_spam_filter = 'dcFilterDuplicate'; 
    69  
     73           
    7074          $cur->update( 
    7175               "WHERE comment_content='".$this->core->con->escape($content)."' ". 
     
    7377          ); 
    7478          $this->core->con->unlock(); 
    75  
     79           
    7680          $this->triggerOtherBlogs($content,$ip); 
    7781     } 
     
    7983     public function gui($url) 
    8084     { 
    81           $minlen = abs((integer) $this->core->blog->settings->dcfilterduplicate_minlen); 
     85          $this->blog->settings->addNamespace('dcFilterDuplicate'); 
     86          $minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen); 
    8287          if (isset($_POST['dcfilterduplicate_minlen'])) 
    8388          { 
    8489               $minlen = abs((integer) $_POST['dcfilterduplicate_minlen']); 
    85                $this->core->blog->settings->setNameSpace('dcFilterDuplicate'); 
    86                $this->core->blog->settings->put('dcfilterduplicate_minlen',$minlen,'integer'); 
    87                $this->core->blog->settings->setNameSpace('system'); 
     90               $this->core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',$minlen,'integer'); 
    8891          } 
    89  
     92           
    9093          $res = 
    9194          '<form action="'.html::escapeURL($url).'" method="post">'. 
     
    98101          return $res; 
    99102     } 
    100  
     103      
    101104     public function triggerOtherBlogs($content,$ip) 
    102105     { 
     
    108111               "AND C.comment_ip='".$ip."' " 
    109112          ); 
    110  
     113           
    111114          while ($rs->fetch()) 
    112115          { 
  • plugins/dcFilterDuplicate/release.txt

    r1981 r2305  
     10.3 20100605 
     2 * Switched to DC 2.2 
     3 
    140.2 20091213 
    25 * Fixed trigger blogs 
Note: See TracChangeset for help on using the changeset viewer.

Sites map