[ticket/416] Use only one method for moving module vertically
B3P-416
This commit is contained in:
@@ -403,11 +403,11 @@ class portal_module
|
||||
|
||||
if ($action == 'move_up')
|
||||
{
|
||||
$this->modules_manager->move_module_up($module_id);
|
||||
$this->modules_manager->move_module_vertical($module_id, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_UP);
|
||||
}
|
||||
else if ($action == 'move_down')
|
||||
{
|
||||
$this->modules_manager->move_module_down($module_id);
|
||||
$this->modules_manager->move_module_vertical($module_id, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_DOWN);
|
||||
}
|
||||
else if($action == 'move_right')
|
||||
{
|
||||
|
||||
@@ -235,39 +235,24 @@ class manager
|
||||
}
|
||||
|
||||
/**
|
||||
* Move module up one row
|
||||
* Move module vertically
|
||||
*
|
||||
* @param int $module_id ID of the module that should be moved
|
||||
* @param int $module_id Module ID
|
||||
* @param int $direction Direction of move, either -1 for up or 1 for down
|
||||
*/
|
||||
public function move_module_up($module_id)
|
||||
public function move_module_vertical($module_id, $direction)
|
||||
{
|
||||
$updated = false;
|
||||
$module_data = $this->get_move_module_data($module_id);
|
||||
|
||||
if (($module_data !== false) && ($module_data['module_order'] > 1))
|
||||
if ($module_data === false || ($direction == database_handler::MOVE_DIRECTION_UP && $module_data['module_order'] <= 1) ||
|
||||
($direction == database_handler::MOVE_DIRECTION_DOWN && $this->get_last_module_order($module_data['module_column']) == $module_data['module_order']))
|
||||
{
|
||||
$updated = $this->database_handler->move_module_vertical($module_id, $module_data, database_handler::MOVE_DIRECTION_UP, 1);
|
||||
$this->handle_after_move(false, true);
|
||||
}
|
||||
|
||||
$this->handle_after_move($updated, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move module down one row
|
||||
*
|
||||
* @param int $module_id ID of the module that should be moved
|
||||
*/
|
||||
public function move_module_down($module_id)
|
||||
{
|
||||
$updated = false;
|
||||
$module_data = $this->get_move_module_data($module_id);
|
||||
|
||||
if ($module_data !== false && $this->get_last_module_order($module_data['module_column']) != $module_data['module_order'])
|
||||
else
|
||||
{
|
||||
$updated = $this->database_handler->move_module_vertical($module_id, $module_data, database_handler::MOVE_DIRECTION_DOWN, 1);
|
||||
$this->handle_after_move($this->database_handler->move_module_vertical($module_id, $module_data, $direction, 1), true);
|
||||
}
|
||||
|
||||
$this->handle_after_move($updated, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -132,24 +132,24 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
public function test_move_module_up()
|
||||
{
|
||||
self::$redirected = false;
|
||||
$this->modules_manager->move_module_up(2);
|
||||
$this->modules_manager->move_module_vertical(2, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_UP);
|
||||
$this->assertTrue(self::$redirected);
|
||||
|
||||
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE_ROW');
|
||||
self::$redirected = false;
|
||||
$this->modules_manager->move_module_up(2);
|
||||
$this->modules_manager->move_module_vertical(2, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_UP);
|
||||
$this->assertFalse(self::$redirected);
|
||||
}
|
||||
|
||||
public function test_move_module_down()
|
||||
{
|
||||
self::$redirected = false;
|
||||
$this->modules_manager->move_module_down(3);
|
||||
$this->modules_manager->move_module_vertical(3, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_DOWN);
|
||||
$this->assertTrue(self::$redirected);
|
||||
|
||||
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE_ROW');
|
||||
self::$redirected = false;
|
||||
$this->modules_manager->move_module_down(3);
|
||||
$this->modules_manager->move_module_vertical(3, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_DOWN);
|
||||
$this->assertFalse(self::$redirected);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user