source: trunk/admin/waiting.php @ 520

Last change on this file since 520 was 520, checked in by gweltas, 20 years ago

waiting tpl migration

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                              waiting.php                              |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-09-11 10:36:03 +0000 (Sat, 11 Sep 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 520 $
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}
31include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
32//--------------------------------------------------------------------- updates
33if ( isset( $_POST['submit'] ) )
34{
35  $query = 'SELECT * FROM '.WAITING_TABLE;
36  $query.= " WHERE validated = 'false';";
37  $result = mysql_query( $query );
38  while ( $row = mysql_fetch_array( $result ) )
39  {
40    $key = 'validate-'.$row['id'];
41    if ( isset( $_POST[$key] ) )
42    {
43      if ( $_POST[$key] == 'true' )
44      {
45        // The uploaded element was validated, we have to set the
46        // "validated" field to "true"
47        $query = 'UPDATE '.WAITING_TABLE;
48        $query.= " SET validated = 'true'";
49        $query.= ' WHERE id = '.$row['id'];
50        $query.= ';';
51        mysql_query( $query );
52        // linking logically the picture to its storage category
53        $query = 'INSERT INTO';
54      }
55      else
56      {
57        // The uploaded element was refused, we have to delete its reference
58        // in the database and to delete the element as well.
59        $query = 'DELETE FROM '.WAITING_TABLE;
60        $query.= ' WHERE id = '.$row['id'];
61        $query.= ';';
62        mysql_query( $query );
63        // deletion of the associated files
64        $dir = get_complete_dir( $row['storage_category_id'] );
65        unlink( '.'.$dir.$row['file'] );
66        if ( $row['tn_ext'] != '' )
67        {
68          $thumbnail = $conf['prefix_thumbnail'];
69          $thumbnail.= get_filename_wo_extension( $row['file'] );
70          $thumbnail.= '.'.$row['tn_ext'];
71          $url = PHPWG_ROOT_PATH.$dir.'thumbnail/'.$thumbnail;
72          unlink( $url );
73        }
74      }
75    }
76  }
77}
78
79//----------------------------------------------------- template initialization
80$template->set_filenames(array('waiting'=>'admin/waiting.tpl'));
81$template->assign_vars(array(
82  'L_WAITING_CONFIRMATION'=>$lang['waiting_update'],
83  'L_AUTHOR'=>$lang['author'],
84  'L_THUMBNAIL'=>$lang['thumbnail'],
85  'L_DATE'=>$lang['date'],
86  'L_FILE'=>$lang['file'],
87  'L_CATEGORY'=>$lang['category'],
88  'L_SUBMIT'=>$lang['submit'],
89  'L_DELETE'=>$lang['delete'],
90 
91  'F_ACTION'=>add_session_id(str_replace( '&', '&amp;', $_SERVER['REQUEST_URI'] ))
92  ));
93 
94//-------------------------------------------------------- confirmation message
95if (isset($_POST['submit']))
96{
97  $template->assign_block_vars('confirmation' ,array());
98}
99//---------------------------------------------------------------- form display
100$cat_names = array();
101$query = 'SELECT * FROM '.WAITING_TABLE;
102$query.= " WHERE validated = 'false'";
103$query.= ' ORDER BY storage_category_id';
104$query.= ';';
105$result = mysql_query( $query );
106$i = 0;
107while ( $row = mysql_fetch_array( $result ) )
108{
109  if ( !isset( $cat_names[$row['storage_category_id']] ) )
110  {
111    $cat = get_cat_info( $row['storage_category_id'] );
112    $cat_names[$row['storage_category_id']] = array();
113    $cat_names[$row['storage_category_id']]['dir'] =
114      PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] );
115    $cat_names[$row['storage_category_id']]['display_name'] =
116      get_cat_display_name( $cat['name'], ' &gt; ', 'font-weight:bold;' );
117  }
118  $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file'];
119  $class='row1';
120  if ( $i++ % 2== 0 ) $class='row2';
121 
122  $template->assign_block_vars('picture' ,array(
123    'WAITING_CLASS'=>$class,
124    'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'],
125    'ID_IMG'=>$row['id'],
126        'DATE_IMG'=>format_date( $row['date'], 'unix', true ),
127        'FILE_IMG'=>$row['file'],
128        'PREVIEW_URL_IMG'=>$preview_url, 
129        'UPLOAD_EMAIL'=>$row['mail_address'],
130        'UPLOAD_USERNAME'=>$row['username']
131        ));
132
133  // is there an existing associated thumnail ?
134  if ( !empty( $row['tn_ext'] ))
135  {
136    $thumbnail = $conf['prefix_thumbnail'];
137    $thumbnail.= get_filename_wo_extension( $row['file'] );
138    $thumbnail.= '.'.$row['tn_ext'];
139        $url = $cat_names[$row['storage_category_id']]['dir'];
140    $url.= 'thumbnail/'.$thumbnail;
141       
142    $template->assign_block_vars('picture.thumbnail' ,array(
143          'PREVIEW_URL_TN_IMG'=>$url,
144          'FILE_TN_IMG'=>$thumbnail
145          ));
146  }
147}
148//----------------------------------------------------------- sending html code
149$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting');
150?>
Note: See TracBrowser for help on using the repository browser.