1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) |
---|
4 | die('Hacking attempt!'); |
---|
5 | global $template, $conf, $user; |
---|
6 | include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php'); |
---|
7 | load_language('plugin.lang', ADD_PROP_PHOTO_PATH); |
---|
8 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
9 | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | // | Check Access and exit when user status is not ok | |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | check_status(ACCESS_ADMINISTRATOR); |
---|
14 | |
---|
15 | //-------------------------------------------------------- sections definitions |
---|
16 | if (!isset($_GET['tab'])) |
---|
17 | $page['tab'] = 'define_properties'; |
---|
18 | else |
---|
19 | $page['tab'] = $_GET['tab']; |
---|
20 | |
---|
21 | |
---|
22 | if ($page['tab'] != 'iap') { |
---|
23 | $tabsheet = new tabsheet(); |
---|
24 | $tabsheet->add('addip', l10n('Property'), ADD_PROP_PHOTO_ADMIN . '-define_properties'); |
---|
25 | $tabsheet->select($page['tab']); |
---|
26 | $tabsheet->assign(); |
---|
27 | } else if ($_GET['tab'] == 'iap') { |
---|
28 | |
---|
29 | $page['active_menu'] = get_active_menu('photo'); // force oppening "Photos" menu block |
---|
30 | |
---|
31 | /* Basic checks */ |
---|
32 | check_status(ACCESS_ADMINISTRATOR); |
---|
33 | |
---|
34 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
35 | $id_img = $_GET['image_id']; |
---|
36 | $admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $_GET['image_id']; |
---|
37 | |
---|
38 | $page['tab'] = 'iap'; |
---|
39 | |
---|
40 | $tabsheet = new tabsheet(); |
---|
41 | $tabsheet->set_id('photo'); |
---|
42 | $tabsheet->select('iap'); |
---|
43 | $tabsheet->assign(); |
---|
44 | |
---|
45 | $template->assign( |
---|
46 | 'gestionD', array( |
---|
47 | 'A' => 'a' |
---|
48 | )); |
---|
49 | |
---|
50 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
51 | if($PAED['state'] == 'active'){ |
---|
52 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
53 | $template->assign('useED',1); |
---|
54 | }else{ |
---|
55 | $template->assign('useED',0); |
---|
56 | } |
---|
57 | |
---|
58 | $tab_add_info_one_photo = tab_add_info_by_photo($_GET['image_id']); |
---|
59 | if (pwg_db_num_rows($tab_add_info_one_photo)) { |
---|
60 | while ($info_photos = pwg_db_fetch_assoc($tab_add_info_one_photo)) { |
---|
61 | |
---|
62 | $d = data_info_photos($id_img, $info_photos['id_prop_pho']); |
---|
63 | $row = pwg_db_fetch_assoc($d); |
---|
64 | |
---|
65 | $items = array( |
---|
66 | 'IDPHO' => $_GET['image_id'], |
---|
67 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
68 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
69 | 'AIPDATA' => $row['data'], |
---|
70 | ); |
---|
71 | |
---|
72 | $template->append('info_photos', $items); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | if (isset($_POST['submitaddinfoimg'])) { |
---|
77 | foreach ($_POST['data'] AS $id_prop_pho => $data) { |
---|
78 | $q = 'SELECT 1 FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
79 | $test = pwg_query($q); |
---|
80 | $row = pwg_db_fetch_assoc($test); |
---|
81 | if (count($row) > 0) { |
---|
82 | if ($data != '') { |
---|
83 | $query = 'UPDATE ' . $prefixeTable . 'add_properties_photos_data SET data="' . $data . '" WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
84 | pwg_query($query); |
---|
85 | } else { |
---|
86 | $query = 'DELETE FROM ' . $prefixeTable . 'add_properties_photos_data WHERE id_img=' . $id_img . ' AND id_prop_pho=' . $id_prop_pho; |
---|
87 | pwg_query($query); |
---|
88 | } |
---|
89 | } else if ($data != '') { |
---|
90 | $query = 'INSERT ' . $prefixeTable . 'add_properties_photos_data(id_img,id_prop_pho,data) VALUES (' . $id_img . ',' . $id_prop_pho . ',"' . $data . '");'; |
---|
91 | pwg_query($query); |
---|
92 | } |
---|
93 | |
---|
94 | } |
---|
95 | $redirect_url = ADD_PROP_PHOTO_ADMIN . '-iap&image_id=' . $id_img; |
---|
96 | $_SESSION['page_infos'] = array(l10n('Properties update')); |
---|
97 | redirect($redirect_url); |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | switch ($page['tab']) { |
---|
102 | case 'define_properties': |
---|
103 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
104 | $template->assign( |
---|
105 | 'addinfotemplate', array( |
---|
106 | 'addinfo' => l10n('addinfo'), |
---|
107 | )); |
---|
108 | |
---|
109 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
110 | if($PAED['state'] == 'active'){ |
---|
111 | add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
112 | $template->assign('useED',1); |
---|
113 | }else{ |
---|
114 | $template->assign('useED',0); |
---|
115 | } |
---|
116 | |
---|
117 | $admin_base_url = ADD_PROP_PHOTO_ADMIN . '-define_properties'; |
---|
118 | $tab_info_photos = tab_info_photos(); |
---|
119 | |
---|
120 | if (pwg_db_num_rows($tab_info_photos)) { |
---|
121 | while ($info_photos = pwg_db_fetch_assoc($tab_info_photos)) { |
---|
122 | if($info_photos['id_prop_pho']==1){ |
---|
123 | $items = array( |
---|
124 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
125 | 'AIPWORDING' => l10n('Author'), |
---|
126 | 'AIPORDER' => $info_photos['orderprop'], |
---|
127 | 'AIPACTIVE' => $info_photos['active'], |
---|
128 | 'AIPEDIT' => $info_photos['edit'], |
---|
129 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
130 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
131 | ); |
---|
132 | }else if($info_photos['id_prop_pho']==2){ |
---|
133 | $items = array( |
---|
134 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
135 | 'AIPWORDING' => l10n('Created on'), |
---|
136 | 'AIPORDER' => $info_photos['orderprop'], |
---|
137 | 'AIPACTIVE' => $info_photos['active'], |
---|
138 | 'AIPEDIT' => $info_photos['edit'], |
---|
139 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
140 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
141 | ); |
---|
142 | }else if($info_photos['id_prop_pho']==3){ |
---|
143 | $items = array( |
---|
144 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
145 | 'AIPWORDING' => l10n('Posted on'), |
---|
146 | 'AIPORDER' => $info_photos['orderprop'], |
---|
147 | 'AIPACTIVE' => $info_photos['active'], |
---|
148 | 'AIPEDIT' => $info_photos['edit'], |
---|
149 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
150 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
151 | ); |
---|
152 | }else if($info_photos['id_prop_pho']==4){ |
---|
153 | $items = array( |
---|
154 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
155 | 'AIPWORDING' => l10n('Dimensions'), |
---|
156 | 'AIPORDER' => $info_photos['orderprop'], |
---|
157 | 'AIPACTIVE' => $info_photos['active'], |
---|
158 | 'AIPEDIT' => $info_photos['edit'], |
---|
159 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
160 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
161 | ); |
---|
162 | }else if($info_photos['id_prop_pho']==5){ |
---|
163 | $items = array( |
---|
164 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
165 | 'AIPWORDING' => l10n('File'), |
---|
166 | 'AIPORDER' => $info_photos['orderprop'], |
---|
167 | 'AIPACTIVE' => $info_photos['active'], |
---|
168 | 'AIPEDIT' => $info_photos['edit'], |
---|
169 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
170 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
171 | ); |
---|
172 | }else if($info_photos['id_prop_pho']==6){ |
---|
173 | $items = array( |
---|
174 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
175 | 'AIPWORDING' => l10n('Filesize'), |
---|
176 | 'AIPORDER' => $info_photos['orderprop'], |
---|
177 | 'AIPACTIVE' => $info_photos['active'], |
---|
178 | 'AIPEDIT' => $info_photos['edit'], |
---|
179 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
180 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
181 | ); |
---|
182 | }else if($info_photos['id_prop_pho']==7){ |
---|
183 | $items = array( |
---|
184 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
185 | 'AIPWORDING' => l10n('Tags'), |
---|
186 | 'AIPORDER' => $info_photos['orderprop'], |
---|
187 | 'AIPACTIVE' => $info_photos['active'], |
---|
188 | 'AIPEDIT' => $info_photos['edit'], |
---|
189 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
190 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
191 | ); |
---|
192 | }else if($info_photos['id_prop_pho']==8){ |
---|
193 | $items = array( |
---|
194 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
195 | 'AIPWORDING' => l10n('Albums'), |
---|
196 | 'AIPORDER' => $info_photos['orderprop'], |
---|
197 | 'AIPACTIVE' => $info_photos['active'], |
---|
198 | 'AIPEDIT' => $info_photos['edit'], |
---|
199 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
200 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
201 | ); |
---|
202 | }else if($info_photos['id_prop_pho']==9){ |
---|
203 | $items = array( |
---|
204 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
205 | 'AIPWORDING' => l10n('Visits'), |
---|
206 | 'AIPORDER' => $info_photos['orderprop'], |
---|
207 | 'AIPACTIVE' => $info_photos['active'], |
---|
208 | 'AIPEDIT' => $info_photos['edit'], |
---|
209 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
210 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
211 | ); |
---|
212 | }else if($info_photos['id_prop_pho']==10){ |
---|
213 | $items = array( |
---|
214 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
215 | 'AIPWORDING' => l10n('Average'), |
---|
216 | 'AIPORDER' => $info_photos['orderprop'], |
---|
217 | 'AIPACTIVE' => $info_photos['active'], |
---|
218 | 'AIPEDIT' => $info_photos['edit'], |
---|
219 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
220 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
221 | ); |
---|
222 | }else if($info_photos['id_prop_pho']==11){ |
---|
223 | $items = array( |
---|
224 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
225 | 'AIPWORDING' => l10n('Who can see this photo?'), |
---|
226 | 'AIPORDER' => $info_photos['orderprop'], |
---|
227 | 'AIPACTIVE' => $info_photos['active'], |
---|
228 | 'AIPEDIT' => $info_photos['edit'], |
---|
229 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
230 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
231 | ); |
---|
232 | }else{ |
---|
233 | $items = array( |
---|
234 | 'IDINFOPHO' => $info_photos['id_prop_pho'], |
---|
235 | 'AIPWORDING' => trigger_change('AP_render_content',$info_photos['wording']), |
---|
236 | 'AIPWORDING2' => $info_photos['wording'], |
---|
237 | 'AIPORDER' => $info_photos['orderprop'], |
---|
238 | 'AIPACTIVE' => $info_photos['active'], |
---|
239 | 'AIPEDIT' => $info_photos['edit'], |
---|
240 | 'U_DELETE' => $admin_base_url . '&delete=' . $info_photos['id_prop_pho'], |
---|
241 | 'U_HIDE' => $admin_base_url . '&hide=' . $info_photos['id_prop_pho'], |
---|
242 | 'U_SHOW' => $admin_base_url . '&show=' . $info_photos['id_prop_pho'], |
---|
243 | ); |
---|
244 | } |
---|
245 | $template->append('info_photos', $items); |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | if (isset($_POST['submitManualOrderInfo'])){ |
---|
250 | |
---|
251 | asort($_POST['infoOrd'], SORT_NUMERIC); |
---|
252 | |
---|
253 | $data = array(); |
---|
254 | foreach ($_POST['infoOrd'] as $id =>$val){ |
---|
255 | |
---|
256 | $data[] = array('id_prop_pho' => $id, 'orderprop' => $val+1); |
---|
257 | } |
---|
258 | $fields = array('primary' => array('id_prop_pho'), 'update' => array('orderprop')); |
---|
259 | mass_updates(ADD_PROP_PHOTO_TABLE, $fields, $data); |
---|
260 | |
---|
261 | $page['infos'][] = l10n('Properties manual order was saved'); |
---|
262 | redirect($admin_base_url); |
---|
263 | } |
---|
264 | |
---|
265 | if (isset($_POST['submitaddAIP'])) { |
---|
266 | if (!isset($_POST['inseractive'])) { |
---|
267 | $_POST['inseractive'] = 0; |
---|
268 | } |
---|
269 | if ($_POST['invisibleID'] == 0) { |
---|
270 | $result = pwg_query('SELECT MAX(orderprop) FROM '. ADD_PROP_PHOTO_TABLE ); |
---|
271 | $row = pwg_db_fetch_assoc($result); |
---|
272 | $or = ($row['MAX(orderprop)'] + 1); |
---|
273 | |
---|
274 | $q = ' |
---|
275 | INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit)VALUES ("' . $_POST['inserwording'] . '","' . $or . '","' . $_POST['inseractive'] . '",1);'; |
---|
276 | pwg_query($q); |
---|
277 | $_SESSION['page_infos'] = array(l10n('Property photo add')); |
---|
278 | } else { |
---|
279 | $q = ' |
---|
280 | UPDATE ' . $prefixeTable . 'add_properties_photos' |
---|
281 | . ' set wording ="' . $_POST['inserwording'] . '" ' |
---|
282 | . ' ,active=' . $_POST['inseractive'] |
---|
283 | . ' WHERE id_prop_pho=' . $_POST['invisibleID'] . ';'; |
---|
284 | pwg_query($q); |
---|
285 | $_SESSION['page_infos'] = array(l10n('Property photo update')); |
---|
286 | } |
---|
287 | redirect($admin_base_url); |
---|
288 | } |
---|
289 | |
---|
290 | if (isset($_GET['delete'])) { |
---|
291 | check_input_parameter('delete', $_GET, false, PATTERN_ID); |
---|
292 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
293 | pwg_query($query); |
---|
294 | $query = 'DELETE FROM ' . ADD_PROP_PHOTO_DATA_TABLE . ' WHERE id_prop_pho = ' . $_GET['delete'] . ';'; |
---|
295 | pwg_query($query); |
---|
296 | |
---|
297 | $_SESSION['page_infos'] = array(l10n('Property delete')); |
---|
298 | redirect($admin_base_url); |
---|
299 | } |
---|
300 | |
---|
301 | if (isset($_GET['hide'])) { |
---|
302 | check_input_parameter('hide', $_GET, false, PATTERN_ID); |
---|
303 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 1 WHERE id_prop_pho=' . $_GET['hide'] . ';'; |
---|
304 | pwg_query($query); |
---|
305 | } |
---|
306 | |
---|
307 | if (isset($_GET['show'])) { |
---|
308 | check_input_parameter('show', $_GET, false, PATTERN_ID); |
---|
309 | $query = 'UPDATE ' . ADD_PROP_PHOTO_TABLE . ' SET active = 0 WHERE id_prop_pho=' . $_GET['show'] . ';'; |
---|
310 | pwg_query($query); |
---|
311 | } |
---|
312 | |
---|
313 | break; |
---|
314 | } |
---|
315 | |
---|
316 | |
---|
317 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin/admin.tpl')); |
---|
318 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
319 | ?> |
---|