Commit 68dc29db authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow users to turn comments on/off for individual files (bug #668236)


Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 00948483
......@@ -445,6 +445,7 @@ function pieform_element_filebrowser_doupdate(Pieform $form, $element) {
'description' => param_variable($prefix . '_edit_description'),
'tags' => param_variable($prefix . '_edit_tags'),
'folder' => $element['folder'],
'allowcomments' => param_boolean($prefix . '_edit_allowcomments'),
);
if ($form->get_property('group')) {
$data['permissions'] = array('admin' => (object) array('view' => true, 'edit' => true, 'republish' => true));
......@@ -866,6 +867,7 @@ function pieform_element_filebrowser_update(Pieform $form, $element, $data) {
$artefact->set('title', $data['title']);
$artefact->set('description', $data['description']);
$artefact->set('allowcomments', (int) $data['allowcomments']);
$oldtags = $artefact->get('tags');
$newtags = preg_split("/\s*,\s*/", trim($data['tags']));
......
......@@ -257,6 +257,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
$(self.id + '_edit_heading').innerHTML = self.filedata[id].artefacttype == 'folder' ? get_string('editfolder') : get_string('editfile');
$(self.id + '_edit_title').value = self.filedata[id].title;
$(self.id + '_edit_description').value = self.filedata[id].description == null ? '' : self.filedata[id].description;
$(self.id + '_edit_allowcomments').checked = self.filedata[id].allowcomments;
$(self.id + '_edit_tags').value = self.filedata[id].tags.join(', ');
replaceChildNodes($(self.id + '_edit_messages'));
forEach(getElementsByTagAndClassName('input', 'permission', self.id + '_edit_row'), function (elem) {
......
......@@ -302,7 +302,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
global $USER;
$select = '
SELECT
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description, a.locked,
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description, a.locked, a.allowcomments,
COUNT(DISTINCT c.id) AS childcount, COUNT (DISTINCT aa.artefact) AS attachcount, COUNT(DISTINCT va.view) AS viewcount';
$from = '
FROM {artefact} a
......@@ -327,7 +327,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
$groupby = '
GROUP BY
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description, a.locked';
a.id, a.artefacttype, a.mtime, f.size, a.title, a.description, a.locked, a.allowcomments';
$phvals = array();
......@@ -386,6 +386,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
foreach ($filedata as $item) {
$item->mtime = format_date(strtotime($item->mtime), 'strfdaymonthyearshort');
$item->tags = array();
$item->allowcomments = (bool) $item->allowcomments;
$item->icon = call_static_method(generate_artefact_class_name($item->artefacttype), 'get_icon', array('id' => $item->id));
if ($item->size) { // Doing this here now for non-js users
$item->size = ArtefactTypeFile::short_size($item->size, true);
......
......@@ -52,6 +52,10 @@
</td>
</tr>
{/if}
<tr>
<th><label>{str tag=allowcomments section=artefact.comment}</label></th>
<td><input type="checkbox" name="{$prefix}_edit_allowcomments" id="{$prefix}_edit_allowcomments" {if $fileinfo->allowcomments}checked {/if}"/></td>
</tr>
<tr>
<td></td>
<td>
......
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