-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.inc.php
126 lines (99 loc) · 4.02 KB
/
main.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/*
Plugin Name: Icy Modify Picture
Version: 2.4.6
Description: Allow normal users to upload / modify pictures
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=563
Author: icy
Author URI: http://icy.theslinux.org/
License: GPL2
*/
if (!defined('PHPWG_ROOT_PATH')) {
die('Hacking attempt!');
}
define('ICY_PICTURE_MODIFY_PATH' , PHPWG_PLUGINS_PATH .'icy_picture_modify/');
require_once(ICY_PICTURE_MODIFY_PATH.'include/functions_icy_picture_modify.inc.php');
# Variable declarations ################################################
global $ICY_ACL;
# Hooks declarations ###################################################
add_event_handler('loc_end_section_init', 'icy_picture_modify_section_init');
add_event_handler('loc_end_index', 'icy_picture_modify_index', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
add_event_handler('loc_begin_picture', 'icy_picture_modify_loc_begin_picture');
add_event_handler('init','icy_picture_modify_fix_community_acl', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
# add_event_handler('login_success', );
add_event_handler('blockmanager_apply', 'icy_picture_modify_fix_community_acl', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
add_event_handler('ws_invoke_allowed', 'icy_picture_modify_fix_community_acl', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
add_event_handler('ws_add_methods', 'icy_picture_modify_fix_community_acl', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
add_event_handler('sendResponse', 'icy_picture_modify_fix_community_acl', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
if (icy_plugin_enabled("community")) {
remove_event_handler('loc_end_index', 'community_index');
add_event_handler('community_ws_categories_getList', 'icy_picture_modify_fix_community_acl', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
add_event_handler('sendResponse', 'icy_picture_modify_fix_community_25c', EVENT_HANDLER_PRIORITY_NEUTRAL - 10);
}
# Hooks definitions ####################################################
/*
Community 2.5.c (community_sendResponse) hook calls to the function
(invalidate_user_cache) which is only available from `admin`
*/
function icy_picture_modify_fix_community_25c() {
include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
}
function icy_picture_modify_fix_community_acl()
{
if (is_admin()) return TRUE;
icy_acl_fix_community(icy_acl_load_configuration());
}
function icy_picture_modify_section_init()
{
global $tokens, $page;
if (is_admin()) return TRUE;
if ($tokens[0] == 'icy_picture_modify')
{
$page['section'] = 'icy_picture_modify';
}
}
function icy_picture_modify_index()
{
global $page;
if (is_admin()) return TRUE;
if (! isset($page['section'])) {
return TRUE;
}
if ($page['section'] == 'icy_picture_modify')
{
require(ICY_PICTURE_MODIFY_PATH.'icy_picture_modify.php');
}
elseif ($page['section'] == 'add_photos') {
require(ICY_PICTURE_MODIFY_PATH.'add_photos.php');
}
}
// provide the link to modify the picture
function icy_picture_modify_loc_begin_picture()
{
global $conf, $template, $page, $user;
if (is_admin()) return TRUE;
icy_acl_load_configuration();
if (icy_acl("edit_image_of",$page['image_id']))
{
$url_admin =
get_root_url().'index.php?/icy_picture_modify&'.'image_id='.$page['image_id'];
if (isset($page['category'])
and isset($page['category']['id'])
and ! empty($page['category']['id']))
{
$url_admin .= '&cat_id='.$page['category']['id'];
}
if (version_compare(PHPWG_VERSION, '2.5.0', '<')) {
$template->assign('U_ADMIN', $url_admin);
}
else {
// Piwigo 2.5 doesn't support U_ADMIN in the `picture.tpl` and
// this just makes this plugin sucks. Using new style? Like this?
// What a boring f***cking style I have to find another way
// FIXME: + translation here
$url_admin = "<a href=\"$url_admin\" title=\"Modify information\" class=\"pwg-state-default pwg-button\" rel=\"nofollow\"> <span class=\"pwg-icon pwg-icon-edit\"> </span><span class=\"pwg-button-text\">Edit</span></a>";
$template->add_picture_button($url_admin, 0);
}
}
}
?>