add group functions

This commit is contained in:
Angelo Cuccato 2010-01-13 00:07:42 +01:00
parent 49858dba14
commit 93e0fc9705
7 changed files with 110 additions and 45 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE `UserCVS` ADD `GroupID` INT NULL AFTER `UID` ;

View File

@ -4,14 +4,28 @@ if( !isset($_SESSION['UID']))
$_SESSION['UID'] = -1; $_SESSION['UID'] = -1;
// CVS import Data // CVS import Data
$SQL = "SELECT * FROM `UserCVS` WHERE UID=".$_SESSION['UID']; $SQL_CVS = "SELECT * FROM `UserCVS` WHERE UID=".$_SESSION['UID'];
$Erg_CVS = mysql_query($SQL, $con); $Erg_CVS = mysql_query($SQL_CVS, $con);
$_SESSION['CVS'] = mysql_fetch_array($Erg_CVS); $_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 //pagename ermitteln
$Page["Name"] = substr( $_SERVER['PHP_SELF'], strlen($ENGEL_ROOT) ); $Page["Name"] = substr( $_SERVER['PHP_SELF'], strlen($ENGEL_ROOT) );
//recht für diese seite auslesen //recht für diese seite auslesen
if( isset( $_SESSION['CVS'][ $Page["Name"] ])) if( isset( $_SESSION['CVS'][ $Page["Name"] ]))
$Page["CVS"] = $_SESSION['CVS'][ $Page["Name"] ]; $Page["CVS"] = $_SESSION['CVS'][ $Page["Name"] ];
@ -23,11 +37,11 @@ else
if( $DEBUG ) if( $DEBUG )
{ {
// echo "UserID:". $_SESSION["UID"]. "<br>"; // foreach( $_SESSION as $k => $v)
// echo "Nick:". $_SESSION["Nick"]. "<br>"; // echo "$k = $v<br>\n";
echo "<pre>\$_SESSION:\n";
foreach( $_SESSION as $k => $v) print_r($_SESSION);
echo "$k = $v<br>\n"; echo "</pre>";
if( strlen($Page["CVS"]) == 0 ) if( strlen($Page["CVS"]) == 0 )
echo "<h1><u> CVS ERROR, on page '". $Page["Name"]. "'</u></h1>"; echo "<h1><u> CVS ERROR, on page '". $Page["Name"]. "'</u></h1>";

View File

@ -4,14 +4,21 @@ function UID2Nick($UID)
{ {
global $con; global $con;
if( $UID>0) {
$SQL = "SELECT Nick FROM `User` WHERE UID='$UID'"; $SQL = "SELECT Nick FROM `User` WHERE UID='$UID'";
} else {
$SQL = "SELECT Name FROM `UserGroups` WHERE UID='$UID'";
}
$Erg = mysql_query($SQL, $con); $Erg = mysql_query($SQL, $con);
//echo $UID."#"; //echo $UID."#";
if( mysql_num_rows($Erg)) if( mysql_num_rows($Erg)) {
if( $UID>0 ) {
return mysql_result($Erg, 0); return mysql_result($Erg, 0);
else } else {
{ return "Group-".mysql_result($Erg, 0);
}
} else {
if( $UID == -1) if( $UID == -1)
return "logout User"; return "logout User";
else else

View File

@ -7,12 +7,7 @@ echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
<HEAD> <HEAD>
<?PHP <?PHP
// SVN versions auswertung echo "<TITLE>--- $title ---</TITLE>";
exec("svnversion", $VersionArray);
if( strlen($VersionArray[0]))
$Version = "(r ". $VersionArray[0]. ")";
echo "<TITLE>--- $title $Version ---</TITLE>";
?> ?>
<meta name="keywords" content="Engel, Himmelsverwaltung"> <meta name="keywords" content="Engel, Himmelsverwaltung">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

View File

@ -129,7 +129,7 @@ else
"bereits sein T-Shirt erhalten hat.<br><br>\n"; "bereits sein T-Shirt erhalten hat.<br><br>\n";
echo "<form action=\"./user2.php?action=change\" method=\"POST\">\n"; echo "<form action=\"./user2.php?action=change\" method=\"POST\">\n";
echo "<table>\n"; echo "<table border=\"0\">\n";
echo "<input type=\"hidden\" name=\"Type\" value=\"". $_GET["Type"]. "\">\n"; echo "<input type=\"hidden\" name=\"Type\" value=\"". $_GET["Type"]. "\">\n";
if( $_GET["Type"] == "Normal" ) if( $_GET["Type"] == "Normal" )
@ -259,6 +259,25 @@ else
//nur jeder zweiter sonst wird für jeden text noch die position (Zahl) ausgegeben //nur jeder zweiter sonst wird für jeden text noch die position (Zahl) ausgegeben
if( $CVS_Data_i%2 && $CVS_Data_Name!="UID") if( $CVS_Data_i%2 && $CVS_Data_Name!="UID")
{ {
if($CVS_Data_Name=="GroupID") {
if( $_GET["enterUID"] > 0 )
{
echo "<tr><td><b>Group</b></td>\n".
"<td><select name=\"GroupID\">";
$SQL_Group = "SELECT * FROM `UserGroups`";
$Erg_Group = mysql_query($SQL_Group, $con);
for ($n = 0 ; $n < mysql_num_rows($Erg_Group) ; $n++)
{
$UID = mysql_result($Erg_Group, $n, "UID");
echo "\t<option value=\"$UID\"";
if( $CVS_Data_Value == $UID)
echo " selected";
echo ">". mysql_result($Erg_Group, $n, "Name"). "</option>\n";
}
echo "</select></td></tr>";
}
} else {
echo "<tr><td>$CVS_Data_Name</td>\n<td>"; echo "<tr><td>$CVS_Data_Name</td>\n<td>";
echo "<input type=\"radio\" name=\"".($CVS_Data_i-1)."\" value=\"Y\" "; echo "<input type=\"radio\" name=\"".($CVS_Data_i-1)."\" value=\"Y\" ";
if( $CVS_Data_Value == "Y" ) if( $CVS_Data_Value == "Y" )
@ -268,7 +287,15 @@ else
if( $CVS_Data_Value == "N" ) if( $CVS_Data_Value == "N" )
echo " checked"; echo " checked";
echo ">denied \n"; echo ">denied \n";
if( $_GET["enterUID"] > 0 )
{
echo "<input type=\"radio\" name=\"".($CVS_Data_i-1)."\" value=\"G\" ";
if( $CVS_Data_Value == "G" )
echo " checked";
echo ">group-setting \n";
echo "</td></tr>"; echo "</td></tr>";
}
}
} //IF } //IF
} //Foreach } //Foreach
echo "</td></tr>\n"; echo "</td></tr>\n";

View File

@ -54,8 +54,15 @@ if (IsSet($_GET["action"]))
$CVS_Data_i = 1; $CVS_Data_i = 1;
foreach ($CVS_Data as $CVS_Data_Name => $CVS_Data_Value) foreach ($CVS_Data as $CVS_Data_Name => $CVS_Data_Value)
{ {
if( ($CVS_Data_i+1)%2 && $CVS_Data_Name!="UID") 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]."', "; $SQL2.= "`$CVS_Data_Name` = '". $_POST[$CVS_Data_i]."', ";
}
}
$CVS_Data_i++; $CVS_Data_i++;
} }
$SQL2 = substr( $SQL2, 0, strlen($SQL2)-2 ); $SQL2 = substr( $SQL2, 0, strlen($SQL2)-2 );

View File

@ -46,7 +46,7 @@ if( isset( $_GET["Field"]) && isset( $_GET["Default"]) && isset( $_GET["Send"]))
"[". mysql_error(). "]<br><br>"; "[". mysql_error(). "]<br><br>";
break; break;
case "SetForAllUser": 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); $Erg = mysql_query( $SQL, $con);
if( $Erg == 1) if( $Erg == 1)
echo "<H2>UPDATE ".$_GET["Field"]. " = ". $_GET["Default"]. " for all Users succesfull</h2>\n"; echo "<H2>UPDATE ".$_GET["Field"]. " = ". $_GET["Default"]. " for all Users succesfull</h2>\n";
@ -70,20 +70,30 @@ if( isset( $_GET["Field"]) && isset( $_GET["Default"]) && isset( $_GET["Send"]))
$erg = mysql_query("SHOW COLUMNS FROM `UserCVS`"); $erg = mysql_query("SHOW COLUMNS FROM `UserCVS`");
echo mysql_error(); echo mysql_error();
for( $i=1; $i<mysql_num_rows($erg); $i++) for( $i=2; $i<mysql_num_rows($erg); $i++)
{ {
echo "\t<tr class=\"content\">\n"; echo "\t<tr class=\"content\">\n";
echo "\t\t<form action=\"userDefaultSetting.php\">\n"; echo "\t\t<form action=\"userDefaultSetting.php\">\n";
echo "\t\t\t<input name=\"Field\" type=\"hidden\" value=\"". mysql_result( $erg, $i, "Field"). "\">\n"; echo "\t\t\t<input name=\"Field\" type=\"hidden\" value=\"". mysql_result( $erg, $i, "Field"). "\">\n";
echo "\t\t\t<td>". mysql_result( $erg, $i, "Field"). "</td>\n"; echo "\t\t\t<td>". mysql_result( $erg, $i, "Field"). "</td>\n";
echo "\t\t\t<td>"; echo "\t\t\t<td>\n";
echo "\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"Y\"";
if( mysql_result( $erg, $i, "Default") == "Y") if( mysql_result( $erg, $i, "Default") == "Y")
echo "<input type=\"radio\" name=\"Default\" value=\"Y\" checked>Y\n". echo " checked";
"\t\t\t <input type=\"radio\" name=\"Default\" value=\"N\">N"; echo ">allow\n";
else
echo "<input type=\"radio\" name=\"Default\" value=\"Y\">Y\n". echo "\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"N\"";
"\t\t\t <input type=\"radio\" name=\"Default\" value=\"N\" checked>N"; if( mysql_result( $erg, $i, "Default") == "N")
echo "</td>\n"; echo " checked";
echo ">denied\n";
echo "\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"G\"";
if( mysql_result( $erg, $i, "Default") == "G")
echo " checked";
echo ">group-setting\n";
echo "\t\t\t</td>\n";
echo "\t\t\t<td><input type=\"submit\" name=\"Send\" value=\"Save\">\n"; echo "\t\t\t<td><input type=\"submit\" name=\"Send\" value=\"Save\">\n";
echo "\t\t\t <input type=\"submit\" name=\"Send\" value=\"Del\">\n"; echo "\t\t\t <input type=\"submit\" name=\"Send\" value=\"Del\">\n";
echo "\t\t\t <input type=\"submit\" name=\"Send\" value=\"SetForAllUser\"></td>\n"; echo "\t\t\t <input type=\"submit\" name=\"Send\" value=\"SetForAllUser\"></td>\n";
@ -95,8 +105,11 @@ echo "\t<tr class=\"content\">\n";
echo "\t\t<form action=\"userDefaultSetting.php\">\n"; echo "\t\t<form action=\"userDefaultSetting.php\">\n";
echo "\t\t\t<input name=\"New\" type=\"hidden\" value=\"New\">\n"; echo "\t\t\t<input name=\"New\" type=\"hidden\" value=\"New\">\n";
echo "\t\t\t<td><input name=\"Field\" type=\"text\" value=\"new\"></td>\n"; echo "\t\t\t<td><input name=\"Field\" type=\"text\" value=\"new\"></td>\n";
echo "\t\t\t<td><input type=\"radio\" name=\"Default\" value=\"Y\">Y\t". echo "\t\t\t<td>\n";
"\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"N\">N</td>\n"; echo "\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"Y\">allow\n";
echo "\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"N\">denied\n";
echo "\t\t\t\t<input type=\"radio\" name=\"Default\" value=\"G\" checked>group-setting\n";
echo "\t\t\t</td>\n";
echo "\t\t\t<td><input type=\"submit\" name=\"Send\" value=\"New\"></td>\n"; echo "\t\t\t<td><input type=\"submit\" name=\"Send\" value=\"New\"></td>\n";
echo "\t\t</form>\n"; echo "\t\t</form>\n";
echo "\t</tr>\n"; echo "\t</tr>\n";