master
Seph 2024-04-23 00:44:42 +02:00
parent db6b0eff95
commit b116f4f090
26 changed files with 911 additions and 134 deletions

View File

@ -0,0 +1,147 @@
#af-wrapper{
color: white;
}
#forum-header,
#statistics,
#af-wrapper #profile-navigation,
#af-wrapper #profile-content
{
display: none !important;
}
#af-wrapper input,
#af-wrapper .forum-poster,
#af-wrapper .topic-poster,
#af-wrapper .member-last-seen,
#af-wrapper .editor-element,
#af-wrapper .content-container,
#af-wrapper .forum-post-header,
#af-wrapper #statistics-body,
#af-wrapper .statistics-element,
#af-wrapper #statistics-online-users,
#af-wrapper .editor-row,
#af-wrapper .editor-row-subject,
#af-wrapper .signature,
#af-wrapper .post-element,
#af-wrapper .post-wrapper,
#af-wrapper .forum-subforums,
#af-wrapper .uploaded-file img,
#af-wrapper .action-panel-option,
#af-wrapper .topic-sticky .topic-poster,
#af-wrapper #profile-layer,
#af-wrapper #profile-layer .pages-and-menu:first-of-type,
#af-wrapper #profile-content,
#af-wrapper #profile-content .profile-row,
#af-wrapper .history-element,
#af-wrapper #memberslist-filter,
#af-wrapper .content-element,
#af-wrapper .ad-forum,
#af-wrapper .ad-topic,
#af-wrapper .spoiler,
#af-wrapper .spoiler .spoiler-body,
#af-wrapper .report-element,
#af-wrapper .report-source,
#af-wrapper .report-content,
#af-wrapper .report-actions,
#af-wrapper #profile-content .profile-section-header,
#af-wrapper #poll-options,
#af-wrapper #poll-panel,
#af-wrapper #poll-panel #poll-headline,
#af-wrapper #poll-results .poll-result-bar,
#af-wrapper .post-reactions-summary .reaction-names,
#af-wrapper .title-element,
#af-wrapper #usergroups-filter {
border-color: var(--color-alliance)
}
#af-wrapper .main-title,
#af-wrapper .highlight-admin, #af-wrapper .highlight-admin a,#af-wrapper a{
color: var(--color-alliance)!important;
}
#af-wrapper .title-element,
#af-wrapper #forum-header,
#af-wrapper #profile-header .background-avatar,
#af-wrapper #profile-navigation,
#af-wrapper input[type="radio"]:checked::before,
#af-wrapper .post-element,
#af-wrapper .post-wrapper,
#af-wrapper .content-container,
#af-wrapper .editor-element,
#af-wrapper #profile-header .background-contrast {
backdrop-filter: blur(5px);
background: unset !important;
}
#af-wrapper #profile-header{
border-width: 1px;
}
#af-wrapper .button-normal{
background-color: var(--color-alliance);
color: black !important;
border-color:unset!important;
margin-left: 4px!important;
margin-right: 4px!important;
}
#af-wrapper img.avatar{
border-radius:15px;
border:3px solid var(--color-alliance)!important;
}
#af-wrapper .user-online .avatar{
box-shadow: unset!important;
}
#af-wrapper .post-author img.avatar{
width: 90px;
height: 90px;
}
#af-wrapper .post-message{
color:white;
}
#af-wrapper .forum-post-header-container{
@apply bg-glass;
}
#af-wrapper a.highlight-admin, .asgarosforum-widget .highlight-admin{
color: var(--color-alliance)!important;
&:hover{
color: white!important;
}
}
h2.widgettitle{
font-size: 1.25rem;
text-align: center;
}
div.mce-panel,div.mce-toolbar-grp{
background: rgba(0,0,0,0)!important;
}
div.mce-statusbar,div.mce-toolbar-grp{
border-bottom: 1px solid var(--color-alliance)!important;
border-top: 1px solid var(--color-alliance)!important;
}
div.mce-floatpanel{
background:white!important;
}
.wp-editor-container{
border-color:var(--color-alliance)!important;
}
.mce-ico{
color:var(--color-alliance)!important;
}

View File

@ -78,5 +78,8 @@ module.exports = {
{ pattern: /text-([a-zA-Z]+)$/, variants: ['hover', 'group-hover', 'has-\[\:checked\]'] },
{ pattern: /shadow-([a-zA-Z]+)$/ },
{ pattern: /border-([a-zA-Z]+)$/ },
{ pattern: /bg-([a-zA-Z]+)-500$/, variants: ['has-\[\:checked\]'] },
{ pattern: /text-([a-zA-Z]+)-500$/, variants: ['hover', 'group-hover', 'has-\[\:checked\]'] },
{ pattern: /border-([a-zA-Z]+)-500$/, variants: ['hover', 'group-hover', 'has-\[\:checked\]'] },
]
};

View File

@ -36,6 +36,9 @@
@import "tailwindcss/utilities";
@import "./custom/utilities.css";
@import "./custom/asgaros.css";
:root {
--wowp-gap: 1em;
--color-deathknight: #C41E3A;
@ -52,6 +55,7 @@
--color-warlock: #8788EE;
--color-warrior: #C69B6D;
--color-deepblue: #000032;
--color-alliance: #f7941e;
--color-background: var(--color-deepblue);
--color-glass:color-mix(in lch, transparent 75%, var(--color-background) );
}
@ -239,3 +243,6 @@ article{
color: black;
}
}

