Merge branch 'master' into sportabzeichen
This commit is contained in:
@@ -8,14 +8,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
require_once("./lib/db.php");
|
||||
require_once("./lib/achievementsLib.php");
|
||||
require_once("./lib/api.php");
|
||||
|
||||
$dbConnection = getPdoDbConnection(
|
||||
$cwsvJudoConfig["db"]["host"],
|
||||
$cwsvJudoConfig["db"]["name"],
|
||||
$cwsvJudoConfig["db"]["user"],
|
||||
$cwsvJudoConfig["db"]["password"]
|
||||
);
|
||||
require_once("./auth.php");
|
||||
require_once("./lib/machs/achievementGroup.php");
|
||||
|
||||
$basePath = "/users/cwsvjudo/www";
|
||||
require_once($basePath."/config/cwsvJudo.config.php");
|
||||
@@ -27,7 +20,6 @@ $dbConnection = getPdoDbConnection(
|
||||
$cwsvJudoConfig["db"]["user"],
|
||||
$cwsvJudoConfig["db"]["password"]
|
||||
);
|
||||
|
||||
require_once("./auth.php");
|
||||
|
||||
achievementGroup::setDbConnection($dbConnection);
|
||||
@@ -44,10 +36,14 @@ processPostData($dbConnection, $_POST);
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- unpkg : use the latest version of Video.js -->
|
||||
<link href="https://unpkg.com/video.js/dist/video-js.min.css" rel="stylesheet">
|
||||
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
|
||||
|
||||
<!-- Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/css/materialize.min.css">
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/js/materialize.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/css/materialize.min.css">
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/js/materialize.min.js"></script>
|
||||
|
||||
<!-- inits for the materializeCss -->
|
||||
<?php include("lib/machs/materializeInit.php");?>
|
||||
@@ -61,34 +57,51 @@ processPostData($dbConnection, $_POST);
|
||||
</head>
|
||||
<body>
|
||||
<?php include("lib/machs/sidenav.php");?>
|
||||
|
||||
<?php // Für die 12-Nächte-Challenge
|
||||
$now = new DateTime();
|
||||
$promoStart = new DateTime("2021-11-24");
|
||||
$promoEnd = new DateTime("2022-02-06");
|
||||
$from = new DateTime("2021-12-24");
|
||||
|
||||
if($promoStart <= $now && $now <= $promoEnd) {
|
||||
echo("<h1 style=\"font-size:1.5rem;\">12-Nächte-Challenge</h1>");
|
||||
if($now < $from) echo("<p>Die 12-Nächte-Challenge geht vom 24.12.2021--06.01.2022. Ziel ist es möglichts an allen Tagen ein Achievement zu erhalten. Sobald es losgeht, wird hier die aktuelle Rangliste stehen.");
|
||||
record::setDbConnection($dbConnection);
|
||||
$zwölfer = record::getTopAchievers(array('from'=>"2021-12-24", 'to'=>"2022-01-06"));
|
||||
echo("<table>");
|
||||
record::setDbConnection($dbConnection);
|
||||
foreach( record::getTopAchievers(array('from'=>"2021-12-24", 'to'=>"2022-01-06")) as $t ){
|
||||
echo("<tr><td>".$t['vorname']."</td><td>".$t['name']."</td><td>".$t['COUNT(*)']."</td></tr>");
|
||||
}
|
||||
echo("</table>");
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if( hasUserAttribute($dbConnection, $_SESSION['user']['userId'], "inTraining" ) ){
|
||||
echo( "<h2>Eigene Achievements</h2>" );
|
||||
echo( htmlUsersUploadBox($dbConnection, $_SESSION['user']['userId']) );
|
||||
echo(htmlAchievementListForUser(
|
||||
$dbConnection,
|
||||
$achievementGroups,
|
||||
$_SESSION['user']['userId'],
|
||||
getUsersAchievements($dbConnection, $_SESSION['user']['userId'])
|
||||
));
|
||||
echo( "<div style=\"display:flex; flex-wrap:wrap; align-items:stretch;\" class=\"row\">");
|
||||
foreach($achievementGroups as $g){
|
||||
echo($g->asHtmlCard($_SESSION['user']['userId']));
|
||||
}
|
||||
echo("</div>" );
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<?php
|
||||
$usersKids = getUsersKids($dbConnection, $_SESSION['user']['userId']);
|
||||
foreach($usersKids as $k){
|
||||
if( hasUserAttribute($dbConnection, $k['kidId'], "inTraining" ) and ($k['kidId']!=$_SESSION['user']['userId']) ){
|
||||
echo( "<h2>".$k['vorname']." ".$k['name']."</h2>" );
|
||||
echo( htmlUsersUploadBox($dbConnection, $k['kidId']) );
|
||||
echo(htmlAchievementListForUser(
|
||||
$dbConnection,
|
||||
$achievementGroups,
|
||||
$k['id'],
|
||||
getUsersAchievements($dbConnection, $k['id'])
|
||||
));
|
||||
<?php // show the achievements of each kid
|
||||
$usersKids = getUsersKids($dbConnection, $_SESSION['user']['userId']);
|
||||
foreach($usersKids as $k){
|
||||
if( hasUserAttribute($dbConnection, $k['kidId'], "inTraining" ) ){
|
||||
echo( "<h2>".$k['vorname']." ".$k['name']."</h2>" );
|
||||
echo( "<div style=\"display:flex; flex-wrap:wrap; align-items:stretch;\" class=\"row\">");
|
||||
foreach($achievementGroups as $g){
|
||||
echo($g->asHtmlCard($k['kidId'], ['noForm'=>false]));
|
||||
}
|
||||
}
|
||||
?>
|
||||
echo("</div>" );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(isUserAdmin($dbConnection, $_SESSION['user']['userId'])){
|
||||
@@ -101,9 +114,11 @@ processPostData($dbConnection, $_POST);
|
||||
echo( htmlUpdateAchievementBox(
|
||||
$a['id'],
|
||||
$a['name'],
|
||||
$a['description'],
|
||||
$a['rootId'],
|
||||
$a['level']
|
||||
$a['achievementGroupId'],
|
||||
$a['level'],
|
||||
$a['description'],
|
||||
$a['imgUrl']
|
||||
));
|
||||
echo("<hr />");
|
||||
}
|
||||
|
||||
@@ -131,17 +131,17 @@ return $groups;
|
||||
}
|
||||
|
||||
function htmlUsersUploadBox($db, $userId){
|
||||
$html = "";
|
||||
$userData = getUserData($db, $userId);
|
||||
$html .= "<div><dl>";
|
||||
$html .= "<dt>Upload Link</dt><dd><a href=\"".$userData['machsUploadUrl']."\">".$userData['machsUploadUrl']."</a></dd>";
|
||||
$html .= "<dt>Upload Passwort</dt><dd>".$userData['machsUploadPw']."</dd>";
|
||||
$html .= "</dl></div>";
|
||||
return $html;
|
||||
$html = "";
|
||||
$userData = getUserData($db, $userId);
|
||||
$html .= "<div><dl>";
|
||||
$html .= "<dt>Upload Link</dt><dd><a href=\"".$userData['machsUploadUrl']."\">".$userData['machsUploadUrl']."</a></dd>";
|
||||
$html .= "<dt>Upload Passwort</dt><dd>".$userData['machsUploadPw']."</dd>";
|
||||
$html .= "</dl></div>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
function htmlAchievementListForUser($db, $achievementGroups, $userId, $usersAchievmentIds, $noForm=false){
|
||||
//var_dump($db, $achievementGroups, $userId, $usersAchievmentIds);
|
||||
// var_dump($db, $achievementGroups, $userId, $usersAchievmentIds);
|
||||
$ids=[];
|
||||
foreach($usersAchievmentIds as $a){
|
||||
$ids[]=$a['achievementId'];
|
||||
@@ -154,12 +154,16 @@ $retHtml = "";
|
||||
}
|
||||
$retHtml .= "<div class=\"row\">";
|
||||
foreach($achievementGroups as $g){
|
||||
$records = record::getGroupsRecords($g->getId(), record::birthday2ageClass($userData[0]['gebDatum']));
|
||||
$records = (
|
||||
($userData[0]['gebDatum']!=null)?
|
||||
(record::getGroupsRecords($g->getId(), record::birthday2ageClass($userData[0]['gebDatum']))):
|
||||
[]
|
||||
);
|
||||
$retHtml .= "<div class=\"col s12 m6 l4 xl3\">";
|
||||
$retHtml .= "<ul class=\"card\">";
|
||||
// see, if there is a record for this group
|
||||
$imgUrl = null;
|
||||
foreach($g->achievements as $a){
|
||||
foreach($g->getAchievements() as $a){
|
||||
if($a['imgUrl'] != null){
|
||||
$imgUrl = $a['imgUrl'];
|
||||
}
|
||||
@@ -256,6 +260,8 @@ $html = "";
|
||||
$html .= "<input style=\"width:100%;display:block;\" name=\"level\" type=\"text\" value=\"".$level."\"/>";
|
||||
$html .= "<label for=\"description\">description</label>";
|
||||
$html .= "<input style=\"width:100%;display:block;\" name=\"description\" type=\"textarea\" value=\"".$description."\"/>";
|
||||
$html .= "<label for=\"imgUrl\">imgUrl</label>";
|
||||
$html .= "<input style=\"width:100%;display:block;\" name=\"imgUrl\" type=\"text\" value=\"".$imgUrl."\"/>";
|
||||
$html .= "<input type=\"submit\"/>";
|
||||
$html .= "</form>";
|
||||
return $html;
|
||||
|
||||
@@ -10,6 +10,7 @@ function getPdoDbConnection($hostname, $dbName, $user, $password){
|
||||
}
|
||||
catch(PDOException $dbError){
|
||||
echo( "Error whilst getting a dbConnection!: " . $dbError->getMessage() );
|
||||
var_dump($hostname, $dbName, $user, $password);
|
||||
}
|
||||
return $dbConnection;
|
||||
}
|
||||
@@ -64,9 +65,7 @@ if( empty($someOptions['dontFetch' ]) ) $someOptions['dontFetch' ] = false;
|
||||
if(!$pdoResult){
|
||||
echo("Error during dbQuery!\n");
|
||||
echo("DB-Error:\n"); var_dump($aDbConnection->errorInfo());
|
||||
// var_dump($aQueryString);
|
||||
// var_dump($aBindArray);
|
||||
// echo($pdoStatement.errorInfo());
|
||||
|
||||
}
|
||||
if($someOptions['dontFetch']){
|
||||
$ret = NULL;
|
||||
@@ -91,9 +90,6 @@ if( empty($someOptions['dontFetch' ]) ) $someOptions['dontFetch' ] = false;
|
||||
);
|
||||
}
|
||||
}
|
||||
//var_dump($ret);
|
||||
//var_dump($aQueryString);
|
||||
//var_dump($aBindArray);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -193,6 +189,7 @@ SQL;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/// @brief Get all members, the user has 'vormundschaft' to
|
||||
function getUsersKids($db, $userId){
|
||||
$query = <<<SQL
|
||||
SELECT *
|
||||
|
||||
@@ -197,7 +197,20 @@ SQL;
|
||||
|
||||
// image + title
|
||||
if($this->imageUrl != null){
|
||||
$retHtml .= "<div class=\"card-image\"><img src=\"".$this->imageUrl."\">";
|
||||
$retHtml .= "<div class=\"card-image\">";
|
||||
$ext = pathinfo($this->imageUrl, PATHINFO_EXTENSION);
|
||||
$ret."<div>".$this->imageUrl."</div>";
|
||||
$ret."<div>".$ext."</div>";
|
||||
switch($ext){
|
||||
case "webm":
|
||||
$retHtml .= "<video controls preload=\"none\"><source src=\"".$this->imageUrl."\" type=\"video/webm\">Video tag is not supported in this browser.</video>";
|
||||
// $retHtml .= videoJsFrame(array('url'=>$this->imageUrl));
|
||||
// $retHtml .= "<div>Hier sollte ein Video sein!</div>";
|
||||
break;
|
||||
default:
|
||||
$retHtml .= "<img src=\"".$this->imageUrl."\">";
|
||||
break;
|
||||
};
|
||||
$retHtml .= "<span class=\"card-title\">".$this->name."</span>";
|
||||
$retHtml .= "</div>";
|
||||
}
|
||||
@@ -248,8 +261,12 @@ SQL;
|
||||
$retHtml .= "<input name=\"redirectLocation\" value=\"./#achievementList-".$uId."\" type=\"hidden\" />";
|
||||
$retHtml .= "<input name=\"userId\" value=\"".$uId."\" type=\"hidden\" />";
|
||||
$retHtml .= "<input name=\"achievementId\" value=\"".$usersNextAchievement['id']."\" type=\"hidden\" />";
|
||||
//! warning for admins, that the user already had an achievement today
|
||||
if( !canUserGetAchievementToday( $this->getDbConnection(), $uId) and isUserAdmin($this->getDbConnection(), $_SESSION['user']['userId']) ){
|
||||
$retHtml .= "<div class=\"pink\" >Heute wurde bereits eine Achievement erreicht!</div>";
|
||||
}
|
||||
//! Only one achievements shall be given daily! Admins can overrule this!
|
||||
if( canUserGetAchievementToday( $this->getDbConnection(), $uId) or isUserAdmin($this->getDbConnection(), $_SESSION['user']['userId']) ){
|
||||
// $retHtml .= "<button style=\"width:100%\" class=\"btn\" name=\"submit\" type=\"submit\" >Achievement ".$usersNextAchievement['name']." geben</button>";
|
||||
$retHtml .= "<button style=\"width:100%\" class=\"btn\" name=\"submit\" type=\"submit\" >Achievement geben</button>";
|
||||
}
|
||||
else{
|
||||
@@ -419,4 +436,24 @@ function collectKeysValues($array, $key){
|
||||
$values[]=$a[$key];
|
||||
return $values;
|
||||
}
|
||||
|
||||
//! create the <video>Tag for videoJs
|
||||
function videoJsFrame($item){
|
||||
return "<video "
|
||||
."id=\"".str_replace("/", "-", $item['url'])."\" "
|
||||
."class=\"video-js\" "
|
||||
."controls "
|
||||
."preload=\"none\" "
|
||||
// ."poster=\"//vjs.zencdn.net/v/oceans.png\""
|
||||
."data-setup='{}' "
|
||||
.">"
|
||||
."<source src=\"".$item['url']."\" type=\"video/webm\">"//</source>"
|
||||
."<p class=\"vjs-no-js\">"
|
||||
."To view this video please enable JavaScript, and consider upgrading to a web browser that "
|
||||
."<a href=\"https://videojs.com/html5-video-support/\" target=\"_blank\">"
|
||||
."supports HTML5 video"
|
||||
."</a>"
|
||||
."</p>"
|
||||
."</video>";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -33,15 +33,20 @@ class record{
|
||||
}
|
||||
|
||||
public static function getTopAchievers($options=array()){
|
||||
$query = <<<SQL
|
||||
SELECT `wkParticipo_Users`.`vorname`, `wkParticipo_Users`.`name`, COUNT(*)
|
||||
FROM `achievements<=>user`
|
||||
JOIN `wkParticipo_Users`
|
||||
ON `wkParticipo_Users`.`id` = `achievements<=>user`.`userId`
|
||||
GROUP BY `wkParticipo_Users`.`id`
|
||||
ORDER BY `COUNT(*)` DESC;
|
||||
SQL;
|
||||
return dbQuery(self::$db, $query);
|
||||
$from = array_key_exists('from',$options)?$options['from']:null;
|
||||
$to = array_key_exists('to',$options)?$options['to']:null;
|
||||
$query =
|
||||
"SELECT `wkParticipo_Users`.`vorname`, `wkParticipo_Users`.`name`, COUNT(*) ".
|
||||
"FROM `achievements<=>user` JOIN `wkParticipo_Users` ".
|
||||
"ON `wkParticipo_Users`.`id` = `achievements<=>user`.`userId` ".
|
||||
(
|
||||
($from!=null&&$to!=null)?
|
||||
(" WHERE `achievements<=>user`.`timestamp` BETWEEN CONVERT(\"".$from."\", datetime) AND CONVERT(\"".$to."\", datetime) "):
|
||||
("")
|
||||
).
|
||||
"GROUP BY `wkParticipo_Users`.`id` ".
|
||||
"ORDER BY `COUNT(*)` DESC;";
|
||||
return dbQuery(self::$db, $query);
|
||||
}
|
||||
|
||||
public static function getAllRecords(){
|
||||
@@ -100,8 +105,9 @@ SQL;
|
||||
$retHtml.= "Die Rekorde der jüngeren gelten auch für die älteren, aber nicht umgekehrt. ";
|
||||
$retHtml.= "Damit ein Rekord auch eingetragen wird, muss er mit einem Nachweis in Videoform gemeldet werden.";
|
||||
$retHtml.= "<h4>Rekord melden</h4>";
|
||||
$retHtml.= "Um einen Rekord zu melden, lade ein Video des Rekordes hoch:";
|
||||
$retHtml.= htmlUsersUploadBox(self::$db, $u['id']);
|
||||
$retHtml.= "Um einen Rekord zu melden, schickt als Nachweis ein Video des Rekordes hoch an <a href=\"mailto:cwsvJudo@arcor.de\">cwsvJudo@arcor.de</a>.";
|
||||
// $retHtml.= "Um einen Rekord zu melden, lade ein Video des Rekordes hoch:";
|
||||
// $retHtml.= htmlUsersUploadBox(self::$db, $u['id']);
|
||||
$retHtml.= "<strong>Anschließend</strong> kannst Du den Rekord melden:";
|
||||
$retHtml.= "<form action=\".\" method=\"POST\">";
|
||||
if(isUserAdmin(record::$db, $_SESSION['user']['userId'])){
|
||||
@@ -121,12 +127,12 @@ SQL;
|
||||
$retHtml.= "<input id=\"submit\" style=\"width:100%\" name=\"submit\" type=\"submit\" value=\"Rekord melden\">";
|
||||
}
|
||||
$retHtml.= "</form>";
|
||||
$retHtml.= "<p>Sobald das Nachweisvideo gesichtet ist und es eine neue Bestleistung darstellt, wird der Rekord dann eingetragen und damit offiziell.</p>";
|
||||
$retHtml.= "</div>";
|
||||
$retHtml.= "<div class=\"modal-footer\">";
|
||||
$retHtml.= "<a href=\"#!\" class=\"modal-close waves-effect waves-green btn-flat\">Zurück</a>";
|
||||
$retHtml.= "</div>";
|
||||
$retHtml.= "</div>";
|
||||
// $retHtml.= "</div>";
|
||||
return $retHtml;
|
||||
}
|
||||
|
||||
@@ -160,7 +166,7 @@ COLLAPSIBLE;
|
||||
$group->loadAchievementGroupFromDb($gid);
|
||||
|
||||
$retHtml.= "";
|
||||
var_dump($group->canHaveRecords());
|
||||
// var_dump($group->canHaveRecords());
|
||||
if($group->canHaveRecords()){
|
||||
$retHtml = "<".$frameTag." class=\"card\">";
|
||||
$retHtml.= "<div class=\"card-content\">";
|
||||
|
||||
@@ -17,10 +17,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
require_once($basePath."/config/cwsvJudo.config.php");
|
||||
require_once($basePath."/config/phpcount.config.php");
|
||||
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
|
||||
PHPCount::AddHit("Achievementsystem (".htmlspecialchars($_SESSION['user']['username']).")");
|
||||
// require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
|
||||
|
||||
// $dbConnection = getCwsvJudoDbConn();
|
||||
$dbConnection = getPdoDbConnection(
|
||||
$cwsvJudoConfig["db"]["host"],
|
||||
$cwsvJudoConfig["db"]["name"],
|
||||
|
||||
@@ -15,12 +15,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
|
||||
$basePath = "/users/cwsvjudo/www";
|
||||
require_once($basePath."/config/cwsvJudo.config.php");
|
||||
require_once($basePath."/config/phpcount.config.php");
|
||||
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
|
||||
PHPCount::AddHit("Achievementsystem setUserData(".htmlspecialchars($_SESSION['user']['username']).")");
|
||||
// require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
|
||||
|
||||
// $dbConnection = getCwsvJudoDbConn();
|
||||
$dbConnection = getPdoDbConnection(
|
||||
$cwsvJudoConfig["db"]["host"],
|
||||
$cwsvJudoConfig["db"]["name"],
|
||||
@@ -66,7 +61,7 @@ processPostData($dbConnection, $_POST);
|
||||
foreach($usersKids as $k){
|
||||
if( hasUserAttribute($dbConnection, $k['kidId'], "inTraining" ) ){
|
||||
echo( "<h2 >".$k['vorname']." ".$k['name']."</h2>" );
|
||||
echo( htmlUsersUploadBox($dbConnection, $_SESSION['user']['userId']) );
|
||||
// echo( htmlUsersUploadBox($dbConnection, $k['kidId']) );
|
||||
echo( setUserDataBox($k['kidId']) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user