hide.php 781 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. $action = get_input('hide');
  3. $file_guid = get_input('guid');
  4. if (($file = get_entity($file_guid)) && ($file->getSubtype() == 'file')) {
  5. if ($file->canEdit()) {
  6. if ($action == 'show') {
  7. $file->show_in_widget = time();
  8. } elseif ($action == 'hide') {
  9. unset($file->show_in_widget);
  10. }
  11. $file->save();
  12. }
  13. }
  14. $options = array(
  15. "type" => "object",
  16. "subtype" => FILE_TOOLS_SUBTYPE,
  17. "container_guid" => $file->getOwnerGUID(),
  18. "limit" => false,
  19. "relationship" => FILE_TOOLS_RELATIONSHIP,
  20. "relationship_guid" => $file->getGUID(),
  21. "inverse_relationship" => true
  22. );
  23. if (stristr($_SERVER["HTTP_REFERER"], "file")) {
  24. if ($folders = elgg_get_entities_from_relationship($options)) {
  25. $folder = $folders[0];
  26. forward($folder->getURL());
  27. }
  28. }
  29. forward(REFERER);