1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Icy Modify Picture |
---|
4 | Version: 2.0.0 |
---|
5 | Description: Allow users to modify pictures they uploaded |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=563 |
---|
7 | Author: icy |
---|
8 | Author URI: http://metakyanh.sarovar.org/ |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) |
---|
12 | { |
---|
13 | die('Hacking attempt!'); |
---|
14 | } |
---|
15 | |
---|
16 | define('ICY_PICTURE_MODIFY_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
17 | require_once(ICY_PICTURE_MODIFY_PATH.'include/functions_icy_picture_modify.inc.php'); |
---|
18 | |
---|
19 | # Variable declarations ################################################ |
---|
20 | |
---|
21 | global $ICY_ACL; |
---|
22 | |
---|
23 | # Hooks declarations ################################################### |
---|
24 | |
---|
25 | add_event_handler('loc_end_section_init', 'icy_picture_modify_section_init'); |
---|
26 | remove_event_handler('loc_end_index', 'community_index'); |
---|
27 | add_event_handler('loc_end_index', 'icy_picture_modify_index', 40); |
---|
28 | |
---|
29 | add_event_handler('loc_begin_picture', 'icy_picture_modify_loc_begin_picture'); |
---|
30 | add_event_handler('init','icy_picture_modify_fix_community_acl', 40); |
---|
31 | # add_event_handler('login_success', ); |
---|
32 | |
---|
33 | add_event_handler('blockmanager_apply', 'icy_picture_modify_fix_community_acl', 40); |
---|
34 | add_event_handler('ws_invoke_allowed', 'icy_picture_modify_fix_community_acl', 40); |
---|
35 | add_event_handler('ws_add_methods', 'icy_picture_modify_fix_community_acl', 40); |
---|
36 | add_event_handler('community_ws_categories_getList', 'icy_picture_modify_fix_community_acl', 40); |
---|
37 | add_event_handler('sendResponse', 'icy_picture_modify_fix_community_acl', 40); |
---|
38 | |
---|
39 | # Hooks definitions #################################################### |
---|
40 | |
---|
41 | function icy_picture_modify_fix_community_acl() |
---|
42 | { |
---|
43 | icy_acl_fix_community(icy_acl_load_configuration()); |
---|
44 | } |
---|
45 | |
---|
46 | function icy_picture_modify_section_init() |
---|
47 | { |
---|
48 | global $tokens, $page; |
---|
49 | |
---|
50 | if ($tokens[0] == 'icy_picture_modify') |
---|
51 | { |
---|
52 | $page['section'] = 'icy_picture_modify'; |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | function icy_picture_modify_index() |
---|
57 | { |
---|
58 | global $page; |
---|
59 | |
---|
60 | if (! isset($page['section'])) { |
---|
61 | return TRUE; |
---|
62 | } |
---|
63 | |
---|
64 | if ($page['section'] == 'icy_picture_modify') |
---|
65 | { |
---|
66 | include(ICY_PICTURE_MODIFY_PATH.'icy_picture_modify.php'); |
---|
67 | } |
---|
68 | elseif ($page['section'] == 'add_photos') { |
---|
69 | icy_picture_modify_fix_community_acl(TRUE); |
---|
70 | include(ICY_PICTURE_MODIFY_PATH.'add_photos.php'); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | // provide the link to modify the picture |
---|
75 | // FIXME: Why use $page['image_id'] instead of $_GET['image_id'] |
---|
76 | function icy_picture_modify_loc_begin_picture() |
---|
77 | { |
---|
78 | global $conf, $template, $page, $user; |
---|
79 | |
---|
80 | icy_acl_load_configuration(); |
---|
81 | |
---|
82 | if (icy_image_editable($page['image_id'])) |
---|
83 | { |
---|
84 | $url_admin = |
---|
85 | get_root_url().'index.php?/icy_picture_modify' |
---|
86 | .'&cat_id='.(isset($page['category']) ? $page['category']['id'] : '') |
---|
87 | .'&image_id='.$page['image_id']; |
---|
88 | |
---|
89 | $template->assign( |
---|
90 | array( |
---|
91 | 'U_ADMIN' => $url_admin, |
---|
92 | ) |
---|
93 | ); |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | ?> |
---|