source: trunk/admin/comments.php @ 2297

Last change on this file since 2297 was 2297, checked in by plg, 16 years ago

Modification: new header on PHP files, PhpWebGallery renamed Piwigo.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23// +-----------------------------------------------------------------------+
24// | PhpWebGallery - a PHP based picture gallery                           |
25// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
26// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
27// +-----------------------------------------------------------------------+
28// | file          : $Id: comments.php 2297 2008-04-04 22:57:23Z plg $
29// | last update   : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $
30// | last modifier : $Author: plg $
31// | revision      : $Revision: 2297 $
32// +-----------------------------------------------------------------------+
33// | This program is free software; you can redistribute it and/or modify  |
34// | it under the terms of the GNU General Public License as published by  |
35// | the Free Software Foundation                                          |
36// |                                                                       |
37// | This program is distributed in the hope that it will be useful, but   |
38// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
39// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
40// | General Public License for more details.                              |
41// |                                                                       |
42// | You should have received a copy of the GNU General Public License     |
43// | along with this program; if not, write to the Free Software           |
44// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
45// | USA.                                                                  |
46// +-----------------------------------------------------------------------+
47
48if (!defined('PHPWG_ROOT_PATH'))
49{
50  die ("Hacking attempt!");
51}
52
53include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
54include_once(PHPWG_ROOT_PATH.'admin/include/functions_waiting.inc.php');
55
56// +-----------------------------------------------------------------------+
57// | Check Access and exit when user status is not ok                      |
58// +-----------------------------------------------------------------------+
59check_status(ACCESS_ADMINISTRATOR);
60
61// +-----------------------------------------------------------------------+
62// |                                actions                                |
63// +-----------------------------------------------------------------------+
64
65if (isset($_POST))
66{
67  $to_validate = array();
68  $to_reject = array();
69
70  if (isset($_POST['submit']) and !is_adviser())
71  {
72    foreach (explode(',', $_POST['list']) as $comment_id)
73    {
74      if (isset($_POST['action-'.$comment_id]))
75      {
76        switch ($_POST['action-'.$comment_id])
77        {
78          case 'reject' :
79          {
80            array_push($to_reject, $comment_id);
81            break;
82          }
83          case 'validate' :
84          {
85            array_push($to_validate, $comment_id);
86            break;
87          }
88        }
89      }
90    }
91  }
92  else if (isset($_POST['validate-all']) and !empty($_POST['list']) and !is_adviser())
93  {
94    $to_validate = explode(',', $_POST['list']);
95  }
96  else if (isset($_POST['reject-all']) and !empty($_POST['list']) and !is_adviser())
97  {
98    $to_reject = explode(',', $_POST['list']);
99  }
100
101  if (count($to_validate) > 0)
102  {
103    $query = '
104UPDATE '.COMMENTS_TABLE.'
105  SET validated = \'true\'
106    , validation_date = NOW()
107  WHERE id IN ('.implode(',', $to_validate).')
108;';
109    pwg_query($query);
110
111    array_push(
112      $page['infos'],
113      l10n_dec(
114        '%d user comment validated', '%d user comments validated',
115        count($to_validate)
116        )
117      );
118  }
119
120  if (count($to_reject) > 0)
121  {
122    $query = '
123DELETE
124  FROM '.COMMENTS_TABLE.'
125  WHERE id IN ('.implode(',', $to_reject).')
126;';
127    pwg_query($query);
128
129    array_push(
130      $page['infos'],
131      l10n_dec(
132        '%d user comment rejected', '%d user comments rejected',
133        count($to_reject)
134        )
135      );
136  }
137}
138
139// +-----------------------------------------------------------------------+
140// |                             template init                             |
141// +-----------------------------------------------------------------------+
142
143$template->set_filenames(array('comments'=>'admin/comments.tpl'));
144
145// TabSheet initialization
146waiting_tabsheet();
147
148$template->assign(
149  array(
150    'F_ACTION' => get_root_url().'admin.php?page=comments'
151    )
152  );
153
154// +-----------------------------------------------------------------------+
155// |                           comments display                            |
156// +-----------------------------------------------------------------------+
157
158$list = array();
159
160$query = '
161SELECT c.id, c.image_id, c.date, c.author, c.content, i.path, i.tn_ext
162  FROM '.COMMENTS_TABLE.' AS c
163    INNER JOIN '.IMAGES_TABLE.' AS i
164      ON i.id = c.image_id
165  WHERE validated = \'false\'
166  ORDER BY c.date DESC 
167;';
168$result = pwg_query($query);
169while ($row = mysql_fetch_assoc($result))
170{
171  $thumb = get_thumbnail_url(
172      array(
173        'id'=>$row['image_id'],
174        'path'=>$row['path'],
175        'tn_ext'=>@$row['tn_ext']
176        )
177     );
178  $template->append(
179    'comments',
180    array(
181      'U_PICTURE' =>
182          PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
183          '&amp;image_id='.$row['image_id'],
184      'ID' => $row['id'],
185      'TN_SRC' => $thumb,
186      'AUTHOR' => trigger_event('render_comment_author', $row['author']),
187      'DATE' => format_date($row['date'],'mysql_datetime',true),
188      'CONTENT' => trigger_event('render_comment_content',$row['content'])
189      )
190    );
191
192  array_push($list, $row['id']);
193}
194
195$template->assign('LIST', implode(',', $list) );
196
197// +-----------------------------------------------------------------------+
198// |                           sending html code                           |
199// +-----------------------------------------------------------------------+
200
201$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
202
203?>
Note: See TracBrowser for help on using the repository browser.