elementArray as $element) { if ($element->geom) { return $element->name; } } $e = new mb_warning("This WFS conf doesn't have a geometry column."); return null; } /** * Finds the featuretype element which stores the authentication data. * * @return String */ public function getAuthElement () { foreach ($this->elementArray as $element) { if (!empty($element->authVarname)) { #$validname = preg_match('/^\$_[a-zA-z]+(\[\"[a-zA-Z_]+\"\])?$/', $element->authVarname); #if ($validname === 1) { return $element; #} #else { # $e = new mb_exception("Found auth element, but variable name is not valid: " . $element->authVarname); #} } } return null; } /** * Checks if the user currently logged in is allowed to access * the WFS configuration * * @return Boolean */ private function accessAllowed () { if ($_SESSION["mb_user_id"]) { $user = new User($_SESSION["mb_user_id"]); $allowedWfsConfIds = $user->getWfsConfByPermission(); $idArray = array_intersect(array($this->id), $allowedWfsConfIds); if (count($idArray) === 1) { return true; } } return false; } /** * 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 = <<id); $t = array("i"); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); $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 = $row["fkey_wfs_id"]; $wfsConf->featureTypeId = $row["fkey_featuretype_id"]; $sql = <<id); $t = array('i'); $res = db_prep_query($sql, $v, $t); while ($row = db_fetch_array($res)) { $element = new WfsConfigurationElement(); $element->name = $row["element_name"]; $element->type = $row["element_type"]; $element->search = $row["f_search"]; $element->styleId = $row["f_style_id"]; $element->toUpper = $row["f_toupper"]; $element->label = $row["f_label"]; $element->labelId = $row["f_label_id"]; $element->geom = $row["f_geom"]; $element->show = $row["f_show"]; $element->mandatory = $row["f_mandatory"]; $element->respos = $row["f_respos"]; $element->minInput = $row["f_min_input"]; $element->formElementHtml = $row["f_form_element_html"]; $element->authVarname = stripslashes($row["f_auth_varname"]); $element->detailpos = $row["f_detailpos"]; $element->operator = $row["f_operator"]; $element->showDetail = $row["f_show_detail"]; array_push($wfsConf->elementArray, $element); } return $wfsConf; } } ?>