[Mapbender-commits] r9186 - in trunk/mapbender/http: php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon May 4 02:03:49 PDT 2015
Author: syed
Date: 2015-05-04 02:03:49 -0700 (Mon, 04 May 2015)
New Revision: 9186
Added:
trunk/mapbender/http/php/mb_checkGuest.php
Modified:
trunk/mapbender/http/plugins/kmlTree.js
Log:
deny wmc-publication for a guest-user
Added: trunk/mapbender/http/php/mb_checkGuest.php
===================================================================
--- trunk/mapbender/http/php/mb_checkGuest.php (rev 0)
+++ trunk/mapbender/http/php/mb_checkGuest.php 2015-05-04 09:03:49 UTC (rev 9186)
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @version Changed: ### 2015-05-04 07:58:43 UTC ###
+ * @author Raphael.Syed <raphael.syed at WhereGroup.com> http://WhereGroup.com
+ */
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_user.php");
+// require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+/**
+ * unpublish the the given wmc
+ */
+// user_id
+$user_id = Mapbender::session()->get("mb_user_id");
+// create user object
+$currentUser = new User($user_id);
+// var_dump($currentUser->isPublic());
+if ($currentUser->isPublic()) {
+ echo(intval(true));
+
+} else {
+ echo(intval(false));
+}
Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js 2015-04-27 09:53:49 UTC (rev 9185)
+++ trunk/mapbender/http/plugins/kmlTree.js 2015-05-04 09:03:49 UTC (rev 9186)
@@ -130,6 +130,8 @@
sTitle: 'public'
}, {
sTitle: 'size'
+ }, {
+ sTitle: 'owner'
}]
})
.find('tr').bind('dblclick', function() {
@@ -160,7 +162,7 @@
} else {
var title = $(this).parent().siblings().eq(1).html();
- var wmc_id = $(this).parent().siblings().eq(0).html();
+ var wmc_serial_id = $(this).parent().siblings().eq(0).html();
var outputFormat;
var dataExportDlg = $('<div id="dataExportDialog"></div>').dialog({
@@ -182,9 +184,9 @@
// '<img src="../img/osgeo_graphics/geosilk/link22.png"/>' + '<label class="export-format-gpx">GPX</label>' + '<label class="export-format-geojson">geoJSON</label><br></br>' +
// '<a download="myfeatures.kml" href="#" class="digitize-image digitize-export" style="float: left;"></a>' + '</form>' + '</div>';
var exportHtml = '<div id="exportHtml"><table><tbody>' +
- '<tr><td>KML:</td><td><label class="export-format-kml exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink kml" wmcId="'+wmc_id+'"outputFormat="kml"><img src="../img/osgeo_graphics/geosilk/link22.png"/></td></tr>' +
- '<tr><td>GPX:</td><td><label class="export-format-gpx exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink gpx" wmcId="'+wmc_id+'"outputFormat="gpx"><img src="../img/osgeo_graphics/geosilk/link22.png"/></td></tr>' +
- '<tr><td>GeoJson:</td><td><label class="export-format-geojson exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink geojson" wmcId="'+wmc_id+'"outputFormat="geojson"><img src="../img/osgeo_graphics/geosilk/link22.png"/></td></tr>' +
+ '<tr><td>KML:</td><td><label class="export-format-kml exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink kml" wmcId="' + wmc_serial_id + '"outputFormat="kml"><img src="../img/osgeo_graphics/geosilk/link22.png"/></td></tr>' +
+ '<tr><td>GPX:</td><td><label class="export-format-gpx exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink gpx" wmcId="' + wmc_serial_id + '"outputFormat="gpx"><img src="../img/osgeo_graphics/geosilk/link22.png"/></td></tr>' +
+ '<tr><td>GeoJson:</td><td><label class="export-format-geojson exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink geojson" wmcId="' + wmc_serial_id + '"outputFormat="geojson"><img src="../img/osgeo_graphics/geosilk/link22.png"/></td></tr>' +
'</tbody></table></div><iframe id="export-DataCollection" style="border:0;height:0; width:0;"></iframe>';
// append the context
$(dataExportDlg).append(exportHtml);
@@ -207,7 +209,7 @@
outputFormat = 'geojson';
break;
}
- $('#export-DataCollection').attr("src", "../php/mod_GetPublishedData.php?wmc_id=" + wmc_id + "&outputFormat=" + outputFormat);
+ $('#export-DataCollection').attr("src", "../php/mod_GetPublishedData.php?wmc_id=" + wmc_serial_id + "&outputFormat=" + outputFormat);
});
@@ -225,7 +227,7 @@
}
});
- var exportDataLinkContent = '<div><label for="exportLinkInput">Link: </label><input id="exportLinkInput" size="35" type="text" value="http://'+window.location.hostname+'/mapbender/php/mod_GetPublishedData.php?wmc_id='+wmc_id+'&outputFormat='+format+'"></div>';
+ var exportDataLinkContent = '<div><label for="exportLinkInput">Link: </label><input id="exportLinkInput" size="35" type="text" value="http://' + window.location.hostname + '/mapbender/php/mod_GetPublishedData.php?wmc_id=' + wmc_serial_id + '&outputFormat=' + format + '"></div>';
$(exportDataLinkDlg).append(exportDataLinkContent);
});
}
@@ -288,7 +290,7 @@
url: '../php/mb_unpublish_wmc.php',
type: 'POST',
data: {
- wmc_id: id
+ wmc_serial_id: id
},
success: function(data) {
@@ -310,221 +312,239 @@
});
$(dlg).find('li.kmltree-metadata-publish').bind('click', function() {
- var publishDialog;
- $(dlg).dialog('destroy');
- if ($('#wmcPublishConfirm').dialog('isOpen') === true) {
+ // check if the user is public(guest-user) or not
+ var isPublic;
+ $.ajax({
+ url: '../php/mb_checkGuest.php',
+ type: 'POST',
+ success: function(data) {
+ isPublic = data;
+ if (isPublic == 1){
- return;
+ alert('To publicate a WMC is not allowed for the Guest-User!'+
+ 'If you want to use this function, please create an account.');
+ return false;
+ }
+ var publishDialog;
+ $(dlg).dialog('destroy');
+ if ($('#wmcPublishConfirm').dialog('isOpen') === true) {
- } else {
- publishDialog = $('<div id="wmcPublishConfirm"></div>').dialog({
- title: "Publish datacollection " + d[1],
- width: 373,
- height: 'auto',
- position: {
- my: "center",
- at: "top",
- of: window
- },
- close: function() {
- // $('#kml-load-tabs').tabs('destroy');
- // $(this).html('').dialog('destroy');
- $('#wmcPublishConfirm').dialog('destroy');
- $('#wmcPublishConfirm').remove();
+ return;
+
+ } else {
+
+ publishDialog = $('<div id="wmcPublishConfirm"></div>').dialog({
+ title: "Publish datacollection " + d[1],
+ width: 373,
+ height: 'auto',
+ position: {
+ my: "center",
+ at: "top",
+ of: window
+ },
+ close: function() {
+ // $('#kml-load-tabs').tabs('destroy');
+ // $(this).html('').dialog('destroy');
+ $('#wmcPublishConfirm').dialog('destroy');
+ $('#wmcPublishConfirm').remove();
+ }
+ });
+
+ var publishDlgContent = "<div style='font-size:16px;text-align:justify'>If you want to publish a datacolletcion, you first have to choose a license" +
+ " under which you want to distribute your data. Actually only OpenData compatible" +
+ " licences are supported in this application. Please read the licenses carefully before" +
+ " you activate this option. All of your data will be available for each person in the web" +
+ " in different formats and may be redistributed freely without any copyright. </div>" +
+ "<table style='margin-top:7px' ><tr><th id = 'publishDenied'><img src='../img/button_digitize/geomRemove.png'></img> No, I dont't want to publish</th>" +
+ "<th style='width:16%;visibility:hidden'>empty</th>" +
+ "<th id = 'publishConfirmed'><img src='../img/osgeo_graphics/check.png'></img> Yes, I know what I am doing </th></tr></table>";
+
+ $(publishDialog).append(publishDlgContent);
+
+
}
- });
- var publishDlgContent = "<div style='font-size:16px;text-align:justify'>If you want to publish a datacolletcion, you first have to choose a license" +
- " under which you want to distribute your data. Actually only OpenData compatible" +
- " licences are supported in this application. Please read the licenses carefully before" +
- " you activate this option. All of your data will be available for each person in the web" +
- " in different formats and may be redistributed freely without any copyright. </div>" +
- "<table style='margin-top:7px' ><tr><th id = 'publishDenied'><img src='../img/button_digitize/geomRemove.png'></img> No, I dont't want to publish</th>" +
- "<th style='width:16%;visibility:hidden'>empty</th>" +
- "<th id = 'publishConfirmed'><img src='../img/osgeo_graphics/check.png'></img> Yes, I know what I am doing </th></tr></table>";
- $(publishDialog).append(publishDlgContent);
- }
+ $(publishDialog).find('#publishConfirmed').bind('click', function() {
+ $(publishDialog).dialog('close');
+ var chooseLicenseDialog = $('<div id="chooseLicenseDialog"></div>').dialog({
+ title: "Choose OpenData license for datacollection " + d[1],
+ width: 720,
+ height: 150,
+ position: {
+ my: "center",
+ at: "top",
+ of: window
+ },
+ close: function() {
+ $('#chooseLicenseDialog').dialog('destroy');
+ $('#chooseLicenseDialog').remove();
+ }
+ });
+ var chooseLicenseDlgCont = "<div><table id='licenseTbl'style='border-collapse: collapse'>" +
+ "<tr><th>Lizenz</th>" +
+ "<th>Logo</th><th>Beschreibung</th><th>Opendata</th></tr>" +
+ "<tr><td><select id='licenseChooser name='license'>" +
+ "</select></td>" +
+ "<td id='licenseImg'></td>" +
+ "<td id='licenseDescription'></td>" +
+ "<td id='licenseOpen' nowrap></td></tr>" +
+ "<tr id='submitLicense' ><td style='border:none;cursor:pointer; nowrap'><img src='../img/osgeo_graphics/check.png' style='margin-top:10px'/> <span>Publish data</span></td></tr>" +
+ "</table></div>";
+ // add options for the select box
+ $(chooseLicenseDialog).append(chooseLicenseDlgCont);
- $(publishDialog).find('#publishConfirmed').bind('click', function() {
- $(publishDialog).dialog('close');
- var chooseLicenseDialog = $('<div id="chooseLicenseDialog"></div>').dialog({
- title: "Choose OpenData license for datacollection " + d[1],
- width: 720,
- height: 150,
- position: {
- my: "center",
- at: "top",
- of: window
- },
- close: function() {
+ $.ajax({
+ url: '../php/mb_publish_wmc.php',
+ type: 'POST',
+ data: {
+ wmc_serial_id: id,
+ mode: 'getAllLicencesMode',
+ license: 'empty',
+ openData_only: options.openData_only,
+ },
- $('#chooseLicenseDialog').dialog('destroy');
- $('#chooseLicenseDialog').remove();
- }
- });
+ success: function(data) {
- var chooseLicenseDlgCont = "<div><table id='licenseTbl'style='border-collapse: collapse'>" +
- "<tr><th>Lizenz</th>" +
- "<th>Logo</th><th>Beschreibung</th><th>Opendata</th></tr>" +
- "<tr><td><select id='licenseChooser name='license'>" +
- "</select></td>" +
- "<td id='licenseImg'></td>" +
- "<td id='licenseDescription'></td>" +
- "<td id='licenseOpen' nowrap></td></tr>" +
- "<tr id='submitLicense' ><td style='border:none;cursor:pointer; nowrap'><img src='../img/osgeo_graphics/check.png' style='margin-top:10px'/> <span>Publish data</span></td></tr>" +
- "</table></div>";
+ for (var i = 0; i < data.length; i++) {
- // add options for the select box
- $(chooseLicenseDialog).append(chooseLicenseDlgCont);
+ $('#licenseTbl select').append("<option>" + data[i].name + "</option>");
+ }
- $.ajax({
- url: '../php/mb_publish_wmc.php',
- type: 'POST',
- data: {
- wmc_id: id,
- mode: 'getAllLicencesMode',
- license: 'empty',
- openData_only: options.openData_only,
- },
+ }
- success: function(data) {
+ });
- for (var i = 0; i < data.length; i++) {
- $('#licenseTbl select').append("<option>" + data[i].name + "</option>");
- }
+ $.ajax({
+ url: '../php/mb_publish_wmc.php',
+ type: 'POST',
+ data: {
+ wmc_serial_id: id,
+ mode: 'getLicenseMode',
+ license: 'cc-by'
+ },
- }
+ success: function(data) {
- });
+ $('#licenseImg').html('<img src="' + data.symbollink + '" />');
+ $('#licenseDescription').html('<a href="' + data.description + '" />' + data.description + '</a>');
+ if (data.isopen == 1) {
+ $('#licenseOpen').html('<img src="../img/od_80x15_blue.png" />');
+ } else {
- $.ajax({
- url: '../php/mb_publish_wmc.php',
- type: 'POST',
- data: {
- wmc_id: id,
- mode: 'getLicenseMode',
- license: 'cc-by'
- },
+ $('#licenseOpen').html('<span>No OpenData</span>');
+ }
- success: function(data) {
+ }
- $('#licenseImg').html('<img src="' + data.symbollink + '" />');
- $('#licenseDescription').html('<a href="' + data.description + '" />' + data.description + '</a>');
- if (data.isopen == 1) {
+ });
- $('#licenseOpen').html('<img src="../img/od_80x15_blue.png" />');
- } else {
- $('#licenseOpen').html('<span>No OpenData</span>');
- }
+ $('#licenseTbl select').bind('change', function(event) {
+ $('#licenseImg').html('');
+ $('#licenseDescription').html('');
- }
+ $.ajax({
+ url: '../php/mb_publish_wmc.php',
+ type: 'POST',
+ data: {
+ wmc_serial_id: id,
+ mode: 'getLicenseMode',
+ license: $('#licenseTbl select').val()
+ },
- });
+ success: function(data) {
+ $('#licenseImg').html('<img src="' + data.symbollink + '" />');
+ $('#licenseDescription').html('<a href="' + data.description + '" />' + data.description + '</a>');
+ if (data.isopen == 1) {
- $('#licenseTbl select').bind('change', function(event) {
- $('#licenseImg').html('');
- $('#licenseDescription').html('');
+ $('#licenseOpen').html('<img src="../img/od_80x15_blue.png" />');
- $.ajax({
- url: '../php/mb_publish_wmc.php',
- type: 'POST',
- data: {
- wmc_id: id,
- mode: 'getLicenseMode',
- license: $('#licenseTbl select').val()
- },
+ } else {
- success: function(data) {
+ $('#licenseOpen').html('<span>No OpenData</span>');
+ }
- $('#licenseImg').html('<img src="' + data.symbollink + '" />');
- $('#licenseDescription').html('<a href="' + data.description + '" />' + data.description + '</a>');
- if (data.isopen == 1) {
+ }
- $('#licenseOpen').html('<img src="../img/od_80x15_blue.png" />');
+ });
+ });
- } else {
+ $('#submitLicense').bind('click', function(event) {
+ //save the license from the choosed wmc
- $('#licenseOpen').html('<span>No OpenData</span>');
- }
+ $.ajax({
+ url: '../php/mb_publish_wmc.php',
+ type: 'POST',
+ data: {
+ wmc_serial_id: id,
+ mode: 'saveLicenseMode',
+ license: $('#licenseTbl select').val()
+ },
- }
+ success: function(data) {
- });
- });
+ $('#chooseLicenseDialog').dialog('destroy');
+ $('#chooseLicenseDialog').remove();
+ $('#mySpatialData').dialog('destroy');
+ $('#mySpatialData').remove();
+ $($addButton).trigger('click');
- $('#submitLicense').bind('click', function(event) {
- //save the license from the choosed wmc
- $.ajax({
- url: '../php/mb_publish_wmc.php',
- type: 'POST',
- data: {
- wmc_id: id,
- mode: 'saveLicenseMode',
- license: $('#licenseTbl select').val()
- },
- success: function(data) {
- $('#chooseLicenseDialog').dialog('destroy');
- $('#chooseLicenseDialog').remove();
- $('#mySpatialData').dialog('destroy');
- $('#mySpatialData').remove();
- $($addButton).trigger('click');
+ }
+ });
+ });
+ });
+ $(publishDialog).find('#publishDenied').bind('click', function() {
+ $(publishDialog).dialog('close');
- }
});
- });
-
+ }
});
- $(publishDialog).find('#publishDenied').bind('click', function() {
- $(publishDialog).dialog('close');
- });
-
});
}
});
});
- // .bind('dblclick', function() {
- // var id = $($(this).find('td')[0]).text();
- // $.ajax({
- // type: 'post',
- // url: '../php/mb_load_local_data.php',
- // data: {
- // id: id
- // },
- // success: function(data) {
- // var kml = $('#mapframe1').data('kml');
- // $.each(data, function(url, json) {
- // kml.addLayer(url, json.data);
- // });
- // $(dlg).dialog('destroy');
- // }
- // });
- // });
+ // .bind('dblclick', function() {
+ // var id = $($(this).find('td')[0]).text();
+ // $.ajax({
+ // type: 'post',
+ // url: '../php/mb_load_local_data.php',
+ // data: {
+ // id: id
+ // },
+ // success: function(data) {
+ // var kml = $('#mapframe1').data('kml');
+ // $.each(data, function(url, json) {
+ // kml.addLayer(url, json.data);
+ // });
+ // $(dlg).dialog('destroy');
+ // }
+ // });
+ // });
}
});
$('#kml-load-tabs').tabs();
@@ -541,8 +561,12 @@
if (title == '') {
return;
}
- kml.addLayer(title,{
- uuid: UUID.genV4().toString(), created: new Date().toISOString() ,title: title, updated: new Date().toISOString(), version: version,
+ kml.addLayer(title, {
+ uuid: UUID.genV4().toString(),
+ created: new Date().toISOString(),
+ title: title,
+ updated: new Date().toISOString(),
+ version: version,
type: 'FeatureCollection',
features: []
});
@@ -566,15 +590,18 @@
// check the features for properties
data = setFeatureAttr(data);
- if( data.hasOwnProperty('title') ){
+ if (data.hasOwnProperty('title')) {
name = data['title'];
kml.addLayer(name, data);
- }else{
+ } else {
name = $('#kml-from-upload input[type="file"]').val();
- if (name.match(/[\\]([^\\]+)/g)) {
- name = name.match(/[\\]([^\\]+)/g);
+
+ // test.replace(/\\/g,"/").split("/")
+ if (name.replace(/\\/g, "/").split("/")) {
+ // name = name.match(/[\\]([^\\]+)/g);
+ name = name.replace(/\\/g, "/").split("/");
}
name = name[name.length - 1];
kml.addLayer(name, data);
@@ -632,19 +659,19 @@
toggle = '<button class="toggle" name="toggle" value="toggle"></button>';
}
- if(obj.data.features[i].properties.name){
+ if (obj.data.features[i].properties.name) {
title = obj.data.features[i].properties.name;
- } else if(obj.data.features[i].properties.title) {
+ } else if (obj.data.features[i].properties.title) {
title = obj.data.features[i].properties.title;
- } else {
+ } else {
title = 'Title undefined';
}
- // title = obj.data.features[i].properties.name;
+ // title = obj.data.features[i].properties.name;
abbrevTitle = title.length < 20 ? title : title.substr(0, 17) + "...";
@@ -774,7 +801,7 @@
});
- var setFeatureAttr = function(data){
+ var setFeatureAttr = function(data) {
var simpleStyleDefaults = {
"title": "",
@@ -791,15 +818,15 @@
if (data.type == 'Feature') {
- if ( Object.getOwnPropertyNames(data.properties).length === 0 || data.properties === null) {
+ if (Object.getOwnPropertyNames(data.properties).length === 0 || data.properties === null) {
data.properties = simplyStyleDefaults;
- } else{
+ } else {
$.each(simpleStyleDefaults, function(index, val) {
- if ( !data.properties.hasOwnProperty(index) ){
+ if (!data.properties.hasOwnProperty(index)) {
data.properties[index] = value;
}
@@ -814,9 +841,9 @@
$.each(simpleStyleDefaults, function(prop, propVal) {
- if ( !val.properties.hasOwnProperty(prop) ){
+ if (!val.properties.hasOwnProperty(prop)) {
- //TODO: get index in this scope
+ //TODO: get index in this scope
data.features[index].properties[prop] = propVal;
}
More information about the Mapbender_commits
mailing list