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