[Mapbender-commits] r1792 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Nov 9 09:34:28 EST 2007
Author: christoph
Date: 2007-11-09 09:34:28 -0500 (Fri, 09 Nov 2007)
New Revision: 1792
Modified:
trunk/mapbender/http/classes/class_wfs_conf.php
Log:
moved get all wfs to class_wfs
Modified: trunk/mapbender/http/classes/class_wfs_conf.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_conf.php 2007-11-09 14:30:22 UTC (rev 1791)
+++ trunk/mapbender/http/classes/class_wfs_conf.php 2007-11-09 14:34:28 UTC (rev 1792)
@@ -18,6 +18,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(dirname(__FILE__)."/class_mb_exception.php");
+require_once(dirname(__FILE__)."/class_administration.php");
require_once(dirname(__FILE__)."/../extensions/JSON.php");
class WfsConf {
@@ -26,8 +27,11 @@
/**
* Gets the configuration from the database
*/
- function __construct ($idOrIdArray) {
+ function __construct () {
+ }
+
+ public function load ($idOrIdArray) {
/*
* Check parameter and set idArray
*/
@@ -35,7 +39,7 @@
// parameter is a number
if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
- $this->getWfsConfFromDB(array(intval($idOrIdArray)));
+ $this->getWfsConfFromDB(array(intval($idOrIdArray)), $_SESSION["mb_user_id"]);
}
// parameter is an array of numbers
else if (is_array($idOrIdArray)) {
@@ -47,7 +51,7 @@
}
array_push($idArray, intval($idOrIdArray[$i]));
}
- $this->getWfsConfFromDB($idArray);
+ $this->getWfsConfFromDB($idArray, $_SESSION["mb_user_id"]);
}
// parameter is invalid
else {
@@ -63,81 +67,103 @@
/**
* get WFS conf data from database
*/
- private function getWfsConfFromDB ($idArray) {
-
- $sql = "SELECT * FROM wfs_conf ";
- $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
- $sql .= "WHERE wfs_conf.wfs_conf_id IN (";
-
- $v = array();
- $t = array();
- for ($i = 0; $i < count($idArray); $i++) {
- if ($i > 0) {$sql .= ", ";}
- $sql .= "$" . ($i+1);
- array_push($v, $idArray[$i]);
- array_push($t, 'i');
+ private function getWfsConfFromDB ($idArray, $userId) {
+ /*
+ * If a user ID is given, remove the ones the user has no access to
+ */
+ if ($userId) {
+ $idArray = array_intersect($idArray, WfsConf::getWfsConfByPermission($userId));
}
- $sql .= ")";
- $res = db_prep_query($sql, $v, $t);
-
- $checkedIdArray = array();
-
- while ($row = db_fetch_array($res)) {
-
- $id = $row["wfs_conf_id"];
-
- $sql_conf_element = "SELECT * FROM wfs_conf_element ";
- $sql_conf_element .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
- $sql_conf_element .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
- $sql_conf_element .= "AND wfs_conf_element.f_search = 1 ORDER BY wfs_conf_element.f_pos";
- $v_conf_element = array($id);
- $t_conf_element = array('i');
- $res_conf_element = db_prep_query($sql_conf_element, $v_conf_element, $t_conf_element);
-
- $elementArray = array();
- while ($row_conf_element = db_fetch_array($res_conf_element)) {
-
-
- $currentElement = array("f_search" => $row_conf_element["f_search"],
- "f_style_id" => $row_conf_element["f_style_id"],
- "f_toupper" => $row_conf_element["f_toupper"],
- "f_label" => $row_conf_element["f_label"],
- "f_label_id" => $row_conf_element["f_label_id"],
- "element_name" => $row_conf_element["element_name"],
- "element_type" => $row_conf_element["element_type"]
- );
- array_push($elementArray, $currentElement);
+ if (count($idArray) > 0) {
+ /*
+ * Get WFS configurations
+ */
+ $sql = "SELECT * FROM wfs_conf ";
+ $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
+ $sql .= "WHERE wfs_conf.wfs_conf_id IN (";
+
+ $v = array();
+ $t = array();
+ for ($i = 0; $i < count($idArray); $i++) {
+ if ($i > 0) {$sql .= ", ";}
+ $sql .= "$" . ($i+1);
+ array_push($v, $idArray[$i]);
+ array_push($t, 'i');
}
+ $sql .= ")";
- $sql_feature_type = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
- $v_feature_type = array($row["fkey_wfs_id"], $row["fkey_featuretype_id"]);
- $t_feature_type = array("i", "i");
-
- $res_feature_type = db_prep_query($sql_feature_type, $v_feature_type, $t_feature_type);
- if($row_feature_type = db_fetch_array($res_feature_type)){
- $featuretype_name = $row_feature_type["featuretype_name"];
- $featuretype_srs = $row_feature_type["featuretype_srs"];
+ $res = db_prep_query($sql, $v, $t);
+
+ while ($row = db_fetch_array($res)) {
+
+
+ /*
+ * Get WFS conf elements
+ */
+ $id = $row["wfs_conf_id"];
+
+ $sql_conf_element = "SELECT * FROM wfs_conf_element ";
+ $sql_conf_element .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+ $sql_conf_element .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+#filtered on client side
+# $sql_conf_element .= "AND wfs_conf_element.f_search = 1 ";
+ $sql_conf_element .= "ORDER BY wfs_conf_element.f_pos";
+ $v_conf_element = array($id);
+ $t_conf_element = array('i');
+ $res_conf_element = db_prep_query($sql_conf_element, $v_conf_element, $t_conf_element);
+
+ $elementArray = array();
+ while ($row_conf_element = db_fetch_array($res_conf_element)) {
+
+
+ $currentElement = array("f_search" => $row_conf_element["f_search"],
+ "f_style_id" => $row_conf_element["f_style_id"],
+ "f_toupper" => $row_conf_element["f_toupper"],
+ "f_label" => $row_conf_element["f_label"],
+ "f_label_id" => $row_conf_element["f_label_id"],
+ "f_geom" => $row_conf_element["f_geom"],
+ "element_name" => $row_conf_element["element_name"],
+ "element_type" => $row_conf_element["element_type"]
+ );
+ array_push($elementArray, $currentElement);
+ }
+
+ /*
+ * Get WFS featuretype
+ */
+ $sql_feature_type = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+ $v_feature_type = array($row["fkey_wfs_id"], $row["fkey_featuretype_id"]);
+ $t_feature_type = array("i", "i");
+
+ $res_feature_type = db_prep_query($sql_feature_type, $v_feature_type, $t_feature_type);
+ if($row_feature_type = db_fetch_array($res_feature_type)){
+ $featuretype_name = $row_feature_type["featuretype_name"];
+ $featuretype_srs = $row_feature_type["featuretype_srs"];
+ }
+
+ $currentRow = array("g_label" => $row["g_label"],
+ "g_label_id" => $row["g_label_id"],
+ "g_style" => $row["g_style"],
+ "g_button" => $row["g_button"],
+ "g_button_id" => $row["g_button_id"],
+ "g_buffer" => $row["g_buffer"],
+ "g_res_style" => $row["g_res_style"],
+ "g_use_wzgraphics" => $row["g_use_wzgraphics"],
+ "wfs_id" => $row["fkey_wfs_id"],
+ "featuretype_id" => $row["fkey_featuretype_id"],
+ "featuretype_name" => $featuretype_name,
+ "featuretype_id" => $featuretype_srs,
+ "wfs_getfeature" => $row["wfs_getfeature"],
+ "element" => $elementArray
+ );
+
+ $this->confArray[$id] = $currentRow;
}
-
- $currentRow = array("g_label" => $row["g_label"],
- "g_label_id" => $row["g_label_id"],
- "g_style" => $row["g_style"],
- "g_button" => $row["g_button"],
- "g_button_id" => $row["g_button_id"],
- "g_buffer" => $row["g_buffer"],
- "g_res_style" => $row["g_res_style"],
- "g_use_wzgraphics" => $row["g_use_wzgraphics"],
- "wfs_id" => $row["fkey_wfs_id"],
- "featuretype_id" => $row["fkey_featuretype_id"],
- "featuretype_name" => $featuretype_name,
- "featuretype_id" => $featuretype_srs,
- "wfs_getfeature" => $row["wfs_getfeature"],
- "element" => $elementArray
- );
-
- $this->confArray[$id] = $currentRow;
}
+ else {
+ $e = new mb_warning("class_wfs_conf.php: getWfsConfFromDB: You don't have access to any WFS confs. Check EDIT WFS.");
+ }
}
/** identifies the Conf-FeatureServices where the current user is owner
@@ -148,8 +174,8 @@
public static function getWfsConfByPermission($userid){
$guisByPer = array();
// 1.
- $guisByPer = $this->getGuisByPermission($userid, true);
-
+ $adm = new administration();
+ $guisByPer = $adm->getGuisByPermission($userid, true);
// 2.
if(count($guisByPer)>0){
$v = array();
@@ -194,39 +220,7 @@
var $elements;
var $namespaces;
- function getallwfs($userid){
- $this->wfs_id = array();
- $this->wfs_name = array();
- $this->wfs_title = array();
- $this->wfs_abstract = array();
-
- global $DBSERVER,$DB,$OWNER,$PW;
- $con = db_connect($DBSERVER,$OWNER,$PW);
- db_select_db($DB,$con);
- if($userid){
- $sql = "SELECT * FROM wfs WHERE wfs_owner = $1";
- $v = array($userid);
- $t = array('i');
- $res = db_prep_query($sql,$v,$t);
- }
- else{
- $sql = "SELECT * FROM wfs";
- $res = db_query($sql);
- }
-
- $cnt = 0;
- while ($row = db_fetch_array($res)){
- $this->wfs_version[$cnt] = $row["wfs_version"];
- $this->wfs_id[$cnt] = $row["wfs_id"];
- $this->wfs_name[$cnt] = $row["wfs_name"];
- $this->wfs_title[$cnt] = $row["wfs_title"];
- $this->wfs_abstract[$cnt] = $row["wfs_abstract"];
- $this->wfs_getcapabilities[$cnt] = $row["wfs_getcapabilities"];
- $this->wfs_describefeaturetype[$cnt] = $row["wfs_describefeaturetype"];
- $this->wfs_getfeature[$cnt] = $row["wfs_getfeature"];
- $cnt++;
- }
- }
+
function getfeatures($wfsid){
$this->features = new features($wfsid);
}
More information about the Mapbender_commits
mailing list