From 93e0fc9705ec2fa8210748be1a56028c0d7c4379 Mon Sep 17 00:00:00 2001 From: Angelo Cuccato Date: Wed, 13 Jan 2010 00:07:42 +0100 Subject: [PATCH] add group functions --- DB/update_20100112_2300.sql | 2 ++ includes/UserCVS.php | 30 ++++++++++++----- includes/funktion_user.php | 19 +++++++---- includes/header.php | 7 +--- www-ssl/admin/user.php | 49 +++++++++++++++++++++------- www-ssl/admin/user2.php | 13 ++++++-- www-ssl/admin/userDefaultSetting.php | 35 +++++++++++++------- 7 files changed, 110 insertions(+), 45 deletions(-) create mode 100644 DB/update_20100112_2300.sql diff --git a/DB/update_20100112_2300.sql b/DB/update_20100112_2300.sql new file mode 100644 index 00000000..ab944226 --- /dev/null +++ b/DB/update_20100112_2300.sql @@ -0,0 +1,2 @@ +ALTER TABLE `UserCVS` ADD `GroupID` INT NULL AFTER `UID` ; + diff --git a/includes/UserCVS.php b/includes/UserCVS.php index f6bc30ed..4f606b7e 100755 --- a/includes/UserCVS.php +++ b/includes/UserCVS.php @@ -4,14 +4,28 @@ if( !isset($_SESSION['UID'])) $_SESSION['UID'] = -1; // CVS import Data -$SQL = "SELECT * FROM `UserCVS` WHERE UID=".$_SESSION['UID']; -$Erg_CVS = mysql_query($SQL, $con); +$SQL_CVS = "SELECT * FROM `UserCVS` WHERE UID=".$_SESSION['UID']; +$Erg_CVS = mysql_query($SQL_CVS, $con); $_SESSION['CVS'] = mysql_fetch_array($Erg_CVS); + +// Group import Data, if nesseary +if( isset( $_SESSION['CVS'][ "GroupID" ])) +{ + $SQL_GRP = "SELECT * FROM `UserCVS` WHERE UID=".$_SESSION['CVS'][ "GroupID" ]; + $Erg_GRP = mysql_query($SQL_GRP, $con); + $_SESSION['CVS_Group'] = mysql_fetch_array($Erg_GRP); + + foreach( $_SESSION['CVS'] as $k => $v) + { + if($v=="G") // Right == Group + $_SESSION['CVS'][$k] = $_SESSION['CVS_Group'][$k]; + } +} + //pagename ermitteln $Page["Name"] = substr( $_SERVER['PHP_SELF'], strlen($ENGEL_ROOT) ); - //recht für diese seite auslesen if( isset( $_SESSION['CVS'][ $Page["Name"] ])) $Page["CVS"] = $_SESSION['CVS'][ $Page["Name"] ]; @@ -23,11 +37,11 @@ else if( $DEBUG ) { -// echo "UserID:". $_SESSION["UID"]. "
"; -// echo "Nick:". $_SESSION["Nick"]. "
"; - - foreach( $_SESSION as $k => $v) - echo "$k = $v
\n"; +// foreach( $_SESSION as $k => $v) +// echo "$k = $v
\n"; + echo "
\$_SESSION:\n";
+		print_r($_SESSION);
+	echo "
"; if( strlen($Page["CVS"]) == 0 ) echo "

CVS ERROR, on page '". $Page["Name"]. "'

"; diff --git a/includes/funktion_user.php b/includes/funktion_user.php index bcb77778..742b2624 100755 --- a/includes/funktion_user.php +++ b/includes/funktion_user.php @@ -3,15 +3,22 @@ function UID2Nick($UID) { global $con; - - $SQL = "SELECT Nick FROM `User` WHERE UID='$UID'"; + + if( $UID>0) { + $SQL = "SELECT Nick FROM `User` WHERE UID='$UID'"; + } else { + $SQL = "SELECT Name FROM `UserGroups` WHERE UID='$UID'"; + } $Erg = mysql_query($SQL, $con); //echo $UID."#"; - if( mysql_num_rows($Erg)) - return mysql_result($Erg, 0); - else - { + if( mysql_num_rows($Erg)) { + if( $UID>0 ) { + return mysql_result($Erg, 0); + } else { + return "Group-".mysql_result($Erg, 0); + } + } else { if( $UID == -1) return "logout User"; else diff --git a/includes/header.php b/includes/header.php index fc5a3a96..6529706a 100755 --- a/includes/header.php +++ b/includes/header.php @@ -7,12 +7,7 @@ echo "\n"; --- $title $Version ---"; +echo "--- $title ---"; ?> diff --git a/www-ssl/admin/user.php b/www-ssl/admin/user.php index 05bc5fd6..5b6077aa 100755 --- a/www-ssl/admin/user.php +++ b/www-ssl/admin/user.php @@ -129,7 +129,7 @@ else "bereits sein T-Shirt erhalten hat.

