source: extensions/photo_update/admin.php @ 19885

Last change on this file since 19885 was 16982, checked in by plg, 12 years ago

add tab "Update" on photo administration screen (requires Piwigo 2.4.2)

File size: 4.9 KB
RevLine 
[16982]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.'admin/include/tabsheet.class.php');
31
32define('COMMUNITY_BASE_URL', get_root_url().'admin.php?page=plugin-community');
33
34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37
38check_status(ACCESS_ADMINISTRATOR);
39
40// +-----------------------------------------------------------------------+
41// | Basic checks                                                          |
42// +-----------------------------------------------------------------------+
43
44$_GET['image_id'] = $_GET['tab'];
45
46check_input_parameter('image_id', $_GET, false, PATTERN_ID);
47
48$admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
49
50// +-----------------------------------------------------------------------+
51// | Process form                                                          |
52// +-----------------------------------------------------------------------+
53
54load_language('plugin.lang', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
55 
56if (isset($_FILES['photo_update']))
57{
58  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
59 
60  if ($_FILES['photo_update']['error'] !== UPLOAD_ERR_OK)
61  {
62    $error_message = file_upload_error_message($_FILES['photo_update']['error']);
63
64    array_push(
65      $page['errors'],
66      $error_message
67      );
68  }
69  else
70  {
71    add_uploaded_file(
72      $_FILES['photo_update']['tmp_name'],
73      $_FILES['photo_update']['name'],
74      null,
75      null,
76      $_GET['image_id']
77      );
78
79    $page['photo_update_refresh_thumbnail'] = true;
80
81    array_push(
82      $page['infos'],
83      l10n('The photo was updated')
84      );
85  }
86}
87
88// +-----------------------------------------------------------------------+
89// | Tabs                                                                  |
90// +-----------------------------------------------------------------------+
91
92include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
93
94$page['tab'] = 'update';
95
96$tabsheet = new tabsheet();
97$tabsheet->set_id('photo');
98$tabsheet->select('update');
99$tabsheet->assign();
100
101// +-----------------------------------------------------------------------+
102// |                             template init                             |
103// +-----------------------------------------------------------------------+
104
105$template->set_filenames(
106  array(
107    'plugin_admin_content' => dirname(__FILE__).'/admin.tpl'
108    )
109  );
110
111// retrieving direct information about picture
112$query = '
113SELECT *
114  FROM '.IMAGES_TABLE.'
115  WHERE id = '.$_GET['image_id'].'
116;';
117$row = pwg_db_fetch_assoc(pwg_query($query));
118
119$template->assign(
120  array(
121    'TN_SRC' => DerivativeImage::thumb_url($row).(isset($_FILES['photo_update']) ? '?'.time() : ''),
122    'TITLE' => render_element_name($row),
123    )
124  );
125
126// +-----------------------------------------------------------------------+
127// | sending html code                                                     |
128// +-----------------------------------------------------------------------+
129
130$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
131?>
Note: See TracBrowser for help on using the repository browser.