source: trunk/admin/comments.php @ 21517

Last change on this file since 21517 was 19703, checked in by plg, 12 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
RevLine 
[839]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[19703]5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[839]23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
[1072]29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30
[839]31// +-----------------------------------------------------------------------+
[1072]32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_ADMINISTRATOR);
35
36// +-----------------------------------------------------------------------+
[839]37// |                                actions                                |
38// +-----------------------------------------------------------------------+
39
[8126]40if (!empty($_POST))
[839]41{
[5381]42  if (empty($_POST['comments']))
[1598]43  {
[5381]44    array_push(
45      $page['errors'],
46      l10n('Select at least one comment')
47      );
[839]48  }
[5381]49  else
[839]50  {
[12596]51    include_once( PHPWG_ROOT_PATH .'include/functions_comment.inc.php' );
[5381]52    check_input_parameter('comments', $_POST, true, PATTERN_ID);
53   
54    if (isset($_POST['validate']))
55    {
[12596]56      validate_user_comment($_POST['comments']);
[839]57
[12596]58      array_push(
59        $page['infos'],
60        l10n_dec(
61          '%d user comment validated', '%d user comments validated',
62          count($_POST['comments'])
63          )
64        );
[5381]65    }
[839]66
[5381]67    if (isset($_POST['reject']))
68    {
[12596]69      delete_user_comment($_POST['comments']);
[839]70
[5381]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    }
[839]79  }
80}
81
82// +-----------------------------------------------------------------------+
83// |                             template init                             |
84// +-----------------------------------------------------------------------+
85
[2530]86$template->set_filenames(array('comments'=>'comments.tpl'));
[839]87
[2249]88$template->assign(
[839]89  array(
[2249]90    'F_ACTION' => get_root_url().'admin.php?page=comments'
[839]91    )
92  );
93
94// +-----------------------------------------------------------------------+
[13079]95// | Tabs                                                                  |
96// +-----------------------------------------------------------------------+
97
98include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
99
100$tabsheet = new tabsheet();
[16925]101$tabsheet->set_id('comments');
[13079]102$tabsheet->select('');
103$tabsheet->assign();
104
105// +-----------------------------------------------------------------------+
[839]106// |                           comments display                            |
107// +-----------------------------------------------------------------------+
108
109$list = array();
110
111$query = '
[3452]112SELECT c.id, c.image_id, c.date, c.author, '.
[12796]113$conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext
[839]114  FROM '.COMMENTS_TABLE.' AS c
115    INNER JOIN '.IMAGES_TABLE.' AS i
116      ON i.id = c.image_id
[3450]117    LEFT JOIN '.USERS_TABLE.' AS u
[3452]118      ON u.'.$conf['user_fields']['id'].' = c.author_id
[839]119  WHERE validated = \'false\'
[3122]120  ORDER BY c.date DESC
[839]121;';
122$result = pwg_query($query);
[4325]123while ($row = pwg_db_fetch_assoc($result))
[839]124{
[12796]125  $thumb = DerivativeImage::thumb_url(
[1598]126      array(
127        'id'=>$row['image_id'],
128        'path'=>$row['path'],
129        )
130     );
[3450]131  if (empty($row['author_id'])) 
132  {
133    $author_name = $row['author'];
134  }
135  else
136  {
[4304]137    $author_name = stripslashes($row['username']);
[3450]138  }
[2249]139  $template->append(
140    'comments',
[839]141    array(
[13077]142      'U_PICTURE' => get_root_url().'admin.php?page=photo-'.$row['image_id'],
[839]143      'ID' => $row['id'],
[1598]144      'TN_SRC' => $thumb,
[3450]145      'AUTHOR' => trigger_event('render_comment_author', $author_name),
[3122]146      'DATE' => format_date($row['date'], true),
[1598]147      'CONTENT' => trigger_event('render_comment_content',$row['content'])
[839]148      )
149    );
150
151  array_push($list, $row['id']);
152}
153
[2249]154$template->assign('LIST', implode(',', $list) );
[839]155
156// +-----------------------------------------------------------------------+
157// |                           sending html code                           |
158// +-----------------------------------------------------------------------+
159
160$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
161
[1730]162?>
Note: See TracBrowser for help on using the repository browser.