Commit 29fc9513 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Don't allow invalid number of view columns during parallel editing (bug #645040)


Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 5fd0cabd
......@@ -223,6 +223,7 @@ $string['changeviewlayout'] = 'Change my View\'s column layout';
$string['backtoyourview'] = 'Back to my View';
$string['viewlayoutchanged'] = 'View layout changed';
$string['numberofcolumns'] = 'Number of columns';
$string['changecolumnlayoutfailed'] = 'Could not change the column layout. Someone else may have been editing the layout at the same time.';
$string['by'] = 'by';
......
......@@ -78,6 +78,8 @@ function viewcolumns_submit(Pieform $form, $values) {
$oldcolumns = $view->get('numcolumns');
$newcolumns = $values['numcolumns'];
db_begin();
if ($oldcolumns > $newcolumns) {
for ($i = $oldcolumns; $i > $newcolumns; $i--) {
$view->removecolumn(array('column' => $i));
......@@ -89,6 +91,16 @@ function viewcolumns_submit(Pieform $form, $values) {
}
}
$dbcolumns = get_field('view', 'numcolumns', 'id', $view->get('id'));
if ($dbcolumns != $newcolumns) {
db_rollback();
$SESSION->add_error_msg(get_string('changecolumnlayoutfailed', 'view'));
redirect(get_config('wwwroot') . 'view/columns.php?id=' . $view->get('id') . '&c=' . $category . '&new=' . $new);
}
db_commit();
if ($newcolumns > 1 && $newcolumns < 5) {
redirect(get_config('wwwroot') . 'view/layout.php?id=' . $view->get('id') . '&c=' . $category . '&new=' . $new);
}
......
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