View File

@ -8,96 +8,111 @@ $id = "raidSignup_" . uniqid();
global $user;
$chars = [];
if(!empty($this->character->user->ID)){
$chars = $this->character->user->characters()->where('raidchar',true)->get();
if (!empty($this->character->user->ID)) {
$chars = $this->character->user->characters()->where('raidchar', true)->get();
}
if(empty($chars) || empty($chars->first())){
if (empty($chars) || empty($chars->first())) {
$chars = [$this->character];
}
?>
<div class="flex <?= $vertical ? "flex-col" : "flex-row" ?> border border-<?= $this->character->color ?> shadow" x-data="{open : false}">
<button <?=($doSignup && $this->character->can_edit)?'x-on:click="open = true"':''?> class="btn btn-outline btn-<?= $this->character->color ?> w-full">
<button <?= ($doSignup && $this->character->can_edit) ? 'x-on:click="open = true"' : '' ?> class="btn btn-outline btn-<?= $this->character->color ?> w-full">
<img src="<?= $this->character->classIcon ?>" class="h-8"><?= $this->character->name ?></button>
<?php if ($showStatus) : ?>
<div class="border border-<?= $this->character->color ?> bg-<?=$this->getStatus()->color?> bg-opacity-25 flex flex-row text-<?= $this->getStatus()->color ?> items-center justify-center p-auto gap-1"><?= Icon::get($this->getStatus()->icon) ?>
<div class="border border-<?= $this->character->color ?> bg-<?= $this->getStatus()->color ?> bg-opacity-25 flex flex-row text-<?= $this->getStatus()->color ?> items-center justify-center p-auto gap-1"><?= Icon::get($this->getStatus()->icon) ?>
<?= $vertical ? $this->getStatus()->name : "" ?>
</div>
<?php endif; ?>
<?php if ($showRole) : ?>
<div class="border border-<?= $this->character->color ?> bg-<?=$this->getRole()->color?> bg-opacity-25 flex flex-row text-<?= $this->getRole()->color ?> items-center justify-center p-auto gap-1"><?= Icon::get($this->getRole()->icon) ?>
<?=$vertical?$this->getRole()->name:""?>
<div class="border border-<?= $this->character->color ?> bg-<?= $this->getRole()->color ?> bg-opacity-25 flex flex-row text-<?= $this->getRole()->color ?> items-center justify-center p-auto gap-1"><?= Icon::get($this->getRole()->icon) ?>
<?= $vertical ? $this->getRole()->name : "" ?>
</div>
<?php endif; ?>
<?php if($doSignup && $this->character->can_edit): ?>
<template x-teleport="body">
<div x-show="open" class="fixed inset-0 px-2 z-10 overflow-hidden flex items-center justify-center">
<div x-show="open" x-on:click="open = false" x-transition:enter="transition-opacity ease-out duration-300" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition-opacity ease-in duration-300" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" class="absolute inset-0 bg-deepblue bg-opacity-75 transition-opacity"></div>
<!-- Modal Content -->
<div x-show="open" x-transition:enter="transition-transform ease-out duration-300" x-transition:enter-start="transform scale-75" x-transition:enter-end="transform scale-100" x-transition:leave="transition-transform ease-in duration-300" x-transition:leave-start="transform scale-100" x-transition:leave-end="transform scale-75" class="bg-glass border shadow overflow-hidden max-w-md w-full sm:w-96 md:w-1/2 lg:w-2/3 xl:w-1/3 z-50">
<!-- Modal Body -->
<form id="<?= $id ?>">
<div class="grid p-auto gap-auto">
<?php foreach($chars as $key => $character):
(new ToggleButton([
'type' => 'radio',
'name' => 'rad_character',
'text' => $character->name,
'color' => $character->color,
'icon_yes' => 'o-check',
'checked' => $character->ID == $this->character->ID,
'row' => false,
]))->render();
endforeach; ?>
</div>
<div class="grid grid-cols-2 gap-auto p-auto">
<div class="col-span-2 text-center">Anwesenheit</div>
<?php
foreach ($this->getStatusList(true) as $key => $status) {
<?php if ($doSignup && $this->character->can_edit) : ?>
<template x-teleport="body">
<div x-show="open" class="fixed inset-0 px-2 z-10 overflow-hidden flex items-center justify-center">
<div x-show="open" x-on:click="open = false" x-transition:enter="transition-opacity ease-out duration-300" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition-opacity ease-in duration-300" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" class="absolute inset-0 bg-deepblue bg-opacity-75 transition-opacity"></div>
<!-- Modal Content -->
<div x-show="open" x-transition:enter="transition-transform ease-out duration-300" x-transition:enter-start="transform scale-75" x-transition:enter-end="transform scale-100" x-transition:leave="transition-transform ease-in duration-300" x-transition:leave-start="transform scale-100" x-transition:leave-end="transform scale-75" class="bg-glass border shadow overflow-hidden max-w-md w-full sm:w-96 md:w-1/2 lg:w-2/3 xl:w-1/3 z-50">
<!-- Modal Body -->
<form id="<?= $id ?>" action="/request" method="POST">
<?php wp_nonce_field('signupRaid', 'signupRaid_nonce'); ?>
<input type="hidden" name="action" value="signupRaid">
<input type="hidden" name="raid_id" value="<?= $this->raid_ID ?>">
<div class="grid p-auto gap-auto">
<?php foreach ($chars as $key => $character) :
?>
<div class="hidden lg:block">
<?php
(new ToggleButton([
'type' => 'radio',
'name' => 'raid_status',
'text' => $status->name,
'color' => $status->color,
'icon_yes' => $status->icon,
'checked' => $key == $this->status,
'row' => false,
]))->render();
}
?>
<div class="col-span-2 text-center">Rolle</div>
<?php
foreach ($this->getRoleList() as $key => $role) {
(new ToggleButton([
'type' => 'radio',
'name' => 'raid_role',
'text' => $role->name,
'color' => $role->color,
'icon_yes' => $role->icon,
'checked' => $key == $this->role,
'row' => false,
]))->render();
}
?>
<div class="col-span-2 text-center">Kommentar</div>
<div class="flex flex-col gap-auto col-span-2">
<input type="text" class="w-full bg-glass text-white border border-white" placeholder="Kommentar eingeben...">
<button x-on:click="open = false" class="btn btn-outline btn-monk">
<?= Icon::get('o-paper-airplane') ?>
Speichern
</button>
'type' => 'radio',
'name' => 'raid_character',
'value' => $character->ID,
'text' => $character->name,
'color' => $character->color,
'icon_yes' => 'o-check',
'checked' => $character->ID == $this->character->ID,
'row' => false,
]))->render();
?>
</div>
<?php
endforeach; ?>
</div>
</div>
<!-- Modal Footer -->
</form>
<div class="grid grid-cols-2 gap-auto p-auto">
<div class="col-span-2 text-center hidden lg:block">Anwesenheit</div>
<?php
foreach ($this->getStatusList(true) as $key => $status) {
(new ToggleButton([
'type' => 'radio',
'name' => 'raid_status',
'text' => $status->name,
'color' => $status->color,
'icon_yes' => $status->icon,
'value' => $key,
'checked' => $key == $this->status,
'row' => false,
]))->render();
}
?>
<div class="col-span-2 text-center hidden lg:block">Rolle</div>
<?php
foreach ($this->getRoleList() as $key => $role) {
(new ToggleButton([
'type' => 'radio',
'name' => 'raid_role',
'text' => $role->name,
'color' => $role->color,
'icon_yes' => $role->icon,
'value' => $key,
'checked' => $key == $this->role,
'row' => false,
]))->render();
}
?>
<div class="col-span-2 text-center">Kommentar</div>
<div class="flex flex-col gap-auto col-span-2">
<input type="text" name="comment" class="w-full bg-glass text-white border border-white" placeholder="Kommentar eingeben...">
<button type="submit" x-on:click="open = false" class="btn btn-outline btn-monk">
<?= Icon::get('o-paper-airplane') ?>
Speichern
</button>
</div>
</div>
<!-- Modal Footer -->
</form>
</div>
</div>
</div>
</template>
</template>
<?php endif; ?>
</div>

