forked from jradwan/Piwigo-physical_photo_move
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
201 lines (167 loc) · 6.4 KB
/
admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if( !defined("PHPWG_ROOT_PATH") )
{
die ("Hacking attempt!");
}
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
include_once(PPM_PATH.'include/functions.inc.php');
// +-----------------------------------------------------------------------+
// | Check access and exit when user status is not ok |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
// +-----------------------------------------------------------------------+
// | Basic checks |
// +-----------------------------------------------------------------------+
$_GET['image_id'] = $_GET['tab'];
$_GET['cat_id'] = $_GET['tab'];
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
check_input_parameter('ppm_type', $_GET, false, '/^(photo|album)$/');
$admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
$admin_album_base_url = get_root_url().'admin.php?page=album-'.$_GET['cat_id'];
// +-----------------------------------------------------------------------+
// | Process form |
// +-----------------------------------------------------------------------+
if (isset($_POST['move_item']))
{
$ppm_test_mode = ppm_check_test_mode();
// check selected option and act accordingly
if (isset($_POST['cat_id']))
{
// make sure category AND root album aren't both selected
if (isset($_POST['root_album']))
{
array_push(
$page['messages'],
l10n('MSG_BOTH_OPTIONS_ERR')
);
}
else
{
// move the item to the selected category
$target_cat = $_POST['cat_id'];
ppm_move_item($target_cat, $_GET['image_id'], $ppm_test_mode, $_GET['ppm_type']);
}
}
else
{
// move to root album option has been selected
if (isset($_POST['root_album']))
{
// move the item to the root album
ppm_move_item('ROOT', $_GET['image_id'], $ppm_test_mode, $_GET['ppm_type']);
}
else // no destination selected
{
array_push(
$page['messages'],
l10n('MSG_NO_DEST')
);
}
}
}
// +-----------------------------------------------------------------------+
// | Tab setup |
// +-----------------------------------------------------------------------+
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
$page['tab'] = 'ppm';
$tabsheet = new tabsheet();
$item_id = ($_GET['image_id']);
$tabsheet->set_id($_GET['ppm_type']);
$tabsheet->select('ppm');
$tabsheet->assign();
// +-----------------------------------------------------------------------+
// | Template init |
// +-----------------------------------------------------------------------+
$template->set_filenames(
array(
'plugin_admin_content' => dirname(__FILE__).'/admin.tpl'
)
);
// initialize the HTML for the item's thumbnail
$item_thumb = '';
if ($_GET['ppm_type'] == 'photo')
{
$image_info = get_image_infos($item_id);
$storage_cat_info = get_cat_info($image_info['storage_category_id']);
$storage_cat_path = $image_info['path'];
$storage_cat_nav = get_cat_display_name($storage_cat_info['upper_names']);
// set template items
$item_thumb .= '<img src="';
$item_thumb .= DerivativeImage::thumb_url($image_info);
$item_thumb .= '" alt={\'THUMBNAIL\'|@translate}" class=Thumbnail">';
$item_path = $storage_cat_path;
$header_text = 'EDIT_PHOTO';
$legend_text = 'MOVE_PHOTO';
$dir_text = 'CURR_FILE_LOC';
$help_text = 'DEST_ALBUM_HELP';
// populate the selection scroll with physical albums
ppm_list_physical_albums();
}
elseif ($_GET['ppm_type'] == 'album')
{
$image_info = get_cat_info($item_id);
$storage_cat_info = $image_info;
$storage_cat_path = get_fulldirs(explode(',', $image_info['uppercats']));
$storage_cat_nav = get_cat_display_name($storage_cat_info['upper_names']);
// determine how many items (not sub-albums) are in the current album
$query = 'SELECT
COUNT(image_id)
FROM '.IMAGES_TABLE.'
JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
WHERE category_id = '.$item_id.';';
list($image_count) = pwg_db_fetch_row(pwg_query($query));
if ($image_count != 0)
{
$item_thumb .= '<img src="';
$item_thumb .= DerivativeImage::thumb_url(get_image_infos($storage_cat_info['representative_picture_id']));
$item_thumb .= '" alt={\'THUMBNAIL\'|@translate}" class=Thumbnail">';
}
else
{
// the current album has no items (and thus no thumbnail to show) so use a placeholder
$item_thumb .= '<i class="icon-picture"></i> ';
}
// set remaining template items
$item_path = $storage_cat_path[$item_id];
$header_text = 'EDIT_ALBUM';
$legend_text = 'MOVE_ALBUM';
$dir_text = 'CURR_DIR_LOC';
$help_text = 'DEST_ALBUM_HELP_2';
// populate the selection scroll with physical albums
// except the current album and its sub-albums
ppm_list_physical_albums_no_subcats($item_id);
}
else
{
array_push(
$page['messages'],
l10n('MSG_NO_TYPE')
);
}
$template->assign(
array(
'TITLE' => render_element_name($image_info),
'TN_SRC' => $item_thumb,
'current_path' => $item_path,
'storage_category' => $storage_cat_nav,
'header_text' => $header_text,
'legend_text' => $legend_text,
'dir_text' => $dir_text,
'help_text' => $help_text,
'root_help' => 'MSG_ROOT_HELP',
'item_type' => $_GET['ppm_type'],
)
);
// +-----------------------------------------------------------------------+
// | Send HTML code |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
?>