/**
  * Loads WFS conf data from the database
  * 
  * @return Object WFS conf data.
  * @param $idOrIdArray Object May be an integer or an array of integers representing WFS conf IDs.
  */
 public function load($idOrIdArray)
 {
     // Check parameter and set idArray
     if (isset($idOrIdArray)) {
         // parameter is a number
         if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
             $idOrIdArray = array(intval($idOrIdArray));
         }
         // parameter is an array of numbers
         if (is_array($idOrIdArray)) {
             $idArray = array();
             foreach ($idOrIdArray as $id) {
                 if (!is_numeric($id)) {
                     $e = new mb_exception("Wfs_conf: constructor: wrong parameter: " . $id . " is not a number.");
                     return array();
                 }
                 array_push($idArray, intval($id));
             }
             // If a user ID is given, remove the ones the user has no access to
             if (Mapbender::session()->get("mb_user_id")) {
                 $user = new User(Mapbender::session()->get("mb_user_id"));
                 $idArray = array_intersect($idArray, $user->getWfsConfByPermission());
             }
             return $this->getWfsConfFromDb($idArray);
         } else {
             $e = new mb_exception("Wfs_conf: constructor: parameter must be number or an array of numbers.");
             return array();
         }
     } else {
         $e = new mb_exception("Wfs_conf: constructor: parameter is not valid");
         return null;
     }
 }
function getWfsConfs($myGui)
{
    $user = new User($_SESSION["mb_user_id"]);
    // get all WFS conf IDs for this application
    $availableWfsConfIds = $user->getWfsConfByPermission($myGui);
    $wfsConfObj = new WfsConf();
    $result = $wfsConfObj->load($availableWfsConfIds);
    return $result;
}
 /** identifies the Conf-FeatureServices where the current user is owner
  * 
  * @deprecated
  * @param integer 		userid the user-ID of the current user
  * @return integer[] 	the IDs of the wfs_conf-table
  */
 function getWfsConfByPermission($userid)
 {
     $e = new mb_notice("administration->getWfsConfByPermission is deprecated, use user->getWfsConfByPermission instead!");
     $user = new User($userid);
     return $user->getWfsConfByPermission();
 }
                $filter = mb_eregi_replace($pattern, $replacement, $filter);
            } else {
                $e = new mb_exception("mod_wfs_gazetteer_server: checkAccessConstraint: invalid value of variable containing user information!");
            }
        } else {
            $e = new mb_exception("mod_wfs_gazetteer_server: checkAccessConstraint: var name is not valid! (" . $auth_varname . ")");
        }
    }
    return $filter;
}
if ($command == "getWfsConf") {
    $wfsConfIdString = $_GET["wfsConfIdString"];
    if ($wfsConfIdString != "") {
        //array_keys(array_flip()) produces an array with unique entries
        $wfsConfIdArray = array_keys(array_flip(mb_split(",", $wfsConfIdString)));
        $availableWfsConfIds = $user->getWfsConfByPermission();
        $wfsConfIdArray = array_intersect($wfsConfIdArray, $availableWfsConfIds);
        if (count($wfsConfIdArray) === 0) {
            echo "no wfs conf available.";
            die;
        }
    } else {
        echo "please specify wfs conf id.";
        die;
    }
    $obj = new WfsConf();
    $obj->load($wfsConfIdArray);
    $json = new Mapbender_JSON();
    $output = $json->encode($obj->confArray);
    echo $output;
} elseif ($command == "getWfsConfsForThisApplication") {
 /**
  * Checks if the user currently logged in is allowed to access
  * the WFS configuration
  * 
  * @return Boolean
  */
 private function accessAllowed()
 {
     if (Mapbender::session()->get("mb_user_id")) {
         $user = new User(Mapbender::session()->get("mb_user_id"));
         $allowedWfsConfIds = $user->getWfsConfByPermission();
         $idArray = array_intersect(array($this->id), $allowedWfsConfIds);
         if (count($idArray) === 1) {
             return true;
         }
     }
     $e = new mb_exception("User '" . Mapbender::session()->get("mb_user_id") . "' is not allowed to access Wfs conf " . $this->id . ".");
     return false;
 }