Dotclear

source: admin/comments_actions.php @ 0:54703be25dd6

Revision 0:54703be25dd6, 3.3 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

2.3 branch (trunk) first checkin

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17$params = array();
18$redir = 'comments.php';
19
20if (!empty($_POST['action']) && !empty($_POST['comments']))
21{
22     $comments = $_POST['comments'];
23     $action = $_POST['action'];
24     
25     if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false)
26     {
27          $redir = $_POST['redir'];
28     }
29     else
30     {
31          $redir =
32          'comments.php?type='.$_POST['type'].
33          '&author='.$_POST['author'].
34          '&status='.$_POST['status'].
35          '&sortby='.$_POST['sortby'].
36          '&ip='.$_POST['ip'].
37          '&order='.$_POST['order'].
38          '&page='.$_POST['page'].
39          '&nb='.(integer) $_POST['nb'];
40     }
41     
42     foreach ($comments as $k => $v) {
43          $comments[$k] = (integer) $v;
44     }
45     
46     $params['sql'] = 'AND C.comment_id IN('.implode(',',$comments).') ';
47     
48     if (!isset($_POST['full_content']) || empty($_POST['full_content'])) {
49          $params['no_content'] = true;
50     }
51     
52     $co = $core->blog->getComments($params);
53     
54     # --BEHAVIOR-- adminCommentsActions
55     $core->callBehavior('adminCommentsActions',$core,$co,$action,$redir);
56     
57     if (preg_match('/^(publish|unpublish|pending|junk)$/',$action))
58     {
59          switch ($action) {
60               case 'unpublish' : $status = 0; break;
61               case 'pending' : $status = -1; break;
62               case 'junk' : $status = -2; break;
63               default : $status = 1; break;
64          }
65         
66          while ($co->fetch())
67          {
68               try {
69                    $core->blog->updCommentStatus($co->comment_id,$status);
70               } catch (Exception $e) {
71                    $core->error->add($e->getMessage());
72               }
73          }
74         
75          if (!$core->error->flag()) {
76               http::redirect($redir);
77          }
78     }
79     elseif ($action == 'delete')
80     {
81          while ($co->fetch())
82          {
83               try {
84                    # --BEHAVIOR-- adminBeforeCommentDelete
85                    $core->callBehavior('adminBeforeCommentDelete',$co->comment_id);               
86                   
87                    $core->blog->delComment($co->comment_id);
88               } catch (Exception $e) {
89                    $core->error->add($e->getMessage());
90               }
91          }
92         
93          if (!$core->error->flag()) {
94               http::redirect($redir);
95          }
96     }
97}
98
99/* DISPLAY
100-------------------------------------------------------- */
101dcPage::open(__('Comments'));
102
103if (!isset($action)) {
104     dcPage::close();
105     exit;
106}
107
108$hidden_fields = '';
109while ($co->fetch()) {
110     $hidden_fields .= form::hidden(array('comments[]'),$co->comment_id);
111} 
112
113if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false)
114{
115     $hidden_fields .= form::hidden(array('redir'),html::escapeURL($_POST['redir']));
116}
117else
118{
119     $hidden_fields .=
120     form::hidden(array('type'),$_POST['type']).
121     form::hidden(array('author'),$_POST['author']).
122     form::hidden(array('status'),$_POST['status']).
123     form::hidden(array('sortby'),$_POST['sortby']).
124     form::hidden(array('ip'),$_POST['ip']).
125     form::hidden(array('order'),$_POST['order']).
126     form::hidden(array('page'),$_POST['page']).
127     form::hidden(array('nb'),$_POST['nb']);
128}
129
130# --BEHAVIOR-- adminCommentsActionsContent
131$core->callBehavior('adminCommentsActionsContent',$core,$action,$hidden_fields);
132
133echo '<p><a class="back" href="'.str_replace('&','&amp;',$redir).'">'.__('back').'</a></p>';
134
135dcPage::close();
136?>
Note: See TracBrowser for help on using the repository browser.

Sites map