Dotclear

source: plugins/atReply/_admin.php @ 3033

Revision 3033, 4.3 KB checked in by Moe, 12 years ago (diff)

@ Reply 1.6.2:

  • Dotclear 2.2 settings
  • added author name on @Reply arrows (closes #657)
Line 
1<?php
2# ***** BEGIN LICENSE BLOCK *****
3#
4# This file is part of @ Reply, a plugin for Dotclear 2
5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) and buns
6#
7# @ Reply 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.
10#
11# @ Reply is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
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 @ Reply for WordPress :
24# <http://iyus.info/at-reply-petit-plugin-wordpress-inspire-par-twitter/>
25#
26# ***** END LICENSE BLOCK *****
27
28if (!defined('DC_CONTEXT_ADMIN')) {return;}
29
30l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin');
31
32$core->addBehavior('adminAfterCommentDesc',
33     array('AtReplyAdmin','adminAfterCommentDesc'));
34
35$core->addBehavior('adminBeforeCommentCreate',
36     array('AtReplyAdmin','adminBeforeCommentCreate'));
37
38$core->addBehavior('adminAfterCommentCreate',
39     array('AtReplyAdmin','adminAfterCommentCreate'));
40
41$_menu['Plugins']->addItem(__('@ Reply'),'plugin.php?p=atReply',
42     'index.php?pf=atReply/icon.png',preg_match('/plugin.php\?p=atReply(&.*)?$/',
43          $_SERVER['REQUEST_URI']),$core->auth->check('admin',$core->blog->id));     
44
45class AtReplyAdmin
46{
47     /**
48     adminAfterCommentDesc behavior
49     display information on the admin comment form
50     @param    rs   <b>recordset</b>    Recordset
51     @return   <b>string</b>  String
52     */
53     public static function adminAfterCommentDesc($rs)
54     {   
55          # ignore trackbacks
56          if ($rs->comment_trackback == 1) {return;}
57         
58          # on comment.php, tell the user what to do
59          if (strpos($_SERVER['REQUEST_URI'],'comment.php') !== false)
60          {
61               if (isset($_GET['at_reply_creaco']))
62               {
63                    return('<p class="message">'.__('@ Reply:').' '.
64                    __('Comment has been successfully created.').' '.
65                    __('Please edit and publish it.').
66                    '</p>');
67               }
68               # don't display the form on comment.php, it would break the <form>
69               return;
70          }
71         
72          global $core;
73         
74          $comment_content = '<p>'.
75               sprintf(__('@%s:'),'<a href="#c'.
76               html::escapeHTML($rs->comment_id).'">'.
77               html::escapeHTML($rs->comment_author).'</a>').' </p>';
78         
79          return(
80               # from /dotclear/admin/post.php, modified
81               '<form action="comment.php" method="post">'.
82               form::hidden(array('comment_author'),html::escapeHTML($core->auth->getInfo('user_cn'))).
83               form::hidden(array('comment_email'),html::escapeHTML($core->auth->getInfo('user_email'))).
84               form::hidden(array('comment_site'),html::escapeHTML($core->auth->getInfo('user_url'))).
85               form::hidden(array('comment_content'),html::escapeHTML($comment_content)).
86               form::hidden(array('comment_atreply_comment_status'),-1).
87               form::hidden(array('post_id'),$rs->post_id).
88               form::hidden(array('at_reply'),1).
89               form::hidden(array('at_reply_email_address'),html::escapeHTML($rs->comment_email)).
90               $core->formNonce().
91               '<p><strong>'.__('@ Reply:').'</strong> '.
92                    '<input type="submit" name="add" value="'.
93                    __('Reply to this comment').'" /></p>'.
94               '</form>'
95               # /from /dotclear/admin/post.php, modified
96          );
97     }
98     
99     /**
100     adminBeforeCommentCreate behavior
101     @param    cur  <b>cursor</b>  Cursor
102     */
103     public static function adminBeforeCommentCreate($cur)
104     {
105          if (isset($_POST['comment_atreply_comment_status']))
106          {
107               $cur->comment_status = (integer) $_POST['comment_atreply_comment_status'];
108          }
109     }
110
111     /**
112     adminAfterCommentCreate behavior
113     directly edit the comment
114     @param    cur  <b>cursor</b>  Cursor
115     @param    comment_id     <b>integer</b> Comment id
116     */
117     public static function adminAfterCommentCreate($cur,$comment_id)
118     {
119          global $core;
120
121          if (isset($_POST['at_reply']))
122          {
123               if ($core->blog->settings->atreply_subscribe_replied_comment == true)
124               {
125                    if ($core->plugins->moduleExists('subscribeToComments'))
126                    {
127                         # subscribe the email address of the replied comment
128                         $subscriber = new subscriber($_POST['at_reply_email_address']);
129                         $subscriber->subscribe($cur->post_id);
130                    }
131               }
132               
133               http::redirect('comment.php?id='.$comment_id.'&at_reply_creaco=1');
134          }
135     }
136}
137
138?>
Note: See TracBrowser for help on using the repository browser.

Sites map