View File

@ -4,7 +4,7 @@ use WoWPress\Frontend\Icon;
<div>
<label style="" for="tb_<?= $this->id ?>" class="w-full flex <?= $this->row ? 'flex-row gap-2' : 'flex-col' ?> items-center justify-center h-auto select-none cursor-pointer border py-3 px-6
font-bold border-<?=$this->color_no?> transition-colors duration-200 ease-in-out has-[:checked]:bg-<?=$this->color_yes?> has-[:checked]:text-black has-[:checked]:border-<?=$this->color_yes?> ">
<input type="<?= $this->type ?>" id="tb_<?= $this->id ?>" name="<?= $this->name ?>" class="peer group hidden" <?= $this->disabled ? 'disabled' : '' ?> <?= $this->checked ? 'checked' : '' ?> />
<input type="<?= $this->type ?>" value="<?=$this->value?>" id="tb_<?= $this->id ?>" name="<?= $this->name ?>" class="peer group hidden" <?= $this->disabled ? 'disabled' : '' ?> <?= $this->checked ? 'checked' : '' ?> />
<div class="peer-checked:block hidden">
<?php
if ($this->icons) : ?>

View File

@ -5,6 +5,7 @@ use WoWPress\Database\CreateCharacterTable;
use WoWPress\Database\CreateRaidTable;
use WoWPress\Database\CreateSignupTable;
use WoWPress\Database\CreateSKSTable;
use WoWPress\Frontend\Widgets\RaidSignup;
use WoWPress\Models\Character;
ini_set('display_errors', 1);
@ -457,3 +458,12 @@ function wowpress_add_category_meta($taxonomy)
/** Roles */
set_roles();
setGlobalUser();
/** Widgets */
$widget_raid_signup = new RaidSignup();
/** Avatar Filters */
add_filter('get_avatar_url', '\WoWPress\Models\User::getAvatar', 10, 3);
add_filter('asgarosforum_filter_username', '\WoWPress\Models\User::getUsername', 10, 2);

View File

