Changeset 2294
- Timestamp:
- 06/05/10 14:58:29 (13 years ago)
- Location:
- plugins/subscribeToComments
- Files:
-
- 2 added
- 1 deleted
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
plugins/subscribeToComments/_admin.php
r1606 r2294 3 3 # 4 4 # This file is part of Subscribe to comments. 5 # Copyright 2008,2009Moe (http://gniark.net/)5 # Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) 6 6 # 7 7 # Subscribe to comments is free software; you can redistribute it and/or modify -
plugins/subscribeToComments/_define.php
r2198 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 4 # This file is part of Subscribe to comments .5 # Copyright 2008,2009Moe (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/) 6 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. 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/>. 19 19 # 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/> 21 22 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** … … 30 32 /* Description*/ "Subscribe to comments by email", 31 33 /* Author */ "Moe (http://gniark.net/)", 32 /* Version */ '1.3. 1',34 /* Version */ '1.3.2', 33 35 /* Permissions */ 'admin' 34 36 ); -
plugins/subscribeToComments/_install.php
r1403 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 4 # This file is part of Subscribe to comments .5 # Copyright 2008,2009Moe (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/) 6 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. 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/>. 19 19 # 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/> 21 22 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** -
plugins/subscribeToComments/_prepend.php
r1517 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 4 # This file is part of Subscribe to comments .5 # Copyright 2008Moe (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/) 6 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. 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/>. 19 19 # 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/> 21 22 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** … … 28 30 $__autoload['subscribeToComments'] = dirname(__FILE__). 29 31 '/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'; 30 36 $__autoload['subscriber'] = dirname(__FILE__). 31 37 '/inc/class.subscriber.php'; -
plugins/subscribeToComments/default-templates/subscribetocomments.html
r2198 r2294 99 99 100 100 <p class="field"> 101 <label for="email">{{tpl:lang Email address}} :</label>101 <label for="email">{{tpl:lang Email address}}:</label> 102 102 <input type="text" name="email" id="email" size="30" maxlength="255" 103 103 value="{{tpl:SubscribeToCommentsEmail}}" /> … … 170 170 <p class="field"> 171 171 <label for="new_email"> 172 {{tpl:lang New email address}} :</label>172 {{tpl:lang New email address}}:</label> 173 173 <input type="text" name="new_email" id="new_email" size="30" 174 174 maxlength="255" /> -
plugins/subscribeToComments/inc/class.subscriber.php
r2198 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** -
plugins/subscribeToComments/inc/lib.subscribeToComments.document.php
r2198 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** 25 27 26 28 if (!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 29 40 30 /** … … 221 211 222 212 $core->tpl->setPath($core->tpl->getPath(), 223 dirname(__FILE__).'/ default-templates/');213 dirname(__FILE__).'/../default-templates/'); 224 214 225 215 self::serveDocument('subscribetocomments.html','text/html',false,false); … … 227 217 } 228 218 229 /**230 @ingroup Subscribe to comments231 @brief Template232 */233 class subscribeToCommentsTpl234 {235 /**236 check the box on post.html if a cookie is present237 @return <b>string</b> PHP block238 */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 page250 @return <b>string</b> text and PHP block251 */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') ? '&' : '?').".260 "'post_id='.\$_ctx->posts->post_id); ?>");261 }262 }263 264 /**265 if there is a message266 @param attr <b>array</b> Attribute267 @param content <b>string</b> Content268 @return <b>string</b> PHP block269 */270 public static function ifMessage($attr,$content)271 {272 return273 "<?php if (\$_ctx->subscribeToComments->message !== null) : ?>"."\n".274 $content.275 "<?php endif; ?>";276 }277 278 /**279 display a message280 @return <b>string</b> PHP block281 */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 nonce291 @return <b>string</b> Nonce292 */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 post300 @param attr <b>array</b> Attribute301 @param content <b>string</b> Content302 @return <b>string</b> PHP block303 */304 public static function entryIf($attr,$content)305 {306 return307 "<?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 in323 @param attr <b>array</b> Attribute324 @param content <b>string</b> Content325 @return <b>string</b> PHP block326 */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 in336 @param attr <b>array</b> Attribute337 @param content <b>string</b> Content338 @return <b>string</b> PHP block339 */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 blocked349 @param attr <b>array</b> Attribute350 @param content <b>string</b> Content351 @return <b>string</b> PHP block352 */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 blocked362 @param attr <b>array</b> Attribute363 @param content <b>string</b> Content364 @return <b>string</b> PHP block365 */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 posts375 @param attr <b>array</b> Attribute376 @param content <b>string</b> Content377 @return <b>string</b> PHP block378 */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 address399 @return <b>string</b> PHP block400 */401 public static function email()402 {403 return('<?php echo($_ctx->subscribeToComments->email); ?>');404 }405 406 /**407 get the URL of the subscriptions page408 @return <b>string</b> URL409 */410 public static function url()411 {412 return("<?php echo(subscribeToComments::url()); ?>");413 }414 415 /**416 display checkbox to subscribe to comments417 */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 it428 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 themes451 */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> tag462 @param core <b>core</b> Dotclear core463 @param b <b>array</b> tag464 @param attr <b>array</b> attributes465 */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)) OR476 (subscribeToComments::getPost($_ctx->posts->post_id) == false))477 {478 return;479 }480 # else481 return482 '<?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") ? "&" : "?").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 # strings503 __("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 # behaviors512 $core->addBehavior('coreAfterCommentCreate',array('subscribeToComments',513 'coreAfterCommentCreate'));514 515 # post.html516 $core->tpl->addValue('SubscribeToCommentsFormChecked',517 array('subscribeToCommentsTpl','formChecked'));518 $core->tpl->addValue('SubscribeToCommentsFormLink',519 array('subscribeToCommentsTpl','formLink'));520 521 # blocks522 $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 # nonce532 $core->tpl->addValue('SubscribeToCommentsNonce',533 array('subscribeToCommentsTpl','getNonce'));534 535 # page536 $core->tpl->addBlock('SubscribeToCommentsEntryIf',537 array('subscribeToCommentsTpl','entryIf'));538 539 # message540 $core->tpl->addBlock('SubscribeToCommentsIfMessage',541 array('subscribeToCommentsTpl','ifMessage'));542 $core->tpl->addValue('SubscribeToCommentsMessage',543 array('subscribeToCommentsTpl','message'));544 545 # form546 $core->tpl->addValue('SubscribeToCommentsURL',547 array('subscribeToCommentsTpl','url'));548 $core->tpl->addValue('SubscribeToCommentsEmail',549 array('subscribeToCommentsTpl','email'));550 551 # posts552 $core->tpl->addBlock('SubscribeToCommentsEntries',553 array('subscribeToCommentsTpl','entries'));554 555 # add code to post.html556 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 573 219 ?> -
plugins/subscribeToComments/inc/lib.subscribeToComments.php
r2124 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** -
plugins/subscribeToComments/inc/lib.subscribeToComments.tpl.php
r2198 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** 25 27 26 28 if (!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 comments42 @brief Document43 */44 class subscribeToCommentsDocument extends dcUrlHandlers45 {46 /**47 serve the document48 */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 key83 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 # subscribe91 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 informations111 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 address119 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 address128 $_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 in137 $_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 # message181 # inspired by contactMe/_public.php182 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 # /message221 222 $core->tpl->setPath($core->tpl->getPath(),223 dirname(__FILE__).'/default-templates/');224 225 self::serveDocument('subscribetocomments.html','text/html',false,false);226 }227 }228 29 229 30 /** … … 464 265 @param attr <b>array</b> attributes 465 266 */ 466 public static function templateAfterBlock( &$core,$b,$attr)267 public static function templateAfterBlock($core,$b,$attr) 467 268 { 468 269 global $_ctx; … … 507 308 } 508 309 509 if ($core->blog->settings->subscribetocomments_active)510 {511 # behaviors512 $core->addBehavior('coreAfterCommentCreate',array('subscribeToComments',513 'coreAfterCommentCreate'));514 515 # post.html516 $core->tpl->addValue('SubscribeToCommentsFormChecked',517 array('subscribeToCommentsTpl','formChecked'));518 $core->tpl->addValue('SubscribeToCommentsFormLink',519 array('subscribeToCommentsTpl','formLink'));520 521 # blocks522 $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 # nonce532 $core->tpl->addValue('SubscribeToCommentsNonce',533 array('subscribeToCommentsTpl','getNonce'));534 535 # page536 $core->tpl->addBlock('SubscribeToCommentsEntryIf',537 array('subscribeToCommentsTpl','entryIf'));538 539 # message540 $core->tpl->addBlock('SubscribeToCommentsIfMessage',541 array('subscribeToCommentsTpl','ifMessage'));542 $core->tpl->addValue('SubscribeToCommentsMessage',543 array('subscribeToCommentsTpl','message'));544 545 # form546 $core->tpl->addValue('SubscribeToCommentsURL',547 array('subscribeToCommentsTpl','url'));548 $core->tpl->addValue('SubscribeToCommentsEmail',549 array('subscribeToCommentsTpl','email'));550 551 # posts552 $core->tpl->addBlock('SubscribeToCommentsEntries',553 array('subscribeToCommentsTpl','entries'));554 555 # add code to post.html556 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 573 310 ?> -
plugins/subscribeToComments/index.php
r1808 r2294 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 4 # This file is part of Subscribe to comments .5 # Copyright 2008,2009Moe (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/) 6 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. 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. 11 10 # 12 11 # Subscribe to comments is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 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/>. 19 19 # 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/> 21 22 # 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/> 23 25 # 24 26 # ***** END LICENSE BLOCK ***** … … 595 597 <h3><?php echo(__('Subscribers')); ?></h3> 596 598 <?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); 600 617 601 618 if ($rs->isEmpty())
Note: See TracChangeset
for help on using the changeset viewer.