From 496e0b79cd56310a846272bb08fe28b8d8740105 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Dec 2014 13:53:27 +0100 Subject: [PATCH] [ticket/416] Further reduce complexity of constraints_handler B3P-416 --- portal/modules/constraints_handler.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/portal/modules/constraints_handler.php b/portal/modules/constraints_handler.php index 8cdbaee2..19479bcc 100644 --- a/portal/modules/constraints_handler.php +++ b/portal/modules/constraints_handler.php @@ -134,16 +134,29 @@ class constraints_handler } // Check if module already exists in the target columns + return $this->check_module_already_exists($target_column, $module_class); + } + + /** + * Check if module already exists in specified target column type + * + * @param string $column Column to check + * @param string $module_class Module class + * + * @return bool False if it already exists, true if not + */ + public function check_module_already_exists($column, $module_class) + { if (isset($this->module_column[$module_class])) { // does the module already exist in the side columns? - if (in_array($target_column, array('left', 'right')) && + if (in_array($column, array('left', 'right')) && (in_array('left', $this->module_column[$module_class]) || in_array('right', $this->module_column[$module_class]))) { return false; } // does the module already exist in the center columns? - else if (in_array($target_column, array('center', 'top', 'bottom')) && + else if (in_array($column, array('center', 'top', 'bottom')) && (in_array('center', $this->module_column[$module_class]) || in_array('top', $this->module_column[$module_class]) || in_array('bottom', $this->module_column[$module_class]))) { return false;