-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.php
82 lines (59 loc) · 2.07 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
<?php
require_once __DIR__ . '/lib/functions.php';
elgg_register_event_handler('init', 'system', 'mygroups_init');
elgg_register_event_handler('init', 'system', 'mygroups_fields_setup', 10000);
function mygroups_init(){
$action_base = __DIR__ . '/actions/mygroups';
elgg_register_action("mygroups/save", "$action_base/save.php");
elgg_register_page_handler('mygroups', 'mygroups_page_handler');
elgg_register_plugin_hook_handler('entity:url', 'group', 'mygroups_set_url');
}
function mygroups_fields_setup() {
$profile_defaults = [
'description' => 'longtext',
'progress' => 'text',
'activity' => 'text',
'markettype' => 'text',
'typemark' => 'text',
'offertype' => 'text',
'turnover' => 'text',
'currency' => 'text',
'location' => 'location',
'projectwebsite' => 'url',
'projectblog' => 'url',
'projectpitch' => 'url',
];
$profile_defaults = elgg_trigger_plugin_hook('profile:fields', 'mygroups', NULL, $profile_defaults);
elgg_set_config('mygroups', $profile_defaults);
// register any tag metadata names
foreach ($profile_defaults as $name => $type) {
if ($type == 'tags') {
elgg_register_tag_metadata_name($name);
// only shows up in search but why not just set this in en.php as doing it here
// means you cannot override it in a plugin
add_translation(get_current_language(), array("tag_names:$name" => elgg_echo("groups:$name")));
}
}
}
function mygroups_set_url($hook,$type,$url,$params){
$entity = $params['entity'];
if(elgg_instanceof($entity, 'group', 'mygroups')){
return "mygroups/view/{$entity->guid}";
}
}
function mygroups_page_handler($segments) {
switch ($segments[0]) {
case 'add':
echo elgg_view_resource('mygroups/add');
break;
case 'view':
$resource_vars['guid'] = elgg_extract(1, $segments);
echo elgg_view_resource('mygroups/view', $resource_vars);
break;
case 'all':
default:
echo elgg_view_resource('mygroups/all');
break;
}
return true;
}