save.php 810 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Save image action
  4. *
  5. * @author Cash Costello
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  7. */
  8. // Get input data
  9. $title = get_input('title');
  10. $description = get_input('description');
  11. $tags = get_input('tags');
  12. $guid = get_input('guid');
  13. elgg_make_sticky_form('tidypics');
  14. if (empty($title)) {
  15. register_error(elgg_echo("image:blank"));
  16. forward(REFERER);
  17. }
  18. $image = get_entity($guid);
  19. $image->title = $title;
  20. $image->description = $description;
  21. if($tags) {
  22. $image->tags = string_to_tag_array($tags);
  23. } else {
  24. $image->deleteMetadata('tags');
  25. }
  26. if (!$image->save()) {
  27. register_error(elgg_echo("image:error"));
  28. forward(REFERER);
  29. }
  30. elgg_clear_sticky_form('tidypics');
  31. system_message(elgg_echo("image:saved"));
  32. forward($image->getURL());