Commit d583d136 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1795758: site skin update not submitted by js

personal skins are submitted by js because
a background image can be added.
We dont allow this for a site skin,
so the submission method has to be changed.

behatnotneeded

Change-Id: I28f83d4bbc6318ec9ff1cc9dc899833d6ba0dcfb
(cherry picked from commit 5444b4ab)
parent d267e433
...@@ -332,25 +332,32 @@ $elements['submitform'] = array( ...@@ -332,25 +332,32 @@ $elements['submitform'] = array(
'goto' => $goto, 'goto' => $goto,
); );
$designskinform = pieform(array( $designskinelements = array(
'name' => 'designskinform', 'name' => 'designskinform',
'class' => 'jstabs form-group-nested', 'class' => 'jstabs form-group-nested',
'method' => 'post', 'method' => 'post',
'jsform' => true,
'newiframeonsubmit' => true,
'jssuccesscallback' => 'designskinform_callback',
'jserrorcallback' => 'designskinform_callback',
'plugintype' => 'core', 'plugintype' => 'core',
'pluginname' => 'skin', 'pluginname' => 'skin',
'renderer' => 'div', // don't change unless you also modify design.js to not require tables. 'renderer' => 'div', // don't change unless you also modify design.js to not require tables.
'autofocus' => false, 'autofocus' => false,
'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'), 'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'),
'elements' => $elements 'elements' => $elements
)); );
if (!$designsiteskin) {
$designskinelements['jssuccesscallback'] = 'designskinform_callback';
$designskinelements['jserrorcallback'] = 'designskinform_callback';
$designskinelements['newiframeonsubmit'] = true;
$designskinelements['jsform'] = true;
}
$designskinform = pieform($designskinelements);
$javascript = <<<EOF $javascript = <<<EOF
function designskinform_callback(form, data) { function designskinform_callback(form, data) {
designskinform_body_background_image.callback(form, data); if (typeof designskinform_body_background_image != "undefined") {
designskinform_body_background_image.callback(form, data);
}
}; };
EOF; EOF;
...@@ -391,7 +398,7 @@ function designskinform_validate(Pieform $form, $values) { ...@@ -391,7 +398,7 @@ function designskinform_validate(Pieform $form, $values) {
} }
function designskinform_submit(Pieform $form, $values) { function designskinform_submit(Pieform $form, $values) {
global $USER, $SESSION; global $USER, $SESSION, $goto;
$siteskin = (isset($values['viewskin_access']) && ($values['viewskin_access'] == 'site')); $siteskin = (isset($values['viewskin_access']) && ($values['viewskin_access'] == 'site'));
// Only an admin can create a site skin // Only an admin can create a site skin
...@@ -444,5 +451,5 @@ function designskinform_submit(Pieform $form, $values) { ...@@ -444,5 +451,5 @@ function designskinform_submit(Pieform $form, $values) {
} }
$SESSION->add_ok_msg(get_string('skinsaved', 'skin')); $SESSION->add_ok_msg(get_string('skinsaved', 'skin'));
redirect($redirect); redirect($goto);
} }
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