Commit ec7d19fd authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

prevent views from taking on an impossible number of columns



This stems from an issue where a user's profile view somehow ended up
with numcolumns set to 6 in the database. The root cause of the problem
is unknown, but this should prevent views from entering a broken state.
Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent 24bc4d44
......@@ -239,6 +239,8 @@ $string['25,50,25'] = 'Larger centre column';
$string['15,70,15'] = 'Much larger centre column';
$string['20,30,30,20'] = 'Larger centre columns';
$string['noviewlayouts'] = 'There are no View layouts for a %s column View';
$string['cantaddcolumn'] = 'You cannot add any more columns to this view';
$string['cantremovecolumn'] = 'You cannot remove the last column from this view';
$string['blocktypecategory.feeds'] = 'External feeds';
$string['blocktypecategory.fileimagevideo'] = 'Files, images and video';
......
......@@ -1394,6 +1394,9 @@ class View {
if (!array_key_exists('before', $values) || empty($values['before'])) {
throw new ParamOutOfRangeException(get_string('missingparamcolumn', 'error'));
}
if (!array_key_exists($this->get('numcolumns') + 1, self::$layouts)) {
throw new ParamOutOfRangeException(get_string('cantaddcolumn', 'view'));
}
db_begin();
$this->set('numcolumns', $this->get('numcolumns') + 1);
if ($values['before'] != ($this->get('numcolumns') + 1)) {
......@@ -1426,6 +1429,9 @@ class View {
if (!array_key_exists('column', $values) || empty($values['column'])) {
throw new ParamOutOfRangeException(get_string('missingparamcolumn', 'error'));
}
if (!array_key_exists($this->get('numcolumns') - 1, self::$layouts)) {
throw new ParamOutOfRangeException(get_string('cantremovecolumn', 'view'));
}
db_begin();
$numcolumns = $this->get('numcolumns') - 1;
$columnmax = array(); // keep track of where we're at in each column
......
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