require_once dirname(__FILE__) . "/../classes/class_administration.php";
require_once dirname(__FILE__) . "/../classes/class_wfs.php";
include_once dirname(__FILE__) . "/../extensions/JSON.php";
//db connection
$con = db_connect(DBSERVER, OWNER, PW);
db_select_db(DB, $con);
$json = new Services_JSON();
$obj = $json->decode(stripslashes($_REQUEST['obj']));
//workflow:
switch ($obj->action) {
    case 'getServices':
        $obj->services = getServices($obj);
        sendOutput($obj);
        break;
    case 'getWfsConfData':
        $obj->wfsConf = getWfsConfData($obj->wfs);
        sendOutput($obj);
        break;
    case 'getAssignedGuis':
        $obj->assignedGuis = getAssignedGuis($obj);
        sendOutput($obj);
        break;
    case 'deleteSelectedConfs':
        deleteWfsConf($obj);
        sendOutput($obj);
        break;
    default:
        sendOutput("no action specified...");
}
/*
 * Get all services (ids and titles) where the current user is owner
function getAssignedConfs($obj)
{
    global $con;
    $assignedConfs = array();
    $confs = getWfsConfData($obj->selectedWfs);
    if ($confs === false || is_null($confs)) {
        return false;
    }
    $sql = "SELECT * FROM gui_wfs_conf WHERE fkey_gui_id = \$1 AND fkey_wfs_conf_id IN (" . join(",", $confs['id']) . ")";
    $v = array($obj->selectedGui);
    $t = array('s');
    $res = db_prep_query($sql, $v, $t);
    if (!$res) {
        $e = new mb_exception("Error: SQL: " . $sql . " -> Gui: " . $obj->selectedGui);
    }
    while ($row = db_fetch_array($res)) {
        array_push($assignedConfs, $row['fkey_wfs_conf_id']);
    }
    return $assignedConfs;
}