[Mapbender-commits] r9896 - in trunk/mapbender/http: classes php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Apr 13 03:02:23 PDT 2018
Author: armin11
Date: 2018-04-13 03:02:23 -0700 (Fri, 13 Apr 2018)
New Revision: 9896
Modified:
trunk/mapbender/http/classes/class_user.php
trunk/mapbender/http/php/mod_showMetadata.php
Log:
New possibility to subscribe wfs monitoring
Modified: trunk/mapbender/http/classes/class_user.php
===================================================================
--- trunk/mapbender/http/classes/class_user.php 2018-04-13 09:46:51 UTC (rev 9895)
+++ trunk/mapbender/http/classes/class_user.php 2018-04-13 10:02:23 UTC (rev 9896)
@@ -901,15 +901,21 @@
return false;
}
- private function addSingleSubscription ($wmsId) {
- if (!is_numeric($wmsId)) {
- $e = new mb_exception("class_user.php: addSingleSubscription: WMS Id not a number.");
+ private function addSingleSubscription ($id, $serviceType = "WMS") {
+ if (!is_numeric($id)) {
+ $e = new mb_exception("class_user.php: addSingleSubscription: ".$serviceType." Id is not a number.");
return false;
}
- $id = intval($wmsId);
-
+ $id = intval($id);
if ($this->cancelSingleSubscription($id)) {
- $sql = "INSERT INTO mb_user_abo_ows (fkey_mb_user_id, fkey_wms_id) VALUES ($1, $2)";
+ switch ($serviceType) {
+ case "WMS":
+ $sql = "INSERT INTO mb_user_abo_ows (fkey_mb_user_id, fkey_wms_id) VALUES ($1, $2)";
+ break;
+ case "WFS":
+ $sql = "INSERT INTO mb_user_abo_ows (fkey_mb_user_id, fkey_wfs_id) VALUES ($1, $2)";
+ break;
+ }
$v = array($this->id, $id);
$t = array('i', 'i');
$res = db_prep_query($sql, $v, $t);
@@ -918,15 +924,22 @@
return false;
}
- private function cancelSingleSubscription ($wmsId) {
- if (!is_numeric($wmsId)) {
- $e = new mb_exception("class_user.php: cancelSingleSubscription: WMS Id not a number.");
+ private function cancelSingleSubscription ($id, $serviceType = "WMS") {
+ if (!is_numeric($id)) {
+ $e = new mb_exception("class_user.php: cancelSingleSubscription: ".$serviceType." Id not a number.");
return false;
}
- $id = intval($wmsId);
-
- $sql = "DELETE FROM mb_user_abo_ows WHERE fkey_wms_id = $1 " .
- "AND fkey_mb_user_id = $2";
+ $id = intval($id);
+ switch ($serviceType) {
+ case "WMS":
+ $sql = "DELETE FROM mb_user_abo_ows WHERE fkey_wms_id = $1 " .
+ "AND fkey_mb_user_id = $2";
+ break;
+ case "WFS":
+ $sql = "DELETE FROM mb_user_abo_ows WHERE fkey_wfs_id = $1 " .
+ "AND fkey_mb_user_id = $2";
+ break;
+ }
$v = array($id, $this->id);
$t = array('i', 'i');
$res = db_prep_query($sql, $v, $t);
@@ -933,44 +946,59 @@
return ($res) ? true : false;
}
- public function addSubscription ($wms) {
- if (is_array($wms)) {
- foreach ($wms as $wmsId) {
- $this->addSingleSubscription($wmsId);
+ public function addSubscription ($services, $serviceType = "WMS") {
+ if (is_array($services)) {
+ foreach ($services as $serviceId) {
+ $this->addSingleSubscription($serviceId, $serviceType);
}
}
else {
- $this->addSingleSubscription($wms);
+ $this->addSingleSubscription($services, $serviceType);
}
}
- public function cancelSubscription ($wms) {
- if (is_array($wms)) {
- foreach ($wms as $wmsId) {
- $this->cancelSingleSubscription($wmsId);
+ public function cancelSubscription ($services, $serviceType = "WMS") {
+ if (is_array($services)) {
+ foreach ($services as $serviceId) {
+ $this->cancelSingleSubscription($serviceId, $serviceType);
}
}
else {
- $this->cancelSingleSubscription($wms);
+ $this->cancelSingleSubscription($services, $serviceType);
}
}
- public function hasSubscription ($wmsId) {
- if (!is_numeric($wmsId)) {
- $e = new mb_exception("class_user.php: cancelSingleSubscription: WMS Id not a number.");
+ public function hasSubscription ($serviceId, $serviceType = "WMS") {
+ if (!is_numeric($serviceId)) {
+ $e = new mb_exception("class_user.php: cancelSingleSubscription: ".$serviceType." Id not a number.");
return false;
}
- $id = intval($wmsId);
-
- $sql = "SELECT * FROM mb_user_abo_ows WHERE fkey_wms_id = $1 AND " .
- "fkey_mb_user_id = $2 LIMIT 1";
+ $id = intval($serviceId);
+ switch ($serviceType) {
+ case "WMS":
+ $sql = "SELECT * FROM mb_user_abo_ows WHERE fkey_wms_id = $1 AND " .
+ "fkey_mb_user_id = $2 LIMIT 1";
+ break;
+ case "WFS":
+ $sql = "SELECT * FROM mb_user_abo_ows WHERE fkey_wfs_id = $1 AND " .
+ "fkey_mb_user_id = $2 LIMIT 1";
+ break;
+ }
$v = array($id, $this->id);
$t = array('i', 'i');
$res = db_prep_query($sql, $v, $t);
$row = db_fetch_array($res);
-
- if (!isset($row['fkey_wms_id'])) {
- return false;
+ switch ($serviceType) {
+ case "WMS":
+ if (!isset($row['fkey_wms_id'])) {
+ return false;
+ }
+ break;
+ case "WFS":
+ if (!isset($row['fkey_wfs_id'])) {
+ return false;
+ }
+ break;
}
return true;
}
Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php 2018-04-13 09:46:51 UTC (rev 9895)
+++ trunk/mapbender/http/php/mod_showMetadata.php 2018-04-13 10:02:23 UTC (rev 9896)
@@ -658,6 +658,14 @@
$res = db_prep_query($sql, $v, $t);
$serviceQuality = db_fetch_array($res);
}
+//db select for service quality
+if ($resource == 'wfs' or $resource == 'featuretype' or $resource == 'wfs-conf') {
+ $sql = "SELECT availability, last_status FROM mb_wfs_availability WHERE fkey_wfs_id = $1";
+ $v = array($serviceId);
+ $t = array('i');
+ $res = db_prep_query($sql, $v, $t);
+ $serviceQuality = db_fetch_array($res);
+}
//db select for content properties
if ($resource == 'wms' or $resource == 'layer') {
//get bbox and crs codes for single layer - maybe some entries ;-)
@@ -908,12 +916,12 @@
//show abo function to registred and authorized users
if (!$is_public) {
if ($subscribe == 1) {
- $user->addSubscription($resourceMetadata['serviceid']);
+ $user->addSubscription($resourceMetadata['serviceid'], "WMS");
}
else if ($subscribe == 0) {
- $user->cancelSubscription($resourceMetadata['serviceid']);
+ $user->cancelSubscription($resourceMetadata['serviceid'], "WMS");
}
- $is_subscribed = $user->hasSubscription($resourceMetadata['serviceid']);
+ $is_subscribed = $user->hasSubscription($resourceMetadata['serviceid'], "WMS");
if ($is_subscribed) {
$aboStr = "<tr><th>Abo</th><td><a href = '../php/mod_showMetadata.php?id=" .
$layerId . "&resource=layer&user_id=" . $user->id . "&subscribe=0'><img style='border: none;' src = '../img/mail_delete.png' title='"._mb("Monitoring Abo löschen")."'></a></td></tr>"; //TODO check wherefor user_id should be given as parameter?
@@ -925,6 +933,30 @@
}
}
$html .= $aboStr;
+}
+
+if ($resource == 'wfs' or $resource == 'featuretype' or $resource == 'wfs-conf') {
+ $is_public = $user->isPublic();
+ //show abo function to registred and authorized users
+ if (!$is_public) {
+ if ($subscribe == 1) {
+ $user->addSubscription($resourceMetadata['serviceid'], "WFS");
+ }
+ else if ($subscribe == 0) {
+ $user->cancelSubscription($resourceMetadata['serviceid'], "WFS");
+ }
+ $e = new mb_exception("test subscription");
+ $is_subscribed = $user->hasSubscription($resourceMetadata['serviceid'], "WFS");
+ if ($is_subscribed) {
+ $aboStr = "<tr><th>Abo</th><td><a href = '../php/mod_showMetadata.php?id=" .
+ $featuretypeId . "&resource=featuretype&user_id=" . $user->id . "&subscribe=0'><img style='border: none;' src = '../img/mail_delete.png' title='"._mb("Monitoring Abo löschen")."'></a></td></tr>"; //TODO check wherefor user_id should be given as parameter?
+ }
+ else if (!$is_subscribed) {
+ $aboStr = "<tr><th>Abo</th><td><a href = '../php/mod_showMetadata.php?id=" . $featuretypeId .
+ "&resource=featuretype&user_id=" . $user->id . "&subscribe=1'><img style='border: none;' src = '../img/mail_send.png' title='"._mb("Monitoring abonnieren")."'></a></td></tr>";
+ }
+ }
+$html .= $aboStr;
}
if ($layerAccessibility && WRAPPER_PATH != '' && ($resource == 'layer' or $resource == 'wms' )) {
More information about the Mapbender_commits
mailing list