source: trunk/admin/comments.php @ 11803

Last change on this file since 11803 was 8728, checked in by plg, 14 years ago

Happy new year 2011

Change "Piwigo - a PHP based picture gallery" into "Piwigo - a PHP based photo gallery"

  • Property svn:eol-style set to LF
File size: 5.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_ADMINISTRATOR);
35
36// +-----------------------------------------------------------------------+
37// |                                actions                                |
38// +-----------------------------------------------------------------------+
39
40if (!empty($_POST))
41{
42  if (empty($_POST['comments']))
43  {
44    array_push(
45      $page['errors'],
46      l10n('Select at least one comment')
47      );
48  }
49  else
50  {
51    check_input_parameter('comments', $_POST, true, PATTERN_ID);
52   
53    if (isset($_POST['validate']))
54    {
55      $query = '
56UPDATE '.COMMENTS_TABLE.'
57  SET validated = \'true\'
58    , validation_date = NOW()
59  WHERE id IN ('.implode(',', $_POST['comments']).')
60;';
61    pwg_query($query);
62
63    array_push(
64      $page['infos'],
65      l10n_dec(
66        '%d user comment validated', '%d user comments validated',
67        count($_POST['comments'])
68        )
69      );
70    }
71
72    if (isset($_POST['reject']))
73    {
74      $query = '
75DELETE
76  FROM '.COMMENTS_TABLE.'
77  WHERE id IN ('.implode(',', $_POST['comments']).')
78;';
79      pwg_query($query);
80
81      array_push(
82        $page['infos'],
83        l10n_dec(
84          '%d user comment rejected', '%d user comments rejected',
85          count($_POST['comments'])
86          )
87        );
88    }
89  }
90}
91
92// +-----------------------------------------------------------------------+
93// |                             template init                             |
94// +-----------------------------------------------------------------------+
95
96$template->set_filenames(array('comments'=>'comments.tpl'));
97
98$template->assign(
99  array(
100    'F_ACTION' => get_root_url().'admin.php?page=comments'
101    )
102  );
103
104// +-----------------------------------------------------------------------+
105// |                           comments display                            |
106// +-----------------------------------------------------------------------+
107
108$list = array();
109
110$query = '
111SELECT c.id, c.image_id, c.date, c.author, '.
112$conf['user_fields']['username'].' AS username, c.content, i.path, i.tn_ext
113  FROM '.COMMENTS_TABLE.' AS c
114    INNER JOIN '.IMAGES_TABLE.' AS i
115      ON i.id = c.image_id
116    LEFT JOIN '.USERS_TABLE.' AS u
117      ON u.'.$conf['user_fields']['id'].' = c.author_id
118  WHERE validated = \'false\'
119  ORDER BY c.date DESC
120;';
121$result = pwg_query($query);
122while ($row = pwg_db_fetch_assoc($result))
123{
124  $thumb = get_thumbnail_url(
125      array(
126        'id'=>$row['image_id'],
127        'path'=>$row['path'],
128        'tn_ext'=>@$row['tn_ext']
129        )
130     );
131  if (empty($row['author_id'])) 
132  {
133    $author_name = $row['author'];
134  }
135  else
136  {
137    $author_name = stripslashes($row['username']);
138  }
139  $template->append(
140    'comments',
141    array(
142      'U_PICTURE' =>
143          PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
144          '&amp;image_id='.$row['image_id'],
145      'ID' => $row['id'],
146      'TN_SRC' => $thumb,
147      'AUTHOR' => trigger_event('render_comment_author', $author_name),
148      'DATE' => format_date($row['date'], true),
149      'CONTENT' => trigger_event('render_comment_content',$row['content'])
150      )
151    );
152
153  array_push($list, $row['id']);
154}
155
156$template->assign('LIST', implode(',', $list) );
157
158// +-----------------------------------------------------------------------+
159// |                           sending html code                           |
160// +-----------------------------------------------------------------------+
161
162$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
163
164?>
Note: See TracBrowser for help on using the repository browser.