Different changes that were made online
This commit is contained in:
@@ -27,6 +27,23 @@ $ret = "";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function arrayKeyed2htmlTableString($anArray, $keyList){
|
||||
$ret = "";
|
||||
if( !is_array($anArray) )
|
||||
return "";
|
||||
$ret .= "<table>";
|
||||
foreach($anArray as $row){
|
||||
if( !is_array($anArray) )
|
||||
continue;
|
||||
$ret .= "<tr>";
|
||||
foreach( $keyList as $key )
|
||||
$ret .= "<td>".$row[$key]."</td>";
|
||||
$ret .= "</tr>";
|
||||
}
|
||||
$ret .= "</table>";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/// einem User ein Attribut zuordnen
|
||||
///
|
||||
/// @param $aDbConnection PDO-Datenbankverbindung, die benutzt werden soll
|
||||
@@ -185,13 +202,37 @@ $userAttributes =
|
||||
<?php echo(array2htmlTableString($userAttributes));?>
|
||||
<?php
|
||||
foreach($userAttributes as $userAttribute){
|
||||
echo("<h2>".$userAttribute["name"]."</h2>");
|
||||
// get the users with the attribute by a cross join
|
||||
// remark: there are two id-columns, from which one gets lost (the one from the user) in the phpArray.
|
||||
// so we (have to) use the userId from the attribute
|
||||
// in short attributed => userId, unattributed => id (is the id of the user)
|
||||
$attributedUsers =
|
||||
dbQuery(
|
||||
$dbConn,
|
||||
"SELECT * FROM wkParticipo_Users, `wkParticipo_user<=>userAttributes` WHERE wkParticipo_Users.id = `wkParticipo_user<=>userAttributes`.userId AND `wkParticipo_user<=>userAttributes`.attributeId=:attributeId;",
|
||||
"SELECT * FROM wkParticipo_Users, `wkParticipo_user<=>userAttributes` WHERE wkParticipo_Users.id = `wkParticipo_user<=>userAttributes`.userId AND `wkParticipo_user<=>userAttributes`.attributeId = :attributeId;",
|
||||
array(":attributeId"=>array('value'=>$userAttribute['id'], 'data_type'=>PDO::PARAM_INT))
|
||||
);
|
||||
echo( "<h2>".$userAttribute['name']."</h2>".array2htmlTableString($attributedUsers) );
|
||||
// Add a withthraw link entry
|
||||
foreach($attributedUsers as $index => $user){
|
||||
$attributedUsers[$index] += ["withdrawLink" => "<a href=\"?action=withdrawUsersAttribute&userId=".$user["userId"]."&attributeId=".$userAttribute["id"]."\">withdraw ".$userAttribute["name"]."</a>"];
|
||||
}
|
||||
echo( "<h3>have it</h3>".arrayKeyed2htmlTableString($attributedUsers, ["userId", "name", "vorname", "withdrawLink"]) );
|
||||
$attributedKeyList = [];
|
||||
foreach($attributedUsers as $user){
|
||||
$attributedKeyList[] = $user["userId"];
|
||||
}
|
||||
$unattributedUsers = array();
|
||||
foreach($users as $user){
|
||||
if(!in_array($user["id"], $attributedKeyList)){
|
||||
$unattributedUsers[] = $user;
|
||||
}
|
||||
}
|
||||
// Add a giveAttribute link entry to every user
|
||||
foreach($unattributedUsers as $index => $user){
|
||||
$unattributedUsers[$index] += ["giveAttributeLink" => "<a href=\"?action=giveUserAnUserAttribute&userId=".$user["id"]."&attributeId=".$userAttribute["id"]."\">give Attribute ".$userAttribute["name"]."</a>"];
|
||||
}
|
||||
echo( "<h3>give it</h3>".arrayKeyed2htmlTableString($unattributedUsers, ["id", "name", "vorname", "giveAttributeLink"]) );
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user