\n"; echo "
\n"; - echo "\n"; + echo "
\n"; echo "\n"; if( $_GET["Type"] == "Normal" ) @@ -259,16 +259,43 @@ else //nur jeder zweiter sonst wird für jeden text noch die position (Zahl) ausgegeben if( $CVS_Data_i%2 && $CVS_Data_Name!="UID") { - echo "\n"; + if($CVS_Data_Name=="GroupID") { + if( $_GET["enterUID"] > 0 ) + { + echo "\n". + ""; + } + } else { + echo "\n"; + } + } } //IF } //Foreach echo "\n"; diff --git a/www-ssl/admin/user2.php b/www-ssl/admin/user2.php index b4647da5..229a4cdc 100755 --- a/www-ssl/admin/user2.php +++ b/www-ssl/admin/user2.php @@ -54,10 +54,17 @@ if (IsSet($_GET["action"])) $CVS_Data_i = 1; foreach ($CVS_Data as $CVS_Data_Name => $CVS_Data_Value) { - if( ($CVS_Data_i+1)%2 && $CVS_Data_Name!="UID") - $SQL2.= "`$CVS_Data_Name` = '". $_POST[$CVS_Data_i]."', "; - $CVS_Data_i++; + if( ($CVS_Data_i+1)%2 && $CVS_Data_Name!="UID") { + if( $CVS_Data_Name == "GroupID") + { + if( $_POST["enterUID"] > 0 ) + $SQL2.= "`$CVS_Data_Name` = ". $_POST["GroupID"].", "; + } else { + $SQL2.= "`$CVS_Data_Name` = '". $_POST[$CVS_Data_i]."', "; + } } + $CVS_Data_i++; + } $SQL2 = substr( $SQL2, 0, strlen($SQL2)-2 ); $SQL2.= " WHERE `UID`='". $_POST["enterUID"]. "' LIMIT 1;"; echo "
Secure-"; diff --git a/www-ssl/admin/userDefaultSetting.php b/www-ssl/admin/userDefaultSetting.php index 3c47ebc7..09c62a15 100755 --- a/www-ssl/admin/userDefaultSetting.php +++ b/www-ssl/admin/userDefaultSetting.php @@ -46,7 +46,7 @@ if( isset( $_GET["Field"]) && isset( $_GET["Default"]) && isset( $_GET["Send"])) "[". mysql_error(). "]

"; break; case "SetForAllUser": - $SQL = "UPDATE `UserCVS` SET `". $_GET["Field"]. "`='". $_GET["Default"]. "'"; + $SQL = "UPDATE `UserCVS` SET `". $_GET["Field"]. "`='". $_GET["Default"]. "' WHERE UID>0"; $Erg = mysql_query( $SQL, $con); if( $Erg == 1) echo "

UPDATE ".$_GET["Field"]. " = ". $_GET["Default"]. " for all Users succesfull

\n"; @@ -70,20 +70,30 @@ if( isset( $_GET["Field"]) && isset( $_GET["Default"]) && isset( $_GET["Send"])) $erg = mysql_query("SHOW COLUMNS FROM `UserCVS`"); echo mysql_error(); -for( $i=1; $i\n"; echo "\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; - echo "\t\t\t\n"; + echo " checked"; + echo ">allow\n"; + + echo "\t\t\t\tdenied\n"; + + echo "\t\t\t\tgroup-setting\n"; + + echo "\t\t\t\n"; echo "\t\t\t\n"; @@ -95,8 +105,11 @@ echo "\t\n"; echo "\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; -echo "\t\t\t\n"; +echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\n"; echo "\t\n";
$CVS_Data_Name"; - echo "allow \n"; - echo "denied \n"; - echo "
Group
$CVS_Data_Name"; + echo "allow \n"; + echo "denied \n"; + if( $_GET["enterUID"] > 0 ) + { + echo "group-setting \n"; + echo "
". mysql_result( $erg, $i, "Field"). ""; + echo "\t\t\t\n"; + + echo "\t\t\t\tY\n". - "\t\t\t N"; - else - echo "Y\n". - "\t\t\t N"; - echo "\n"; echo "\t\t\t \n"; echo "\t\t\t
Y\t". - "\t\t\t\tN\n"; +echo "\t\t\t\tallow\n"; +echo "\t\t\t\tdenied\n"; +echo "\t\t\t\tgroup-setting\n"; +echo "\t\t\t