start.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Elgg Donation plugin
  4. * @license: GPL v 2.
  5. * @author slyhne
  6. * @copyright Tiger-Inc I/S
  7. * @link http://tiger-inc.eu
  8. */
  9. elgg_register_event_handler('init','system','donation_init');
  10. function donation_footer_menu_hook($hook, $type, $return_value, $params) {
  11. //if (elgg_get_plugin_setting("add_donation_footer_menu_item", "donation") == "yes") {
  12. $return_value[] = ElggMenuItem::factory(array(
  13. "name" => "donations",
  14. "text" => elgg_echo("donation"),
  15. "href" => "donation"
  16. ));
  17. //}
  18. return $return_value;
  19. }
  20. function donation_init() {
  21. elgg_extend_view('css/elgg','donation/css');
  22. // Show donation status on profile
  23. if (elgg_get_plugin_setting('profile_donation', 'donation') == 'yes' && elgg_in_context('profile')) {
  24. elgg_extend_view('profile/status', 'donation/profile_donation');
  25. }
  26. if (elgg_get_plugin_setting('sidebar_donation', 'donation') != 'no') {
  27. elgg_extend_view('page/elements/sidebar', 'donation/sidebar');
  28. }
  29. // Register a page handler, so we can have nice URLs
  30. elgg_register_page_handler('donation', 'donation_page_handler');
  31. elgg_register_plugin_hook_handler("register", "menu:footer", "donation_footer_menu_hook");
  32. if (elgg_is_admin_logged_in()) {
  33. // user hover menu
  34. elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'donation_user_hover_menu');
  35. // register actions
  36. elgg_register_action("donation/add", elgg_get_plugins_path() . "donation/actions/add.php");
  37. }
  38. }
  39. function donation_page_handler($page) {
  40. // gatekeeper();
  41. $title = elgg_echo('donation:title:everyone', array(elgg_get_config('sitename')));
  42. if (elgg_is_logged_in()) {
  43. $content = elgg_view('donation/everyone');
  44. } else {
  45. $content = elgg_echo('donation:page1');
  46. }
  47. if (elgg_get_plugin_setting('sidebar_donation', 'donation') != 'yes') {
  48. $sidebar = elgg_view("donation/sidebar");
  49. }
  50. $params = array(
  51. 'content' => $content,
  52. 'title' => $title,
  53. 'sidebar' => $sidebar,
  54. );
  55. $body = elgg_view_layout('one_sidebar', $params);
  56. echo elgg_view_page($title, $body);
  57. }
  58. // Donations are announced to the river
  59. function donation_add_to_river($user, $type) {
  60. if (elgg_get_plugin_setting('useriver', 'donation') == 'yes') {
  61. add_to_river('river/donation/donation',$type, $user->guid, $user->guid);
  62. }
  63. }
  64. // Add to the user hover menu
  65. function donation_user_hover_menu($hook, $type, $return, $params) {
  66. $user = $params['entity'];
  67. $url = "action/donation/add?guid={$user->guid}";
  68. $url = elgg_add_action_tokens_to_url($url);
  69. $item = new ElggMenuItem('donation', elgg_echo('donation:add'), $url);
  70. $item->setSection('admin');
  71. $return[] = $item;
  72. return $return;
  73. }