@ -71,4 +71,42 @@ function setGlobalUser(){
$user->ID = 0;
$user->login = "Gast";
}
}
add_action( 'show_user_profile', 'wowpress_extra_user_profile_fields' );
add_action( 'edit_user_profile', 'wowpress_extra_user_profile_fields' );
function wowpress_extra_user_profile_fields( $user ) {
?>
<h3><?php _e("Nette Zusatzinfos", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="birthday"><?php _e("Geburtstag"); ?></label></th>
<td>
<input type="date" name="birthday" id="birthday" class="regular-text"
value="<?php echo esc_attr( get_the_author_meta( 'birthday', $user->ID ) ); ?>" /><br />
<span class="description"><?php _e("Bitte gib doch dein Geburtsdatum ein :)"); ?></span>
</td>
</tr>
<tr>
<th><label for="btag"><?php _e("Battle-Tag"); ?></label></th>
<td>
<input type="text" name="btag" id="btag" class="regular-text"
value="<?php echo esc_attr( get_the_author_meta( 'btag', $user->ID ) ); ?>" /><br />
<span class="description"><?php _e("Nur wenn du willst :D"); ?></span>
</td>
</tr>
</table>
<?php
}
add_action( 'personal_options_update', 'wowpress_save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'wowpress_save_extra_user_profile_fields' );
function wowpress_save_extra_user_profile_fields( $user_id ) {
$saved = false;
if ( current_user_can( 'edit_user', $user_id ) ) {
update_user_meta( $user_id, 'birthday', $_POST['birthday'] );
update_user_meta( $user_id, 'btag', $_POST['btag'] );
$saved = true;
}
return true;
}

View File

@ -0,0 +1,78 @@
<?php
/**
* The Forum template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no `home.php` file exists.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WowPress
*/
set_sidebar_status('top',false);
get_header();
?>
<section id="primary" <?php if(!get_sidebar_status('top')):?> style="margin-top:calc(-1 * var(--wowp-gap))" <?php endif; ?>>
<main id="main">
<?php
if ( have_posts() ) {
if ( is_home() && ! is_front_page() ) :
?>
<header class="entry-header">
<h1 class="entry-title"><?php single_post_title(); ?></h1>
</header><!-- .entry-header -->
<?php
endif;
// Load posts loop.
while ( have_posts() ) {
the_post();
?>
<article class="p-auto" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php wowpress_post_thumbnail(); ?>
<div class="" <?php wowpress_content_class( 'entry-content' ); ?>>
<?php
the_content();
wp_link_pages(
array(
'before' => '<div>' . __( 'Pages:', 'wowpress' ),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php
}
// Previous/next page navigation.
wowpress_the_posts_navigation();
} else {
// If no content, include the "No posts found" template.
get_template_part( 'template-parts/content/content', 'none' );
}
?>
</main><!-- #main -->
</section><!-- #primary -->
<?php
get_footer();

View File

@ -94,6 +94,45 @@ get_header();
</div>
</main>
</section>
<?php if (current_user_can('wowpress_edit_characters')) : ?>
<div x-data="{addRaid:true}">
<template x-teleport="#sidebar_right">
<div class="bg-glass shadow p-auto order-1 hidden lg:block">
<div class="flex flex-col gap-2">
<h4 class="text-xl font-bold text-center mb-2">Raid importieren</h4>
<form action="/request" method="POST">
<div class="flex flex-col gap-2">
<?php wp_nonce_field('importRaid', 'importRaid_nonce'); ?>
<input type="hidden" name="action" value="importRaid">
<input type="text" name="id_wowaudit" placeholder="WoW-Audit ID" class="text-black">
<button type="submit" class="btn btn-outline btn-hunter">Importieren</a>
</div>
</form>
<div class="text-sm text-center">- oder -</div>
<h4 class="text-xl font-bold text-center mb-2 mt-2">Termin erstellen</h4>
<form action="/request" method="POST">
<div class="flex flex-col gap-2">
<?php wp_nonce_field('addRaid', 'addRaid_nonce'); ?>
<input type="hidden" name="action" value="addRaid">
<input type="text" name="name" placeholder="Titel" class="text-black">
<input type="text" name="difficulty" placeholder="Schwierigkeit" class="text-black">
<label for="start_date">Datum</label>
<input type="date" id="start_date" name="start_date" class="text-black">
<label for="start_time">Start</label>
<input type="time" name="start_time" id="start_time" class="text-black">
<label for="end_time">Datum</label>
<input type="time" name="end_time" id="end_time" class="text-black">
<button type="submit" class="btn btn-outline btn-hunter">Hinzufügen</a>
</div>
</form>
</div>
</div>
</template>
</div>
<?php
endif;
get_footer();

View File

@ -31,9 +31,10 @@ get_header();
<td class="p-auto hidden lg:table-cell">Rang</td>
<td class="p-auto hidden lg:table-cell">Server</td>
<td class="p-auto hidden lg:table-cell">Gilde</td>
<td class="p-auto hidden lg:table-cell">Raider</td>
<?php if (current_user_can('wowpress_edit_characters')) : ?>
<td class="p-auto hidden lg:table-cell">Raider</td>
<td class="p-auto hidden lg:table-cell">
User
</td>
@ -61,9 +62,21 @@ get_header();
<td class="p-auto hidden lg:table-cell"><?= $char->rank ?></td>
<td class="p-auto hidden lg:table-cell"><?= $char->realm ?></td>
<td class="p-auto hidden lg:table-cell"><?= $char->guild ?></td>
<td class="p-auto hidden lg:table-cell"><?= $char->raidchar?"Ja":"Nein" ?></td>
<?php if (current_user_can('wowpress_edit_characters')) : ?>
<td class="p-auto hidden lg:table-cell">
<form action="/request" method="POST">
<?php wp_nonce_field('toggleRaidchar', 'toggleRaidchar_nonce'); ?>
<input type="hidden" name="action" value="toggleRaidchar">
<input type="hidden" name="id" value="<?= $char->ID ?>">
<?php if ($char->raidchar) : ?>
<button type="submit" class="btn btn-<?=$char->color?>"><?=Icon::get('o-check-circle')?> Ja</button>
<?php else : ?>
<button type="submit" class="btn btn-gray"><?=Icon::get('o-no-symbol')?> Nein</button>
<?php endif; ?>
</form>
</td>
<td class="p-auto hidden lg:table-cell">
<form action="/request" method="POST">
<input type="hidden" name="char_id" value="<?= $char->ID ?>">

View File

@ -18,7 +18,9 @@
$raid->sync(true);
$raid->save();
}
$unkowns = [];
$unknowns = [];
get_header();
?>

View File

@ -2,6 +2,7 @@
use Wenprise\Eloquent\Database;
use Wenprise\Eloquent\Facades\DB;
use WoWPress\Frontend\Icon;
use WoWPress\Models\SKS;
@ -9,62 +10,143 @@ set_sidebar_status('top', false);
$liste = $GLOBALS['wowpress']['liste'];
#$sks = new SKS();
#$sks->list_name = "Normal";
#$sks->char_name = "Gasti";
#$sks->realm_name = "McGaston";
#$sks->rank = 4;
#$sks->active = true;
#$sks->save();
if(!$liste){
if (!$liste) {
$listen = SKS::getLists();
get_header();
?>
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $GLOBALS['wowpress']['page_title']?>n
</div>
</div>
<section id="primary">
<main id="main">
<div class="bg-glass shadow p-auto">
<?php foreach($listen as $list): ?>
<a class="btn btn-outline" href="/sks/<?=$list->ID?>"><?=$list->list_name?></a>
<?php endforeach; ?>
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $GLOBALS['wowpress']['page_title'] ?>n
</div>
</main>
</section>
</div>
<section id="primary">
<main id="main">
<div class="bg-glass shadow p-auto">
<?php foreach ($listen as $list) : ?>
<a class="btn btn-outline" href="/sks/<?= $list->ID ?>"><?= $list->list_name ?></a>
<?php endforeach; ?>
</div>
</main>
</section>
<?php
get_footer();
exit;
}else{
get_footer();
exit;
} else {
$liste = SKS::find($liste);
get_header();
get_header();
?>
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $GLOBALS['wowpress']['page_title'] ?> "<?=$liste->list_name?>"
</div>
</div>
<section id="primary">
<main id="main">
<div class="bg-glass shadow p-auto">
<?php
foreach(SKS::getList($liste->list_name) as $sk):
?>
<div class="flex flex-row">
<button class="btn btn-outline"><?=$sk->char_name?></button>
<div class="border p-auto"><?=$sk->rank?></div>
<div class="border p-auto"><?=$sk->active?"Aktiv":"Inaktiv"?></div>
</div>
<?php
endforeach;
?>
<div class="top-title flex flex-row gap-2" style="margin-top:calc(-1 * var(--wowp-gap))">
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $GLOBALS['wowpress']['page_title'] ?> "<?= $liste->list_name ?>"
</div>
</main>
</section>
</div>
<section id="primary">
<main id="main">
<div class="bg-glass shadow p-auto">
<table class="table-auto w-full">
<thead>
<tr class="bg-glass">
<th class="p-auto w-40">Rang</th>
<th class="p-auto">Charakter</th>
<th class="p-auto hidden lg:table-cell">Server</th>
<th class="p-auto hidden lg:table-cell">Status</th>
<?php if (current_user_can('wowpress_edit_raids')) : ?>
<th class="p-auto w-0">Aktion</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php
foreach (SKS::getList($liste->list_name) as $sk) :
?>
<tr class="text-<?= $sk->active ? $sk->character->color : "slate-500" ?> odd:bg-slate-900">
<?php if (current_user_can('wowpress_edit_raids')) : ?>
<td class="p-auto text-center">
<div class="flex flex-row">
<input type="text" class="bg-glass w-full text-center border-0 border-b border-<?= $sk->character->color ?>" name="rank" value="<?= $sk->rank ?>">
<button class="btn btn-outline btn-alliance" title="Manueller Eingriff">
<?= Icon::get('o-wrench') ?>
</button>
</div>
</td>
<?php else : ?>
<td class="p-auto text-center"><?= $sk->rank ?></td>
<?php endif; ?>
<td class="p-auto text-center"><?= $sk->character->name ?></td>
<td class="p-auto text-center hidden lg:table-cell"><?= $sk->character->realm ?></td>
<td class="p-auto text-center hidden lg:table-cell">
<button class="btn w-full btn-outline btn-<?= $sk->active ? $sk->character->color : "slate" ?>"><?= $sk->active ? "Aktiv" : "Inaktiv" ?></button>
</td>
<?php if (current_user_can('wowpress_edit_raids')) : ?>
<td class="p-auto">
<div class="flex gap-2 flex-col lg:flex-row justify-end">
<?php if ($sk->active) : ?>
<form action="/request" method="POST">
<?php wp_nonce_field('lootSKS', 'lootSKSnonce'); ?>
<input type="hidden" name="action" value="lootSKS">
<input type="hidden" name="id" value="<?= $sk->ID ?>">
<button type="submit" class="btn btn-outline btn-<?=$sk->character->color?>"><?= Icon::get('o-sparkles') ?></button>
</form>
<?php else : ?>
<form action="/request" method="POST">
<?php wp_nonce_field('deleteSKS', 'deleteSKS_nonce'); ?>
<input type="hidden" name="action" value="deleteSKS">
<input type="hidden" name="id" value="<?= $sk->ID ?>">
<button type="submit" class="btn btn-outline btn-gray"><?= Icon::get('o-trash') ?></button>
</form>
<? endif; ?>
</div>
</td>
<?php endif; ?>
</tr>
</div>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</main>
</section>
<?php if (current_user_can('wowpress_edit_characters')) : ?>
<div x-data>
<template x-teleport="#sidebar_right">
<div class="bg-glass shadow p-auto order-1">
<h4 class="text-xl font-bold text-center mb-2">Charakter Hinzufügen</h4>
<form action="/request" method="POST">
<div class="flex flex-col gap-2">
<?php wp_nonce_field('addSKS', 'addSKS_nonce'); ?>
<input type="hidden" name="action" value="addSKS">
<input type="text" name="name" placeholder="Name" class="text-black">
<input type="text" name="realm" placeholder="Server" class="text-black">
<button type="submit" class="btn btn-outline btn-hunter">Hinzufügen</a>
</div>
</form>
</div>
</template>
</div>
<?php
get_footer();
endif;
get_footer();
}
?>

View File

@ -3,6 +3,8 @@ require_once('vendor/autoload.php');
use Illuminate\Support\Facades\Redirect;
use WoWPress\Models\Character;
use WoWPress\Models\Raid;
use WoWPress\Models\Signup;
use WoWPress\Models\User;
if (empty($_POST['action'])) {
@ -54,6 +56,18 @@ switch ($_POST['action']) {
}
}
break;
case 'toggleRaidchar':
isAllowed('wowpress_edit_characters');
if (isset($_POST['toggleRaidchar_nonce']) && wp_verify_nonce($_POST['toggleRaidchar_nonce'], 'toggleRaidchar')) {
if (isset($_POST['id'])) {
$char = Character::find($_POST['id']);
if ($char->ID) {
$char->raidchar = !$char->raidchar;
$char->save();
}
}
}
break;
case 'changeUser':
isAllowed('wowpress_edit_characters');
if (isset($_POST['changeUser_nonce']) && wp_verify_nonce($_POST['changeUser_nonce'], 'changeUser')) {
@ -71,6 +85,63 @@ switch ($_POST['action']) {
}
}
break;
case 'importRaid':
isAllowed('wowpress_edit_raids');
if (isset($_POST['importRaid_nonce']) && wp_verify_nonce($_POST['importRaid_nonce'], 'importRaid')) {
if (isset($_POST['id_wowaudit'])) {
if(!empty(Raid::where('id_wowaudit',$_POST['id_wowaudit'])->first())){
break;
}
$raid = new Raid();
$raid->id_wowaudit = $_POST['id_wowaudit'];
$raid->sync();
if(!empty($raid->title)){
$raid->save();
}
}
}
break;
case 'signupRaid':
isAllowed('wowpress_view_raids');
if (isset($_POST['signupRaid_nonce']) && wp_verify_nonce($_POST['signupRaid_nonce'], 'signupRaid')) {
if (isset($_POST['raid_id']) && isset($_POST['raid_character']) && isset($_POST['raid_status']) && isset($_POST['raid_role']) && isset($_POST['comment'])) {
$char = Character::find($_POST['raid_character']);
$raid = Raid::find($_POST['raid_id']);
if ($char->can_edit) {
if (!$char->id_wowaudit) {
$cw = $char->user->characters()->whereNot('id_wowaudit', 'NULL')->first();
if (empty($cw->ID)) {
break;
}
} else {
$cw = $char;
}
$comment = htmlentities2($_POST['comment']);
$signup = new Signup();
$signup->raid_id = $raid->ID;
$signup->character_id = $cw->ID;
$signup->setStatus($_POST['raid_status']);
$signup->setRole($_POST['raid_role']);
$signup->comment = $comment;
$sup = $signup->updateAPI($char);
if (!empty($sup['error'])) {
dd($sup);
}
$raid->sync(true);
$raid->save();
}
}
}
break;
}
header('Location: ' . $_SERVER['HTTP_REFERER']);

View File

@ -15,7 +15,7 @@ $author = User::find(get_the_author_meta('ID'));
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-wrapper" style="--author-class:var(--color-deathknight)">
<div class="post-wrapper" style="--author-class:var(--color-<?=$author->color?>)">
<div class="post-title">
<h1><?php the_title() ?></h1>
</div>
@ -28,14 +28,14 @@ $author = User::find(get_the_author_meta('ID'));
$color = get_term_meta($category->term_id, 'color', true);
?>
<div class="post-category ribbon" style="--color-ribbon:#<?= ctype_xdigit($color) ? $color : 'fff' ?>"><span><?= $category->name ?></span></div>
<div class="post-avatar"><img src="<?= get_avatar_url(get_the_author_meta('ID')); ?>"></div>
<div class="post-avatar"><img src="<?= $author->avatar ?>"></div>
<div class="post-author">
<?php if (current_user_can('edit_post', $post->ID)) : ?>
<a href="<?= get_edit_post_link($post->ID) ?>">
<?= $author->display_name ?>
<?= $author->username ?>
</a>
<?php else : ?>
<?= $author->display_name ?>
<?= $author->username ?>
<?php endif; ?>
</div>
</article><!-- #post-${ID} -->

View File

@ -0,0 +1,34 @@
<?php
use WoWPress\Models\Raid;
use WoWPress\Models\Signup;
use WoWPress\Models\User;
#dd($instance['count']);
$user = User::find(get_current_user_id());
$raids = Raid::where('start', '>', date('Y-m-d H:i', strtotime('NOW')))->get()->take(intval($instance['count']) ?: 1);
$character = $user->raiders->first();
?>
<div class="bg-glass shadow p-auto flex flex-col gap-auto order-last">
<h3 class="text-xl font-bold text-center"><?= $this->title ?></h3>
<?php if(!empty($character->ID)): ?>
<?php foreach ($raids as $raid) : ?>
<?php
?>
<div class="border shadow p-auto flex flex-col gap-2">
<h1 class="text-xl font-bold text-center"><?= $raid->title ?></h1>
<div class="text-center text-<?= $raid->color ?>"><?= $raid->difficulty ?></div>
<div class="flex gap-1 justify-center">
<div class="text-center text-white"><?= format_date($raid->start, 'E, dd.MM.') ?></div>
<div class="text-center text-white"><?= format_date($raid->start, 'HH:mm') ?> - <?= format_date($raid->end, 'HH:mm') ?></div>
</div>
<?php
$raid->showSignup($character,false, true, true);
?>
</div>
<?php endforeach; endif;?>
</div>

View File

@ -71,6 +71,7 @@ abstract class Api
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {

View File

@ -2,6 +2,9 @@
namespace WoWPress\Api;
use WoWPress\Models\Character;
use WoWPress\Models\Raid;
class WoWAudit extends Api{
protected $api_url = "https://www.wowaudit.com/v1/";
@ -20,4 +23,27 @@ class WoWAudit extends Api{
return $this->get("characters",[],true,5);
}
public function changeSignup($raid,$character,$status,$role,$comment="",$second_char=null){
if(empty($character->ID) || empty($raid->ID)) return false;
$body = [
'id' => $raid->id_wowaudit,
'signup_changes' => [
[
'character_id' => $character->id_wowaudit,
'status' => $status,
'role' => $role,
'class' => $second_char->ID?$second_char->class:$character->class,
'comment' => $comment,
]
],
];
$url = "raids/".$raid->id_wowaudit;
return $this->put($url,$body);
}
}

View File

@ -12,6 +12,7 @@ class CreateSignupTable extends CreateTable
'boss_id' => 'mediumint',
'status' => 'text NOT NULL',
'role' => 'text NOT NULL',
'comment' => 'text',
'created_at' => 'timestamp NOT NULL',
'updated_at' => 'timestamp NOT NULL',
];

View File

@ -15,7 +15,8 @@ class ToggleButton{
public $text;
public $icon_yes = "o-check-badge";
public $icon_no = "o-no-symbol";
public $value = "";
public $color_yes = "monk";
public $color_no = "monk";

View File

@ -0,0 +1,32 @@
<?php
namespace WoWPress\Frontend\Widgets;
class RaidSignup extends Widget {
protected $template_path = "raid_signup.php";
protected $title = "Raid-Anmeldungen";
protected $base_id = "wowpress_raid_signup";
public $name = "Raidanmeldungen";
protected $restricted = "wowpress_view_raids";
public function form( $instance ) {
$count = ! empty( $instance['count'] ) ? $instance['count'] : 1;
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php echo esc_html__( 'Anzahl', 'wowpress' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>" min="1" max="5" type="number" value="<?php echo esc_attr( $count ); ?>">
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['count'] = ( ! empty( $new_instance['count'] ) ) ? strip_tags( $new_instance['count'] ) : '';
return $instance;
}
}

View File

@ -0,0 +1,63 @@
<?php
namespace WoWPress\Frontend\Widgets;
use WoWPress\Models\Raid;
use WoWPress\Models\User;
use WP_Widget;
class Widget extends WP_Widget {
protected $template_path = "";
protected $title = "";
protected $base_id = "wowpress_widget";
public $name = "WoWPress Widget";
protected $restricted = false;
public function __construct() {
parent::__construct(
$this->base_id, // Base ID
$this->name // Name
);
add_action( 'widgets_init', function() {
register_widget( $this::class);
});
}
public $args = array(
'before_title' => '',
'after_title' => '',
'before_widget' => '',
'after_widget' => '',
);
private function getTemplatePath(){
return get_template_directory()."/template-parts/widgets/".$this->template_path;
}
public function widget( $args, $instance ) {
#dd($instance);
if(!$this->restricted || (current_user_can($this->restricted))){
require($this->getTemplatePath());
}
}
public function form( $instance ) {
$count = ! empty( $instance['count'] ) ? $instance['count'] : 1;
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php echo esc_html__( 'Anzahl', 'wowpress' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>" min="1" max="5" type="number" value="<?php echo esc_attr( $count ); ?>">
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['count'] = ( ! empty( $new_instance['count'] ) ) ? strip_tags( $new_instance['count'] ) : '';
return $instance;
}
}

View File

@ -34,7 +34,10 @@ class Character extends Model
}
public function getCanEditAttribute(){
return current_user_can('wowpress_edit_raids') || (get_current_user_id() == $this->ID);
if(empty($this->user->ID)){
return current_user_can('wowpress_edit_raids');
}
return current_user_can('wowpress_edit_raids') || (get_current_user_id() == $this->user->ID);
}

View File

@ -92,6 +92,7 @@ class Raid extends Model
$partial = false;
$signups = [];
$sup = [];
foreach ($encounters as $key => &$encounter) {
$partial = $encounter['enabled'] || $partial;
if (empty($encounter['selections'])) {
@ -99,6 +100,8 @@ class Raid extends Model
}
$encounters[$key]['selections'] = collect($encounter['selections']);
}
$this->partial = $partial;
foreach ($raid->signups as $signup) {
$character = Character::whereName($signup['character']['name'])->whereRealm($signup['character']['realm'])->first();
@ -140,12 +143,11 @@ class Raid extends Model
$s->role = $signup['status'] == "Unknown" ? "Unknown" : $signup['role'];
$signups[] = $s;
}
$this->signups = collect($signups);
foreach ($encounters as $encounter) {
foreach ($encounters as &$encounter) {
foreach ($encounter['selections'] as $key => &$selection) {
$character = Character::where('id_wowaudit', $selection['character_id'])->first();
$selection['status'] = $sup[$character->id_wowaudit];
@ -160,8 +162,9 @@ class Raid extends Model
$encounter['selections'][$key] = $s;
}
}
array_unshift($encounters, [
'name' => "Alle Bosse",
@ -176,10 +179,13 @@ class Raid extends Model
}
$this->encounters = collect($encounters);
}else{
return false;
}
}
return false;
return $this;
}
public function getColorAttribute($type = "")
@ -237,6 +243,7 @@ class Raid extends Model
} else {
$chars = [$character];
}
if(!empty($this->id_wowaudit)) $this->sync();
if (!empty($character->ID) && !empty($this->signups)) {
foreach ($this->signups as $signup) {
foreach ($chars as $character) {

View File

@ -23,6 +23,20 @@ class SKS extends Model
return static::distinct('list_name')->get();
}
public function getCharacterAttribute(){
$char= Character::where('name',$this->char_name)->where('realm',$this->realm_name)->first();
if(!empty($char->ID)){
return $char;
}
$char = new Character();
$char->name = $this->char_name;
$char->realm = $this->realm_name;
$char->class = "yellow";
return $char;
}
}

View File

@ -3,15 +3,18 @@
namespace WoWPress\Models;
use Wenprise\Eloquent\Model;
use WoWPress\Api\WoWAudit;
class Signup extends Model
{
protected $table = "wowpress_characters";
protected $table = "wowpress_signups";
protected $primaryKey = 'ID';
protected $guarded = ['ID'];
protected $statusList = [];
private $api;
protected $roleList = [];
public $status = "Unknown";
@ -90,6 +93,15 @@ class Signup extends Model
'color' => 'white',
],
];
$options = get_option('wowpress_api');
if (isset($options['bnet'])) {
$key = get_option('wowpress_api')['wowaudit']['key'];
} else {
return false;
}
$this->api = new WoWAudit(null, $key);
}
public function character(){
@ -160,4 +172,12 @@ class Signup extends Model
}
return false;
}
public function updateAPI(Character $second_char = null){
if($second_char->ID){
return $this->api->changeSignup($this->raid,$this->character,$this->status,$this->role,$this->comment,$second_char);
}else{
return $this->api->changeSignup($this->raid,$this->character,$this->status,$this->role,$this->comment);
}
}
}

