canEdit() || ($page_owner instanceof ElggGroup && $page_owner->isMember())) { elgg_require_js('file_tools/reorder'); } if (empty($sort_by)) { $sort_value = "e.time_created"; if (elgg_instanceof($page_owner, "group") && !empty($page_owner->file_tools_sort)) { $sort_value = $page_owner->file_tools_sort; } elseif ($site_sort_default = elgg_get_plugin_setting("sort", "file_tools")) { $sort_value = $site_sort_default; } $sort_by = $sort_value; } if (empty($direction)) { $sort_direction_value = "asc"; if (elgg_instanceof($page_owner, "group") && !empty($page_owner->file_tools_sort_direction)) { $sort_direction_value = $page_owner->file_tools_sort_direction; } elseif ($site_sort_direction_default = elgg_get_plugin_setting("sort_direction", "file_tools")) { $sort_direction_value = $site_sort_direction_default; } $direction = $sort_direction_value; } $wheres = array(); $wheres[] = "NOT EXISTS ( SELECT 1 FROM " . elgg_get_config("dbprefix") . "entity_relationships r WHERE r.guid_two = e.guid AND r.relationship = '" . FILE_TOOLS_RELATIONSHIP . "')"; $files_options = array( "type" => "object", "subtype" => "file", "limit" => $limit, "offset" => $offset, "container_guid" => $page_owner->getGUID() ); $files_options["joins"][] = "JOIN " . elgg_get_config("dbprefix") . "objects_entity oe ON oe.guid = e.guid"; if ($sort_by == "simpletype") { $files_options["order_by_metadata"] = array("name" => "mimetype", "direction" => $direction); } else { $files_options["order_by"] = $sort_by . " " . $direction; } $folder = false; if ($folder_guid !== false) { $folder = get_entity($folder_guid); if (!empty($folder) && elgg_instanceof($folder, "object", FILE_TOOLS_SUBTYPE) && ($folder->getContainerGUID() == $page_owner->getGUID())) { $files_options["relationship"] = FILE_TOOLS_RELATIONSHIP; $files_options["relationship_guid"] = $folder_guid; $files_options["inverse_relationship"] = false; } else { $folder = false; // just to be save $files_options["wheres"] = $wheres; } } // get the files $files = elgg_get_entities_from_relationship($files_options); // get count $files_options["count"] = true; $files_count = elgg_get_entities_from_relationship($files_options); // do we need a more button $show_more = false; if ($limit) { $show_more = $files_count > ($offset + $limit); } if (!$draw_page) { echo elgg_view("file_tools/list/files", array( "folder" => $folder, "files" => $files, "sort_by" => $sort_by, "direction" => $direction, "show_more" => $show_more, "limit" => $limit, "offset" => $offset )); } else { // build breadcrumb elgg_push_breadcrumb(elgg_echo("file"), "file/all"); elgg_push_breadcrumb($page_owner->name); // register title button to add a new file elgg_register_title_button(); // get data for tree $folders = file_tools_get_folders($page_owner->getGUID()); // build page elements $title_text = elgg_echo("file:user", array($page_owner->name)); $body = "