1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | //Ajout du prefiltre |
---|
6 | add_event_handler('loc_begin_picture', 'udp', 55 ); |
---|
7 | |
---|
8 | function udp() |
---|
9 | { |
---|
10 | global $template; |
---|
11 | $template->set_prefilter('picture', 'udpT'); |
---|
12 | } |
---|
13 | |
---|
14 | function udpT($content, &$smarty) |
---|
15 | { |
---|
16 | global $conf; |
---|
17 | |
---|
18 | $search = '#<div id="'.$conf['udp'].'" class="imageInfo">#'; |
---|
19 | |
---|
20 | $replacement = ' |
---|
21 | |
---|
22 | {if $UDFA} |
---|
23 | <div id="udp" class="imageInfo"> |
---|
24 | <form method="post"> |
---|
25 | <input class="submit" name="submitudpA" type="submit" value="{\'delete photo\'|@translate}"> |
---|
26 | <label><input type="checkbox" name="confirm_deletionudp" value="1"> {\'Are you sure?\'|@translate}</label> |
---|
27 | </form> |
---|
28 | </div> |
---|
29 | {/if} |
---|
30 | <div id="'.$conf['udp'].'" class="imageInfo">'; |
---|
31 | |
---|
32 | return preg_replace($search, $replacement, $content); |
---|
33 | } |
---|
34 | |
---|
35 | add_event_handler('loc_begin_picture', 'udpA'); |
---|
36 | |
---|
37 | function udpA() |
---|
38 | { |
---|
39 | global $conf, $page, $template ; |
---|
40 | load_language('plugin.lang', UDP_PATH); |
---|
41 | load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); |
---|
42 | |
---|
43 | global $conf, $user, $page; |
---|
44 | |
---|
45 | $query = ' |
---|
46 | select added_by |
---|
47 | FROM ' . IMAGES_TABLE . ' |
---|
48 | WHERE id = \''.$page['image_id'].'\' |
---|
49 | ;'; |
---|
50 | $result = pwg_query($query); |
---|
51 | $row = pwg_db_fetch_assoc($result); |
---|
52 | $userudp=$row['added_by']; |
---|
53 | |
---|
54 | $query = ' |
---|
55 | select username |
---|
56 | FROM ' . USERS_TABLE . ' |
---|
57 | WHERE id = \''.$userudp.'\' |
---|
58 | ;'; |
---|
59 | $result = pwg_query($query); |
---|
60 | $row = pwg_db_fetch_assoc($result); |
---|
61 | $udp=$row['username']; |
---|
62 | |
---|
63 | if (($udp == $user['username'])) |
---|
64 | { |
---|
65 | $template->assign( array ( |
---|
66 | 'UDFA' => 'udp', |
---|
67 | ) ); |
---|
68 | } |
---|
69 | |
---|
70 | if ((isset($_POST['submitudpA']) and ($udp == $user['username']))) |
---|
71 | { |
---|
72 | |
---|
73 | if (!(isset($_POST['confirm_deletionudp']) and 1 == $_POST['confirm_deletionudp'])) |
---|
74 | { |
---|
75 | array_push($page['errors'], l10n('You need to confirm deletion')); |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
80 | global $page; |
---|
81 | $deletephotoudp =array($page['image_id']); |
---|
82 | delete_elements($deletephotoudp, true); |
---|
83 | invalidate_user_cache(); |
---|
84 | $redirect_url = get_root_url().'index.php?/category/'.($page['category']['id']); |
---|
85 | $_SESSION['page_infos'] = array(l10n('Photo deleted')); |
---|
86 | redirect($redirect_url); |
---|
87 | } |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | ?> |
---|