[839] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 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 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
[1072] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 30 | |
---|
[839] | 31 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 32 | // | Check Access and exit when user status is not ok | |
---|
| 33 | // +-----------------------------------------------------------------------+ |
---|
| 34 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 35 | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
[839] | 37 | // | actions | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | |
---|
[8126] | 40 | if (!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 | { |
---|
[12597] | 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 | { |
---|
[12597] | 56 | validate_user_comment($_POST['comments']); |
---|
[839] | 57 | |
---|
[12597] | 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 | { |
---|
[12597] | 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 | // +-----------------------------------------------------------------------+ |
---|
| 95 | // | comments display | |
---|
| 96 | // +-----------------------------------------------------------------------+ |
---|
| 97 | |
---|
| 98 | $list = array(); |
---|
| 99 | |
---|
| 100 | $query = ' |
---|
[3452] | 101 | SELECT c.id, c.image_id, c.date, c.author, '. |
---|
| 102 | $conf['user_fields']['username'].' AS username, c.content, i.path, i.tn_ext |
---|
[839] | 103 | FROM '.COMMENTS_TABLE.' AS c |
---|
| 104 | INNER JOIN '.IMAGES_TABLE.' AS i |
---|
| 105 | ON i.id = c.image_id |
---|
[3450] | 106 | LEFT JOIN '.USERS_TABLE.' AS u |
---|
[3452] | 107 | ON u.'.$conf['user_fields']['id'].' = c.author_id |
---|
[839] | 108 | WHERE validated = \'false\' |
---|
[3122] | 109 | ORDER BY c.date DESC |
---|
[839] | 110 | ;'; |
---|
| 111 | $result = pwg_query($query); |
---|
[4325] | 112 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[839] | 113 | { |
---|
[1598] | 114 | $thumb = get_thumbnail_url( |
---|
| 115 | array( |
---|
| 116 | 'id'=>$row['image_id'], |
---|
| 117 | 'path'=>$row['path'], |
---|
| 118 | 'tn_ext'=>@$row['tn_ext'] |
---|
| 119 | ) |
---|
| 120 | ); |
---|
[3450] | 121 | if (empty($row['author_id'])) |
---|
| 122 | { |
---|
| 123 | $author_name = $row['author']; |
---|
| 124 | } |
---|
| 125 | else |
---|
| 126 | { |
---|
[4304] | 127 | $author_name = stripslashes($row['username']); |
---|
[3450] | 128 | } |
---|
[2249] | 129 | $template->append( |
---|
| 130 | 'comments', |
---|
[839] | 131 | array( |
---|
| 132 | 'U_PICTURE' => |
---|
| 133 | PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. |
---|
[1004] | 134 | '&image_id='.$row['image_id'], |
---|
[839] | 135 | 'ID' => $row['id'], |
---|
[1598] | 136 | 'TN_SRC' => $thumb, |
---|
[3450] | 137 | 'AUTHOR' => trigger_event('render_comment_author', $author_name), |
---|
[3122] | 138 | 'DATE' => format_date($row['date'], true), |
---|
[1598] | 139 | 'CONTENT' => trigger_event('render_comment_content',$row['content']) |
---|
[839] | 140 | ) |
---|
| 141 | ); |
---|
| 142 | |
---|
| 143 | array_push($list, $row['id']); |
---|
| 144 | } |
---|
| 145 | |
---|
[2249] | 146 | $template->assign('LIST', implode(',', $list) ); |
---|
[839] | 147 | |
---|
| 148 | // +-----------------------------------------------------------------------+ |
---|
| 149 | // | sending html code | |
---|
| 150 | // +-----------------------------------------------------------------------+ |
---|
| 151 | |
---|
| 152 | $template->assign_var_from_handle('ADMIN_CONTENT', 'comments'); |
---|
| 153 | |
---|
[1730] | 154 | ?> |
---|