[ticket/416] Fix incorrect behavior discovered by tests
B3P-416
This commit is contained in:
@@ -443,6 +443,12 @@ class portal_module
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not add modules that shouldn't be added
|
||||||
|
if (!$this->modules_constraints->can_add_module($this->c_class, $add_column))
|
||||||
|
{
|
||||||
|
trigger_error($this->user->lang('UNABLE_TO_ADD_MODULE') . adm_back_link($this->u_action), E_USER_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
// Do not install if module already exists in the
|
// Do not install if module already exists in the
|
||||||
// column and it can't be added more than once
|
// column and it can't be added more than once
|
||||||
if (!$this->c_class->can_multi_include() && !$this->modules_constraints->can_move_module($this->portal_columns->number_to_string($add_column), $module_classname))
|
if (!$this->c_class->can_multi_include() && !$this->modules_constraints->can_move_module($this->portal_columns->number_to_string($add_column), $module_classname))
|
||||||
@@ -512,6 +518,12 @@ class portal_module
|
|||||||
// Find new modules
|
// Find new modules
|
||||||
foreach ($modules_list as $module_class => $module)
|
foreach ($modules_list as $module_class => $module)
|
||||||
{
|
{
|
||||||
|
// Module can't be added to this column
|
||||||
|
if (!$this->modules_constraints->can_add_module($module, $add_column))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Do not install if module already exists in the
|
// Do not install if module already exists in the
|
||||||
// column and it can't be added more than once
|
// column and it can't be added more than once
|
||||||
if (!$module->can_multi_include() && !$this->modules_constraints->can_move_module($this->portal_columns->number_to_string($add_column), $module_class))
|
if (!$module->can_multi_include() && !$this->modules_constraints->can_move_module($this->portal_columns->number_to_string($add_column), $module_class))
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ $lang = array_merge($lang, array(
|
|||||||
'B3P_FILE_NOT_FOUND' => 'The requested file could not be found',
|
'B3P_FILE_NOT_FOUND' => 'The requested file could not be found',
|
||||||
'UNABLE_TO_MOVE' => 'It is not possible to move the block to the selected column.',
|
'UNABLE_TO_MOVE' => 'It is not possible to move the block to the selected column.',
|
||||||
'UNABLE_TO_MOVE_ROW' => 'It is not possible to move the block to the selected row.',
|
'UNABLE_TO_MOVE_ROW' => 'It is not possible to move the block to the selected row.',
|
||||||
|
'UNABLE_TO_ADD_MODULE' => 'It is not possible to add the module to the selected column.',
|
||||||
'DELETE_MODULE_CONFIRM' => 'Are you sure you wish to delete the module "%1$s"?',
|
'DELETE_MODULE_CONFIRM' => 'Are you sure you wish to delete the module "%1$s"?',
|
||||||
'MODULE_RESET_SUCCESS' => 'Successfully reset the module settings.',
|
'MODULE_RESET_SUCCESS' => 'Successfully reset the module settings.',
|
||||||
'MODULE_RESET_CONFIRM' => 'Are you sure you wish to reset the settings of the module "%1$s"?',
|
'MODULE_RESET_CONFIRM' => 'Are you sure you wish to reset the settings of the module "%1$s"?',
|
||||||
|
|||||||
@@ -139,6 +139,19 @@ class constraints_handler
|
|||||||
return $this->check_module_already_exists($target_column, $module_class);
|
return $this->check_module_already_exists($target_column, $module_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if module can be moved to desired column
|
||||||
|
*
|
||||||
|
* @param \board3\portal\modules\module_interface $module
|
||||||
|
* @param string $column Column string
|
||||||
|
*
|
||||||
|
* @return bool True if module can be moved, false if not
|
||||||
|
*/
|
||||||
|
public function can_add_module($module, $column)
|
||||||
|
{
|
||||||
|
return $module->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($column));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if module already exists in specified target column type
|
* Check if module already exists in specified target column type
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user