public static function invoke_move_action($action, $dir, $table, $field, $key, $index, $position) {
        global $CFG, $XMLDB, $SESSION;
        require_once($CFG->libdir.'/ddllib.php');
        require_once("$CFG->dirroot/$CFG->admin/tool/xmldb/actions/XMLDBAction.class.php");
        require_once("$CFG->dirroot/$CFG->admin/tool/xmldb/actions/XMLDBCheckAction.class.php");
        $params = self::validate_parameters(self::invoke_move_action_parameters(), [
            'action' => $action,
            'dir' => $dir,
            'table' => $table,
            'field' => $field,
            'key' => $key,
            'index' => $index,
            'position' => $position
        ]);

        self::validate_context(context_system::instance());
        require_capability('moodle/site:config', context_system::instance());

        if (!in_array($action, ['move_updown_table', 'move_updown_field', 'move_updown_key', 'move_updown_index'])) {
            throw new coding_exception('Unsupported action');
        }

        $action = $params['action'];
        $actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions";
        $actionclass = $action . '.class.php';
        $actionpath = "$actionsroot/$action/$actionclass";

        if (file_exists($actionpath) && is_readable($actionpath)) {
            require_once($actionpath);
        }
        if (!class_exists($action)) {
            throw new coding_exception('Action class not found');
        }

        if (!isset($SESSION->xmldb)) {
            $XMLDB = new stdClass;
        } else {
            $XMLDB = unserialize($SESSION->xmldb);
        }

        $_POST['dir'] = $params['dir'];
        $_POST['table'] = $params['table'];
        $_POST['field'] = $params['field'];
        $_POST['key'] = $params['key'];
        $_POST['index'] = $params['index'];
        $_POST['direction'] = ($params['position'] > 0) ? 'down' : 'up';
        for ($i = 0; $i < abs($params['position']); $i++) {
            $a = new $action();
            $a->invoke();
        }
        $SESSION->xmldb = serialize($XMLDB);
    }
public static function invoke_move_action($action, $dir, $table, $field, $key, $index, $position) {
        global $CFG, $XMLDB, $SESSION;
        require_once($CFG->libdir.'/ddllib.php');
        require_once("$CFG->dirroot/$CFG->admin/tool/xmldb/actions/XMLDBAction.class.php");
        require_once("$CFG->dirroot/$CFG->admin/tool/xmldb/actions/XMLDBCheckAction.class.php");
        $params = self::validate_parameters(self::invoke_move_action_parameters(), [
            'action' => $action,
            'dir' => $dir,
            'table' => $table,
            'field' => $field,
            'key' => $key,
            'index' => $index,
            'position' => $position
        ]);

        self::validate_context(context_system::instance());
        require_capability('moodle/site:config', context_system::instance());

        if (!in_array($action, ['move_updown_table', 'move_updown_field', 'move_updown_key', 'move_updown_index'])) {
            throw new coding_exception('Unsupported action');
        }

        $action = $params['action'];
        $actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions";
        $actionclass = $action . '.class.php';
        $actionpath = "$actionsroot/$action/$actionclass";

        if (file_exists($actionpath) && is_readable($actionpath)) {
            require_once($actionpath);
        }
        if (!class_exists($action)) {
            throw new coding_exception('Action class not found');
        }

        if (!isset($SESSION->xmldb)) {
            $XMLDB = new stdClass;
        } else {
            $XMLDB = unserialize($SESSION->xmldb);
        }

        $_POST['dir'] = $params['dir'];
        $_POST['table'] = $params['table'];
        $_POST['field'] = $params['field'];
        $_POST['key'] = $params['key'];
        $_POST['index'] = $params['index'];
        $_POST['direction'] = ($params['position'] > 0) ? 'down' : 'up';
        for ($i = 0; $i < abs($params['position']); $i++) {
            $a = new $action();
            $a->invoke();
        }
        $SESSION->xmldb = serialize($XMLDB);
    }
public static function invoke_move_action ( $ action , $ dir , $ table , $ field , $ key , $ index , $ position ) { global $ CFG , $ XMLDB , $ SESSION ; require_once ( $ CFG -> libdir . '/ddllib.php' ) ; require_once ( "$CFG->dirroot/$CFG->admin/tool/xmldb/actions/XMLDBAction.class.php" ) ; require_once ( "$CFG->dirroot/$CFG->admin/tool/xmldb/actions/XMLDBCheckAction.class.php" ) ; $ params = self :: validate_parameters ( self :: invoke_move_action_parameters ( ) , [ 'action' => $ action , 'dir' => $ dir , 'table' => $ table , 'field' => $ field , 'key' => $ key , 'index' => $ index , 'position' => $ position ] ) ; self :: validate_context ( context_system :: instance ( ) ) ; require_capability ( 'moodle/site:config' , context_system :: instance ( ) ) ; if ( ! in_array ( $ action , [ 'move_updown_table' , 'move_updown_field' , 'move_updown_key' , 'move_updown_index' ] ) ) { throw new coding_exception ( 'Unsupported action' ) ; } $ action = $ params [ 'action' ] ; $ actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions" ; $ actionclass = $ action . '.class.php' ; $ actionpath = "$actionsroot/$action/$actionclass" ; if ( file_exists ( $ actionpath ) && is_readable ( $ actionpath ) ) { require_once ( $ actionpath ) ; } if ( ! class_exists ( $ action ) ) { throw new coding_exception ( 'Action class not found' ) ; } if ( ! isset ( $ SESSION -> xmldb ) ) { $ XMLDB = new stdClass ; } else { $ XMLDB = unserialize ( $ SESSION -> xmldb ) ; } $ _POST [ 'dir' ] = $ params [ 'dir' ] ; $ _POST [ 'table' ] = $ params [ 'table' ] ; $ _POST [ 'field' ] = $ params [ 'field' ] ; $ _POST [ 'key' ] = $ params [ 'key' ] ; $ _POST [ 'index' ] = $ params [ 'index' ] ; $ _POST [ 'direction' ] = ( $ params [ 'position' ] > 0 ) ? 'down' : 'up' ; for ( $ i = 0 ; $ i < abs ( $ params [ 'position' ] ) ; $ i ++ ) { $ a = new $ action ( ) ; $ a -> invoke ( ) ; } $ SESSION -> xmldb = serialize ( $ XMLDB ) ; }
WS 'tool_xmldb_invoke_move_action' that invokes a move action

@param string $action
@param string $dir
@param string $table
@param string $field
@param string $key
@param string $index
@param int $position
@throws coding_exception
WS tool_xmldb_invoke_move_action that invokes a move action