source: extensions/community/admin_pendings.php @ 19675

Last change on this file since 19675 was 16637, checked in by plg, 12 years ago

Compatibility with Piwigo 2.4

Better "zoom" feature on gallery side and admin side

Bug fixed: the "Upload Photos" link in menubar is hidden when Advanced Menu Manager is activated.

File size: 7.7 KB
RevLine 
[9372]1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 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');
30include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
31load_language('plugin.lang', COMMUNITY_PATH);
32
33$admin_base_url = get_root_url().'admin.php?page=plugin-community-pendings';
34
35// +-----------------------------------------------------------------------+
36// | Check Access and exit when user status is not ok                      |
37// +-----------------------------------------------------------------------+
38
39check_status(ACCESS_ADMINISTRATOR);
40
41// +-----------------------------------------------------------------------+
42// |                                actions                                |
43// +-----------------------------------------------------------------------+
44
45if (!empty($_POST))
46{
47  if (empty($_POST['photos']))
48  {
49    array_push(
50      $page['errors'],
51      l10n('Select at least one photo')
52      );
53  }
54  else
55  {
56    check_input_parameter('photos', $_POST, true, PATTERN_ID);
57    check_input_parameter('level', $_POST, false, PATTERN_ID);
58   
59    if (isset($_POST['validate']))
60    {
61      $query = '
62UPDATE '.COMMUNITY_PENDINGS_TABLE.'
63  SET state = \'validated\',
64      validated_by = '.$user['id'].'
65  WHERE image_id IN ('.implode(',', $_POST['photos']).')
66;';
67      pwg_query($query);
68
69      $query = '
70UPDATE '.IMAGES_TABLE.'
71  SET level = '.$_POST['level'].',
72      date_available = NOW()
73  WHERE id IN ('.implode(',', $_POST['photos']).')
74;';
75      pwg_query($query);
76
77      array_push(
78        $page['infos'],
79        sprintf(
80          l10n('%d photos validated'),
81          count($_POST['photos'])
82          )
83        );
84    }
85
86    if (isset($_POST['reject']))
87    {
88      $query = '
89DELETE
90  FROM '.COMMUNITY_PENDINGS_TABLE.'
91  WHERE image_id IN ('.implode(',', $_POST['photos']).')
92;';
93      pwg_query($query);
94
95      delete_elements($_POST['photos'], true);
96
97      array_push(
98        $page['infos'],
99        sprintf(
100          l10n('%d photos rejected'),
101          count($_POST['photos'])
102          )
103        );
104    }
105
106    invalidate_user_cache();
107  }
108}
109
110// +-----------------------------------------------------------------------+
111// | template init                                                         |
112// +-----------------------------------------------------------------------+
113
114$template->set_filenames(
115  array(
116    'plugin_admin_content' => dirname(__FILE__).'/admin_pendings.tpl'
117    )
118  );
119
120// +-----------------------------------------------------------------------+
121// | pending photos list                                                   |
122// +-----------------------------------------------------------------------+
123
124$list = array();
125
126$query = '
127SELECT
128    image_id,
129    added_on,
130
131    i.id,
132    path,
133    date_creation,
134    name,
135    comment,
136    added_by,
137    file,
138    name,
139    filesize,
140    width,
141    height,
[16637]142    rotation,
[9372]143
144    '.$conf['user_fields']['username'].' AS username
145
146  FROM '.COMMUNITY_PENDINGS_TABLE.' AS cp
147    INNER JOIN '.IMAGES_TABLE.' AS i ON i.id = cp.image_id
148    LEFT JOIN '.USERS_TABLE.' AS u ON u.'.$conf['user_fields']['id'].' = i.added_by
149
150  WHERE state = \'moderation_pending\'
151
152  ORDER BY image_id DESC
153;';
154$result = pwg_query($query);
155$rows = array();
156$image_ids = array();
157while ($row = pwg_db_fetch_assoc($result))
158{
159  array_push($rows, $row);
160  array_push($image_ids, $row['id']);
161}
162
163$category_for_image = array();
164
165if (count($image_ids) > 0)
166{
167  $query = '
168SELECT
169    id,
170    image_id,
171    uppercats
172  FROM '.IMAGE_CATEGORY_TABLE.'
173    JOIN '.CATEGORIES_TABLE.' ON id = category_id
174  WHERE image_id IN ('.implode(',', $image_ids).')
175;';
176  $result = pwg_query($query);
177
178  while ($row = pwg_db_fetch_assoc($result))
179  {
180    $category_for_image[ $row['image_id'] ] = get_cat_display_name_cache(
181      $row['uppercats'],
182      'admin.php?page=cat_modify&amp;cat_id=',
183      false,
184      true,
185      'externalLink'
186      );
187  }
188}
189
190foreach ($rows as $row)
191{
[16637]192  $src_image = new SrcImage($row);
193  $thumb_url = DerivativeImage::url(IMG_THUMB, $src_image);
194  $medium_url = DerivativeImage::url(IMG_MEDIUM, $src_image);
195 
[9372]196  // file properties
197  $dimensions = null;
198  $websize_props = $row['width'].'x'.$row['height'].' '.l10n('pixels').', '.sprintf(l10n('%d Kb'), $row['filesize']);
199  if (!empty($row['has_high']) and get_boolean($row['has_high']))
200  {
201    $high_path = get_high_path($row);
202    list($high_width, $high_height) = getimagesize($high_path);
203    $high_props = $high_width.'x'.$high_height.' '.l10n('pixels').', '.sprintf(l10n('%d Kb'), $row['high_filesize']);
204   
205    $dimensions = $high_props.' ('.l10n('web size').' '.$websize_props.')';
206  }
207  else
208  {
209    $dimensions = $websize_props;
210  }
[9453]211
212  $album = null;
213  if (isset($category_for_image[ $row['id'] ]))
214  {
215    $album = $category_for_image[ $row['id'] ];
216  }
217  else
218  {
219    $album = '<em>'.l10n('No album, this photo is orphan').'</em>';
220  }
[9372]221 
222  $template->append(
223    'photos',
224    array(
225      'U_EDIT' => get_root_url().'admin.php?page=picture_modify&amp;image_id='.$row['image_id'],
226      'ID' => $row['image_id'],
[16637]227      'TN_SRC' => $thumb_url,
228      'MEDIUM_SRC' => $medium_url,
[9372]229      'ADDED_BY' => $row['username'],
230      'ADDED_ON' => format_date($row['added_on'], true),
[16637]231      'NAME' => $row['name'],
[9372]232      'DIMENSIONS' => $dimensions,
233      'FILE' => $row['file'],
234      'DATE_CREATION' => format_date($row['date_creation']),
[9453]235      'ALBUM' => $album,
[9372]236      )
237    );
238}
239
240// +-----------------------------------------------------------------------+
241// | form options                                                          |
242// +-----------------------------------------------------------------------+
243
244// image level options
245$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
246$template->assign(
247    array(
248      'level_options'=> get_privacy_level_options(),
249      'level_options_selected' => array($selected_level)
250    )
251  );
252
253
254// +-----------------------------------------------------------------------+
255// | sending html code                                                     |
256// +-----------------------------------------------------------------------+
257
258$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
259?>
Note: See TracBrowser for help on using the repository browser.