source: trunk/admin/waiting.php @ 1740

Last change on this file since 1740 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
RevLine 
[2]1<?php
[362]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[675]5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
[362]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[362]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// +-----------------------------------------------------------------------+
[520]27if( !defined("PHPWG_ROOT_PATH") )
28{
[696]29  die ("Hacking attempt!");
[520]30}
[1072]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
[26]39//--------------------------------------------------------------------- updates
[849]40
41if (isset($_POST))
[26]42{
[849]43  $to_validate = array();
44  $to_reject = array();
[1609]45
[849]46  if (isset($_POST['submit']))
[1609]47  {
[849]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  }
[1245]68  elseif (isset($_POST['validate-all']) and !empty($_POST['list']))
[26]69  {
[849]70    $to_validate = explode(',', $_POST['list']);
71  }
[1245]72  elseif (isset($_POST['reject-all']) and !empty($_POST['list']))
[849]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))
[26]106    {
[849]107      $dir = get_complete_dir($row['storage_category_id']);
108      unlink($dir.$row['file']);
[1609]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) )
[26]117      {
[1609]118        unlink( $tn_path );
[26]119      }
120    }
[1609]121
[849]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      );
[26]136  }
137}
[520]138
[26]139//----------------------------------------------------- template initialization
[520]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'],
[699]148  'L_RESET'=>$lang['reset'],
[520]149  'L_DELETE'=>$lang['delete'],
[1609]150
[1004]151  'F_ACTION'=>str_replace( '&', '&amp;', $_SERVER['REQUEST_URI'])
[520]152  ));
[1609]153
[26]154//---------------------------------------------------------------- form display
155$cat_names = array();
[849]156$list = array();
157
[520]158$query = 'SELECT * FROM '.WAITING_TABLE;
[26]159$query.= " WHERE validated = 'false'";
[61]160$query.= ' ORDER BY storage_category_id';
[26]161$query.= ';';
[587]162$result = pwg_query( $query );
[26]163$i = 0;
164while ( $row = mysql_fetch_array( $result ) )
165{
[61]166  if ( !isset( $cat_names[$row['storage_category_id']] ) )
[26]167  {
[61]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'] =
[520]171      PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
[61]172    $cat_names[$row['storage_category_id']]['display_name'] =
[642]173      get_cat_display_name($cat['name']);
[26]174  }
[520]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';
[1609]178
[849]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'],
[1609]190      'PREVIEW_URL_IMG'=>$preview_url,
[1458]191      'UPLOAD_EMAIL'=>get_email_address_as_display_text($row['mail_address']),
[849]192      'UPLOAD_USERNAME'=>$row['username']
193      )
194    );
[520]195
[26]196  // is there an existing associated thumnail ?
[520]197  if ( !empty( $row['tn_ext'] ))
[26]198  {
199    $thumbnail = $conf['prefix_thumbnail'];
200    $thumbnail.= get_filename_wo_extension( $row['file'] );
201    $thumbnail.= '.'.$row['tn_ext'];
[520]202        $url = $cat_names[$row['storage_category_id']]['dir'];
[61]203    $url.= 'thumbnail/'.$thumbnail;
[1609]204
[849]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      );
[26]215  }
[849]216
217  array_push($list, $row['id']);
[26]218}
[849]219
220$template->assign_vars(
221  array(
222    'LIST' => implode(',', $list)
223    )
224  );
[1609]225
[26]226//----------------------------------------------------------- sending html code
[520]227$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting');
[362]228?>
Note: See TracBrowser for help on using the repository browser.