source: extensions/Icy_Picture_Modify/main.inc.php @ 26984

Last change on this file since 26984 was 16495, checked in by icy, 12 years ago

Version 2.0.0, advance ACL . Code copied from git/master.

I could not use merging with git svn . Stupidly copy-&-paste ;)

File size: 2.7 KB
Line 
1<?php
2/*
3Plugin Name: Icy Modify Picture
4Version: 2.0.0
5Description: Allow users to modify pictures they uploaded
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=563
7Author: icy
8Author URI: http://metakyanh.sarovar.org/
9*/
10
11if (!defined('PHPWG_ROOT_PATH'))
12{
13  die('Hacking attempt!');
14}
15
16define('ICY_PICTURE_MODIFY_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
17require_once(ICY_PICTURE_MODIFY_PATH.'include/functions_icy_picture_modify.inc.php');
18
19# Variable declarations ################################################
20
21global $ICY_ACL;
22
23# Hooks declarations ###################################################
24
25add_event_handler('loc_end_section_init', 'icy_picture_modify_section_init');
26remove_event_handler('loc_end_index', 'community_index');
27add_event_handler('loc_end_index', 'icy_picture_modify_index', 40);
28
29add_event_handler('loc_begin_picture', 'icy_picture_modify_loc_begin_picture');
30add_event_handler('init','icy_picture_modify_fix_community_acl', 40);
31# add_event_handler('login_success', );
32
33add_event_handler('blockmanager_apply', 'icy_picture_modify_fix_community_acl', 40);
34add_event_handler('ws_invoke_allowed', 'icy_picture_modify_fix_community_acl', 40);
35add_event_handler('ws_add_methods', 'icy_picture_modify_fix_community_acl', 40);
36add_event_handler('community_ws_categories_getList', 'icy_picture_modify_fix_community_acl', 40);
37add_event_handler('sendResponse', 'icy_picture_modify_fix_community_acl', 40);
38
39# Hooks definitions ####################################################
40
41function icy_picture_modify_fix_community_acl()
42{
43  icy_acl_fix_community(icy_acl_load_configuration());
44}
45
46function 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
56function 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']
76function 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      .'&amp;cat_id='.(isset($page['category']) ? $page['category']['id'] : '')
87      .'&amp;image_id='.$page['image_id'];
88
89    $template->assign(
90      array(
91        'U_ADMIN' => $url_admin,
92        )
93      );
94  }
95}
96
97?>
Note: See TracBrowser for help on using the repository browser.