diff --git a/homepage/participo/admin.inc.php b/homepage/participo/admin.inc.php
new file mode 100644
index 0000000..20fb1b2
--- /dev/null
+++ b/homepage/participo/admin.inc.php
@@ -0,0 +1,31 @@
+ "AdminStuff",
+ 'description' => "Administrative Verwaltung"
+);
+?>
\ No newline at end of file
diff --git a/homepage/participo/admin.js b/homepage/participo/admin.js
new file mode 100644
index 0000000..ba97259
--- /dev/null
+++ b/homepage/participo/admin.js
@@ -0,0 +1,12 @@
+// What to do when the document is loaded.
+document.addEventListener('DOMContentLoaded', function () {
+ // init materialize elements
+ initSidenav();
+});
+
+function initSidenav() {
+ var sidenavElements = document.querySelectorAll('.sidenav');
+ // var sidenavInstances =
+ M.Sidenav.init(sidenavElements, {
+ });
+};
diff --git a/homepage/participo/admin.php b/homepage/participo/admin.php
new file mode 100644
index 0000000..b3b0918
--- /dev/null
+++ b/homepage/participo/admin.php
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AdminStuff
+
+ 'lastLogins',
+ 'description' => '' . lastLoginTable() . ''
+ ])->htmlCode()
+ );
+ echo(
+ AppCard::fromArray([
+ 'title' => 'Add User',
+ 'description' => User::getHtmlFormAddUser(),
+ ])->htmlCode()
+ );
+?>
+
+
+
+
+
diff --git a/homepage/participo/admin.sidenav.inc.php b/homepage/participo/admin.sidenav.inc.php
new file mode 100644
index 0000000..00fc11c
--- /dev/null
+++ b/homepage/participo/admin.sidenav.inc.php
@@ -0,0 +1,37 @@
+
+
diff --git a/homepage/participo/api.user.add.php b/homepage/participo/api.user.add.php
new file mode 100644
index 0000000..9bb60da
--- /dev/null
+++ b/homepage/participo/api.user.add.php
@@ -0,0 +1,32 @@
+addToDb();
+
+header('Location: ' . urldecode($returnToUrl), true, 301);
+exit(-1); // shouldn't matter
diff --git a/homepage/participo/css/participo.css b/homepage/participo/css/participo.css
index 3b81feb..897e3a9 100644
--- a/homepage/participo/css/participo.css
+++ b/homepage/participo/css/participo.css
@@ -1,49 +1,48 @@
/*
-on large screens add a padding on the left for the fixed sidnav
+on large screens add a padding on the left for the fixed sidenav
*/
header,
main,
footer {
- padding-left: 300px;
+ padding-left: 300px;
}
-@media only screen and (max-width : 992px) {
-
- header,
- main,
- footer {
- padding-left: 0;
- }
+@media only screen and (max-width: 992px) {
+ header,
+ main,
+ footer {
+ padding-left: 0;
+ }
}
.card video {
- width: 100%;
- max-width: 100%;
+ width: 100%;
+ max-width: 100%;
}
/*
overrides for the header font sizes
*/
h1 {
- font-size: 2.00rem;
+ font-size: 2rem;
}
h2 {
- font-size: 1.50rem;
+ font-size: 1.5rem;
}
h3 {
- font-size: 1.25rem;
+ font-size: 1.25rem;
}
h3 {
- font-size: 1.20rem;
+ font-size: 1.2rem;
}
h3 {
- font-size: 1.15rem;
+ font-size: 1.15rem;
}
h6 {
- font-size: 1.10rem;
+ font-size: 1.1rem;
}
diff --git a/homepage/participo/events.inc.php b/homepage/participo/events.inc.php
index 8d9fd96..be40f9e 100644
--- a/homepage/participo/events.inc.php
+++ b/homepage/participo/events.inc.php
@@ -21,7 +21,6 @@ require_once("config/participo.php");
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
- eventPlaner::setDbConnection(dbConnector::getDbConnection());
participo::authentificate();
diff --git a/homepage/participo/events.php b/homepage/participo/events.php
index feeaf72..816959f 100644
--- a/homepage/participo/events.php
+++ b/homepage/participo/events.php
@@ -1,6 +1,5 @@
@@ -9,7 +8,7 @@ include_once 'events.inc.php';
-
+
diff --git a/homepage/participo/index.inc.php b/homepage/participo/index.inc.php
new file mode 100644
index 0000000..4f326a9
--- /dev/null
+++ b/homepage/participo/index.inc.php
@@ -0,0 +1,37 @@
+
-
-
+
+
-
-
-
+
participo
@@ -219,6 +166,16 @@ if (participo::isUserAdmin($userData['id'])) {
])->htmlCode() .
''
);
+ echo(
+ AppCard::fromArray([
+ 'link' => 'admin',
+ 'title' => 'Admin',
+ 'description' => 'Admin Stuff',
+ 'actions' => [
+ AppCardAction::fromArray(['caption' => 'Admin', 'link' => 'admin']),
+ ],
+ ])->htmlCode()
+ );
} ?>
shiaiId = filterId($shiaiId);
$this->deadline = DateTime::createFromFormat('Y-m-d', $deadline);
$this->remarks = $remarks;
-
- $this->shiai = $shiai;
}
// Getter
@@ -75,17 +74,15 @@ class Event
}
/** Getter for the shiai
+ *
+ * If the Shiai isn't loaded yet, it is loaded
*
* @return Shiai shiai for the event
*/
- public function getShiai()
+ public function getShiai($forceLoading = false)
{
- return $this->shiai;
- }
-
- public function loadShiai()
- {
- if ($this->shiaiId != null) {
+ // We want to load if it isn't loaded yet or we want to enforce it. But in either case we need an id to load
+ if( (!isset($this->shiai) || $forceLoading) && isset($this->shiaiId) ){
$this->shiai = Shiai::loadFromDb($this->shiaiId);
}
return $this->shiai;
@@ -112,7 +109,7 @@ class Event
*/
public function asHtmlCard()
{
- $shiai = self::loadShiai();
+ $shiai = $this->getShiai();
return
'' .
'
' .
@@ -124,13 +121,14 @@ class Event
'
' . $this->deadline->format('Y-m-d') . '' .
'Altersklassen' .
'' . $this->shiai->getAgeClasses() . '' .
+ ''.
'' .
'
';
}
public function htmlTableRow()
{
- $shiai = $this->loadShiai();
+ $shiai = $this->getShiai();
return
'' .
'| ' . $this->date->format('Y-m-d') . ' | ' .
diff --git a/homepage/participo/lib/participoLib/participo.php b/homepage/participo/lib/participoLib/participo.php
index 498d891..a0bb57a 100644
--- a/homepage/participo/lib/participoLib/participo.php
+++ b/homepage/participo/lib/participoLib/participo.php
@@ -168,8 +168,9 @@ class participo
* @retval true user with id $userId has attribute "isAdmin"
* @retval false otherwise
*/
- public static function isUserAdmin($userId)
+ public static function isUserAdmin($userId = null)
{
+ $userId = $userId ?? $_SESSION['user']['userId'];
return self::hasUserAttribute($userId, 'isAdmin');
}
@@ -550,8 +551,7 @@ function getHtmlSquareDate($date = null)
. '';
}
-/**
- * filter_var for a (db)id
+/** filter_var for a (db)id
*
* check for valid id; null is default; only values > 0 are excepted
*
diff --git a/homepage/participo/lib/participoLib/shiai.php b/homepage/participo/lib/participoLib/shiai.php
index b619a5f..0480e76 100644
--- a/homepage/participo/lib/participoLib/shiai.php
+++ b/homepage/participo/lib/participoLib/shiai.php
@@ -1,4 +1,5 @@
['value' => $id, 'data_type' => PDO::PARAM_INT]];
$response = dbConnector::query($query, $params);
@@ -88,7 +91,7 @@ class Shiai
/**
* shiai event as html code for displaying
*
- * @return html formated string
+ * @return html formatted string
*/
public function getHtml()
{
diff --git a/homepage/participo/lib/participoLib/starter.php b/homepage/participo/lib/participoLib/starter.php
index 536f5d9..a260e1e 100644
--- a/homepage/participo/lib/participoLib/starter.php
+++ b/homepage/participo/lib/participoLib/starter.php
@@ -57,7 +57,7 @@ class Starter
////
// dbInterface
- ///
+ ////
/** Load a Start from the db via an id
*
@@ -117,7 +117,7 @@ class Starter
{
// - if the id is already set it *has* to be already in the DB hence we don't add it
// - the logged in user must have wardship over the starter
- if (isset($this->id) && !participo::isWardOf($this->userId)) {
+ if (isset($this->id) || !participo::isWardOf($this->userId)) {
return null;
}
diff --git a/homepage/participo/lib/participoLib/user.php b/homepage/participo/lib/participoLib/user.php
index 6eab3ca..cf8cc9b 100644
--- a/homepage/participo/lib/participoLib/user.php
+++ b/homepage/participo/lib/participoLib/user.php
@@ -1,20 +1,72 @@
id = filterId($id);
+ $this->loginName = $loginName;
+ $this->name = $name;
+ $this->firstName = $firstName;
+ $this->dateOfBirth = ($dateOfBirth != null) ? DateTime::createFromFormat('Y-m-d', $dateOfBirth) : null;
+ $this->eMail = ($eMail!=null) ? filter_var($eMail, FILTER_VALIDATE_EMAIL,['options'=>['default'=>null]]):null;
+ $this->config = $config;
+ $this->pwHash = $pwHash;
+ }
- /** columns in the user table (in the database) with their type
+ ////
+ // dbInterface
+ ////
+
+ public function addToDb(){
+ // if the user has an Id set it has to come from the Db. Hence don't add an User that is already added.
+ if(isset($this->id) || !participo::isUserAdmin()){
+ return;
+ }
+ $this->id = self::dbInsert(
+ $this->loginName
+ , $this->name
+ , $this->firstName
+ , (isset($this->dateOfBirth))?($this->dateOfBirth->format('Y-m-d')):null
+ , $this->eMail
+ , $this->config
+ , $this->pwHash
+ );
+ return $this->id;
+ }
+
+ private static function dbInsert($loginName, $name, $firstName, $dateOfBirth=null, $eMail=null, $config=null, $pwHash=null){
+ $query = 'INSERT INTO `'.self::$tableName.'` '
+ .'(loginName, name, vorname, gebDatum, eMail, config, pwHash) '
+ .' VALUES (:loginName, :name, :vorname, :gebDatum, :eMail, :config, :pwHash);';
+ $params = [
+ ':loginName'=>['value'=>$loginName, 'data_type' => self::$dbColumns['loginName']],
+ ':name'=>['value'=>$name, 'data_type' => self::$dbColumns['name']],
+ ':vorname'=>['value'=>$firstName, 'data_type' => self::$dbColumns['vorname']],
+ ':gebDatum'=>['value'=>$dateOfBirth, 'data_type' => self::$dbColumns['gebDatum']],
+ ':eMail'=>['value'=>$eMail, 'data_type' => self::$dbColumns['eMail']],
+ ':config'=>['value'=>$config, 'data_type' => self::$dbColumns['config']],
+ ':pwHash'=>['value'=>$pwHash, 'data_type' => self::$dbColumns['pwHash']],
+ ];
+ $response = dbConnector::query($query, $params);
+ return dbConnector::getLastInsertId();
+ }
+
+ /** Name of the table with all the Users
+ *
+ * @var string
+ */
+ private static $tableName = 'wkParticipo_Users';
+
+ /** columns in the User table (in the database) with their type
*
* @var array
*/
@@ -25,26 +77,48 @@ class User
'vorname' => PDO::PARAM_STR,
'gebDatum' => PDO::PARAM_STR,
'eMail' => PDO::PARAM_STR,
- 'pwHash' => PDO::PARAM_STR,
- 'config' => PDO::PARAM_STR
+ 'config' => PDO::PARAM_STR,
+ 'pwHash' => PDO::PARAM_STR
];
- /** Constructor
- * @todo Document parameter
- * @todo Input sanitation
- */
- public function __construct($id, $loginName, $name, $firstName, $dateOfBirth, $eMail, $config, $pwHash)
+
+ ////
+ // html interface
+ ////
+
+ public static function getHtmlFormAddUser($options = [])
{
- $this->id = (int) $id;
- $this->loginName = $loginName;
- $this->name = $name;
- $this->firstName = $firstName;
- $this->dateOfBirth = $dateOfBirth != null ? DateTime::createFromFormat('Y-m-d', $dateOfBirth) : null;
- $this->eMail = $eMail;
- $this->config = $config;
- $this->pwHash = $pwHash;
+ $returnToUrl = $options['returnToUrl'] ?? urlencode(getCurPagesUrl());
+ $formClass = isset($options['formClass']) ? 'class="'.$options['formClass'].'"' : '';
+
+ $form =
+ '';
+ return $form;
}
+ public static function htmlFormAddUser($options = []){
+ echo(self::getHtmlFormAddUser($options));
+ }
+
+
+ // member variables
+ private $id;
+ private $loginName;
+ private $name;
+ private $firstName;
+ private $dateOfBirth;
+ private $eMail;
+ private $config;
+ private $pwHash;
+
/** Export the User data into an associative array
*
* @return array associative array representing the user
@@ -105,7 +179,7 @@ class User
/** Create a User from an assoziative array like it is returned from db requests
*
* @param array $member associative array with the UserData from the dbRequest
- * @param $columnMappings renaming of columnNames, e.g., if the id isn't under id in the array, add 'id'=>'userId' to the mappings
+ * @param $columnMappings renaming of columnNames, e.g., if the id isn't under 'id' in the array but under 'userID', add 'id'=>'userId' to the mappings
* @return User initialized user
*/
public static function fromDbArray($member, $columnMappings = [])