forked from jonabasque/proposals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.php
77 lines (64 loc) · 1.93 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
<?php
/**
* Proposals
*
* @package Proposals
*
*/
elgg_register_event_handler('init', 'system', 'proposals_init');
/**
* Init proposals plugin.
*/
function proposals_init() {
if (!elgg_is_active_plugin('crud')) {
return;
}
// register proposals library
elgg_register_library('elgg:proposals', elgg_get_plugins_path() . 'proposals/lib/proposals.php');
// add to the main css
elgg_extend_view('css/elgg', 'proposals/css');
// Add group option
add_group_tool_option('proposals', elgg_echo('proposals:enableproposals'), false);
elgg_extend_view('groups/tool_latest', 'proposals/group_module');
//
$action_path = elgg_get_plugins_path() . 'proposals/actions/proposals';
elgg_register_action("proposals/vote", "$action_path/vote.php");
elgg_register_plugin_hook_handler('permissions_check:annotate', 'object', 'proposals_user_can_vote');
// data types
$variables = array(
'title' => 'text',
'description' => 'longtext',
#'tags' => 'tags',
'access_id' => 'access',
);
$crud = crud_register_type('decision', $variables);
$crud->children_type = 'proposal';
// the following is to not overwrite module if assemblies set it
// before, since we don't need explicit module.
if ($crud->module == 'decision') {
$crud->module = 'proposals';
}
//$crud->module = 'proposals';
$crud->owner_menu = 'group';
$variables = array(
'title' => 'text',
'description' => 'longtext',
'tags' => 'tags',
'access_id' => 'access',
'improves_guid' => array(
'type' => 'url',
'input_view' => 'hidden',
'output_view' => 'proposal',
'default_value' => get_input('improves'),
),
);
$crud = crud_register_type('proposal', $variables);
#$crud->children_type = 'agenda_point';
$crud->module = 'proposals';
}
function proposals_user_can_vote($hook, $type, $return, $params) {
if ($params['annotation_name'] == 'votes') {
$return = $params['entity']->getContainerEntity()->isMember($params['user']);
}
return $return;
}