start.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Proposals
  4. *
  5. * @package Proposals
  6. *
  7. */
  8. elgg_register_event_handler('init', 'system', 'proposals_init');
  9. /**
  10. * Init proposals plugin.
  11. */
  12. function proposals_init() {
  13. if (!elgg_is_active_plugin('crud')) {
  14. return;
  15. }
  16. // register proposals library
  17. elgg_register_library('elgg:proposals', elgg_get_plugins_path() . 'proposals/lib/proposals.php');
  18. // add to the main css
  19. elgg_extend_view('css/elgg', 'proposals/css');
  20. // Add group option
  21. add_group_tool_option('proposals', elgg_echo('proposals:enableproposals'), false);
  22. elgg_extend_view('groups/tool_latest', 'proposals/group_module');
  23. //
  24. $action_path = elgg_get_plugins_path() . 'proposals/actions/proposals';
  25. elgg_register_action("proposals/vote", "$action_path/vote.php");
  26. elgg_register_plugin_hook_handler('permissions_check:annotate', 'object', 'proposals_user_can_vote');
  27. // data types
  28. $variables = array(
  29. 'title' => 'text',
  30. 'description' => 'longtext',
  31. #'tags' => 'tags',
  32. 'access_id' => 'access',
  33. );
  34. $crud = crud_register_type('decision', $variables);
  35. $crud->children_type = 'proposal';
  36. // the following is to not overwrite module if assemblies set it
  37. // before, since we don't need explicit module.
  38. if ($crud->module == 'decision') {
  39. $crud->module = 'proposals';
  40. }
  41. //$crud->module = 'proposals';
  42. $crud->owner_menu = 'group';
  43. $variables = array(
  44. 'title' => 'text',
  45. 'description' => 'longtext',
  46. 'tags' => 'tags',
  47. 'access_id' => 'access',
  48. 'improves_guid' => array(
  49. 'type' => 'url',
  50. 'input_view' => 'hidden',
  51. 'output_view' => 'proposal',
  52. 'default_value' => get_input('improves'),
  53. ),
  54. );
  55. $crud = crud_register_type('proposal', $variables);
  56. #$crud->children_type = 'agenda_point';
  57. $crud->module = 'proposals';
  58. }
  59. function proposals_user_can_vote($hook, $type, $return, $params) {
  60. if ($params['annotation_name'] == 'votes') {
  61. $return = $params['entity']->getContainerEntity()->isMember($params['user']);
  62. }
  63. return $return;
  64. }