source: trunk/admin/comments.php @ 13018

Last change on this file since 13018 was 12922, checked in by mistic100, 12 years ago

update Piwigo headers to 2012, last change before the expected (or not) apocalypse

  • Property svn:eol-style set to LF
File size: 5.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 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    include_once( PHPWG_ROOT_PATH .'include/functions_comment.inc.php' );
52    check_input_parameter('comments', $_POST, true, PATTERN_ID);
53   
54    if (isset($_POST['validate']))
55    {
56      validate_user_comment($_POST['comments']);
57
58      array_push(
59        $page['infos'],
60        l10n_dec(
61          '%d user comment validated', '%d user comments validated',
62          count($_POST['comments'])
63          )
64        );
65    }
66
67    if (isset($_POST['reject']))
68    {
69      delete_user_comment($_POST['comments']);
70
71      array_push(
72        $page['infos'],
73        l10n_dec(
74          '%d user comment rejected', '%d user comments rejected',
75          count($_POST['comments'])
76          )
77        );
78    }
79  }
80}
81
82// +-----------------------------------------------------------------------+
83// |                             template init                             |
84// +-----------------------------------------------------------------------+
85
86$template->set_filenames(array('comments'=>'comments.tpl'));
87
88$template->assign(
89  array(
90    'F_ACTION' => get_root_url().'admin.php?page=comments'
91    )
92  );
93
94// +-----------------------------------------------------------------------+
95// |                           comments display                            |
96// +-----------------------------------------------------------------------+
97
98$list = array();
99
100$query = '
101SELECT c.id, c.image_id, c.date, c.author, '.
102$conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext
103  FROM '.COMMENTS_TABLE.' AS c
104    INNER JOIN '.IMAGES_TABLE.' AS i
105      ON i.id = c.image_id
106    LEFT JOIN '.USERS_TABLE.' AS u
107      ON u.'.$conf['user_fields']['id'].' = c.author_id
108  WHERE validated = \'false\'
109  ORDER BY c.date DESC
110;';
111$result = pwg_query($query);
112while ($row = pwg_db_fetch_assoc($result))
113{
114  $thumb = DerivativeImage::thumb_url(
115      array(
116        'id'=>$row['image_id'],
117        'path'=>$row['path'],
118        'tn_ext'=>@$row['tn_ext']
119        )
120     );
121  if (empty($row['author_id'])) 
122  {
123    $author_name = $row['author'];
124  }
125  else
126  {
127    $author_name = stripslashes($row['username']);
128  }
129  $template->append(
130    'comments',
131    array(
132      'U_PICTURE' =>
133          PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
134          '&amp;image_id='.$row['image_id'],
135      'ID' => $row['id'],
136      'TN_SRC' => $thumb,
137      'AUTHOR' => trigger_event('render_comment_author', $author_name),
138      'DATE' => format_date($row['date'], true),
139      'CONTENT' => trigger_event('render_comment_content',$row['content'])
140      )
141    );
142
143  array_push($list, $row['id']);
144}
145
146$template->assign('LIST', implode(',', $list) );
147
148// +-----------------------------------------------------------------------+
149// |                           sending html code                           |
150// +-----------------------------------------------------------------------+
151
152$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
153
154?>
Note: See TracBrowser for help on using the repository browser.