[Mapbender-commits] r9281 - trunk/mapbender/http/geoportal

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Sep 8 06:21:30 PDT 2015


Author: armin11
Date: 2015-09-08 06:21:30 -0700 (Tue, 08 Sep 2015)
New Revision: 9281

Added:
   trunk/mapbender/http/geoportal/deleteUserProfile.php
Modified:
   trunk/mapbender/http/geoportal/authentication.php
   trunk/mapbender/http/geoportal/insertUserDataIntoDb.php
   trunk/mapbender/http/geoportal/updateUserDataIntoDb.php
Log:
M?\195?\182glichkeit Newsletter zu abonnieren und eigenes Profil zu l?\195?\182schen

Modified: trunk/mapbender/http/geoportal/authentication.php
===================================================================
--- trunk/mapbender/http/geoportal/authentication.php	2015-09-08 13:10:50 UTC (rev 9280)
+++ trunk/mapbender/http/geoportal/authentication.php	2015-09-08 13:21:30 UTC (rev 9281)
@@ -28,6 +28,17 @@
 	Mapbender::session()->set("Textsize",$isAuthenticated["mb_user_textsize"]);
 	Mapbender::session()->set("Glossar",$isAuthenticated["mb_user_glossar"]);
 	Mapbender::session()->set("mb_user_spatial_suggest",$isAuthenticated["mb_user_spatial_suggest"]);
+	$e = new mb_exception('geoportal/authentication.php: mb_user_newsletter: '.$isAuthenticated["mb_user_newsletter"]);
+	if ($isAuthenticated["mb_user_newsletter"] == "t") {
+		Mapbender::session()->set("mb_user_newsletter","ja");
+	} else {
+		Mapbender::session()->set("mb_user_newsletter","nein");
+	}
+	if ($isAuthenticated["mb_user_allow_survey"] == "t") {
+		Mapbender::session()->set("mb_user_allow_survey","ja");
+	} else {
+		Mapbender::session()->set("mb_user_allow_survey","nein");
+	}
 	Mapbender::session()->set("mb_user_description",$isAuthenticated["mb_user_description"]);
 	Mapbender::session()->set("mb_user_city",$isAuthenticated["mb_user_city"]);
 	Mapbender::session()->set("mb_user_postal_code",$isAuthenticated["mb_user_postal_code"]);
