Commit 2d051472 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Warn before letting users access empty views (bug 407)

parent 0271a6d7
......@@ -292,6 +292,7 @@ $string['editview'] = 'Edit View';
$string['editviewinformation'] = 'Edit View Information';
$string['myviews'] = 'My Views';
$string['notownerofview'] = 'You are not the owner of this view';
$string['reallyaddaccesstoemptyview'] = 'Your view contains no artefacts. Do you really want to give these users access to the view?';
$string['saveaccess'] = 'Save Access';
$string['submitview'] = 'Submit View';
$string['submitviewfailed'] = 'Submit view failed';
......
......@@ -35,6 +35,22 @@ $createid = param_integer('createid', null);
$data = $SESSION->get('create_' . $createid);
if (empty($data['artefacts'])) {
$confirmmessage = get_string('reallyaddaccesstoemptyview');
$backpage = get_config('wwwroot') . 'view/create3.php?createid=' . $createid;
$js = <<<EOF
addLoadEvent(function() {
connect('createview4_submit', 'onclick', function () {
var accesslistrows = getElementsByTagAndClassName('tr', null, 'accesslistitems');
if (accesslistrows.length > 0 && !confirm('{$confirmmessage}')) {
replaceChildNodes('accesslistitems', []);
}
});
});
EOF;
$smarty->assign('INLINEJAVASCRIPT', $js);
}
$form = array(
'name' => 'createview4',
'elements' => array(
......@@ -53,8 +69,10 @@ function createview4_submit_cancel() {
redirect('/view/');
}
function createview4_submit(Pieform $form, $values) {
global $SESSION, $USER, $createid, $data;
log_debug($values);
if (param_boolean('back')) {
$data['accesslist'] = array_values((array)$values['accesslist']);
......
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