source: trunk/admin/comments.php @ 19703

Last change on this file since 19703 was 19703, checked in by plg, 11 years ago

update Piwigo headers to 2013 (the end of the world didn't occur as expected on r12922)

  • Property svn:eol-style set to LF
File size: 5.6 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2013 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// | Tabs                                                                  |
96// +-----------------------------------------------------------------------+
97
98include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
99
100$tabsheet = new tabsheet();
101$tabsheet->set_id('comments');
102$tabsheet->select('');
103$tabsheet->assign();
104
105// +-----------------------------------------------------------------------+
106// |                           comments display                            |
107// +-----------------------------------------------------------------------+
108
109$list = array();
110
111$query = '
112SELECT c.id, c.image_id, c.date, c.author, '.
113$conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext
114  FROM '.COMMENTS_TABLE.' AS c
115    INNER JOIN '.IMAGES_TABLE.' AS i
116      ON i.id = c.image_id
117    LEFT JOIN '.USERS_TABLE.' AS u
118      ON u.'.$conf['user_fields']['id'].' = c.author_id
119  WHERE validated = \'false\'
120  ORDER BY c.date DESC
121;';
122$result = pwg_query($query);
123while ($row = pwg_db_fetch_assoc($result))
124{
125  $thumb = DerivativeImage::thumb_url(
126      array(
127        'id'=>$row['image_id'],
128        'path'=>$row['path'],
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' => get_root_url().'admin.php?page=photo-'.$row['image_id'],
143      'ID' => $row['id'],
144      'TN_SRC' => $thumb,
145      'AUTHOR' => trigger_event('render_comment_author', $author_name),
146      'DATE' => format_date($row['date'], true),
147      'CONTENT' => trigger_event('render_comment_content',$row['content'])
148      )
149    );
150
151  array_push($list, $row['id']);
152}
153
154$template->assign('LIST', implode(',', $list) );
155
156// +-----------------------------------------------------------------------+
157// |                           sending html code                           |
158// +-----------------------------------------------------------------------+
159
160$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
161
162?>
Note: See TracBrowser for help on using the repository browser.