@@ -61,9 +72,9 @@
  $res = db_prep_query($sql,$v,$t);
 
  if($row = db_fetch_array($res)){
-   $e = new mb_exception('row mb_user_name: '.$row['mb_user_name']);
-   return $row;	
-  }
+   	$e = new mb_exception('geoportal/authentication.php: user login: '.$row['mb_user_name']);
+  	return $row;	
+ }
   else 
   {
   return false;

Added: trunk/mapbender/http/geoportal/deleteUserProfile.php
===================================================================
--- trunk/mapbender/http/geoportal/deleteUserProfile.php	                        (rev 0)
+++ trunk/mapbender/http/geoportal/deleteUserProfile.php	2015-09-08 13:21:30 UTC (rev 9281)
@@ -0,0 +1,122 @@
+<?php
+# $Id: 
+# http://www.mapbender.org/index.php/
+# 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.
+
+//script is invoked from cms to delete a mapbender user profile from the mapbender db
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+$ajaxResponse = new AjaxResponse($_POST);
+//$admin = new Administration();
+
+function abort ($message) {
+	global $ajaxResponse;
+	$ajaxResponse->setSuccess(false);
+	$ajaxResponse->setMessage($message);
+	$ajaxResponse->send();
+	die();
+}
+
+function getUserFromSession()
+{
+    if (Mapbender::session()->get('mb_user_id')) {
+        if ((integer) Mapbender::session()->get('mb_user_id') >= 0) {
+            $foundUserId = (integer) Mapbender::session()->get('mb_user_id');
+        } else {
+            $foundUserId = false;
+        }
+    } else {
+        $foundUserId = false;
+    }
+    return $foundUserId;
+}
+
+if (getUserFromSession() == (integer)PUBLIC_USER) {
+	abort(_mb("The profile of the Public User cannot be deleted!"));
+} 
+
+if (getUserFromSession() == false) {
+	abort(_mb("Your are not logged in and therefor your user profile cannot be deleted!"));
+} 
+
+//Message if some things have to be done before the profile can be deleted from mapbender database:
+//initialize message
+$message = "";
+
+$sql = "SELECT count(a.service_id) from (SELECT wms_id AS service_id, 'wms' AS service_type FROM wms WHERE wms_owner = $1 UNION SELECT wfs_id AS service_id, 'wfs' as service_type from wfs WHERE wfs_owner = $1 LIMIT 1) AS a;";
+
+$v = array(getUserFromSession());
+$t = array('i');
+$res = db_prep_query($sql,$v,$t);
+
+while($row = db_fetch_array($res)){
+	if ($row['count'] !== "0") {
+		$message .= "\n"._mb("You are owner of registrated services - please delete them or give the ownership to another user.");
+	}
+}
+
+$sql = "SELECT count(fkey_gui_id) FROM  (SELECT fkey_gui_id FROM gui_mb_user WHERE fkey_mb_user_id = $1 AND  mb_user_type = 'owner' LIMIT 1) AS a;";
+$v = array(getUserFromSession());
+$t = array('i');
+$res = db_prep_query($sql,$v,$t);
+
+while($row = db_fetch_array($res)){
+	if ($row['count'] !== "0") {
+		$message .= "\n"._mb("You are owner of guis/applications - please delete them or give the ownership to another user.");
+	}
+}
+
+$sql = "SELECT count(fkey_wms_id) FROM mb_proxy_log INNER JOIN (SELECT wms_id FROM wms WHERE (wms_pricevolume NOTNULL AND wms_pricevolume <> 0) OR (wms_price_fi NOTNULL AND wms_price_fi <> 0)) as a ON a.wms_id = mb_proxy_log.fkey_wms_id WHERE fkey_mb_user_id = $1 LIMIT 1;";
+
+$v = array(getUserFromSession());
+$t = array('i');
+$res = db_prep_query($sql,$v,$t);
+
+while($row = db_fetch_array($res)){
+	if ($row['count'] !== "0") {
+		$message .= "\n"._mb("There are logged service accesses for this user profile. Please connect the service administrators for the billing first.");
+	}
+}
+
+if ($message !=="") {
+	$message = "The current profile cannot be deleted for the following reasons: ".$message;
+	abort($message);
+}
+
+switch ($ajaxResponse->getMethod()){
+	case "deleteUserProfile" :
+		$sql = "DELETE FROM mb_user WHERE mb_user_id = $1;";
+		$v = array(getUserFromSession());
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		if ($res !== false) {
+			$ajaxResponse->setSuccess(true);
+			$ajaxResponse->setMessage(_mb("User with ID")." - ".getUserFromSession()." - "._mb("was deleted from the geoportal database")."!");
+			$ajaxResponse->setResult("User deleted successfully!");
+			$ajaxResponse->send();
+		} else {
+			abort(_mb("User with ID")." - ".getUserFromSession()." - "._mb("cannot be deleted from the geoportal database - something went wrong")."!");
+		}	
+	break;
+	default :
+		abort(_mb("Used request method is not allowed!"));	
+	break;
+}
+
+?>

Modified: trunk/mapbender/http/geoportal/insertUserDataIntoDb.php
===================================================================
--- trunk/mapbender/http/geoportal/insertUserDataIntoDb.php	2015-09-08 13:10:50 UTC (rev 9280)
+++ trunk/mapbender/http/geoportal/insertUserDataIntoDb.php	2015-09-08 13:21:30 UTC (rev 9281)
@@ -1,6 +1,6 @@
 <?php
 # $Id: 
-# http://www.mapbender.org/index.php/Monitor_Capabilities
+# http://www.mapbender.org/index.php/
 # Copyright (C) 2002 CCGIS 
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,10 +17,10 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-#	require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+//script is invoked from cms to insert a mapbender user into the mapbender db
+
 	require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 	require_once(dirname(__FILE__)."/../classes/class_administration.php");
-	#echo "test<br>";
 	$mb_user_password = '';
 	$adm = new administration();
 	$con = db_connect(DBSERVER,OWNER,PW);
@@ -39,41 +39,32 @@
 	if ($mb_user_name == 'guest') {
 		$registerAsGuest = true;
 	}
-	//// überprüfen ob User und oder Mail bereits existieren
+	//überprüfen ob User und oder Mail bereits existieren
 		$sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_email = $2";
  		$v = array($mb_user_name,$mb_user_email); // wird in unserer Lösung immer md5 genutzt?
-		 $t = array('s','s');
+		$t = array('s','s');
  		$res = db_prep_query($sql,$v,$t);
- 		//$row = db_fetch_array($res);
- 	$emailValid = 1;
-	if(db_numrows($res) == 0 and !($registerAsGuest)){
-	
+ 		$emailValid = 1;
+		if(db_numrows($res) == 0 and !($registerAsGuest)){
 		$userAlreadyExists = 0;
-		/// pr�fen auf email und richtigkeit
+		//prüfen auf email und richtigkeit
 		if($adm->isValidEmail($mb_user_email))
 		{
 			$emailValid = 1;	
-			/////INSERT
+			//INSERT
 			if(!isset($mb_user_postal_code) || $mb_user_postal_code == ''){ $mb_user_postal_code = 0;}
-			$sql = "INSERT INTO mb_user (mb_user_name,mb_user_password,mb_user_digest,mb_user_owner,mb_user_description,mb_user_email,mb_user_phone,mb_user_department,mb_user_organisation_name,mb_user_position_name,mb_user_city,mb_user_postal_code, mb_user_textsize, mb_user_glossar) VALUES ($1, $2,$13, '5299', $3, $4, $5, $6, $7, $8, $9, $10,$11,$12)";
-			$v = array($mb_user_name, md5($mb_user_password), $mb_user_description, $mb_user_email, $mb_user_phone, $mb_user_department, $mb_user_organisation_name, $mb_user_position_name, $mb_user_city, $mb_user_postal_code, 'textsize1' ,'ja',md5($mb_user_name.";".$mb_user_email.":".REALM.":".$mb_user_password));
-			$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 's', 's', 's');
+			$sql = "INSERT INTO mb_user (mb_user_name,mb_user_password,mb_user_digest,mb_user_owner,mb_user_description,mb_user_email,mb_user_phone,mb_user_department,mb_user_organisation_name,mb_user_position_name,mb_user_city,mb_user_postal_code, mb_user_textsize, mb_user_glossar, mb_user_allow_survey) VALUES ($1, $2, $13, '5299', $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $14)";
+			$v = array($mb_user_name, md5($mb_user_password), $mb_user_description, $mb_user_email, $mb_user_phone, $mb_user_department, $mb_user_organisation_name, $mb_user_position_name, $mb_user_city, $mb_user_postal_code, 'textsize1' ,'ja',md5($mb_user_name.";".$mb_user_email.":".REALM.":".$mb_user_password), 't');
+			$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 's', 's', 's', 'b');
 			$res = db_prep_query($sql, $v, $t);
-	
-			//$sql = "SELECT mb_group_id FROM mb_group WHERE mb_group_name = 'guest' LIMIT 1";
-			//$res = db_prep_query($sql, array(), array());
-			//$row = db_fetch_array($res);
 			$group_id = 37;
 			$sql = "INSERT INTO mb_user_mb_group (fkey_mb_user_id, fkey_mb_group_id) VALUES ($1, $2)";
 			$v = array($adm->getUserIdByUserName($mb_user_name), $group_id);
 			$t = array('i', 'i');
 			$res = db_prep_query($sql, $v, $t);
-	
 			//Mailversand
 			$mailBody = $mailBody1.$mb_user_name.$mailBody2.$mb_user_password.$mailBody3;
-
 			$mailBody = iconv("UTF-8", "ISO-8859-1", $mailBody);
-			#echo $mailBody."<br>";
 			$success = $adm->sendEmail(MAILADMIN, MAILADMINNAME, $mb_user_email, $mb_user_name, 'Ihre Registrierung', $mailBody, $error_msg );
 		}
 		else

Modified: trunk/mapbender/http/geoportal/updateUserDataIntoDb.php
===================================================================
--- trunk/mapbender/http/geoportal/updateUserDataIntoDb.php	2015-09-08 13:10:50 UTC (rev 9280)
+++ trunk/mapbender/http/geoportal/updateUserDataIntoDb.php	2015-09-08 13:21:30 UTC (rev 9281)
@@ -33,7 +33,7 @@
 	// start sql statement
 	$sql = "UPDATE mb_user SET";
         $sql .= " mb_user_owner = 5299"; #all users belong to the central administrator
-         //change username if field is not empty - the variables are from the calling script
+        //change username if field is not empty - the variables are from the calling script
         if ($mb_user_name != '') {
             $fields[] = array('mb_user_name', $mb_user_name, 's');
         }
@@ -67,6 +67,11 @@
         $fields[] = array('mb_user_textsize', $Textsize, 's');
         $fields[] = array('mb_user_glossar', $Glossar, 's');
         $fields[] = array('mb_user_spatial_suggest', $mb_user_spatial_suggest, 's');
+	if ($mb_user_newsletter == "ja") {$mb_user_newsletter = "t";} else {$mb_user_newsletter = "f";}
+	if ($mb_user_allow_survey == "ja") {$mb_user_allow_survey = "t";} else {$mb_user_allow_survey = "f";}
+        $fields[] = array('mb_user_newsletter', $mb_user_newsletter, 'b');
+	$fields[] = array('mb_user_allow_survey', $mb_user_allow_survey, 'b');
+	
         // build sql statement
         foreach ($fields as $idx => $field) {
             $sql .= ', '.$field[0].' = $'.($idx + 1);
@@ -74,7 +79,6 @@
             $t[] = $field[2];
         }
         // + where condition
-	
         $v[] = $_SESSION["mb_user_id"];
         $t[] = 'i';
         $sql .= 'WHERE mb_user_id = $'.count($v);//.' AND mb_user_name != \'guest\'';
@@ -86,6 +90,8 @@
 		$e = new mb_exception("db_query($qstring)=$ret db_error=".db_error());	
 	}
 	//UPDATE of the SESSION VARS
