source: trunk/admin/waiting.php @ 1738

Last change on this file since 1738 was 1609, checked in by rvelices, 18 years ago

completely replaced get_thumbnail_src it get_thumbnail_url
or get_thumbnail_path

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-11-15 04:25:12 +0000 (Wed, 15 Nov 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1609 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27if( !defined("PHPWG_ROOT_PATH") )
28{
29  die ("Hacking attempt!");
30}
31
32include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
33
34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37check_status(ACCESS_ADMINISTRATOR);
38
39//--------------------------------------------------------------------- updates
40
41if (isset($_POST))
42{
43  $to_validate = array();
44  $to_reject = array();
45
46  if (isset($_POST['submit']))
47  {
48    foreach (explode(',', $_POST['list']) as $waiting_id)
49    {
50      if (isset($_POST['action-'.$waiting_id]))
51      {
52        switch ($_POST['action-'.$waiting_id])
53        {
54          case 'reject' :
55          {
56            array_push($to_reject, $waiting_id);
57            break;
58          }
59          case 'validate' :
60          {
61            array_push($to_validate, $waiting_id);
62            break;
63          }
64        }
65      }
66    }
67  }
68  elseif (isset($_POST['validate-all']) and !empty($_POST['list']))
69  {
70    $to_validate = explode(',', $_POST['list']);
71  }
72  elseif (isset($_POST['reject-all']) and !empty($_POST['list']))
73  {
74    $to_reject = explode(',', $_POST['list']);
75  }
76
77  if (count($to_validate) > 0)
78  {
79    $query = '
80UPDATE '.WAITING_TABLE.'
81  SET validated = \'true\'
82  WHERE id IN ('.implode(',', $to_validate).')
83;';
84    pwg_query($query);
85
86    array_push(
87      $page['infos'],
88      sprintf(
89        l10n('%d waiting pictures validated'),
90        count($to_validate)
91        )
92      );
93  }
94
95  if (count($to_reject) > 0)
96  {
97    // The uploaded element was refused, we have to delete its reference in
98    // the database and to delete the element as well.
99    $query = '
100SELECT id, storage_category_id, file, tn_ext
101  FROM '.WAITING_TABLE.'
102  WHERE id IN ('.implode(',', $to_reject).')
103;';
104    $result = pwg_query($query);
105    while($row = mysql_fetch_array($result))
106    {
107      $dir = get_complete_dir($row['storage_category_id']);
108      unlink($dir.$row['file']);
109      $element_info = array(
110        'path' => $dir.$row['file'],
111        'tn_ext' =>
112          (isset($row['tn_ext']) and $row['tn_ext']!='') ? $row['tn_ext']:'jpg'
113        );
114      $tn_path = get_thumbnail_path( $element_info );
115
116      if ( @is_file($tn_path) )
117      {
118        unlink( $tn_path );
119      }
120    }
121
122    $query = '
123DELETE
124  FROM '.WAITING_TABLE.'
125  WHERE id IN ('.implode(',', $to_reject).')
126;';
127    pwg_query($query);
128
129    array_push(
130      $page['infos'],
131      sprintf(
132        l10n('%d waiting pictures rejected'),
133        count($to_reject)
134        )
135      );
136  }
137}
138
139//----------------------------------------------------- template initialization
140$template->set_filenames(array('waiting'=>'admin/waiting.tpl'));
141$template->assign_vars(array(
142  'L_AUTHOR'=>$lang['author'],
143  'L_THUMBNAIL'=>$lang['thumbnail'],
144  'L_DATE'=>$lang['date'],
145  'L_FILE'=>$lang['file'],
146  'L_CATEGORY'=>$lang['category'],
147  'L_SUBMIT'=>$lang['submit'],
148  'L_RESET'=>$lang['reset'],
149  'L_DELETE'=>$lang['delete'],
150
151  'F_ACTION'=>str_replace( '&', '&amp;', $_SERVER['REQUEST_URI'])
152  ));
153
154//---------------------------------------------------------------- form display
155$cat_names = array();
156$list = array();
157
158$query = 'SELECT * FROM '.WAITING_TABLE;
159$query.= " WHERE validated = 'false'";
160$query.= ' ORDER BY storage_category_id';
161$query.= ';';
162$result = pwg_query( $query );
163$i = 0;
164while ( $row = mysql_fetch_array( $result ) )
165{
166  if ( !isset( $cat_names[$row['storage_category_id']] ) )
167  {
168    $cat = get_cat_info( $row['storage_category_id'] );
169    $cat_names[$row['storage_category_id']] = array();
170    $cat_names[$row['storage_category_id']]['dir'] =
171      PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
172    $cat_names[$row['storage_category_id']]['display_name'] =
173      get_cat_display_name($cat['name']);
174  }
175  $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
176  $class='row1';
177  if ( $i++ % 2== 0 ) $class='row2';
178
179  $template->assign_block_vars(
180    'picture',
181    array(
182      'WAITING_CLASS'=>$class,
183      'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'],
184      'ID_IMG'=>$row['id'],
185      'DATE_IMG' => date('Y-m-d H:i:s', $row['date']),
186      'FILE_TITLE'=>$row['file'],
187      'FILE_IMG' =>
188        (strlen($row['file']) > 10) ?
189          (substr($row['file'], 0, 10)).'...' : $row['file'],
190      'PREVIEW_URL_IMG'=>$preview_url,
191      'UPLOAD_EMAIL'=>get_email_address_as_display_text($row['mail_address']),
192      'UPLOAD_USERNAME'=>$row['username']
193      )
194    );
195
196  // is there an existing associated thumnail ?
197  if ( !empty( $row['tn_ext'] ))
198  {
199    $thumbnail = $conf['prefix_thumbnail'];
200    $thumbnail.= get_filename_wo_extension( $row['file'] );
201    $thumbnail.= '.'.$row['tn_ext'];
202        $url = $cat_names[$row['storage_category_id']]['dir'];
203    $url.= 'thumbnail/'.$thumbnail;
204
205    $template->assign_block_vars(
206      'picture.thumbnail',
207      array(
208        'PREVIEW_URL_TN_IMG' => $url,
209        'FILE_TN_IMG' =>
210          (strlen($thumbnail) > 10) ?
211            (substr($thumbnail, 0, 10)).'...' : $thumbnail,
212        'FILE_TN_TITLE' => $thumbnail
213        )
214      );
215  }
216
217  array_push($list, $row['id']);
218}
219
220$template->assign_vars(
221  array(
222    'LIST' => implode(',', $list)
223    )
224  );
225
226//----------------------------------------------------------- sending html code
227$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting');
228?>
Note: See TracBrowser for help on using the repository browser.