diff --git a/homepage/participo/index.php b/homepage/participo/index.php index b02391b..21986b8 100644 --- a/homepage/participo/index.php +++ b/homepage/participo/index.php @@ -7,6 +7,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge'); require_once("./lib/db.php"); require_once("./lib/api.php"); + require_once("./lib/participoLib/participo.php"); require_once("./auth.php"); @@ -27,12 +28,14 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge'); - + + - + - + + @@ -67,14 +70,14 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
  • - Apps + Apps
  • - UserInfos + UserInfos
  • - adminStuff + adminStuff
  • @@ -86,99 +89,67 @@ if($_SESSION['login']){
    - - - -
    - + "kyu", + 'title' => "Kyu", + 'description'=> "Die Prüfungsprogamme der einzelnen Gürtelstufen in Bild, Ton und Text", + 'imgUrl' => "images/obi.svg", + 'actions' => [ + AppCardAction::fromArray(['caption'=>"Kyu-Programme", 'link'=>"kyu"]), + ], + ])->htmlCode(). + AppCard::fromArray([ + 'link' => "/machs", + 'title' => "Mein Achievement System", + 'description'=> "Ein kleines Achievementsystem für die tägliche Herausforderung", + 'imgUrl' => "images/mountain-climber.svg", + 'actions' => [ + AppCardAction::fromArray(['caption'=>"MAchS", 'link'=>"/machs"]), + ], + ])->htmlCode(). + AppCard::fromArray([ + 'link' => "/pages/desktop/wkParticipo", + 'title' => "Event-Planer", + 'description'=> "Organisieren der Teilnahmen (und nicht-Teilnahmen) an Wettkämpfen, Sondertrainingseinheiten, Feiern etc.", + 'imgUrl' => "/ressourcen/graphiken/icons/terminKalender.svg", + 'actions' => [ + AppCardAction::fromArray(['caption'=>"Planer", 'link'=>"/pages/desktop/wkParticipo"]), + ], + ])->htmlCode() +); +?> +
    - -
    - - -
    - -
    -
    -
    -
    - lastLogins - -

    Die letzten Logins der einzelnen User

    - - - - - - - - - - $lastLogins ){ ?> - - - - - - -
    userNamelastLogins
    -
    -
    -
    -
    -
    -
    - - - + "user", + 'title' => "User-Config", + 'description' => "Einstellungen zum aktuellen Benutzer dessen Kindern", + 'imgUrl' => "images/account.svg", + 'actions' => [ + AppCardAction::fromArray(['caption'=>"Config", 'link'=>"user"]), + ], + ])->htmlCode() +); +// AdminStuff, thats only visible for Admins +if( isUserAdmin($dbConnection, $userData['id']) ){ + echo( + AppCard::fromArray([ + 'title' =>"lastLogins", + 'description' => lastLoginTable() + ])->htmlCode() + ); +} +?> +
    link = $link; + $this->caption = $caption; + } + /** + * Create htmlCode for the action + * + * @return string with htmlCode of the action + */ + function htmlCode(){ + return "link."\">".$this->caption.""; + } + /** + * Create AppCardAction from assoziative array + * + * @param array $member array with the member values + * @return AppCardAction + */ + static public function fromArray($member){ + $caption = $member['caption'] ?? null; + $link = $member['link'] ?? "."; + return new AppCardAction($caption, $link); + } +} + +/** + * MaterializeCss card for an App + */ +class AppCard{ + private $title = ""; //< title of the card + private $description = ""; //< description of the App + private $link = null; //< link for the card-content + private $imgUrl = null; //< url for an image right under the title + private $actionList = []; //< list of actions for the bottom of the card + /** + * Constructor for the AppCard + * + * @param string $title title of the card + * @param string $description description of the card + * @param string $link link for the card-content + * @param string $imgUrl url for an image right under the title + * @param array $actionList list of actions at the bottom of the card + */ + function __construct($title, $description, $link=null, $imgUrl=null, $actionList=[]){ + //! @todo input sanitation + $this->title = $title; + $this->description = $description; + $this->link = $link; + $this->imgUrl = $imgUrl; + $this->actionList = $actionList; + } + /** + * Create htmlCode for the AppCard + * + * @return string html code for the AppCard + */ + public function htmlCode(){ + $actionListCode = ""; + foreach($this->actionList as $a){ + $actionListCode .= $a->htmlCode(); + } + return + "
    ". + "
    ". + (($this->link!=null)?("appLink."\">"):(""))."
    ". + "".$this->title."". + (($this->imgUrl!=null)?("imgUrl."\" />"):("")). + "

    ".$this->description."

    ". + "
    ".(($this->link!=null)?("
    "):("")). + "
    ".$actionListCode."
    ". + "
    ". + "
    "; + } + /** + * Create AppCard from an associative array + * + * @param array $member array with member as keys and values as the member values + * @return AppCard from array values + */ + static public function fromArray($member){ + $title = $member['title'] ?? ""; + $description = $member['description'] ?? ""; + $link = $member['link'] ?? null; + $imgUrl = $member['imgUrl'] ?? null; + $actionList = $member['actions'] ?? []; + + return new AppCard($title, $description, $link, $imgUrl, $actionList); + } +} + +/** + * Generate a html table of the last logins of the users + * + * @param string $jsonFileName path to the json file with the logged logins + * @return string Html table of users last logins + */ +function lastLoginTable($jsonFileName="lastLogins.json"){ + $lastLogins=json_decode( file_get_contents($jsonFileName), true); + $lastLoginsTable = + "". + "". + ""; + foreach( $lastLogins as $userName => $lastLogins ){ + $lastLoginsTable .= + ""; + } + $lastLoginsTable .= "
    userNamelastLogins
    ".$userName."".$lastLogins['lastLogins'][0]."
    "; + return $lastLoginsTable; +} + /// Eine Fehler/Warnung/Notiz/Erfolgsmeldung als divBox im String zurückgeben function htmlRetMessage($anRetMessage){ $retHtmlString = "";