@ -35,26 +35,27 @@ function getOtherUserGroups($user) {
}
}
function displayUserGroups($action, $name, $ugname, $delete, $add) {
function displayUserGroups($action, $name, $ugname, $delete, $add) {
if($action === 'search') {
if($action === 'search') {
$username = validateName($name);
$username = validateName($name);
if ($delete !== NULL & & $delete >= 0) {
if($username !== NULL) {
$qry = 'DELETE FROM user_gruppe_zuordnung WHERE user_id in (SELECT id FROM user WHERE nickname = \''.$username.
if ($delete !== NULL & & $delete >= 0) {
$qry = 'DELETE FROM user_gruppe_zuordnung WHERE user_id in (SELECT id FROM user WHERE nickname = \''.$username.
'\') AND gruppen_id = '.$delete.';';
'\') AND gruppen_id = '.$delete.';';
mysql_query($qry);
mysql_query($qry);
} else if($add !== NULL & & $add >= 0) {
} else if($add !== NULL & & $add >= 0) {
$qry = 'INSERT INTO user_gruppe_zuordnung(user_id, gruppen_id)
$qry = 'INSERT INTO user_gruppe_zuordnung(user_id, gruppen_id)
VALUES((SELECT id FROM user WHERE nickname = \''.$username.'\'), '.$add.');';
VALUES((SELECT id FROM user WHERE nickname = \''.$username.'\'), '.$add.');';
mysql_query($qry);
mysql_query($qry);
}
}
$usergroups = getUserGroups($username);
$usergroups = getUserGroups($username);
$notusergroups = getOtherUserGroups($username);
$notusergroups = getOtherUserGroups($username);
?>
?>
< form action = " <?php echo $_SERVER [ 'PHP_SELF' ]; ?> " method = "POST" >
< form action = " <?php echo $_SERVER [ 'PHP_SELF' ]; ?> " method = "POST" >
< input name = "choose" value = "usergroups" type = "hidden" > < / input >
< input name = "choose" value = "usergroups" type = "hidden" > < / input > < input
< input name = "action" value = "search" type = "hidden" > < / input >
name="action" value="search" type="hidden">< / input > < input
< input name = "uname" value = " <?php echo $username ; ?> " type = "hidden" > </input >
name="uname" value="<?php echo $username ; ?> " type="hidden"> </input >
< table width = "80%" >
< table width = "80%" >
< tr >
< tr >
< th align = "center" colspan = "3" > User <?php echo $username ; ?> </ th >
< th align = "center" colspan = "3" > User <?php echo $username ; ?> </ th >
@ -107,7 +108,9 @@ function displayUserGroups($action, $name, $ugname, $delete, $add) {
< / tr >
< / tr >
< / table >
< / table >
< / form >
< / form >
<?php
<?php } else {
echo 'Ungültiger Username!< br > < a href = '.$_SERVER[' PHP_SELF ' ] . ' ? choose = usergroups > Zurü ck< / a > ';
}
} else if($action === 'show') {
} else if($action === 'show') {
$username = validateName($ugname);
$username = validateName($ugname);
$sqlqry = 'SELECT u.nickname FROM user_gruppe_zuordnung ugz
$sqlqry = 'SELECT u.nickname FROM user_gruppe_zuordnung ugz
@ -122,7 +125,7 @@ function displayUserGroups($action, $name, $ugname, $delete, $add) {
< tr >
< tr >
< td colspan = "3" >
< td colspan = "3" >
< table border = "1" width = "100%" >
< table border = "1" width = "100%" >
<?php
<?php
echo '< tr > ';
echo '< tr > ';
$x = 0;
$x = 0;
while($row = mysql_fetch_assoc($usergroups_qry)){
while($row = mysql_fetch_assoc($usergroups_qry)){
@ -154,15 +157,15 @@ function displayUserGroups($action, $name, $ugname, $delete, $add) {
} else {
} else {
?>
?>
< form action = " <?php echo $_SERVER [ 'PHP_SELF' ]; ?> " method = "POST" >
< form action = " <?php echo $_SERVER [ 'PHP_SELF' ]; ?> " method = "POST" >
< input name = "choose" value = "usergroups" type = "hidden" > < / input >
< input name = "choose" value = "usergroups" type = "hidden" > < / input > < input
< input name = "action" value = "search" type = "hidden" > < / input >
name="action" value="search" type="hidden"> < / input >
< table width = "80%" >
< table width = "80%" >
< tr >
< tr >
< th align = "center" colspan = "3" > User suchen< / th >
< th align = "center" colspan = "3" > User suchen< / th >
< / tr >
< / tr >
< tr >
< tr >
< td align = "center" > Username: < input name = "uname" value = "" / >
< td align = "center" > Username: < input name = "uname" value = "" / > < input
< input type = "submit" value = "search" / >
type="submit" value="search" />
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
@ -190,7 +193,7 @@ function displayUserGroups($action, $name, $ugname, $delete, $add) {
< / tr >
< / tr >
< / table >
< / table >
< / form >
< / form >
<?php
<?php
}
}
}?>
}?>