+	if ($mb_user_newsletter == "t") {$mb_user_newsletter = "ja";} else {$mb_user_newsletter = "nein";}
+	if ($mb_user_allow_survey == "t") {$mb_user_allow_survey = "ja";} else {$mb_user_allow_survey = "nein";}
 	$_SESSION["mb_user_email"] = $mb_user_email; 
 	$_SESSION["mb_user_department"] = $mb_user_department; 
 	$_SESSION["mb_user_organisation_name"] = $mb_user_organisation_name; 
@@ -93,22 +99,10 @@
 	$_SESSION["mb_user_phone"] = $mb_user_phone; 
 	$_SESSION["Textsize"] = $Textsize;
 	$_SESSION["Glossar"] = $Glossar;	
-	$_SESSION["mb_user_spatial_suggest"] = $mb_user_spatial_suggest;	
+	$_SESSION["mb_user_spatial_suggest"] = $mb_user_spatial_suggest;
+	$_SESSION["mb_user_newsletter"] = $mb_user_newsletter;
+	$_SESSION["mb_user_allow_survey"] = $mb_user_allow_survey;
 	$_SESSION["mb_user_description"]= $mb_user_description;
 	$_SESSION["mb_user_city"]= $mb_user_city;
 	$_SESSION["mb_user_postal_code"]= $mb_user_postal_code;
-	
-	
-	
-	
-/*	//Push registrated user into ANONYMOUS_GROUP guest????
-	$sql = "SELECT mb_group_id FROM mb_group WHERE mb_group_name = 'guest' LIMIT 1";
-	$res = db_prep_query($sql, array(), array());
-	$row = db_fetch_array($res);
-	$group_id = $row['mb_group_id'];
-	$sql = "INSERT INTO mb_user_mb_group (fkey_mb_user_id, fkey_mb_group_id) VALUES ($1, $2)";
-	$v = array($adm->getUserIdByUserName($mb_user_name), $group_id);
-	$t = array('i', 'i');
-	$res = db_prep_query($sql, $v, $t);
-*/
 ?>



More information about the Mapbender_commits mailing list