Commit 637f4493 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Only show delete button for empty folders

parent 4f4550a2
......@@ -32,7 +32,7 @@ function FileBrowser(element, source, changedircallback, actionname, actioncallb
this.lastcolumnfunc = function (r) {
var editb = INPUT({'type':'button', 'value':get_string('edit')});
editb.onclick = function () { self.openeditform(r); };
if (r.emptyfolder) {
if (r.childcount > 0) {
return TD(null, editb);
}
var deleteb = INPUT({'type':'button', 'value':get_string('delete')});
......
......@@ -158,12 +158,16 @@ class ArtefactTypeFileBase extends ArtefactType {
}
$filetypesql = "('" . join("','", PluginArtefactFile::get_artefact_types()) . "')";
$prefix = get_config('dbprefix');
$filedata = get_records_sql_array('SELECT a.id, a.artefacttype, a.mtime, f.size, a.title, a.description
$filedata = get_records_sql_array('SELECT
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description, COUNT(c.*) AS childcount
FROM ' . $prefix . 'artefact a
LEFT OUTER JOIN ' . $prefix . 'artefact_file_files f ON f.artefact = a.id
LEFT OUTER JOIN ' . $prefix . 'artefact_file_files f ON f.artefact = a.id
LEFT OUTER JOIN ' . $prefix . 'artefact c ON c.parent = a.id
WHERE a.owner = ' . $userid . '
AND a.parent' . $foldersql . "
AND a.artefacttype IN " . $filetypesql, '');
AND a.parent' . $foldersql . '
AND a.artefacttype IN ' . $filetypesql . '
GROUP BY
1, 2, 3, 4, 5, 6;', '');
if (!$filedata) {
$filedata = array();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment