[11610] | 1 | <?php |
---|
| 2 | /* |
---|
[11611] | 3 | Plugin Name: Icy Modify Picture |
---|
[16495] | 4 | Version: 2.0.0 |
---|
[11614] | 5 | Description: Allow users to modify pictures they uploaded |
---|
[11612] | 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=563 |
---|
[11610] | 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__)).'/'); |
---|
[16495] | 17 | require_once(ICY_PICTURE_MODIFY_PATH.'include/functions_icy_picture_modify.inc.php'); |
---|
[11610] | 18 | |
---|
[16495] | 19 | # Variable declarations ################################################ |
---|
[11612] | 20 | |
---|
[16495] | 21 | global $ICY_ACL; |
---|
| 22 | |
---|
| 23 | # Hooks declarations ################################################### |
---|
| 24 | |
---|
[11610] | 25 | add_event_handler('loc_end_section_init', 'icy_picture_modify_section_init'); |
---|
[16495] | 26 | remove_event_handler('loc_end_index', 'community_index'); |
---|
| 27 | add_event_handler('loc_end_index', 'icy_picture_modify_index', 40); |
---|
| 28 | |
---|
[11612] | 29 | add_event_handler('loc_begin_picture', 'icy_picture_modify_loc_begin_picture'); |
---|
[16495] | 30 | add_event_handler('init','icy_picture_modify_fix_community_acl', 40); |
---|
| 31 | # add_event_handler('login_success', ); |
---|
[11612] | 32 | |
---|
[16495] | 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); |
---|
[11612] | 38 | |
---|
[16495] | 39 | # Hooks definitions #################################################### |
---|
| 40 | |
---|
| 41 | function icy_picture_modify_fix_community_acl() |
---|
| 42 | { |
---|
| 43 | icy_acl_fix_community(icy_acl_load_configuration()); |
---|
| 44 | } |
---|
| 45 | |
---|
[11610] | 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 | |
---|
[16495] | 60 | if (! isset($page['section'])) { |
---|
| 61 | return TRUE; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | if ($page['section'] == 'icy_picture_modify') |
---|
[11610] | 65 | { |
---|
| 66 | include(ICY_PICTURE_MODIFY_PATH.'icy_picture_modify.php'); |
---|
| 67 | } |
---|
[16495] | 68 | elseif ($page['section'] == 'add_photos') { |
---|
| 69 | icy_picture_modify_fix_community_acl(TRUE); |
---|
| 70 | include(ICY_PICTURE_MODIFY_PATH.'add_photos.php'); |
---|
| 71 | } |
---|
[11610] | 72 | } |
---|
| 73 | |
---|
| 74 | // provide the link to modify the picture |
---|
[11612] | 75 | // FIXME: Why use $page['image_id'] instead of $_GET['image_id'] |
---|
[11610] | 76 | function icy_picture_modify_loc_begin_picture() |
---|
| 77 | { |
---|
| 78 | global $conf, $template, $page, $user; |
---|
[16495] | 79 | |
---|
| 80 | icy_acl_load_configuration(); |
---|
| 81 | |
---|
| 82 | if (icy_image_editable($page['image_id'])) |
---|
[11610] | 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 | ?> |
---|