[ticket/416] Reduce size of can_move_module() method

B3P-416
This commit is contained in:
Marc Alexander
2014-12-01 13:45:27 +01:00
parent a1ec325790
commit 8294faf6e6

View File

@@ -122,41 +122,34 @@ class constraints_handler
*/ */
public function can_move_module($target_column, $module_class) public function can_move_module($target_column, $module_class)
{ {
$submit = true;
if (is_array($target_column)) if (is_array($target_column))
{ {
foreach ($target_column as $column) foreach ($target_column as $column)
{ {
if (!$this->can_move_module($column, $module_class)) if (!$this->can_move_module($column, $module_class))
{ {
$submit = false; return false;
} }
} }
} }
// do we want to add the module to the side columns or to the center columns? // Check if module already exists in the target columns
if (in_array($target_column, array('left', 'right'))) if (isset($this->module_column[$module_class]))
{ {
// does the module already exist in the side columns? // does the module already exist in the side columns?
if (isset($this->module_column[$module_class]) && if (in_array($target_column, array('left', 'right')) &&
(in_array('left', $this->module_column[$module_class]) || in_array('right', $this->module_column[$module_class]))) (in_array('left', $this->module_column[$module_class]) || in_array('right', $this->module_column[$module_class])))
{ {
$submit = false; return false;
} }
}
else if (in_array($target_column, array('center', 'top', 'bottom')))
{
// does the module already exist in the center columns? // does the module already exist in the center columns?
if (isset($this->module_column[$module_class]) && else if (in_array($target_column, array('center', 'top', 'bottom')) &&
(in_array('center', $this->module_column[$module_class]) || (in_array('center', $this->module_column[$module_class]) || in_array('top', $this->module_column[$module_class]) || in_array('bottom', $this->module_column[$module_class])))
in_array('top', $this->module_column[$module_class]) ||
in_array('bottom', $this->module_column[$module_class])))
{ {
$submit = false; return false;
} }
} }
return $submit; return true;
} }
} }