Files
cwsvJudo/homepage/redesign2018/markdownExperiment/wkParticipo/lib/wkParticipo-userAttribute.php
marko 7c9f4b8baa Erweiterungen am Wettkampkalender:
- wettkampfkalenderlose Events

- neue Funktion zur Ausführung einer DatenbankAbfrage
	modified:   markdownExperiment/phpLib/cwsvJudo/miscAssis.php
- URL der Wettkämpfe um Wetkampfname erweitert
	modified:   markdownExperiment/phpLib/cwsvJudo/wkKalender.php
- events haben jetzt ein eigenes Datum und nehmen es nicht mehr aus
dem zugeordneten Wettkampf (für die events ohne zugehörigen Eintrag im
Wettkampfkalender)
	modified:   markdownExperiment/wkParticipo/addEvent.php
	modified:   markdownExperiment/wkParticipo/admin/addEvent.php
- In der Adminansicht eines Events können jetzt auch Starter eintfernt
werden; @todo: Was noch fehlt ist die Behandlung der Fahrten!
	modified:   markdownExperiment/wkParticipo/admin/showEvent.php
- dbQuery wurde in cwsvJudoe/miscAssis eingepflegt.
	modified:   markdownExperiment/wkParticipo/lib/wkParticipo-userAttribute.php
2019-01-09 07:51:54 +01:00

140 lines
3.4 KiB
PHP

<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors',1);
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
function array2htmlTableString($anArray){
$ret = "";
if( !is_array($anArray) )
return "";
$ret .= "<table>";
foreach($anArray as $row){
if( !is_array($anArray) )
continue;
$ret .= "<tr>";
foreach( $row as $entry )
$ret .= "<td>".$entry."</td>";
$ret .= "</tr>";
}
$ret .= "</table>";
return $ret;
}
function giveUserAnUserAttribute($aDbConnection, $anUserId, $anAttributeId){
echo("Entering giveUserAnUserAttribute!");
try{
dbQuery(
$aDbConnection,
"INSERT INTO `wkParticipo_user<=>userAttributes` (userId, attributeId) VALUES (:userId, :attributeId);",
array(
':userId' => array('value'=>$anUserId, 'data_type'=>PDO::PARAM_INT),
':attributeId'=>array('value'=>$anAttributeId, 'data_type'=>PDO::PARAM_INT)
)
);
}
catch(PDOException $db_error){
print "Error!: " . $db_error->getMessage() . "<br/>";
}
return;
}
#exit();
var_dump($_GET);
$actions = ["giveUserAnUserAttribute"];
$dbConn = getCwsvJudoDbConn();
$dbConn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
if(isset($_GET['action'])){
switch($_GET['action']){
case "giveUserAnUserAttribute":
//echo("Doing giveUserAnUserAttribute!");
try{
giveUserAnUserAttribute($dbConn, intval($_GET['userIdToGetAttribute']), intval($_GET['attributeIdToGet']));
}
catch(Exception $e){
print("UPS: ".$e->getMessage());
}
break;
default:
echo("Ungültige Aktion erwünscht!");
break;
}
}
$users =
dbQuery(
$dbConn,
"SELECT * FROM cwsvjudo.wkParticipo_Users;"
);
$userAttributes =
dbQuery(
$dbConn,
"SELECT * FROM cwsvjudo.wkParticipo_userAttributes;"
);
?>
<html>
<head>
</head>
<body>
<form>
<label>Action:
<select name="action">
<option disabled selected value> -- Aktion auswählen -- </option>
<?php
foreach($actions as $action)
echo("<option>".$action."</option>");
?>
</select>
</label>
<label>User:
<select name="userIdToGetAttribute">
<option disabled selected value> -- User auswählen -- </option>
<?php
foreach($users as $user)
echo("<option value=\"".$user['id']."\">".$user['loginName']."</option>");
?>
</select>
</label>
<label>Attribut:
<select name="attributeIdToGet">
<option disabled selected value> -- Attribut auswählen -- </option>
<?php
foreach($userAttributes as $userAttribute)
echo("<option value=\"".$userAttribute['id']."\">".$userAttribute['name']."</option>");
?>
</select>
</label>
<button type="submit">Eingaben absenden</button>
</form>
<h1>Attribute</h1>
<?php echo(array2htmlTableString($userAttributes));?>
<?php
foreach($userAttributes as $userAttribute){
$attributedUsers =
dbQuery(
$dbConn,
"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) );
}
?>
<h1>User</h1>
<?php echo(array2htmlTableString($users));?>
</body>
</html>