page_handlers.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * All page handlers are bundled here
  4. */
  5. /**
  6. * Take over the groupicon page handler for fallback
  7. *
  8. * @param array $page the url elements
  9. *
  10. * @return void
  11. */
  12. function group_tools_groupicon_page_handler($page) {
  13. // group guid
  14. if (!isset($page[0])) {
  15. header("HTTP/1.1 400 Bad Request");
  16. exit;
  17. }
  18. $group_guid = $page[0];
  19. $group = get_entity($group_guid);
  20. if (empty($group) || !elgg_instanceof($group, "group")) {
  21. header("HTTP/1.1 400 Bad Request");
  22. exit;
  23. }
  24. $owner_guid = $group->getOwnerGUID();
  25. $icontime = (int) $group->icontime;
  26. if (empty($icontime)) {
  27. header("HTTP/1.1 404 Not Found");
  28. exit;
  29. }
  30. // size
  31. $size = "medium";
  32. if (isset($page[1])) {
  33. $icon_sizes = elgg_get_config("icon_sizes");
  34. if (!empty($icon_sizes) && array_key_exists($page[1], $icon_sizes)) {
  35. $size = $page[1];
  36. }
  37. }
  38. $params = array(
  39. "group_guid" => $group_guid,
  40. "guid" => $owner_guid,
  41. "size" => $size,
  42. "icontime" => $icontime
  43. );
  44. $url = elgg_http_add_url_query_elements("mod/group_tools/pages/groups/thumbnail.php", $params);
  45. forward($url);
  46. }