Commit 4d388e99 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Move upload agreement from site pages to file plugin config

parent e6a3908b
......@@ -78,8 +78,10 @@ $form['elements']['save'] = array(
'value' => get_string('save'),
);
$form = pieform($form);
$smarty = smarty();
$smarty->assign('form', pieform($form));
$smarty->assign('form', $form);
$smarty->assign('plugintype', $plugintype);
$smarty->assign('pluginname', $pluginname);
$smarty->assign('type', $type);
......
......@@ -35,7 +35,11 @@ require(dirname(dirname(dirname(__FILE__))).'/init.php');
require_once('pieforms/pieform.php');
define('TITLE', get_string('editsitepages', 'admin'));
$sitepages = get_records_array('site_content');
$sitepages = array();
$sitepagenames = site_content_pages();
if ($sitepagenames) {
$sitepages = get_records_select_array('site_content', 'name IN (' . join(',', array_map('db_quote', $sitepagenames)) . ')');
}
$pageoptions = array();
foreach ($sitepages as $page) {
$pageoptions[$page->name] = get_string($page->name, 'admin');
......
......@@ -218,6 +218,7 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
if ($oldversion < 2009033000) {
if (!get_record('artefact_config', 'plugin', 'file', 'field', 'uploadagreement')) {
insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'uploadagreement', 'value' => 1));
insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'usecustomagreement', 'value' => 1));
}
}
......
......@@ -39,7 +39,9 @@ $string['copyrightnotice'] = 'Copyright notice';
$string['create'] = 'Create';
$string['Created'] = 'Created';
$string['createfolder'] = 'Create folder';
$string['customagreement'] = 'Custom Agreement';
$string['Date'] = 'Date';
$string['defaultagreement'] = 'Default Agreement';
$string['defaultquota'] = 'Default Quota';
$string['defaultquotadescription'] = 'You can set the amount of disk space that new users will have as their quota here. Existing user quotas will not be changed.';
$string['deletefile?'] = 'Are you sure you want to delete this file?';
......@@ -109,8 +111,7 @@ $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['usecustomagreement'] = 'Use Custom Agreement';
$string['youmustagreetothecopyrightnotice'] = 'You must agree to the copyright notice';
$string['fileuploadedtofolderas'] = '%s uploaded to %s as "%s"';
$string['fileuploadedas'] = '%s uploaded as "%s"';
......
......@@ -976,7 +976,7 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
// 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');
$usecustomagreement = get_config_plugin('artefact', 'file', 'usecustomagreement');
$elements['uploadagreementfieldset'] = array(
'type' => 'fieldset',
'legend' => get_string('uploadagreement', 'artefact.file'),
......@@ -989,16 +989,24 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
'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(
'defaultagreement' => array(
'type' => 'html',
'title' => get_string('defaultagreement', 'artefact.file'),
'value' => get_string('uploadcopyrightdefaultcontent', 'install'),
),
'usecustomagreement' => array(
'title' => get_string('usecustomagreement', 'artefact.file'),
'type' => 'checkbox',
'defaultvalue' => $usecustomagreement,
),
'customagreement' => array(
'name' => 'customagreement',
'title' => get_string('customagreement', 'artefact.file'),
'type' => 'wysiwyg',
'rows' => 10,
'cols' => 80,
'defaultvalue' => get_field('site_content', 'content', 'name', 'uploadcopyright'),
),
),
'collapsible' => true
);
......@@ -1044,11 +1052,18 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
}
public static function save_config_options($values) {
global $USER;
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']);
set_config_plugin('artefact', 'file', 'usecustomagreement', $values['usecustomagreement']);
$data = new StdClass;
$data->name = 'uploadcopyright';
$data->content = $values['customagreement'];
$data->mtime = db_format_timestamp(time());
$data->mauthor = $USER->get('id');
update_record('site_content', $data, 'name');
}
public static function short_size($bytes, $abbr=false) {
......
......@@ -1876,7 +1876,7 @@ function site_menu() {
* @return array of names
*/
function site_content_pages() {
return array('about', 'home', 'loggedouthome', 'privacy', 'termsandconditions', 'uploadcopyright');
return array('about', 'home', 'loggedouthome', 'privacy', 'termsandconditions');
}
function get_site_page_content($pagename) {
......
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