[ticket/416] Reduce duplicated code in modules manager

B3P-416
This commit is contained in:
Marc Alexander
2014-11-27 13:26:01 +01:00
parent c470ebe386
commit 8738847a2d

View File

@@ -96,6 +96,20 @@ class manager
return $this; return $this;
} }
/**
* Get module object
*
* @param string $class_name Module class name
* @return null
*/
protected function get_module($class_name)
{
if (($this->module = $this->portal_helper->get_module($class_name)) === false)
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
}
/** /**
* Reset module settings to default options * Reset module settings to default options
* *
@@ -110,10 +124,7 @@ class manager
{ {
$module_data = $this->get_move_module_data($module_id); $module_data = $this->get_move_module_data($module_id);
if (!($this->module = $this->portal_helper->get_module($module_data['module_classname']))) $this->get_module($module_data['module_classname']);
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
$sql_ary = array( $sql_ary = array(
'module_name' => $this->module->get_name(), 'module_name' => $this->module->get_name(),
@@ -294,10 +305,7 @@ class manager
{ {
$module_data = $this->get_move_module_data($module_id); $module_data = $this->get_move_module_data($module_id);
if (!($this->module = $this->portal_helper->get_module($module_data['module_classname']))) $this->get_module($module_data['module_classname']);
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
$move_action = 0; $move_action = 0;
@@ -389,10 +397,7 @@ class manager
{ {
$module_data = $this->get_move_module_data($module_id); $module_data = $this->get_move_module_data($module_id);
if (!($this->module = $this->portal_helper->get_module($module_data['module_classname']))) $this->get_module($module_data['module_classname']);
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
$move_action = 0; $move_action = 0;
@@ -492,10 +497,7 @@ class manager
{ {
$module_classname = $this->request->variable('module_classname', ''); $module_classname = $this->request->variable('module_classname', '');
if (!($this->module = $this->portal_helper->get_module($module_classname))) $this->get_module($module_data['module_classname']);
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
if (confirm_box(true)) if (confirm_box(true))
{ {