-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathstart.php
207 lines (169 loc) · 7.54 KB
/
start.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
/**
* Elgg community plugin repository
*
*/
namespace Elgg\CommunityPlugins;
require_once __DIR__ . '/lib/events.php';
require_once __DIR__ . '/lib/hooks.php';
require_once __DIR__ . '/lib/functions.php';
require_once __DIR__ . '/lib/page_handlers.php';
define('PLUGINS_CONTRIBUTOR_RELATIONSHIP', 'plugin_contributor');
const PLUGIN_ID = 'community_plugins';
const UPGRADE_VERSION = 20141125;
elgg_register_event_handler('init', 'system', __NAMESPACE__ . '\\init');
/**
* Initialize the community plugin repository plugin
*/
function init() {
elgg_register_library('plugins:upgrades', __DIR__ . '/lib/upgrades.php');
elgg_register_css('jquery.chosen', elgg_get_simplecache_url('chosen/chosen.css'));
// Set up menu for logged in users
elgg_register_menu_item('site', array(
'href' => "/plugins",
'name' => 'plugins',
'text' => elgg_echo('plugins'),
));
elgg_register_menu_item('site', array(
'href' => '/plugins/category/themes',
'name' => 'themes',
'text' => elgg_echo('plugins:type:theme'),
));
/**
* Extend views
*/
// Extend CSS and JS
elgg_extend_view('elgg.css', 'plugins/css');
elgg_extend_view('css/admin', 'plugins/admin_css');
// Extend hover-over and profile menu
elgg_extend_view('profile/menu/links', 'plugins/profile_menu');
elgg_extend_view('groups/left_column', 'plugins/groupprofile_files');
// Register a page handler, so we can have nice URLs
elgg_register_page_handler('plugins', __NAMESPACE__ . '\\plugins_page_handler');
// Tell core to send notifications when new projects and releases are created
elgg_register_notification_event('object', 'plugin_project', array('create'));
elgg_register_notification_event('object', 'plugin_release', array('create'));
/**
* Register Hooks
*/
// The notifications for projects and releases are almost identical so we can use the same handler for both
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:plugin_project', __NAMESPACE__ . '\\prepare_notification');
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:plugin_release', __NAMESPACE__ . '\\prepare_notification');
// Releases are contained by a project so we need to get the notification subscriptions manually
elgg_register_plugin_hook_handler('get', 'subscriptions', __NAMESPACE__ . '\\get_release_subscriptions');
// Make sure Releases are editable
elgg_register_plugin_hook_handler('permissions_check', 'object', __NAMESPACE__ . '\\release_permissions_check');
// make projects non-commentable in the river
elgg_register_plugin_hook_handler('permissions_check:comment', 'object', __NAMESPACE__ . '\\project_comments');
// manage owner block menu
elgg_register_plugin_hook_handler('register', 'menu:owner_block', __NAMESPACE__ . '\\owner_block_menu');
// register url handlers for the 2 object subtypes
elgg_register_plugin_hook_handler('entity:url', 'object', __NAMESPACE__ . '\\release_url_handler');
elgg_register_plugin_hook_handler('entity:url', 'object', __NAMESPACE__ . '\\project_url_handler');
elgg_register_plugin_hook_handler('register', 'menu:annotation', __NAMESPACE__ . '\\ownership_request_menu');
// Special hook for searching against metadata (category)
elgg_register_plugin_hook_handler('search', 'object:plugin_project', __NAMESPACE__ . '\\search_hook');
elgg_register_plugin_hook_handler('cron', 'daily', __NAMESPACE__ . '\\update_download_counts');
// add project info to <meta> tags
elgg_register_plugin_hook_handler('head', 'page', __NAMESPACE__ . '\\prepare_page_head_meta');
/**
* Register Events
*/
elgg_register_event_handler('pagesetup', 'system', __NAMESPACE__ . '\\add_submenus');
elgg_register_event_handler('upgrade', 'system', __NAMESPACE__ . '\\upgrades');
elgg_register_event_handler('create', 'object', __NAMESPACE__ . '\\release_comment_notification');
elgg_register_event_handler('update', 'object', __NAMESPACE__ . '\\project_update');
//register a widget
elgg_register_widget_type('plugins', elgg_echo('plugins'), elgg_echo('plugins'), array('profile'));
// Only projects should show up in search
elgg_register_entity_type('object', 'plugin_project');
// Elgg versions (The forms expect this to be an associative array)
elgg_set_config('elgg_versions', array(
'6.1' => '6.1',
'6.0' => '6.0',
'5.1' => '5.1',
'5.0' => '5.0',
'4.3' => '4.3',
'4.2' => '4.2',
'4.1' => '4.1',
'4.0' => '4.0',
'3.3' => '3.3',
'3.2' => '3.2',
'3.1' => '3.1',
'3.0' => '3.0',
'2.3' => '2.3',
'2.2' => '2.2',
'2.1' => '2.1',
'2.0' => '2.0',
'1.12' => '1.12',
'1.11' => '1.11',
'1.10' => '1.10',
'1.9' => '1.9',
'1.8' => '1.8',
'1.7' => '1.7',
'1.6' => '1.6',
'1.5' => '1.5',
'1.2' => '1.2',
'1.0' => '1.0',
));
// GPL-compatible licenses
elgg_set_config('gpllicenses', array(
'none' => 'No license selected',
'gpl2' => 'GNU General Public License (GPL) version 2',
'lgpl2.1' => 'GNU Lesser General Public License (LGPL) version 2.1',
'berkeleydb' => 'Berkeley Database License (aka the Sleepycat Software Product License)',
'mbsd' => 'Modified BSD license',
'cbsd' => 'The Clear BSD License',
'expat' => 'Expat (MIT) License',
'freebsd' => 'FreeBSD license',
'intel' => 'Intel Open Source License',
'openbsd' => 'ISC (OpenBSD) License',
'ncsa' => 'NCSA/University of Illinois Open Source License',
'w3c' => 'W3C Software Notice and License',
'x11' => 'X11 License',
'zope' => 'Zope Public License, versions 2.0 and 2.1',
));
// Defined plugin categories
elgg_set_config('plugincats', array(
'admin' => 'Site admin',
'user' => 'User admin',
'authentication' => 'Authentication',
'tools' => 'Tools',
'spam' => 'Spam',
'communication' => 'Communication',
'events' => 'Events',
'media' => 'Media',
'photos' => 'Photos and Images',
'tpintegrations' => 'Third Party integrations',
'clients' => 'Clients',
'widgets' => 'Widgets',
'games' => 'Games',
'ecommerce' => 'eCommerce',
'languages' => 'Language packs',
'themes' => 'Themes',
'misc' => 'Misc',
'uncategorized' => 'Uncategorized',
));
/**
* Register actions
*/
$action_base = dirname(__FILE__) . "/actions/plugins";
elgg_register_action("plugins/create_project", "$action_base/create_project.php");
elgg_register_action("plugins/create_release", "$action_base/create_release.php");
elgg_register_action("plugins/save_project", "$action_base/save_project.php");
elgg_register_action("plugins/save_release", "$action_base/save_release.php");
elgg_register_action("plugins/delete_project", "$action_base/delete_project.php");
elgg_register_action("plugins/delete_release", "$action_base/delete_release.php");
elgg_register_action("plugins/delete_project_image", "$action_base/delete_project_image.php");
elgg_register_action("plugins/recommend", "$action_base/recommend.php");
elgg_register_action("plugins/add_contributors", "$action_base/add_contributors.php");
elgg_register_action("plugins/delete_contributor", "$action_base/delete_contributor.php");
elgg_register_action("plugins/request_ownership", "$action_base/request_ownership.php");
elgg_register_action("plugins/admin/upgrade", "$action_base/admin/upgrade.php", 'admin');
elgg_register_action("plugins/admin/combine", "$action_base/admin/combine.php", 'admin');
elgg_register_action("plugins/admin/normalize", "$action_base/admin/normalize.php", 'admin');
elgg_register_action("plugins/admin/search", "$action_base/admin/search.php", 'admin');
elgg_register_action("plugins/admin/transfer", "$action_base/admin/transfer.php", 'admin');
elgg_register_tag_metadata_name('plugin_type');
elgg_register_ajax_view('object/plugin_project/release_table');
}