PHPFusion\QuantumFields::_move_fields PHP Method

_move_fields() private method

### SQL Actions ###
private _move_fields ( )
    private function _move_fields()
    {
        global $aidlink;
        if (isset($_GET['action']) && isset($_GET['order']) && isnum($_GET['order']) && isset($_GET['parent_id']) && isnum($_GET['parent_id'])) {
            if (isset($_GET['cat_id']) && isnum($_GET['cat_id']) && ($_GET['action'] == 'cmu' or $_GET['action'] == 'cmd')) {
                $data = array();
                $result = dbquery("SELECT field_cat_id FROM " . $this->category_db . " WHERE field_parent='" . intval($_GET['parent_id']) . "' AND field_cat_order='" . intval($_GET['order']) . "'");
                // more than 1.
                if (dbrows($result) > 0) {
                    $data = dbarray($result);
                }
                if ($_GET['action'] == 'cmu') {
                    // category move up.
                    if (!$this->debug) {
                        $result = dbquery("UPDATE " . $this->category_db . " SET field_cat_order=field_cat_order+1 WHERE field_cat_id='" . $data['field_cat_id'] . "'");
                    }
                    if (!$this->debug) {
                        $result = dbquery("UPDATE " . $this->category_db . " SET field_cat_order=field_cat_order-1 WHERE field_cat_id='" . $_GET['cat_id'] . "'");
                    }
                } elseif ($_GET['action'] == 'cmd') {
                    if (!$this->debug) {
                        $result = dbquery("UPDATE " . $this->category_db . " SET field_cat_order=field_cat_order-1 WHERE field_cat_id='" . $data['field_cat_id'] . "'");
                    }
                    if (!$this->debug) {
                        $result = dbquery("UPDATE " . $this->category_db . " SET field_cat_order=field_cat_order+1 WHERE field_cat_id='" . $_GET['cat_id'] . "'");
                    }
                }
                if (!$this->debug) {
                    redirect(FUSION_SELF . $aidlink);
                }
            } elseif (isset($_GET['field_id']) && isnum($_GET['field_id']) && ($_GET['action'] == 'fmu' or $_GET['action'] == 'fmd')) {
                $data = array();
                $result = dbquery("SELECT field_id FROM " . $this->field_db . " WHERE field_cat='" . intval($_GET['parent_id']) . "' AND field_order='" . intval($_GET['order']) . "'");
                if (dbrows($result) > 0) {
                    $data = dbarray($result);
                }
                if ($_GET['action'] == 'fmu') {
                    // field move up.
                    if (!$this->debug) {
                        dbquery("UPDATE " . DB_USER_FIELDS . " SET field_order=field_order+1 WHERE field_id='" . $data['field_id'] . "'");
                        dbquery("UPDATE " . $this->field_db . " SET field_order=field_order-1 WHERE field_id='" . $_GET['field_id'] . "'");
                    } else {
                        print_p("Move Field ID " . $_GET['field_id'] . " Up a slot and Field ID " . $data['field_id'] . " down a slot.");
                    }
                } elseif ($_GET['action'] == 'fmd') {
                    if (!$this->debug) {
                        dbquery("UPDATE " . $this->field_db . " SET field_order=field_order-1 WHERE field_id='" . $data['field_id'] . "'");
                        dbquery("UPDATE " . $this->field_db . " SET field_order=field_order+1 WHERE field_id='" . $_GET['field_id'] . "'");
                    } else {
                        print_p("Move Field ID " . $_GET['field_id'] . " down a slot and Field ID " . $data['field_id'] . " up a slot.");
                    }
                }
                if (!$this->debug) {
                    redirect(FUSION_SELF . $aidlink);
                }
            }
        }
    }