$availableWfsConfIds = $user->getWfsConfByPermission(Mapbender::session()->get("mb_user_gui")); $obj = new WfsConf(); $obj->load($availableWfsConfIds); $json = new Mapbender_JSON(); $output = $json->encode($obj->confArray); echo $output; } else { if ($command == "getSearchResults") { $wfs_conf_id = $_REQUEST["wfs_conf_id"]; $backlink = $_REQUEST["backlink"]; $frame = $_REQUEST["frame"]; $filter = $_REQUEST["filter"]; $url = $_REQUEST["url"]; $typename = $_REQUEST["typename"]; $destSrs = $_REQUEST["destSrs"]; $wfsConf = WfsConfiguration::createFromDb($wfs_conf_id); if (is_null($wfsConf)) { sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id); } // append authorisation condition to filter $filter = checkAccessConstraint($filter, $wfs_conf_id); $admin = new administration(); $filter = administration::convertIncomingString($filter); $wfsId = $wfsConf->wfsId; $myWfsFactory = new UniversalWfsFactory(); $myWfs = $myWfsFactory->createFromDb($wfsId); $data = $myWfs->getFeature($typename, $filter, $destSrs); if ($data === null) { die('{}'); } if (defined("WFS_RESPONSE_SIZE_LIMIT") && WFS_RESPONSE_SIZE_LIMIT < strlen($data)) {
$wfsConfObj = $ajaxResponse->getParameter("wfsConf"); $wfsConf = WfsConfiguration::createFromObject($wfsConfObj); $success = WfsConfiguration::updateInDb($wfsConf); $ajaxResponse->setSuccess($success); $message = "The WFS configuration has been updated in the database."; if (!$success) { $message = "An error occured when updating the WFS configuration in the database."; } $ajaxResponse->setMessage($message); $ajaxResponse->send(); break; case "insertWfsConf": $wfsConfObj = $ajaxResponse->getParameter("wfsConf"); $wfsConf = WfsConfiguration::createFromObject($wfsConfObj); $success = false; $id = WfsConfiguration::insertIntoDb($wfsConf); if ($id === null) { $success = false; $message = "An error occured when inserting the WFS configuration into the database."; } else { $success = true; $message = "The WFS configuration has been inserted into the database. Go to 'Assign WFS conf to application' and assign the new conf to an application."; $ajaxResponse->setResult("id", $id); } $ajaxResponse->setSuccess($success); $ajaxResponse->setMessage($message); $ajaxResponse->send(); break; } // If no response is sent previously, send an error message $ajaxResponse->setMessage("Invalid command.");
/** * Creates an object from the database. * Maybe we could have a factory for this later...let's * keep it simple for now * * @return WfsConfiguration * @param $id Integer */ public static function createFromDb($id) { if (!is_numeric($id)) { return null; } $wfsConf = new WfsConfiguration(); $wfsConf->id = intval($id); if (!$wfsConf->accessAllowed()) { return null; } $sql = <<<SQL SELECT * FROM wfs_conf JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id WHERE wfs_conf.wfs_conf_id = \$1 LIMIT 1 SQL; $v = array($wfsConf->id); $t = array("i"); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); $wfsConf->abstr = $row["wfs_conf_abstract"]; $wfsConf->description = $row["wfs_conf_description"]; $wfsConf->label = $row["g_label"]; $wfsConf->labelId = $row["g_label_id"]; $wfsConf->style = $row["g_style"]; $wfsConf->button = $row["g_button"]; $wfsConf->buttonId = $row["g_button_id"]; $wfsConf->buffer = $row["g_buffer"]; $wfsConf->resStyle = $row["g_res_style"]; $wfsConf->wfsId = intval($row["fkey_wfs_id"]); $wfsConf->type = intval($row["wfs_conf_type"]); $wfsConf->featureTypeId = intval($row["fkey_featuretype_id"]); $sql = <<<SQL SELECT featuretype_name FROM wfs_featuretype WHERE featuretype_id = \$1 LIMIT 1 SQL; $v = array($wfsConf->featureTypeId); $t = array("i"); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); $wfsConf->featureTypeName = $row["featuretype_name"]; $sql = <<<SQL SELECT * FROM wfs_conf_element JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id WHERE wfs_conf_element.fkey_wfs_conf_id = \$1 ORDER BY wfs_conf_element.f_id SQL; $v = array($wfsConf->id); $t = array('i'); $res = db_prep_query($sql, $v, $t); while ($row = db_fetch_array($res)) { $element = new WfsConfigurationElement(); $element->id = intval($row["element_id"]); $element->name = $row["element_name"]; $element->type = $row["element_type"]; $element->search = intval($row["f_search"]); $element->pos = intval($row["f_pos"]); $element->edit = intval($row["f_edit"]); $element->styleId = $row["f_style_id"]; $element->toUpper = intval($row["f_toupper"]); $element->label = $row["f_label"]; $element->labelId = $row["f_label_id"]; $element->geom = intval($row["f_geom"]); $element->show = intval($row["f_show"]); $element->mandatory = intval($row["f_mandatory"]); $element->respos = intval($row["f_respos"]); $element->minInput = intval($row["f_min_input"]); // $element->formElementHtmlTemplate = $row["f_html_template"]; $element->formElementHtml = $row["f_form_element_html"]; $element->authVarname = stripslashes($row["f_auth_varname"]); $element->detailPos = intval($row["f_detailpos"]); $element->operator = $row["f_operator"]; $element->showDetail = intval($row["f_show_detail"]); $element->helptext = $row["f_helptext"]; $element->category = $row["f_category_name"]; $wfsConf->elementArray[] = $element; } $wfsConf->id = intval($id); return $wfsConf; }