protected function move_step($id) {
        require_sesskey();

        $direction = required_param('direction', PARAM_INT);

        $step = step::instance($id);
        $currentsortorder   = $step->get_sortorder();
        $targetsortorder    = $currentsortorder + $direction;

        $tour = $step->get_tour();
        $swapwith = helper::get_step_from_sortorder($tour->get_id(), $targetsortorder);

        // Set the sort order to something out of the way.
        $step->set_sortorder(-1);
        $step->persist();

        // Swap the two sort orders.
        $swapwith->set_sortorder($currentsortorder);
        $swapwith->persist();

        $step->set_sortorder($targetsortorder);
        $step->persist();

        // Reset the sort order.
        $tour->reset_step_sortorder();
        redirect($tour->get_view_link());
    }
protected function move_step($id) {
        require_sesskey();

        $direction = required_param('direction', PARAM_INT);

        $step = step::instance($id);
        $currentsortorder   = $step->get_sortorder();
        $targetsortorder    = $currentsortorder + $direction;

        $tour = $step->get_tour();
        $swapwith = helper::get_step_from_sortorder($tour->get_id(), $targetsortorder);

        // Set the sort order to something out of the way.
        $step->set_sortorder(-1);
        $step->persist();

        // Swap the two sort orders.
        $swapwith->set_sortorder($currentsortorder);
        $swapwith->persist();

        $step->set_sortorder($targetsortorder);
        $step->persist();

        // Reset the sort order.
        $tour->reset_step_sortorder();
        redirect($tour->get_view_link());
    }
protected function move_step ( $ id ) { require_sesskey ( ) ; $ direction = required_param ( 'direction' , PARAM_INT ) ; $ step = step :: instance ( $ id ) ; $ currentsortorder = $ step -> get_sortorder ( ) ; $ targetsortorder = $ currentsortorder + $ direction ; $ tour = $ step -> get_tour ( ) ; $ swapwith = helper :: get_step_from_sortorder ( $ tour -> get_id ( ) , $ targetsortorder ) ; // Set the sort order to something out of the way. $ step -> set_sortorder ( - 1 ) ; $ step -> persist ( ) ; // Swap the two sort orders. $ swapwith -> set_sortorder ( $ currentsortorder ) ; $ swapwith -> persist ( ) ; $ step -> set_sortorder ( $ targetsortorder ) ; $ step -> persist ( ) ; // Reset the sort order. $ tour -> reset_step_sortorder ( ) ; redirect ( $ tour -> get_view_link ( ) ) ; }
Move a step up or down.

@param   int     $id     The step to move.
Move a step up or down .