Commit 646a1c78 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Configuration for upload copyright agreement

parent 527c1ca5
......@@ -124,7 +124,7 @@ $form = pieform(array(
'highlight' => null,
'config' => array(
'upload' => true,
'uploadagreement' => true,
'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'),
'createfolder' => false,
'edit' => false,
'select' => true,
......
......@@ -215,6 +215,12 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
// type declared by the browser if we see an image.
}
if ($oldversion < 2009033000) {
if (!get_record('artefact_config', 'plugin', 'file', 'field', 'uploadagreement')) {
insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'uploadagreement', 'value' => 1));
}
}
return $status;
}
......
......@@ -70,7 +70,14 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$smarty->assign('selectedlist', $selected);
$selectedliststr = json_encode($selected);
}
$smarty->assign('agreementtext', get_field('site_content', 'content', 'name', 'uploadcopyright'));
if ($config['uploadagreement']) {
if (get_config_plugin('artefact', 'file', 'usedefaultagreement')) {
$smarty->assign('agreementtext', get_string('uploadcopyrightdefaultcontent', 'install'));
}
else {
$smarty->assign('agreementtext', get_field('site_content', 'content', 'name', 'uploadcopyright'));
}
}
$filedata = ArtefactTypeFileBase::get_my_files_data($folder, $userid, $group, $institution);
$smarty->assign('filelist', $filedata);
......@@ -575,7 +582,7 @@ function pieform_element_filebrowser_changefolder(Pieform $form, $element, $fold
$js = "var {$prefix} = new Uploader('{$prefix}', {$parentfolder}); {$prefix}.init();";
$js .= "{$prefix}.uploadscript = '" . get_config('wwwroot') . "artefact/file/upload2.php';";
$js .= "window.{$prefix} = {$prefix};";
if (get_config('uploadagreement')) {
if (get_config_plugin('artefact', 'file', 'uploadagreement')) {
$js .= <<<JAVASCRIPT
connect('{$prefix}_openbutton', 'onclick', function () {
addElementClass('{$prefix}_openbutton', 'hidden');
......
......@@ -89,6 +89,7 @@ $string['overwrite'] = 'Overwrite';
$string['Owner'] = 'Owner';
$string['parentfolder'] = 'Parent folder';
$string['Preview'] = 'Preview';
$string['requireagreement'] = 'Require Agreement';
$string['savechanges'] = 'Save changes';
$string['selectafile'] = 'Select a file';
$string['Size'] = 'Size';
......@@ -98,6 +99,8 @@ $string['titlefieldisrequired'] = 'The name field is required';
$string['Type'] = 'Type';
$string['unlinkthisfilefromblogposts?'] = 'This file is attached to one or more blog posts. If you delete the file, it will be removed from these posts.';
$string['upload'] = 'Upload';
$string['uploadagreement'] = 'Upload Agreement';
$string['uploadagreementdescription'] = 'Enable this option if you would like to force users to agree to the text below before they can upload a file to the site.';
$string['uploadexceedsquota'] = 'Uploading this file would exceed your disk quota. Try deleting some files you have uploaded.';
$string['uploadfile'] = 'Upload file';
$string['uploadfileexistsoverwritecancel'] = 'A file with that name already exists. You can rename the file you are about to upload, or overwrite the existing file.';
......@@ -106,6 +109,8 @@ $string['uploadoffilecomplete'] = 'Upload of %s complete';
$string['uploadoffilefailed'] = 'Upload of %s failed';
$string['uploadoffiletofoldercomplete'] = 'Upload of %s to %s complete';
$string['uploadoffiletofolderfailed'] = 'Upload of %s to %s failed';
$string['usedefaulttext'] = 'Use Default Text';
$string['usedefaultdescription'] = 'Use the default agreement below and ignore the text configured on <a href="%sadmin/site/pages.php">Edit Site Pages</a>.';
$string['youmustagreetothecopyrightnotice'] = 'You must agree to the copyright notice';
$string['fileuploadedtofolderas'] = '%s uploaded to %s as "%s"';
$string['fileuploadedas'] = '%s uploaded as "%s"';
......
......@@ -88,6 +88,7 @@ class PluginArtefactFile extends PluginArtefact {
public static function postinst($prevversion) {
if ($prevversion == 0) {
set_config_plugin('artefact', 'file', 'defaultquota', 52428800);
set_config_plugin('artefact', 'file', 'uploadagreement', 1);
}
self::resync_filetype_list();
}
......@@ -536,7 +537,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
'edit' => $edit,
'config' => array(
'upload' => true,
'uploadagreement' => true,
'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'),
'createfolder' => true,
'edit' => true,
'select' => false,
......@@ -969,6 +970,36 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
'collapsible' => true
);
// Require user agreement before uploading files
// Rework this when/if we provide translatable agreements
$uploadagreement = get_config_plugin('artefact', 'file', 'uploadagreement');
$usedefaultagreement = get_config_plugin('artefact', 'file', 'usedefaultagreement');
$elements['uploadagreementfieldset'] = array(
'type' => 'fieldset',
'legend' => get_string('uploadagreement', 'artefact.file'),
'elements' => array(
'uploadagreementdescription' => array(
'value' => '<tr><td colspan="2">' . get_string('uploadagreementdescription', 'artefact.file') . '</td></tr>'
),
'uploadagreement' => array(
'title' => get_string('requireagreement', 'artefact.file'),
'type' => 'checkbox',
'defaultvalue' => $uploadagreement,
),
'usedefaultagreement' => array(
'title' => get_string('usedefaulttext', 'artefact.file'),
'description' => get_string('usedefaultdescription', 'artefact.file', get_config('wwwroot')),
'type' => 'checkbox',
'defaultvalue' => $usedefaultagreement,
),
'defaulttext' => array(
'type' => 'html',
'value' => get_string('uploadcopyrightdefaultcontent', 'install'),
),
),
'collapsible' => true
);
// Profile icon size
$currentwidth = get_config_plugin('artefact', 'file', 'profileiconwidth');
$currentheight = get_config_plugin('artefact', 'file', 'profileiconheight');
......@@ -1013,6 +1044,8 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
set_config_plugin('artefact', 'file', 'defaultquota', $values['defaultquota']);
set_config_plugin('artefact', 'file', 'profileiconwidth', $values['profileiconwidth']);
set_config_plugin('artefact', 'file', 'profileiconheight', $values['profileiconheight']);
set_config_plugin('artefact', 'file', 'uploadagreement', $values['uploadagreement']);
set_config_plugin('artefact', 'file', 'usedefaultagreement', $values['usedefaultagreement']);
}
public static function short_size($bytes, $abbr=false) {
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2009021301;
$config->version = 2009033000;
$config->release = '1.1.0';
?>
Markdown is supported
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