hooks.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace AU\LikedContent;
  3. /**
  4. *
  5. * @param type $hook
  6. * @param type $type
  7. * @param type $return
  8. * @param type $params
  9. * @return ElggMenuItem
  10. */
  11. function owner_block($hook, $type, $return, $params) {
  12. if (elgg_instanceof($params['entity'], 'group') && $params['entity']->liked_content_enable != 'no') {
  13. $url = 'liked_content/group/' . $params['entity']->guid;
  14. $item = new \ElggMenuItem('liked_content', elgg_echo('liked_content:group:liked_content'), $url);
  15. $return[] = $item;
  16. }
  17. if (elgg_instanceof($params['entity'], 'user')) {
  18. $url = 'liked_content/user/' . $params['entity']->username;
  19. $item = new \ElggMenuItem('liked_content', elgg_echo('liked_content:user:liked_content'), $url);
  20. $return[] = $item;
  21. }
  22. return $return;
  23. }
  24. /**
  25. *
  26. * @param type $hook
  27. * @param type $type
  28. * @param type $return
  29. * @param type $params
  30. * @return type
  31. */
  32. function entity_menu($hook, $type, $return, $params) {
  33. if (elgg_get_context() != 'liked_content_widget') {
  34. return $return;
  35. }
  36. foreach ($return as $key => $item) {
  37. if ($item->getName() != 'likes_count') {
  38. unset($return[$key]);
  39. }
  40. }
  41. return $return;
  42. }