Ejemplo n.º 1
0
    if (ossim_error()) {
        die(ossim_error());
    }
    $group_dst = Policy::get_group_from_id($conn, $policy_dst);
    $policy_dst = Policy::get_list($conn, " AND id=UNHEX('{$policy_dst}')");
    if (is_array($policy_dst) && !empty($policy_dst)) {
        $policy_dst = array_shift($policy_dst);
        $order_dst = $policy_dst->get_order();
    } else {
        die('Source was an incorrect parameter.');
    }
    $log_dst = $order_dst . " (" . $policy_dst->get_id() . ")";
}
if ($group_src == $group_dst) {
    // same group => swap
    Policy::swap_simple_orders($conn, $policy_src, $policy_dst);
} else {
    // different group => especial swap
    if ($order_src < $order_dst) {
        // Only change group (do not change order value)
        if ($order_src == $order_dst - 1) {
            Policy::change_group($conn, $policy_src->get_id(), $group_dst);
        } else {
            for ($i = $order_src; $i < $order_dst - 1; $i++) {
                Policy::swap_orders($conn, $i, $i + 1, $group_dst, $ctx, "src");
            }
        }
    } else {
        if ($order_src == $order_dst) {
            Policy::change_group($conn, $policy_src->get_id(), $group_dst);
        }
Ejemplo n.º 2
0
if (preg_match("/\\:/", $dst)) {
    // dst is a group
    $groups[1] = preg_replace("/\\:.*/", "", $dst) * 1;
    $dst = Policy::get_order_from_group($conn, $groups[1], $groups[0], "min");
    // grupo destino, grupo origen
} else {
    $groups[1] = Policy::get_group_from_order($conn, $dst);
}
$change_group = $groups[1];
// need a final group change
echo "change from {$src} ({$groups['0']}) and {$dst} ({$groups['1']})<br>\n";
//logprint($conn);
if ($groups[0] == $groups[1]) {
    // same group => swap
    echo "change simple {$src} <> {$dst}<br>\n";
    Policy::swap_simple_orders($conn, $src, $dst);
} else {
    // different group => especial swap
    if ($src < $dst) {
        echo "{$src} < {$dst}<br>\n";
        // Only change group (do not change order value)
        if ($src == $dst - 1) {
            Policy::change_group($conn, $src, $groups[1]);
        } else {
            for ($i = $src; $i < $dst - 1; $i++) {
                echo "change {$i} <-> " . ($i + 1) . " and group=" . $groups[1] . "<br>\n";
                Policy::swap_orders($conn, $i, $i + 1, $groups[1], "src");
            }
        }
    } else {
        if ($src == $dst) {