View File

@ -4,12 +4,82 @@ namespace WoWPress\Models;
use Wenprise\ORM\WP\User as WPUser;
class User extends WPUser{
class User extends WPUser
{
public function characters(){
public function characters()
{
return $this->hasMany(Character::class)->orderBy('rank');
}
public function raiders()
{
return $this->hasMany(Character::class, 'user_id')->where('raidchar', true)->orderBy('rank');
}
}
public static function getAvatar($avatar, $user_object)
{
if(is_numeric($user_object)){
$user = User::find($user_object);
if(!empty($user->ID)){
return $user->getAvatarAttribute();
}
}
if(!empty($user_object->user_id)){
$user = User::find($user_object->user_id);
if(!empty($user->ID)){
return $user->getAvatarAttribute();
}
}
return $avatar;
}
public function getAvatarAttribute(){
$chars = $this->characters;
if (!empty($chars->first())) {
return $chars->first()->avatar;
}
return $this->avatar_url;
}
public static function getUsername($username, $user_object)
{
if(is_numeric($user_object)){
$user = User::find($user_object);
if(!empty($user->ID)){
return $user->getUsernameAttribute();
}
}
if (!empty($user_object->user_id)) {
$user = User::find($user_object->user_id);
return $user->getUsernameAttribute();
}
if (!empty($user_object->ID)) {
$user = User::find($user_object->ID);
return $user->getUsernameAttribute();
}
return $username;
}
public function getUsernameAttribute()
{
$chars = $this->characters;
if (!empty($chars->first())) {
return $chars->first()->name;
}
return $this->user_nickname ?: $this->login;
}
public function getColorAttribute()
{
$chars = $this->characters;
if (!empty($chars->first())) {
return $chars->first()->color;
}
return "priest";
}
}