owner.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * show the blogs owned by the provided user
  4. */
  5. $container_guid = (int) get_input("owner_guid");
  6. $params["filter_context"] = "mine";
  7. $options = array(
  8. "type" => "object",
  9. "subtype" => "blog",
  10. "full_view" => false,
  11. );
  12. $current_user = elgg_get_logged_in_user_entity();
  13. if ($container_guid) {
  14. // access check for closed groups
  15. //group_gatekeeper();
  16. $options["owner_guid"] = $container_guid;
  17. $container = get_entity($container_guid);
  18. $params["title"] = elgg_echo("blog:title:user_blogs", array($container->name));
  19. elgg_push_breadcrumb($container->name);
  20. if ($current_user && ($container_guid == $current_user->getGUID())) {
  21. $params["filter_context"] = "mine";
  22. } elseif (elgg_instanceof($container, "group")) {
  23. $params["filter"] = false;
  24. } else {
  25. // do not show button or select a tab when viewing someone else"s posts
  26. $params["filter_context"] = "none";
  27. }
  28. }
  29. elgg_register_title_button();
  30. // show all posts for admin or users looking at their own blogs
  31. // show only published posts for other users.
  32. $show_only_published = true;
  33. if ($current_user) {
  34. if (($current_user->getGUID() == $container_guid) || $current_user->isAdmin()) {
  35. $show_only_published = false;
  36. }
  37. }
  38. if ($show_only_published) {
  39. $options["metadata_name_value_pairs"] = array(
  40. "name" => "status",
  41. "value" => "published"
  42. );
  43. }
  44. $list = elgg_list_entities_from_metadata($options);
  45. if (!$list) {
  46. $params["content"] = elgg_echo("blog:none");
  47. } else {
  48. $params["content"] = $list;
  49. }
  50. $params["sidebar"] = elgg_view("blog/sidebar", array("page" => $page_type));
  51. $body = elgg_view_layout("content", $params);
  52. echo elgg_view_page($params["title"], $body);