pickercallback.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Elgg friends picker callback
  4. *
  5. * @package Elgg.Core
  6. * @subpackage Social.Collections
  7. */
  8. // Load Elgg engine
  9. require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");
  10. $site_url = elgg_get_site_url();
  11. // Get callback type (list or picker)
  12. $type = get_input('type', 'picker');
  13. $collection = (int) get_input('collection', 0);
  14. $members = get_members_of_access_collection($collection, true);
  15. if (!$members) {
  16. $members = array();
  17. }
  18. $friendspicker = (int) get_input('friendspicker', 0);
  19. // Get page owner (bomb out if there isn't one)
  20. $pageowner = elgg_get_page_owner_entity();
  21. if (!$pageowner) {
  22. forward();
  23. exit;
  24. }
  25. // Depending on the view type, launch a different view
  26. switch($type) {
  27. case 'list':
  28. $js_segment = elgg_view('core/friends/tablelistcountupdate', array(
  29. 'friendspicker' => $friendspicker,
  30. 'count' => sizeof($members),
  31. ));
  32. $content = elgg_view('core/friends/tablelist', array(
  33. 'entities' => $members,
  34. 'content' => $js_segment,
  35. ));
  36. break;
  37. default:
  38. $friends = $pageowner->getFriends(array('limit' => 0));
  39. $content = elgg_view('input/friendspicker', array(
  40. 'entities' => $friends,
  41. 'value' => $members,
  42. 'callback' => true,
  43. 'friendspicker' => $friendspicker,
  44. 'collection_id' => $collection,
  45. 'formtarget' => $site_url . 'action/friends/collections/edit',
  46. ));
  47. break;
  48. }
  49. // Output the content
  50. echo $content;