Dotclear

Changeset 2294


Ignore:
Timestamp:
06/05/10 14:58:29 (13 years ago)
Author:
Moe
Message:

Subscribe to comments 1.3.2 :

  • limited subscribers list to the current blog (closes #461)
  • moved _public.php classes in inc/
  • switched to GPL v2
  • PHP 5.3 compatibility ?
Location:
plugins/subscribeToComments
Files:
2 added
1 deleted
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • plugins/subscribeToComments/_admin.php

    r1606 r2294  
    33# 
    44# This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
    66# 
    77# Subscribe to comments is free software; you can redistribute it and/or modify 
  • plugins/subscribeToComments/_define.php

    r2198 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
    66# 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
    1919# 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
    2122# 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
     
    3032     /* Description*/                "Subscribe to comments by email", 
    3133     /* Author */                    "Moe (http://gniark.net/)", 
    32      /* Version */                   '1.3.1', 
     34     /* Version */                   '1.3.2', 
    3335     /* Permissions */               'admin' 
    3436); 
  • plugins/subscribeToComments/_install.php

    r1403 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
    66# 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
    1919# 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
    2122# 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
  • plugins/subscribeToComments/_prepend.php

    r1517 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008 Moe (http://gniark.net/) 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
    66# 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
    1919# 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
    2122# 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
     
    2830$__autoload['subscribeToComments'] = dirname(__FILE__). 
    2931     '/inc/lib.subscribeToComments.php'; 
     32$__autoload['subscribeToCommentsDocument'] = dirname(__FILE__). 
     33     '/inc/lib.subscribeToComments.document.php'; 
     34$__autoload['subscribeToCommentsTpl'] = dirname(__FILE__). 
     35     '/inc/lib.subscribeToComments.tpl.php'; 
    3036$__autoload['subscriber'] = dirname(__FILE__). 
    3137     '/inc/class.subscriber.php'; 
  • plugins/subscribeToComments/default-templates/subscribetocomments.html

    r2198 r2294  
    9999                          
    100100                    <p class="field"> 
    101                               <label for="email">{{tpl:lang Email address}}&nbsp;:</label> 
     101                              <label for="email">{{tpl:lang Email address}}:</label> 
    102102                              <input type="text" name="email" id="email" size="30" maxlength="255"  
    103103                                   value="{{tpl:SubscribeToCommentsEmail}}" /> 
     
    170170                         <p class="field"> 
    171171                              <label for="new_email"> 
    172                                    {{tpl:lang New email address}}&nbsp;:</label> 
     172                                   {{tpl:lang New email address}}:</label> 
    173173                              <input type="text" name="new_email" id="new_email" size="30" 
    174174                                   maxlength="255"  /> 
  • plugins/subscribeToComments/inc/class.subscriber.php

    r2198 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
    6 # 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
     6# 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    19 # 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
    21 # 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
     19# 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
     22# 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
  • plugins/subscribeToComments/inc/lib.subscribeToComments.document.php

    r2198 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
    6 # 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
     6# 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    19 # 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
    21 # 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
     19# 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
     22# 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
    2527 
    2628if (!defined('DC_RC_PATH')) {return;} 
    27  
    28 l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public'); 
    29  
    30 $core->tpl->addBlock('SubscribeToCommentsIsActive', 
    31      'subscribeToCommentsIsActive'); 
    32  
    33 function subscribeToCommentsIsActive($attr,$content) 
    34 { 
    35      return '<?php if ($core->blog->settings->subscribetocomments_active) : ?>'. 
    36           $content. 
    37           '<?php endif; ?>'; 
    38 } 
    3929 
    4030/** 
     
    221211           
    222212          $core->tpl->setPath($core->tpl->getPath(), 
    223                dirname(__FILE__).'/default-templates/'); 
     213               dirname(__FILE__).'/../default-templates/'); 
    224214           
    225215          self::serveDocument('subscribetocomments.html','text/html',false,false); 
     
    227217} 
    228218 
    229 /** 
    230 @ingroup Subscribe to comments 
    231 @brief Template 
    232 */ 
    233 class subscribeToCommentsTpl 
    234 { 
    235      /** 
    236      check the box on post.html if a cookie is present 
    237      @return   <b>string</b> PHP block 
    238      */ 
    239      public static function formChecked() 
    240      { 
    241           return("<?php ". 
    242           "if (isset(\$_POST['subscribeToComments'])) {echo(' checked=\"checked\" ');}". 
    243           "elseif (isset(\$_COOKIE['subscribetocomments']))". 
    244           "{echo(' checked=\"checked\" ');}". 
    245           " ?>"); 
    246      } 
    247  
    248      /** 
    249      get link from post.html to subscriptions page 
    250      @return   <b>string</b> text and PHP block 
    251      */ 
    252      public static function formLink() 
    253      { 
    254           global $core; 
    255  
    256           if ($core->blog->settings->subscribetocomments_active) 
    257           { 
    258                return("<?php echo(subscribeToComments::url().". 
    259                "((\$core->blog->settings->url_scan == 'query_string') ? '&amp;' : '?').". 
    260                "'post_id='.\$_ctx->posts->post_id); ?>"); 
    261           } 
    262      } 
    263            
    264      /** 
    265      if there is a message 
    266      @param    attr <b>array</b>   Attribute 
    267      @param    content   <b>string</b>  Content 
    268      @return   <b>string</b> PHP block 
    269      */ 
    270      public static function ifMessage($attr,$content) 
    271      { 
    272           return 
    273           "<?php if (\$_ctx->subscribeToComments->message !== null) : ?>"."\n". 
    274           $content. 
    275           "<?php endif; ?>"; 
    276      } 
    277  
    278      /** 
    279      display a message 
    280      @return   <b>string</b> PHP block 
    281      */ 
    282      public static function message() 
    283      { 
    284           return("<?php if (\$_ctx->subscribeToComments->message !== null) :"."\n". 
    285           "echo(\$_ctx->subscribeToComments->message);". 
    286           "endif; ?>"); 
    287      } 
    288  
    289      /** 
    290      get nonce 
    291      @return   <b>string</b> Nonce 
    292      */ 
    293      public static function getNonce() 
    294      { 
    295           return "<?php echo(crypt::hmac(DC_MASTER_KEY,session_id())); ?>"; 
    296      } 
    297  
    298      /** 
    299      if it's a post 
    300      @param    attr <b>array</b>   Attribute 
    301      @param    content   <b>string</b>  Content 
    302      @return   <b>string</b> PHP block 
    303      */ 
    304      public static function entryIf($attr,$content) 
    305      { 
    306           return 
    307           "<?php if ((isset(\$_GET['post_id'])) AND ". 
    308           "(is_numeric(\$_GET['post_id']))) : "."\n". 
    309           "\$_ctx->posts = \$core->blog->getPosts(". 
    310           "array('no_content' => true, 'post_id' => \$_GET['post_id'],". 
    311           "'post_open_comment' => 1,". 
    312           "'post_type' => subscribeToComments::getAllowedPostTypes())". 
    313           "); "."\n". 
    314           "if (!\$_ctx->posts->isEmpty()) : ?>"."\n". 
    315           $content. 
    316           "<?php unset(\$_ctx->posts); ". 
    317           "endif;"."\n". 
    318           "endif; ?>"; 
    319      } 
    320  
    321      /** 
    322      if user is not logged in 
    323      @param    attr <b>array</b>   Attribute 
    324      @param    content   <b>string</b>  Content 
    325      @return   <b>string</b> PHP block 
    326      */ 
    327      public static function loggedIfNot($attr,$content) 
    328      { 
    329           return('<?php if (!$_ctx->subscribeToComments->checkCookie) : ?>'."\n". 
    330           $content."\n". 
    331           "<?php endif; ?>"); 
    332      } 
    333  
    334      /** 
    335      if user is logged in 
    336      @param    attr <b>array</b>   Attribute 
    337      @param    content   <b>string</b>  Content 
    338      @return   <b>string</b> PHP block 
    339      */ 
    340      public static function loggedIf($attr,$content) 
    341      { 
    342           return('<?php if ($_ctx->subscribeToComments->checkCookie) : ?>'."\n". 
    343           $content."\n". 
    344           "<?php endif; ?>"); 
    345      } 
    346  
    347      /** 
    348      if user is not blocked 
    349      @param    attr <b>array</b>   Attribute 
    350      @param    content   <b>string</b>  Content 
    351      @return   <b>string</b> PHP block 
    352      */ 
    353      public static function blockedIfNot($attr,$content) 
    354      { 
    355           return('<?php if (!$_ctx->subscribeToComments->blocked) : ?>'."\n". 
    356           $content."\n". 
    357           "<?php endif; ?>"); 
    358      } 
    359  
    360      /** 
    361      if user is blocked 
    362      @param    attr <b>array</b>   Attribute 
    363      @param    content   <b>string</b>  Content 
    364      @return   <b>string</b> PHP block 
    365      */ 
    366      public static function blockedIf($attr,$content) 
    367      { 
    368           return('<?php if ($_ctx->subscribeToComments->blocked) : ?>'."\n". 
    369           $content."\n". 
    370           "<?php endif; ?>"); 
    371      } 
    372  
    373      /** 
    374      loop on posts 
    375      @param    attr <b>array</b>   Attribute 
    376      @param    content   <b>string</b>  Content 
    377      @return   <b>string</b> PHP block 
    378      */ 
    379      public static function entries($attr,$content) 
    380      { 
    381           return("<?php ". 
    382           '$_ctx->meta = new dcMeta($core);'. 
    383           "\$_ctx->posts = \$_ctx->meta->getPostsByMeta(array(". 
    384           "'meta_type' => 'subscriber','meta_id' => ". 
    385           "subscriber::getCookie('id'),". 
    386           "'no_content' => true,". 
    387           "'post_type' => subscribeToComments::getAllowedPostTypes()));". 
    388           "if (!\$_ctx->posts->isEmpty()) :"."\n". 
    389           "while (\$_ctx->posts->fetch()) : ?>"."\n". 
    390           $content. 
    391           "<?php endwhile; "."\n". 
    392           " endif;"."\n". 
    393           'unset($_ctx->meta);'. 
    394           "unset(\$_ctx->posts); ?>"); 
    395      } 
    396  
    397      /** 
    398      get email address 
    399      @return   <b>string</b> PHP block 
    400      */ 
    401      public static function email() 
    402      { 
    403           return('<?php echo($_ctx->subscribeToComments->email); ?>');      
    404      } 
    405  
    406      /** 
    407      get the URL of the subscriptions page 
    408      @return   <b>string</b> URL 
    409      */ 
    410      public static function url() 
    411      { 
    412           return("<?php echo(subscribeToComments::url()); ?>"); 
    413      } 
    414  
    415      /** 
    416      display checkbox to subscribe to comments 
    417      */ 
    418      public static function publicCommentFormAfterContent() 
    419      { 
    420           global $_ctx; 
    421  
    422           if (subscribeToComments::getPost($_ctx->posts->post_id) == false) 
    423           {return;} 
    424  
    425           $checked = null; 
    426  
    427           # if checkbox is unchecked, don't check it 
    428           if (isset($_POST['subscribeToComments']))  
    429                {$checked = true;} 
    430           elseif (isset($_COOKIE['subscribetocomments'])) 
    431                {$checked = true;} 
    432           if ($checked) {$checked =  ' checked="checked" ';} 
    433  
    434           $logged =  
    435           (subscriber::checkCookie()) 
    436           ? 
    437                $logged = ' (<strong><a href="'.subscribeToComments::url().'">'. 
    438                     __('Logged in').'</a></strong>)' 
    439           : ''; 
    440  
    441           echo '<p>'. 
    442           '<label><input type="checkbox" name="subscribeToComments" '. 
    443           'id="subscribeToComments"'.$checked.' /> '. 
    444           __('Receive following comments by email').'</label>'. 
    445           $logged. 
    446           '</p>'; 
    447      } 
    448       
    449      /** 
    450      display a CSS rule for default themes 
    451      */ 
    452      public static function publicHeadContent() 
    453      { 
    454           echo '<style type="text/css" media="screen">'."\n". 
    455           '#comment-form #subscribeToComments '. 
    456           '{width:auto;border:0;margin:0 5px 0 140px;}'."\n". 
    457           '</style>'; 
    458      } 
    459  
    460      /** 
    461      add tpl code after the <tpl:EntryIf comments_active="1">...</tpl:EntryIf> tag 
    462      @param    core <b>core</b>    Dotclear core 
    463      @param    b    <b>array</b>   tag 
    464      @param    attr <b>array</b>   attributes 
    465      */ 
    466      public static function templateAfterBlock(&$core,$b,$attr) 
    467      { 
    468           global $_ctx; 
    469  
    470           if ($core->url->type == 'feed') {return;} 
    471  
    472           if ($b == 'EntryIf' && isset($attr['comments_active']) 
    473                && $attr['comments_active'] == 1 && !isset($attr['pings_active'])) 
    474           { 
    475                if ((!is_numeric($_ctx->posts->post_id)) OR 
    476                (subscribeToComments::getPost($_ctx->posts->post_id) == false)) 
    477                { 
    478                     return; 
    479                } 
    480                # else 
    481                return  
    482                '<?php if (($core->blog->settings->subscribetocomments_active) && 
    483                     $_ctx->posts->commentsActive()) : ?> 
    484                     <div id="subscribetocomments_block"> 
    485                          <h3><?php echo __("Subscribe to comments"); ?></h3> 
    486                          <p> 
    487                               <a href="<?php echo(subscribeToComments::url(). 
    488                               (($core->blog->settings->url_scan == "query_string") ? "&amp;" : "?"). 
    489                               "post_id=".$_ctx->posts->post_id); ?>"> 
    490                                    <!-- # If the subscriber is logged in --> 
    491                                    <?php if (subscriber::checkCookie()) : ?> 
    492                                         <?php echo __("Subscribe to receive following comments by email or manage subscriptions"); ?> 
    493                                    <?php endif; ?> 
    494                                    <!-- # If the subscriber is not logged in --> 
    495                                    <?php if (!subscriber::checkCookie()) : ?> 
    496                                         <?php echo __("Subscribe to receive following comments by email"); ?> 
    497                                    <?php endif; ?> 
    498                               </a> 
    499                          </p> 
    500                     </div> 
    501                <?php endif; ?>'; 
    502                # strings 
    503                __("Subscribe to receive following comments by email or manage subscriptions"); 
    504                __("Subscribe to receive following comments by email"); 
    505           } 
    506      } 
    507 } 
    508  
    509 if ($core->blog->settings->subscribetocomments_active) 
    510 { 
    511      # behaviors 
    512      $core->addBehavior('coreAfterCommentCreate',array('subscribeToComments', 
    513           'coreAfterCommentCreate')); 
    514  
    515      # post.html 
    516      $core->tpl->addValue('SubscribeToCommentsFormChecked', 
    517           array('subscribeToCommentsTpl','formChecked')); 
    518      $core->tpl->addValue('SubscribeToCommentsFormLink', 
    519           array('subscribeToCommentsTpl','formLink')); 
    520  
    521      # blocks 
    522      $core->tpl->addBlock('SubscribeToCommentsLoggedIf', 
    523           array('subscribeToCommentsTpl','loggedIf')); 
    524      $core->tpl->addBlock('SubscribeToCommentsLoggedIfNot', 
    525           array('subscribeToCommentsTpl','loggedIfNot')); 
    526      $core->tpl->addBlock('SubscribeToCommentsBlockedIf', 
    527           array('subscribeToCommentsTpl','blockedIf')); 
    528      $core->tpl->addBlock('SubscribeToCommentsBlockedIfNot', 
    529           array('subscribeToCommentsTpl','blockedIfNot')); 
    530  
    531      # nonce 
    532      $core->tpl->addValue('SubscribeToCommentsNonce', 
    533           array('subscribeToCommentsTpl','getNonce')); 
    534  
    535      # page 
    536      $core->tpl->addBlock('SubscribeToCommentsEntryIf', 
    537           array('subscribeToCommentsTpl','entryIf')); 
    538       
    539      # message 
    540      $core->tpl->addBlock('SubscribeToCommentsIfMessage', 
    541           array('subscribeToCommentsTpl','ifMessage')); 
    542      $core->tpl->addValue('SubscribeToCommentsMessage', 
    543           array('subscribeToCommentsTpl','message')); 
    544  
    545      # form     
    546      $core->tpl->addValue('SubscribeToCommentsURL', 
    547           array('subscribeToCommentsTpl','url')); 
    548      $core->tpl->addValue('SubscribeToCommentsEmail', 
    549           array('subscribeToCommentsTpl','email')); 
    550  
    551      # posts 
    552      $core->tpl->addBlock('SubscribeToCommentsEntries', 
    553           array('subscribeToCommentsTpl','entries')); 
    554  
    555      # add code to post.html 
    556      if ($core->blog->settings->subscribetocomments_tpl_checkbox === true) 
    557      { 
    558           $core->addBehavior('publicCommentFormAfterContent', 
    559                array('subscribeToCommentsTpl','publicCommentFormAfterContent')); 
    560      } 
    561      if ($core->blog->settings->subscribetocomments_tpl_css === true) 
    562      { 
    563           $core->addBehavior('publicHeadContent', 
    564                array('subscribeToCommentsTpl','publicHeadContent')); 
    565      } 
    566      if ($core->blog->settings->subscribetocomments_tpl_link === true) 
    567      { 
    568           $core->addBehavior('templateAfterBlock', 
    569                array('subscribeToCommentsTpl','templateAfterBlock')); 
    570      } 
    571 } 
    572  
    573219?> 
  • plugins/subscribeToComments/inc/lib.subscribeToComments.php

    r2124 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
    6 # 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
     6# 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    19 # 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
    21 # 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
     19# 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
     22# 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
  • plugins/subscribeToComments/inc/lib.subscribeToComments.tpl.php

    r2198 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
    6 # 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
     6# 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
    19 # 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
    21 # 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
     19# 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
     22# 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
    2527 
    2628if (!defined('DC_RC_PATH')) {return;} 
    27  
    28 l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public'); 
    29  
    30 $core->tpl->addBlock('SubscribeToCommentsIsActive', 
    31      'subscribeToCommentsIsActive'); 
    32  
    33 function subscribeToCommentsIsActive($attr,$content) 
    34 { 
    35      return '<?php if ($core->blog->settings->subscribetocomments_active) : ?>'. 
    36           $content. 
    37           '<?php endif; ?>'; 
    38 } 
    39  
    40 /** 
    41 @ingroup Subscribe to comments 
    42 @brief Document 
    43 */ 
    44 class subscribeToCommentsDocument extends dcUrlHandlers 
    45 { 
    46      /** 
    47      serve the document 
    48      */ 
    49      public static function page($args) 
    50      { 
    51           global $core; 
    52  
    53           if (!$core->blog->settings->subscribetocomments_active) 
    54           { 
    55                self::p404(); 
    56                return; 
    57           } 
    58            
    59           $session_id = session_id(); 
    60           if (empty($session_id)) {session_start();} 
    61            
    62           $_ctx =& $GLOBALS['_ctx']; 
    63            
    64           $_ctx->subscribeToComments = new ArrayObject(); 
    65           $_ctx->subscribeToComments->email = ''; 
    66           $_ctx->subscribeToComments->checkCookie = false; 
    67           $_ctx->subscribeToComments->blocked = false; 
    68            
    69           try { 
    70                subscribeToComments::cleanKeys(); 
    71  
    72                if (((isset($_GET['post_id']))) && (!is_numeric($_GET['post_id']))) 
    73                { 
    74                     throw new Exception(__('Invalid post ID.')); 
    75                } 
    76  
    77                if (isset($_POST['logout'])) { 
    78                     subscriber::checkNonce(); 
    79                     subscriber::logout(); 
    80                     subscribeToComments::redirect('loggedout'); 
    81                } 
    82                # login with key 
    83                elseif ((isset($_GET['email'])) AND (isset($_GET['key']))) 
    84                { 
    85                     subscribeToComments::checkEmail($_GET['email']); 
    86                     subscribeToComments::checkKey($_GET['key']); 
    87                     subscriber::loginKey($_GET['email'],$_GET['key']); 
    88                     subscribeToComments::redirect('loggedin'); 
    89                } 
    90                # subscribe 
    91                elseif ((isset($_POST['subscribe'])) AND (isset($_POST['post_id']))) 
    92                { 
    93                     subscriber::checkNonce(); 
    94                     if (isset($_POST['email'])) 
    95                     { 
    96                          subscribeToComments::checkEmail($_POST['email']); 
    97                          $email = $_POST['email']; 
    98                     } 
    99                     elseif (subscriber::checkCookie()) 
    100                     { 
    101                          $email = subscriber::getCookie('email'); 
    102                     } 
    103                     if (!empty($email)) 
    104                     { 
    105                          $subscriber = new subscriber($email); 
    106                          $subscriber->subscribe($_POST['post_id']); 
    107                          subscribeToComments::redirect('subscribed'); 
    108                     } 
    109                } 
    110                # request account informations 
    111                elseif ((isset($_POST['resend'])) AND (isset($_POST['email']))) 
    112                { 
    113                     subscriber::checkNonce(); 
    114                     subscribeToComments::checkEmail($_POST['email']); 
    115                     subscriber::resendInformations($_POST['email']); 
    116                     subscribeToComments::redirect('informationsresent'); 
    117                } 
    118                # update the email address 
    119                elseif ((isset($_GET['new_email'])) AND (isset($_GET['temp_key']))) 
    120                { 
    121                     subscribeToComments::checkEmail($_GET['new_email']); 
    122                     subscribeToComments::checkKey($_GET['temp_key']); 
    123                     subscriber::updateEmail($_GET['new_email'],$_GET['temp_key']); 
    124                     subscribeToComments::redirect('updatedemail'); 
    125                } 
    126                 
    127                # email address 
    128                $_ctx->subscribeToComments->email = ''; 
    129                if (isset($_COOKIE['comment_info'])) 
    130                { 
    131                     $email = explode("\n",$_COOKIE['comment_info']); 
    132                     $_ctx->subscribeToComments->email = $email['1']; 
    133                     unset($email); 
    134                } 
    135  
    136                # subscriber is logged in 
    137                $_ctx->subscribeToComments->checkCookie = subscriber::checkCookie(); 
    138                if ($_ctx->subscribeToComments->checkCookie) 
    139                { 
    140                     $subscriber = new subscriber(subscriber::getCookie('email')); 
    141                     $_ctx->subscribeToComments->email = $subscriber->email; 
    142       
    143                     if ((isset($_POST['requestChangeEmail'])) AND (isset($_POST['new_email']))) 
    144                     { 
    145                          subscriber::checkNonce(); 
    146                          subscribeToComments::checkEmail($_POST['new_email']); 
    147                          $subscriber->requestUpdateEmail($_POST['new_email']); 
    148                          subscribeToComments::redirect('requestsent');      
    149                     } 
    150                     elseif ((isset($_POST['remove'])) AND (isset($_POST['entries']))) 
    151                     { 
    152                          subscriber::checkNonce(); 
    153                          $subscriber->removeSubscription($_POST['entries']); 
    154                          subscribeToComments::redirect('removedsubscriptions'); 
    155                     } 
    156                     elseif (isset($_POST['deleteAccount'])) { 
    157                          subscriber::checkNonce(); 
    158                          $subscriber->deleteAccount(); 
    159                          subscribeToComments::redirect('accountdeleted'); 
    160                     } 
    161                     elseif (isset($_POST['blockEmails'])) { 
    162                          subscriber::checkNonce(); 
    163                          $subscriber->blockEmails(true); 
    164                          subscribeToComments::redirect('emailsblocked'); 
    165                     } 
    166                     elseif (isset($_POST['allowEmails'])) { 
    167                          subscriber::checkNonce(); 
    168                          $subscriber->blockEmails(false); 
    169                          subscribeToComments::redirect('emailsallowed'); 
    170                     } 
    171                } 
    172           } 
    173           catch (Exception $e) 
    174           { 
    175                $_ctx->form_error = $e->getMessage(); 
    176           } 
    177            
    178           $_ctx->subscribeToComments->blocked = subscriber::blocked(); 
    179            
    180           # message 
    181           # inspired by contactMe/_public.php 
    182           switch($args) 
    183           { 
    184                case 'informationsresent' : 
    185                     $msg = __('Account informations sent'); 
    186                     break; 
    187                case 'removedsubscriptions' : 
    188                     $msg = __('Subscriptions removed'); 
    189                     break; 
    190                case 'loggedout' : 
    191                     $msg = __('Logged out'); 
    192                     break; 
    193                case 'loggedin' : 
    194                     $msg = __('Logged in'); 
    195                     break; 
    196                case 'emailsblocked' : 
    197                     $msg = __('Emails blocked'); 
    198                     break; 
    199                case 'emailsallowed' : 
    200                     $msg = __('Emails allowed'); 
    201                     break; 
    202                case 'requestsent' : 
    203                     $msg = __('An email has been sent to the new email address'); 
    204                     break; 
    205                case 'updatedemail' : 
    206                     $msg = __('Email address changed'); 
    207                     break; 
    208                case 'accountdeleted' : 
    209                     $msg = __('Account deleted'); 
    210                     break; 
    211                case 'subscribed' : 
    212                     $msg = __('Subscribed to the entry'); 
    213                     break; 
    214                 default : 
    215                     $msg = null; 
    216                     break; 
    217           } 
    218            
    219           $_ctx->subscribeToComments->message = $msg; 
    220           # /message 
    221            
    222           $core->tpl->setPath($core->tpl->getPath(), 
    223                dirname(__FILE__).'/default-templates/'); 
    224            
    225           self::serveDocument('subscribetocomments.html','text/html',false,false); 
    226      } 
    227 } 
    22829 
    22930/** 
     
    464265     @param    attr <b>array</b>   attributes 
    465266     */ 
    466      public static function templateAfterBlock(&$core,$b,$attr) 
     267     public static function templateAfterBlock($core,$b,$attr) 
    467268     { 
    468269          global $_ctx; 
     
    507308} 
    508309 
    509 if ($core->blog->settings->subscribetocomments_active) 
    510 { 
    511      # behaviors 
    512      $core->addBehavior('coreAfterCommentCreate',array('subscribeToComments', 
    513           'coreAfterCommentCreate')); 
    514  
    515      # post.html 
    516      $core->tpl->addValue('SubscribeToCommentsFormChecked', 
    517           array('subscribeToCommentsTpl','formChecked')); 
    518      $core->tpl->addValue('SubscribeToCommentsFormLink', 
    519           array('subscribeToCommentsTpl','formLink')); 
    520  
    521      # blocks 
    522      $core->tpl->addBlock('SubscribeToCommentsLoggedIf', 
    523           array('subscribeToCommentsTpl','loggedIf')); 
    524      $core->tpl->addBlock('SubscribeToCommentsLoggedIfNot', 
    525           array('subscribeToCommentsTpl','loggedIfNot')); 
    526      $core->tpl->addBlock('SubscribeToCommentsBlockedIf', 
    527           array('subscribeToCommentsTpl','blockedIf')); 
    528      $core->tpl->addBlock('SubscribeToCommentsBlockedIfNot', 
    529           array('subscribeToCommentsTpl','blockedIfNot')); 
    530  
    531      # nonce 
    532      $core->tpl->addValue('SubscribeToCommentsNonce', 
    533           array('subscribeToCommentsTpl','getNonce')); 
    534  
    535      # page 
    536      $core->tpl->addBlock('SubscribeToCommentsEntryIf', 
    537           array('subscribeToCommentsTpl','entryIf')); 
    538       
    539      # message 
    540      $core->tpl->addBlock('SubscribeToCommentsIfMessage', 
    541           array('subscribeToCommentsTpl','ifMessage')); 
    542      $core->tpl->addValue('SubscribeToCommentsMessage', 
    543           array('subscribeToCommentsTpl','message')); 
    544  
    545      # form     
    546      $core->tpl->addValue('SubscribeToCommentsURL', 
    547           array('subscribeToCommentsTpl','url')); 
    548      $core->tpl->addValue('SubscribeToCommentsEmail', 
    549           array('subscribeToCommentsTpl','email')); 
    550  
    551      # posts 
    552      $core->tpl->addBlock('SubscribeToCommentsEntries', 
    553           array('subscribeToCommentsTpl','entries')); 
    554  
    555      # add code to post.html 
    556      if ($core->blog->settings->subscribetocomments_tpl_checkbox === true) 
    557      { 
    558           $core->addBehavior('publicCommentFormAfterContent', 
    559                array('subscribeToCommentsTpl','publicCommentFormAfterContent')); 
    560      } 
    561      if ($core->blog->settings->subscribetocomments_tpl_css === true) 
    562      { 
    563           $core->addBehavior('publicHeadContent', 
    564                array('subscribeToCommentsTpl','publicHeadContent')); 
    565      } 
    566      if ($core->blog->settings->subscribetocomments_tpl_link === true) 
    567      { 
    568           $core->addBehavior('templateAfterBlock', 
    569                array('subscribeToCommentsTpl','templateAfterBlock')); 
    570      } 
    571 } 
    572  
    573310?> 
  • plugins/subscribeToComments/index.php

    r1808 r2294  
    22# ***** BEGIN LICENSE BLOCK ***** 
    33# 
    4 # This file is part of Subscribe to comments. 
    5 # Copyright 2008,2009 Moe (http://gniark.net/) 
     4# This file is part of Subscribe to comments, a plugin for Dotclear 2 
     5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 
    66# 
    7 # Subscribe to comments is free software; you can redistribute it and/or modify 
    8 # it under the terms of the GNU General Public License as published by 
    9 # the Free Software Foundation; either version 3 of the License, or 
    10 # (at your option) any later version. 
     7# Subscribe to comments is free software; you can redistribute it and/or 
     8# modify it under the terms of the GNU General Public License v2.0 
     9# as published by the Free Software Foundation. 
    1110# 
    1211# Subscribe to comments is distributed in the hope that it will be useful, 
    1312# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1514# GNU General Public License for more details. 
    1615# 
    17 # You should have received a copy of the GNU General Public License 
    18 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     16# You should have received a copy of the GNU General Public 
     17# License along with this program. If not, see 
     18# <http://www.gnu.org/licenses/>. 
    1919# 
    20 # Icon (icon.png) is from Silk Icons : http://www.famfamfam.com/lab/icons/silk/ 
     20# Icon (icon.png) and images are from Silk Icons : 
     21# <http://www.famfamfam.com/lab/icons/silk/> 
    2122# 
    22 # Inspired by http://txfx.net/code/wordpress/subscribe-to-comments/ 
     23# Inspired by Subscribe to Comments for WordPress : 
     24# <http://txfx.net/code/wordpress/subscribe-to-comments/> 
    2325# 
    2426# ***** END LICENSE BLOCK ***** 
     
    595597          <h3><?php echo(__('Subscribers')); ?></h3> 
    596598          <?php 
    597                $rs = $core->con->select('SELECT email, user_key '. 
    598                     'FROM '.$core->prefix.'comment_subscriber '. 
    599                     'ORDER BY email ASC'); 
     599               $query = 'SELECT DISTINCT S.id, S.email, S.user_key FROM '. 
     600                    $core->prefix.'comment_subscriber S '. 
     601                    'INNER JOIN '.$core->prefix.'meta M ON '. 
     602                    (($core->con->driver() == 'pgsql') ? 
     603                    # CAST = PostgreSQL compatibility : 
     604                    # PGSQL need datas of the same type to compare 
     605                    '(S.id = CAST(M.meta_id AS integer))':  
     606                    '(S.id = M.meta_id)'). 
     607                    'INNER JOIN '.$core->prefix.'post P ON '. 
     608                    (($core->con->driver() == 'pgsql') ? 
     609                    # CAST = PostgreSQL compatibility : 
     610                    # PGSQL need datas of the same type to compare 
     611                    '(M.post_id = CAST(P.post_id AS integer))':  
     612                    '(M.post_id = P.post_id)'). 
     613                    ' AND (M.meta_type = \'subscriber\') '. 
     614                    ' AND P.blog_id = \''.$core->con->escape($core->blog->id).'\''; 
     615                
     616               $rs = $core->con->select($query); 
    600617                
    601618               if ($rs->isEmpty()) 
Note: See TracChangeset for help on using the changeset viewer.

Sites map