[Mapbender-commits] r7695 - in branches/kmq_dev: . http/classes
http/extensions http/extensions/FirePHP-0.3 http/javascripts
http/php http/print resources/db
resources/db/pgsql/UTF-8/update tools
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Mar 11 03:09:01 EST 2011
Author: kmq
Date: 2011-03-11 00:09:01 -0800 (Fri, 11 Mar 2011)
New Revision: 7695
Added:
branches/kmq_dev/http/php/mod_group_user_role.php
branches/kmq_dev/resources/db/new_role_concept.sql
branches/kmq_dev/tools/build_dist.sh
Modified:
branches/kmq_dev/
branches/kmq_dev/http/classes/class_user.php
branches/kmq_dev/http/extensions/FirePHP-0.3/FirePHP.class.php
branches/kmq_dev/http/extensions/FirePHP-0.3/fb.php
branches/kmq_dev/http/extensions/jqjson.min.js
branches/kmq_dev/http/javascripts/mod_sandclock.js
branches/kmq_dev/http/php/mod_layerISOMetadata.php
branches/kmq_dev/http/php/mod_wmc2ol.php
branches/kmq_dev/http/print/mapbender_template.json
branches/kmq_dev/resources/db/pgsql/UTF-8/update/update_2.6rc1_to_2.6_pgsql_UTF-8.sql
Log:
merging in changes from trunk
Property changes on: branches/kmq_dev
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/kmq_dev:4021-4487
/trunk/mapbender:7670-7690
+ /branches/kmq_dev:4021-4487
/trunk/mapbender:7670-7694
Modified: branches/kmq_dev/http/classes/class_user.php
===================================================================
--- branches/kmq_dev/http/classes/class_user.php 2011-03-11 07:55:42 UTC (rev 7694)
+++ branches/kmq_dev/http/classes/class_user.php 2011-03-11 08:09:01 UTC (rev 7695)
@@ -508,6 +508,11 @@
$mb_user_id = $this->id;
$arrayGuis = array();
$mb_user_groups = array();
+ //exchange for the new role system - there are roles which don't include permissions explicitly
+ /*$sql_groups = "SELECT fkey_mb_group_id FROM ";
+ $sql_groups .= "(SELECT * from mb_user_mb_group left join mb_role on ";
+ $sql_groups .= " mb_user_mb_group.mb_user_mb_group_type = mb_role.role_id ";
+ $sql_groups .= " WHERE mb_role.role_exclude_auth != 1) AS mb_user_mb_group WHERE fkey_mb_user_id = $1 ";*/
$sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
$v = array($mb_user_id);
$t = array("i");
Property changes on: branches/kmq_dev/http/extensions/FirePHP-0.3/FirePHP.class.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/kmq_dev/http/extensions/FirePHP.class.php:4021-4487
+ /branches/kmq_dev/http/extensions/FirePHP.class.php:4021-4487
/trunk/mapbender/http/extensions/FirePHP-0.3/FirePHP.class.php:7670-7694
Property changes on: branches/kmq_dev/http/extensions/FirePHP-0.3/fb.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/kmq_dev/http/extensions/fb.php:4021-4487
+ /branches/kmq_dev/http/extensions/fb.php:4021-4487
/trunk/mapbender/http/extensions/FirePHP-0.3/fb.php:7670-7694
Property changes on: branches/kmq_dev/http/extensions/jqjson.min.js
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/mapbender/http/extensions/jqjson.min.js:7670-7690
+ /trunk/mapbender/http/extensions/jqjson.min.js:7670-7694
Property changes on: branches/kmq_dev/http/javascripts/mod_sandclock.js
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/mapbender/http/javascripts/mod_sandclock.js:7670-7690
+ /trunk/mapbender/http/javascripts/mod_sandclock.js:7670-7694
Copied: branches/kmq_dev/http/php/mod_group_user_role.php (from rev 7694, trunk/mapbender/http/php/mod_group_user_role.php)
===================================================================
--- branches/kmq_dev/http/php/mod_group_user_role.php (rev 0)
+++ branches/kmq_dev/http/php/mod_group_user_role.php 2011-03-11 08:09:01 UTC (rev 7695)
@@ -0,0 +1,373 @@
+<?php
+# $Id: mod_group_user.php 7276 2010-12-12 10:36:40Z apour $
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+$e_id="Group_User_Role";
+require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+//require_once(dirname(__FILE__)."/../core/globalSettings.php");
+/*
+ * @security_patch irv done
+ */
+//security_patch_log(__FILE__,__LINE__);
+//import_request_variables("PG");
+
+$postvars = explode(",", "selected_group,filter2,insert,remove,filter3,remove_user,selected_user,select_role,alterrole");
+foreach ($postvars as $value) {
+ $$value = $_POST[$value];
+}
+
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+?>
+<title>Edit Group Members</title>
+<?php include '../include/dyn_css.php'; ?>
+<script language="JavaScript">
+function validate(wert){
+ if(document.forms[0]["selected_group"].selectedIndex == -1){
+ document.getElementsByName("selected_group")[0].style.backgroundColor = '#ff0000';
+ return;
+ }else{
+ if(wert == "remove"){
+ if(document.forms[0]["remove_user[]"].selectedIndex == -1){
+ document.getElementsByName("remove_user[]")[0].style.backgroundColor = '#ff0000';
+ return;
+ }
+ document.form1.remove.value = 'true';
+ document.form1.submit();
+ }
+ if(wert == "insert"){
+ if(document.forms[0]["selected_user[]"].selectedIndex == -1){
+ document.getElementsByName("selected_user[]")[0].style.backgroundColor = '#ff0000';
+ return;
+ }
+ document.form1.insert.value = 'true';
+ document.form1.submit();
+ }
+ if(wert == "showrole"){
+ document.forms[0]["select_role"].disabled=false;
+ var removeUser = document.forms[0]["remove_user[]"].value;
+ var removeUserArray = removeUser.split("+");
+ //alert(removeUserArray[1]);
+ for(index = 0; index < document.forms[0]["select_role"].length; index++) {
+ if(document.forms[0]["select_role"][index].value == removeUserArray[1]) {
+ document.forms[0]["select_role[]"].selectedIndex = index;
+ }
+ }
+ }
+ if(wert == "changerole"){
+ document.form1.alterrole.value = 'true';
+ document.form1.submit();
+ }
+ }
+}
+/**
+ * filter the Userlist by str
+ */
+function filterUser(list, all, str){
+ str=str.toLowerCase();
+ var selection=[];
+ var i,j,selected;
+ for(i=0;i<list.options.length;i++){
+ if(list.options[i].selected)
+ selection[selection.length]=list.options[i].value;
+ }
+
+ list.options.length = 0;
+ for(i=0; i<all.length; i++){
+ if(all[i]['name'].toLowerCase().indexOf(str)==-1)
+ continue;
+ selected=false;
+ for(j=0;j<selection.length;j++){
+ if(selection[j]==all[i]['id']){
+ selected=true;
+ break;
+ }
+ }
+ var newOption = new Option(selected?all[i]['name']+" ("+all[i]['email']+")":all[i]['name'],all[i]['id'],false,selected);
+ newOption.setAttribute("title", all[i]['email']);
+ list.options[list.options.length] = newOption;
+ }
+}
+/**
+ * add Mail adress on selection
+ */
+function updateMail(list, all){
+ var j=0;
+ for(var i=0; i<list.options.length;i++){
+ if(list.options[i].selected){
+ for(j=j;j<all.length;j++){
+ if(all[j]['id']==list.options[i].value){
+ list.options[i].text=all[j]['name']+" ("+all[j]['email']+")";
+ list.options[i].selected = true;
+ break;
+ }
+ }
+ }
+ else{
+ for(j=j;j<all.length;j++){
+ if(all[j]['id']==list.options[i].value){
+ list.options[i].text=all[j]['name'];
+ list.options[i].selected = false;
+ break;
+ }
+ }
+ }
+ }
+}
+function showAvailableRoles(){
+
+}
+function selectRole(){
+
+}
+
+</script>
+
+</head>
+<body>
+<?php
+
+$fieldHeight = 20;
+
+$cnt_group = 0;
+$cnt_user = 0;
+$cnt_group = 0;
+$cnt_group_user = 0;
+$cnt_group_group = 0;
+$cnt_role = 0;
+$exists = false;
+
+/*handle remove, update and insert**************************************************************************************/
+if($insert){
+ if(count($selected_user)>0){
+ for($i=0; $i<count($selected_user); $i++){
+ $exists = false;
+ //check if a user is already in this group a standard role
+ $sql = "SELECT * from mb_user_mb_group where fkey_mb_group_id = $1 and fkey_mb_user_id = $2 and mb_user_mb_group_type = $3";
+ $v = array($selected_group,$selected_user[$i],1);
+ $t = array('i','i','i');
+ $res_insert = db_prep_query($sql,$v,$t);
+ while(db_fetch_row($res_insert)){$exists = true;}
+ if($exists == false){
+ //add a user without any special role to the selected group
+ $sql = "INSERT INTO mb_user_mb_group(fkey_mb_group_id, fkey_mb_user_id) ";
+ $sql .= "VALUES($1, $2);";
+ $v = array($selected_group,$selected_user[$i]);
+ $t = array('i','i');
+ $res = db_prep_query($sql,$v,$t);
+ }
+ }
+ }
+}
+if($remove){
+ if(count($remove_user)>0){
+ for($i=0; $i<count($remove_user); $i++){
+ $sql_remove = "DELETE FROM mb_user_mb_group WHERE ";
+ $sql_remove .= "fkey_mb_user_id = $1 and fkey_mb_group_id = $2 AND mb_user_mb_group_type = $3";
+ //explode identifier for selected user option
+ $remove_user_explode = explode('+',$remove_user[$i]);
+ $v = array($remove_user_explode[0],$selected_group,$remove_user_explode[1]);
+ $t = array('i','i','i');
+ db_prep_query($sql_remove,$v,$t);
+ }
+ }
+}
+if($alterrole){
+ $e = new mb_exception("alterrole send");
+ if(count($remove_user)==1){
+ $e = new mb_exception("only one user selected");
+ //update role of the selected user-role combination - if it doesn't exists at all!
+ //check if combi exists
+ $exists = false;
+ //check if a user is already in this group without that role
+ $sql = "SELECT * from mb_user_mb_group where fkey_mb_group_id = $1 and fkey_mb_user_id = $2 and mb_user_mb_group_type = $3";
+ //explode user-role combi to single elements userId and roleId
+ $remove_user_explode = explode('+',$remove_user[0]);
+ $v = array($selected_group,$remove_user_explode[0],$select_role[0]);
+ $t = array('i','i','i');
+ $res_insert = db_prep_query($sql,$v,$t);
+ while(db_fetch_row($res_insert)){$exists = true;}
+ if($exists == false){
+ //the given one will be updated
+ $e = new mb_exception("Requested combination user_group_role does not exist in database - update will be performed");
+ //change this role
+ $sql_alterrole = "UPDATE mb_user_mb_group SET mb_user_mb_group_type = $1 WHERE ";
+ $sql_alterrole .= "fkey_mb_user_id = $2 and fkey_mb_group_id = $3 AND mb_user_mb_group_type = $4";
+ $e = new mb_exception("select_row: ".$select_row);
+ $v = array($select_role[0],$remove_user_explode[0],$selected_group,$remove_user_explode[1]);
+ $t = array('i','i','i','i');
+ db_prep_query($sql_alterrole,$v,$t);
+ } else {
+ $e = new mb_exception("Combi user_group_role does already exist in the database - it need not to be added again!");
+ }
+ }
+}
+
+/*get all group ********************************************************************************************/
+$sql_group = "SELECT * FROM mb_group ORDER BY mb_group_name";
+$res_group = db_query($sql_group);
+while($row = db_fetch_array($res_group)){
+ $group_id[$cnt_group] = $row["mb_group_id"];
+ $group_name[$cnt_group] = $row["mb_group_name"];
+ $cnt_group++;
+}
+
+/*get all user **********************************************************************************************/
+$sql_user = "SELECT * FROM mb_user ORDER BY mb_user_name";
+$res_user = db_query($sql_user);
+while($row = db_fetch_array($res_user)){
+ $user_id[$cnt_user] = $row["mb_user_id"];
+ $user_name[$cnt_user] = $row["mb_user_name"];
+ $user_email[$cnt_user] = $row["mb_user_email"];
+ $cnt_user++;
+}
+/*get all roles **********************************************************************************************/
+$sql_role = "SELECT * FROM mb_role ORDER BY role_name";
+$res_role = db_query($sql_role);
+while($row = db_fetch_array($res_role)){
+ $role_id[$cnt_role] = $row["role_id"];
+ $role_name[$cnt_role] = $row["role_name"];
+ $role_description[$cnt_role] = $row["role_description"];
+ $role_exclude_auth[$cnt_role] = $row["role_exclude_auth"];
+ $cnt_role++;
+}
+/*get all user from selected group******************************************************************************/
+$sql_mb_user_mb_group = "SELECT mb_user.mb_user_id, mb_user.mb_user_name, "; $sql_mb_user_mb_group .= "mb_user.mb_user_email, mb_user_mb_group.fkey_mb_group_id, "; $sql_mb_user_mb_group .= "mb_user_mb_group.mb_user_mb_group_type, "; $sql_mb_user_mb_group .= "mb_user_mb_group.role_exclude_auth ";
+$sql_mb_user_mb_group .= "FROM (select * from mb_user_mb_group left join mb_role on "; $sql_mb_user_mb_group .= "mb_user_mb_group.mb_user_mb_group_type = mb_role.role_id ) as "; $sql_mb_user_mb_group .= "mb_user_mb_group INNER JOIN mb_user ON ";
+$sql_mb_user_mb_group .= "mb_user_mb_group.fkey_mb_user_id = mb_user.mb_user_id ";
+$sql_mb_user_mb_group .= "WHERE mb_user_mb_group.fkey_mb_group_id= $1 ";
+$sql_mb_user_mb_group .= "ORDER BY mb_user.mb_user_name ";
+
+
+
+/*$sql_mb_user_mb_group = "SELECT mb_user.mb_user_id, mb_user.mb_user_name, mb_user.mb_user_email, mb_user_mb_group.fkey_mb_group_id, mb_user_mb_group.mb_user_mb_group_type FROM mb_user_mb_group ";
+$sql_mb_user_mb_group .= "INNER JOIN mb_user ON mb_user_mb_group.fkey_mb_user_id = mb_user.mb_user_id ";
+$sql_mb_user_mb_group .= "WHERE mb_user_mb_group.fkey_mb_group_id= $1 ";
+$sql_mb_user_mb_group .= " ORDER BY mb_user.mb_user_name";
+*/
+if(!$selected_group){$v = array($group_id[0]);}
+if($selected_group){$v = array($selected_group);}
+$t = array('i');
+
+$res_mb_user_mb_group = db_prep_query($sql_mb_user_mb_group,$v,$t);
+while($row = db_fetch_array($res_mb_user_mb_group)){
+ $user_id_group[$cnt_group_user] = $row["mb_user_id"];
+ $user_name_group[$cnt_group_user] = $row["mb_user_name"];
+ $user_email_group[$cnt_group_user] = $row["mb_user_email"];
+ $user_group_type_group[$cnt_group_user] = $row["mb_user_mb_group_type"];
+ $user_role_exclude_auth_group[$cnt_group_user] = $row["role_exclude_auth"];
+ $cnt_group_user++;
+}
+
+
+/*INSERT HTML*/
+echo "<form name='form1' action='" . $self . "' method='post'>";
+
+/*insert projects in selectbox*************************************************************************************/
+echo "<div class='text1'>GROUP: </div>";
+echo "<select style='background:#ffffff' class='select1' name='selected_group' onChange='submit()' size='10'>";
+for($i=0; $i<$cnt_group; $i++){
+ echo "<option value='" . $group_id[$i] . "' ";
+ if($selected_group && $selected_group == $group_id[$i]){
+ echo "selected";
+ }
+ echo ">" . $group_name[$i] . "</option>";
+}
+echo "</select>";
+
+/*filterbox****************************************************************************************/
+echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
+/*insert all profiles in selectbox*****************************************************************/
+echo "<div class='text2'>USER:</div>";
+echo "<select style='background:#ffffff' onchange='updateMail(this, user)' class='select2' multiple='multiple' id='selecteduser' name='selected_user[]' size='$fieldHeight' >";
+for($i=0; $i<$cnt_user; $i++){
+ echo "<option value='" . $user_id[$i] . "' title='".$user_email[$i]."'>" . $user_name[$i] . "</option>";
+}
+echo "</select>";
+
+/*Button****************************************************************************************************/
+
+echo "<div class='button1'><input type='button' value='==>' onClick='validate(\"insert\")'></div>";
+echo "<input type='hidden' name='insert'>";
+
+echo "<div class='button2'><input type='button' value='<==' onClick='validate(\"remove\")'></div>";
+echo "<input type='hidden' name='remove'>";
+echo "<input type='hidden' name='alterrole'>";
+/*filterbox****************************************************************************************/
+echo "<input type='text' value='' class='filter3' id='filter3' name='filter3' onkeyup='filterUser(document.getElementById(\"removeuser\"),groupuser,this.value);'/>";
+/*insert container_profile_dependence and container_group_dependence in selectbox******************/
+echo "<div class='text3'>SELECTED USER:</div>";
+echo "<select style='background:#ffffff' onchange='validate(\"showrole\")' class='select3' name='remove_user[]' id='removeuser' size='$fieldHeight' >";
+for($i=0; $i<$cnt_group_user; $i++){
+ if ($user_role_exclude_auth_group[$i] == 1) {
+ echo "<option value='".$user_id_group[$i]."+".$user_group_type_group[$i]."' title='".$user_email_group[$i]."' style='background-color: Red;'>" . $user_name_group[$i] . " - " .$user_group_type_group[$i]. "</option>";
+ } else {
+ echo "<option value='".$user_id_group[$i]."+".$user_group_type_group[$i]."' title='".$user_email_group[$i]."'>" . $user_name_group[$i] . " - " .$user_group_type_group[$i]. "</option>";
+ }
+}
+echo "</select>";
+echo "<div class='roleHeader'>SELECTED ROLE:</div>";
+echo "<select style='background:#ffffff' onchange='validate(\"changerole\")' class='selectRole' name='select_role[]' id='select_role' size='1' disabled='true'>";
+//echo "<option value='0' title='no role defined'>no special role defined yet!</option>";
+for($i=0; $i<$cnt_role; $i++){
+ echo "<option value='" . $role_id[$i] . "' title='".$role_id[$i]." - ".$role_description[$i]."'>".$role_id[$i]." - ". $role_name[$i] . "</option>";
+}
+echo "</select>";
+echo "<table><tr><td bgcolor=\"#FF0000\">Role has no influence on authorization!</td></tr></table>";
+echo "</form>";
+
+?>
+<script type="text/javascript">
+<!--
+document.forms[0].selected_group.focus();
+var user=[];
+<?php
+for($i=0; $i<$cnt_user; $i++){
+ echo "user[".$i."]=[];\n";
+ echo "user[".$i."]['id']='" . $user_id[$i] . "';\n";
+ echo "user[".$i."]['name']='" . $user_name[$i] . "';\n";
+ echo "user[".$i."]['email']='" . $user_email[$i] . "';\n";
+}
+?>
+var groupuser=[];
+<?php
+for($i=0; $i<$cnt_group_user; $i++){
+ echo "groupuser[".$i."]=[];\n";
+ echo "groupuser[".$i."]['id']='" . $user_id_group[$i] . "';\n";
+ echo "groupuser[".$i."]['name']='" . $user_name_group[$i] . "';\n";
+ echo "groupuser[".$i."]['email']='" . $user_email_group[$i] . "';\n";
+ echo "groupuser[".$i."]['group_type']='" . $user_group_type_group[$i] . "';\n";
+}
+?>
+var groupuserrole=[];
+<?php
+for($i=0; $i<$cnt_role; $i++){
+ echo "groupuserrole[".$i."]=[];\n";
+ echo "groupuserrole[".$i."]['id']='" . $role_id[$i] . "';\n";
+ echo "groupuserrole[".$i."]['name']='" . $role_name[$i] . "';\n";
+ echo "groupuserrole[".$i."]['description']='" . $role_description[$i] . "';\n";
+}
+?>
+// -->
+</script>
+</body>
+</html>
Modified: branches/kmq_dev/http/php/mod_layerISOMetadata.php
===================================================================
--- branches/kmq_dev/http/php/mod_layerISOMetadata.php 2011-03-11 07:55:42 UTC (rev 7694)
+++ branches/kmq_dev/http/php/mod_layerISOMetadata.php 2011-03-11 08:09:01 UTC (rev 7695)
@@ -21,10 +21,13 @@
require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
require_once(dirname(__FILE__) . "/../classes/class_connector.php");
+require_once(dirname(__FILE__) . "/../classes/class_administration.php");
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
+$admin = new administration();
+
//define the view or table to use as input for metadata generation
$wmsView = "wms_search_table";
$wmsView = '';
@@ -66,6 +69,7 @@
function fillISO19139($iso19139, $recordId) {
global $wmsView;
+ global $admin;
//read out relevant information from mapbender database:
if ($wmsView != '') {
$sql = "SELECT * ";
@@ -110,7 +114,7 @@
$res = db_prep_query($sql,$v,$t);
$userMetadata = db_fetch_array($res);
//check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
- $hasPermission=getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_id'],ANONYMOUS_USER);
+ $hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],ANONYMOUS_USER);
//Creating the "MD_Metadata" node
$MD_Metadata = $iso19139->createElementNS('http://www.isotc211.org/2005/gmd', 'gmd:MD_Metadata');
//$MD_Metadata=$iso19139->registerNamespace('srv','http://www.iso211.org/2005/srv');
@@ -896,88 +900,6 @@
die();
}
- function user_authorization($wms_id,$layer_name,$user_id){
- $n = new administration();
- $this->n = $n;
- $permission=$this->n->getLayerPermission($wms_id, $layer_name, $user_id);
- return $permission;
- }
-
-//functions necessary to decide if service url should be displayed
- function getLayerPermission($wms_id, $layer_id, $user_id){
- //$layer_id = $this->getLayerIdByLayerName($wms_id,$layer_name);
- $array_guis = getGuisByPermission($user_id,true);
- $v = array();
- $t = array();
- $sql = "SELECT * FROM gui_layer WHERE fkey_gui_id IN (";
- $c = 1;
- //generate guilist assigned to specific user
- for($i=0; $i<count($array_guis); $i++){
- if($i>0){ $sql .= ",";}
- $sql .= "$".$c;
- $c++;
- array_push($v, $array_guis[$i]);
- array_push($t, 's');
- }
- $sql .= ") AND fkey_layer_id = $".$c." AND gui_layer_status = 1"; //Status must be 1
- array_push($v,$layer_id);
- array_push($t,'i');
- $res = db_prep_query($sql,$v,$t);
- if($row = db_fetch_array($res)){
- return true;
- }
- else{
- return false;
- }
- }
- function getGuisByPermission($mb_user_id,$ignoreublic){
- $arrayGuis = array();
- $mb_user_groups = array();
- $sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
- $v = array($mb_user_id);
- $t = array("i");
- $res_groups = db_prep_query($sql_groups,$v,$t);
- $cnt_groups = 0;
- while($row = db_fetch_array($res_groups)){
- $mb_user_groups[$cnt_groups] = $row["fkey_mb_group_id"];
- $cnt_groups++;
- }
- if($cnt_groups > 0){
- $v = array();
- $t = array();
- $sql_g = "SELECT gui.gui_id FROM gui JOIN gui_mb_group ";
- $sql_g .= " ON gui.gui_id = gui_mb_group.fkey_gui_id WHERE gui_mb_group.fkey_mb_group_id IN (";
- for($i=0; $i<count($mb_user_groups);$i++){
- if($i > 0){$sql_g .= ",";}
- $sql_g .= "$".strval($i+1);
- array_push($v,$mb_user_groups[$i]);
- array_push($t,"i");
- }
- $sql_g .= ") GROUP BY gui.gui_id";
- $res_g = db_prep_query($sql_g,$v,$t);
- while($row = db_fetch_array($res_g)){
- array_push($arrayGuis,$row["gui_id"]);
- }
- }
- $sql_guis = "SELECT gui.gui_id FROM gui JOIN gui_mb_user ON gui.gui_id = gui_mb_user.fkey_gui_id";
- $sql_guis .= " WHERE (gui_mb_user.fkey_mb_user_id = $1) ";
- if (!isset($ignore_public) OR $ignore_public== false){
- $sql_guis .= " AND gui.gui_public = 1 ";
- }
- $sql_guis .= " GROUP BY gui.gui_id";
- $v = array($mb_user_id);
- $t = array("i");
- $res_guis = db_prep_query($sql_guis,$v,$t);
- $guis = array();
- while($row = db_fetch_array($res_guis)){
- if(!in_array($row['gui_id'],$arrayGuis)){
- array_push($arrayGuis,$row["gui_id"]);
- }
- }
- return $arrayGuis;
- }
-
-
function getEpsgByLayerId ($layer_id) { // from merge_layer.php
$epsg_list = "";
$sql = "SELECT DISTINCT epsg FROM layer_epsg WHERE fkey_layer_id = $1";
Modified: branches/kmq_dev/http/php/mod_wmc2ol.php
===================================================================
--- branches/kmq_dev/http/php/mod_wmc2ol.php 2011-03-11 07:55:42 UTC (rev 7694)
+++ branches/kmq_dev/http/php/mod_wmc2ol.php 2011-03-11 08:09:01 UTC (rev 7695)
@@ -16,13 +16,11 @@
#http://www.geoportal.rlp.de/mapbender/php/mod_wmc2ol.php?wmc_id=45_1291218568&GEORSS=1&LayerSwitcher=1
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-//require_once(dirname(__FILE__)."/../classes/class_wmc.php");
require_once(dirname(__FILE__)."/../classes/class_user.php");
-//require_once(dirname(__FILE__)."/../classes/class_json.php");
-//require_once(dirname(__FILE__)."/../classes/class_administration.php");
-//require_once(dirname(__FILE__)."/../classes/class_wmcToXml.php");
-//$userId = Mapbender::session()->get("mb_user_id");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
$user = new User();
+$admin = new administration();
$userId = $user->id;
//check for parameter wmc_id
if(!isset($_GET["wmc_id"])){
@@ -98,39 +96,8 @@
$testMatch = NULL;
}
-
-
-
-
-
-//the next functions should come from class administration, but they are not included as they are needed
-//TODO
-function getLayerPermission($wms_id, $layer_id, $user_id){
- //$layer_id = $this->getLayerIdByLayerName($wms_id,$layer_name);
- $array_guis = getGuisByPermission($user_id,true);
- $v = array();
- $t = array();
- $sql = "SELECT * FROM gui_layer WHERE fkey_gui_id IN (";
- $c = 1;
- //generate guilist assigned to specific user
- for($i=0; $i<count($array_guis); $i++){
- if($i>0){ $sql .= ",";}
- $sql .= "$".$c;
- $c++;
- array_push($v, $array_guis[$i]);
- array_push($t, 's');
- }
- $sql .= ") AND fkey_layer_id = $".$c." AND gui_layer_status = 1"; //status 1 must be
- array_push($v,$layer_id);
- array_push($t,'i');
- $res = db_prep_query($sql,$v,$t);
- if($row = db_fetch_array($res)){
- return true;
- }
- else{
- return false;
- }
- }
+//**************************************************************************
+//functions which may be integrated from class_administration
function getWmsGetMapUrl($wmsId){
$sql = "SELECT wms_getmap FROM wms WHERE wms_id =$1";
$v = array($wmsId);
@@ -142,58 +109,14 @@
return false;
}
}
-function getGuisByPermission($mb_user_id,$ignoreublic){
- $arrayGuis = array();
- $mb_user_groups = array();
- $sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
- $v = array($mb_user_id);
- $t = array("i");
- $res_groups = db_prep_query($sql_groups,$v,$t);
- $cnt_groups = 0;
- while($row = db_fetch_array($res_groups)){
- $mb_user_groups[$cnt_groups] = $row["fkey_mb_group_id"];
- $cnt_groups++;
- }
- if($cnt_groups > 0){
- $v = array();
- $t = array();
- $sql_g = "SELECT gui.gui_id FROM gui JOIN gui_mb_group ";
- $sql_g .= " ON gui.gui_id = gui_mb_group.fkey_gui_id WHERE gui_mb_group.fkey_mb_group_id IN (";
- for($i=0; $i<count($mb_user_groups);$i++){
- if($i > 0){$sql_g .= ",";}
- $sql_g .= "$".strval($i+1);
- array_push($v,$mb_user_groups[$i]);
- array_push($t,"i");
- }
- $sql_g .= ") GROUP BY gui.gui_id";
- $res_g = db_prep_query($sql_g,$v,$t);
- while($row = db_fetch_array($res_g)){
- array_push($arrayGuis,$row["gui_id"]);
- }
- }
- $sql_guis = "SELECT gui.gui_id FROM gui JOIN gui_mb_user ON gui.gui_id = gui_mb_user.fkey_gui_id";
- $sql_guis .= " WHERE (gui_mb_user.fkey_mb_user_id = $1) ";
- if (!isset($ignore_public) OR $ignore_public== false){
- $sql_guis .= " AND gui.gui_public = 1 ";
- }
- $sql_guis .= " GROUP BY gui.gui_id";
- $v = array($mb_user_id);
- $t = array("i");
- $res_guis = db_prep_query($sql_guis,$v,$t);
- $guis = array();
- while($row = db_fetch_array($res_guis)){
- if(!in_array($row['gui_id'],$arrayGuis)){
- array_push($arrayGuis,$row["gui_id"]);
- }
- }
- return $arrayGuis;
-}
-//end of functions which m,ay be included from class_administration in next versions
-#**************************************************************************
+//end of functions which may be included from class_administration in next versions
+//**************************************************************************
//Function to create an OpenLayers Javascript from a mapbender wmc document
function createOlFromWMC_id($wmc_id, $pointRadius, $fillColor){
//$myWmc = new wmc();
+ global $user;
global $userId;
+ global $admin;
//Get WMC out of mb Database
$sql = "SELECT wmc, wmc_serial_id FROM mb_user_wmc WHERE wmc_serial_id = $1";
$res = db_prep_query($sql, array($wmc_id), array("s"));
@@ -406,9 +329,9 @@
$html.=" layer0 = new OpenLayers.Layer.WMS( \"".$xml->LayerList->Layer[$i]->Title."\",\n";
$extensions=$xml->LayerList->Layer[$i]->Extension->children('http://www.mapbender.org/context');
$layer_id=dom_import_simplexml($extensions->layer_id)->nodeValue;
+ $layer_name=$xml->LayerList->Layer[$i]->Name;
$wms_id=dom_import_simplexml($extensions->wms_id)->nodeValue;
- $has_permission=getLayerPermission($wms_id,$layer_id,$userId);//problem: guest user must have fix id
- //echo $layer_id."<br>";
+ $has_permission=$admin->getLayerPermission($wms_id, $layer_name, $userId);
if ($has_permission || $layer_id==''){
$getMapUrl = $xml->LayerList->Layer[$i]->Server->OnlineResource->attributes('http://www.w3.org/1999/xlink')->href;
if (getWmsGetMapUrl($wms_id) != false) {
@@ -462,8 +385,9 @@
#$layer_id=$extensions->layer_id;
$wms_id=$extensions->wms_id;
$layer_id=dom_import_simplexml($extensions->layer_id)->nodeValue;
+ $layer_name=$xml->LayerList->Layer[$i]->Name;
$wms_id=dom_import_simplexml($extensions->wms_id)->nodeValue;
- $has_permission=getLayerPermission($wms_id,$layer_id,$userId);//problem: guest user must have fix id TODO
+ $has_permission=$admin->getLayerPermission($wms_id, $layer_name, $userId);
if (($xml->LayerList->Layer[$i]->attributes()->hidden=='0' && $has_permission) ||
($layer_id=='' && $xml->LayerList->Layer[$i]->attributes()->hidden=='0')){
$html.=" layer".$i." = new OpenLayers.Layer.WMS( \"".$xml->LayerList->Layer[$i]->Title."\",\n";
Property changes on: branches/kmq_dev/http/print/mapbender_template.json
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/mapbender/http/print/mapbender_template.json:7670-7690
+ /trunk/mapbender/http/print/mapbender_template.json:7670-7694
Copied: branches/kmq_dev/resources/db/new_role_concept.sql (from rev 7694, trunk/mapbender/resources/db/new_role_concept.sql)
===================================================================
--- branches/kmq_dev/resources/db/new_role_concept.sql (rev 0)
+++ branches/kmq_dev/resources/db/new_role_concept.sql 2011-03-11 08:09:01 UTC (rev 7695)
@@ -0,0 +1,63 @@
+
+--***** new role system - should not influence the normal behaviour
+-- Table: mb_role
+
+-- DROP TABLE mb_role;
+
+CREATE TABLE mb_role
+(
+ role_id serial NOT NULL,
+ role_name character varying(50),
+ role_description character varying(255),
+ role_exclude_auth integer NOT NULL DEFAULT 0,
+ CONSTRAINT role_id PRIMARY KEY (role_id)
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE mb_role OWNER TO postgres;
+
+
+--things to be done for mb_user_mb_group table:
+--drop old constraint
+--Allow to be member in a group with different roles
+ALTER TABLE mb_user_mb_group DROP CONSTRAINT pk_fkey_mb_user_mb_group_id;
+
+UPDATE mb_user_mb_group SET mb_user_mb_group_type = 1 WHERE mb_user_mb_group_type IS NULL OR mb_user_mb_group_type = 0;
+
+--default to standard role
+ALTER TABLE mb_user_mb_group ALTER COLUMN mb_user_mb_group_type SET DEFAULT 1;
+
+-- Constraint: pk_fkey_mb_user_mb_group_id
+
+-- ALTER TABLE mb_user_mb_group DROP CONSTRAINT pk_fkey_mb_user_mb_group_id;
+--create new constraint
+ALTER TABLE mb_user_mb_group
+ ADD CONSTRAINT pk_fkey_mb_user_mb_group_id PRIMARY KEY(fkey_mb_user_id, fkey_mb_group_id, mb_user_mb_group_type);
+
+
+
+--things for the role table
+--standard roles:
+INSERT INTO mb_role (role_name,role_description,role_exclude_auth) VALUES ('standard role','No special role - old behaviour.',0);
+
+INSERT INTO mb_role (role_name,role_description,role_exclude_auth) VALUES ('primary','Primary group for a mapbender user.',0);
+
+INSERT INTO mb_role (role_name,role_description,role_exclude_auth) VALUES ('metadata editor','Group for which the user can edit and publish metadata.',1);
+
+--constraint for new role system
+-- ALTER TABLE mb_user_mb_group DROP CONSTRAINT fkey_mb_user_mb_group_role_id;
+
+ALTER TABLE mb_user_mb_group
+ ADD CONSTRAINT fkey_mb_user_mb_group_role_id FOREIGN KEY (mb_user_mb_group_type)
+ REFERENCES mb_role (role_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE;
+
+--link for admin1
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin1','Group_User_Role',2,1,'allocate groups to user and roles','','a','','href = "../php/mod_group_user_role.php?sessionID&e_id_css=Group_User_Role" target = "AdminFrame" ',10,1234,200,20,NULL ,'font-family: Arial, Helvetica, sans-serif; font-size : 12px; text-decoration : none;color: #808080;','GROUP -> USER -> ROLE','a','','','','AdminFrame','http://www.mapbender.org/index.php/user');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('admin1', 'Group_User_Role', 'file css', '../css/administration_alloc.css', 'file css' ,'file/css');
+
+
+--*****end of role concept****
+
+
Property changes on: branches/kmq_dev/resources/db/pgsql/UTF-8/update/update_2.6rc1_to_2.6_pgsql_UTF-8.sql
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/kmq_dev/resources/db/pgsql/UTF-8/update/update_2.6rc1_to_2.6rc2_pgsql_UTF-8.sql:4021-4487
+ /branches/kmq_dev/resources/db/pgsql/UTF-8/update/update_2.6rc1_to_2.6rc2_pgsql_UTF-8.sql:4021-4487
/trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.6rc1_to_2.6_pgsql_UTF-8.sql:7670-7694
Copied: branches/kmq_dev/tools/build_dist.sh (from rev 7694, trunk/mapbender/tools/build_dist.sh)
===================================================================
--- branches/kmq_dev/tools/build_dist.sh (rev 0)
+++ branches/kmq_dev/tools/build_dist.sh 2011-03-11 08:09:01 UTC (rev 7695)
@@ -0,0 +1,17 @@
+#!/bin/bash
+TMPDIR=`mktemp -d`
+OLDPWD=$PWD
+
+echo $TMPDIR
+svn export . $TMPDIR/mapbender
+
+cd $TMPDIR
+rm -rf mapbender/build mapbender/test
+
+NaturalDocs --exclude-input mapbender/http/extensions/ --exclude-input mapbender/resources --exclude-input mapbender/tools -i mapbender/ -o html mapbender/documents/api_js -p mapbender/documents/api_js
+
+zip -r mapbender.zip mapbender/
+
+cd $OLDPWD
+cp $TMPDIR/mapbender.zip .
+rm -rf $TMPDIR
More information about the Mapbender_commits
mailing list