source: trunk/admin/comments.php @ 13077

Revision 13077, 5.2 KB checked in by plg, 8 years ago (diff)

feature 2564: redesign on photo administration screen.

  • one screen with several tabs (for now: properties + coi)
  • double select boxes for album associations and representation have been converted to simple multiple select boxes with jQuery Chosen
  • more details about the photo in an introduction text
  • Property svn:eol-style set to LF
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' => get_root_url().'admin.php?page=photo-'.$row['image_id'],
133      'ID' => $row['id'],
134      'TN_SRC' => $thumb,
135      'AUTHOR' => trigger_event('render_comment_author', $author_name),
136      'DATE' => format_date($row['date'], true),
137      'CONTENT' => trigger_event('render_comment_content',$row['content'])
138      )
139    );
140
141  array_push($list, $row['id']);
142}
143
144$template->assign('LIST', implode(',', $list) );
145
146// +-----------------------------------------------------------------------+
147// |                           sending html code                           |
148// +-----------------------------------------------------------------------+
149
150$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
151
152?>
Note: See TracBrowser for help on using the repository browser.