selectalbum.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Tidypics plugin
  4. *
  5. * Selection of album to upload new images to
  6. *
  7. * (c) iionly 2013-2014
  8. * Contact: iionly@gmx.de
  9. * Website: https://github.com/iionly
  10. * License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
  11. *
  12. */
  13. $owner_guid = get_input('owner_guid', elgg_get_logged_in_user_guid());
  14. $owner = get_entity($owner_guid);
  15. if (!($owner instanceof ElggUser || $owner instanceof ElggGroup)) {
  16. $owner = elgg_get_logged_in_user_entity();
  17. }
  18. $action = "action/photos/image/selectalbum";
  19. $albums = elgg_get_entities(array('type' => 'object', 'subtype' => 'album', 'container_guid' => $owner->getGUID(), 'limit' => false));
  20. $album_options = array();
  21. $album_options[-1] = elgg_echo('album:create');
  22. if ($albums) {
  23. foreach ($albums as $album) {
  24. $album_title = $album->getTitle();
  25. if (strlen($album_title) > 50) {
  26. $album_title = substr($album_title, 0, 47).'...';
  27. }
  28. $album_options[$album->guid] = $album_title;
  29. }
  30. }
  31. $body = "<div style=\"width:400px;\">".elgg_echo('tidypics:album_select')."<br><br>";
  32. $body .= elgg_view('input/hidden', array('name' => 'owner_guid','value' => $owner->guid));
  33. $body .= elgg_view('input/dropdown', array('name' => 'album_guid',
  34. 'value' => '',
  35. 'options_values' => $album_options));
  36. $body .= "<br><br>";
  37. $body .= elgg_view('input/submit', array('value' => elgg_echo('tidypics:continue'))).'</div>';
  38. echo elgg_view('input/form', array('action' => $action, 'body' => $body));