Dotclear

source: admin/comments_actions.php @ 782:01efbf050a8a

Revision 782:01efbf050a8a, 3.1 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

Merged last default changes with formfilter branch

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 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?'.urldecode($_POST['f_query']);
33     }
34     
35     foreach ($comments as $k => $v) {
36          $comments[$k] = (integer) $v;
37     }
38     
39     $params['sql'] = 'AND C.comment_id IN('.implode(',',$comments).') ';
40     
41     if (!isset($_POST['full_content']) || empty($_POST['full_content'])) {
42          $params['no_content'] = true;
43     }
44     
45     $co = $core->blog->getComments($params);
46     
47     # --BEHAVIOR-- adminCommentsActions
48     $core->callBehavior('adminCommentsActions',$core,$co,$action,$redir);
49     
50     if (preg_match('/^(publish|unpublish|pending|junk)$/',$action))
51     {
52          switch ($action) {
53               case 'unpublish' : $status = 0; break;
54               case 'pending' : $status = -1; break;
55               case 'junk' : $status = -2; break;
56               default : $status = 1; break;
57          }
58         
59          while ($co->fetch())
60          {
61               try {
62                    $core->blog->updCommentStatus($co->comment_id,$status);
63               } catch (Exception $e) {
64                    $core->error->add($e->getMessage());
65               }
66          }
67         
68          if (!$core->error->flag()) {
69               http::redirect($redir);
70          }
71     }
72     elseif ($action == 'delete')
73     {
74          while ($co->fetch())
75          {
76               try {
77                    # --BEHAVIOR-- adminBeforeCommentDelete
78                    $core->callBehavior('adminBeforeCommentDelete',$co->comment_id);               
79                   
80                    $core->blog->delComment($co->comment_id);
81               } catch (Exception $e) {
82                    $core->error->add($e->getMessage());
83               }
84          }
85         
86          if (!$core->error->flag()) {
87               http::redirect($redir);
88          }
89     }
90}
91
92/* DISPLAY
93-------------------------------------------------------- */
94dcPage::open(__('Comments'));
95
96if (!isset($action)) {
97     dcPage::close();
98     exit;
99}
100
101$hidden_fields = '';
102while ($co->fetch()) {
103     $hidden_fields .= form::hidden(array('comments[]'),$co->comment_id);
104} 
105
106if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false)
107{
108     $hidden_fields .= form::hidden(array('redir'),html::escapeURL($_POST['redir']));
109}
110else
111{
112     $hidden_fields .=
113     form::hidden(array('type'),$_POST['type']).
114     form::hidden(array('author'),$_POST['author']).
115     form::hidden(array('status'),$_POST['status']).
116     form::hidden(array('sortby'),$_POST['sortby']).
117     form::hidden(array('ip'),$_POST['ip']).
118     form::hidden(array('order'),$_POST['order']).
119     form::hidden(array('page'),$_POST['page']).
120     form::hidden(array('nb'),$_POST['nb']);
121}
122
123# --BEHAVIOR-- adminCommentsActionsContent
124$core->callBehavior('adminCommentsActionsContent',$core,$action,$hidden_fields);
125
126echo '<p><a class="back" href="'.str_replace('&','&amp;',$redir).'">'.__('back').'</a></p>';
127
128dcPage::close();
129?>
Note: See TracBrowser for help on using the repository browser.

Sites map