diff --git a/tailwind/custom/asgaros.css b/tailwind/custom/asgaros.css new file mode 100644 index 0000000..89ffe00 --- /dev/null +++ b/tailwind/custom/asgaros.css @@ -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; +} + + diff --git a/tailwind/tailwind.config.js b/tailwind/tailwind.config.js index ad3e078..3f11032 100644 --- a/tailwind/tailwind.config.js +++ b/tailwind/tailwind.config.js @@ -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\]'] }, ] }; diff --git a/tailwind/tailwind.css b/tailwind/tailwind.css index 610087f..74c51c2 100644 --- a/tailwind/tailwind.css +++ b/tailwind/tailwind.css @@ -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; } } + + + diff --git a/theme/components/raid-signup.php b/theme/components/raid-signup.php index c11826c..95269de 100644 --- a/theme/components/raid-signup.php +++ b/theme/components/raid-signup.php @@ -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]; } + ?>
border border-character->color ?> shadow" x-data="{open : false}"> - -
getStatus()->icon) ?> +
getStatus()->icon) ?> getStatus()->name : "" ?>
-
getRole()->icon) ?> - getRole()->name:""?> +
getRole()->icon) ?> + getRole()->name : "" ?>
- - character->can_edit): ?> -
\ No newline at end of file diff --git a/theme/components/toggle-button.php b/theme/components/toggle-button.php index 1b2a1b6..a3a2214 100644 --- a/theme/components/toggle-button.php +++ b/theme/components/toggle-button.php @@ -4,7 +4,7 @@ use WoWPress\Frontend\Icon;
+
+
+
+ + + + + + + + + + + + + + list_name) as $sk) : + ?> + odd:bg-slate-900"> + + + + + + + + + + + + + + + +
RangCharakterAktion
+
+ + +
+ +
rank ?>character->name ?> +
+ active) : ?> + + + + + + + +
+ + + + +
+ + +
+ +
+ +
+
+
+ +
+ +
+ \ No newline at end of file diff --git a/theme/request.php b/theme/request.php index 762a2b2..7be6bca 100644 --- a/theme/request.php +++ b/theme/request.php @@ -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']); diff --git a/theme/template-parts/content/content.php b/theme/template-parts/content/content.php index 8d2caed..698ce15 100644 --- a/theme/template-parts/content/content.php +++ b/theme/template-parts/content/content.php @@ -15,7 +15,7 @@ $author = User::find(get_the_author_meta('ID')); ?>
> -
+

@@ -28,14 +28,14 @@ $author = User::find(get_the_author_meta('ID')); $color = get_term_meta($category->term_id, 'color', true); ?> -
+
\ No newline at end of file diff --git a/theme/template-parts/widgets/raid_signup.php b/theme/template-parts/widgets/raid_signup.php new file mode 100644 index 0000000..e3c98b1 --- /dev/null +++ b/theme/template-parts/widgets/raid_signup.php @@ -0,0 +1,34 @@ +', date('Y-m-d H:i', strtotime('NOW')))->get()->take(intval($instance['count']) ?: 1); +$character = $user->raiders->first(); + +?> + +
+

title ?>

+ ID)): ?> + + +
+

title ?>

+
difficulty ?>
+ +
+
start, 'E, dd.MM.') ?>
+
start, 'HH:mm') ?> - end, 'HH:mm') ?>
+
+ showSignup($character,false, true, true); + ?> +
+ +
\ No newline at end of file diff --git a/theme/wowpress/Api/Api.php b/theme/wowpress/Api/Api.php index 528b137..6e592c2 100644 --- a/theme/wowpress/Api/Api.php +++ b/theme/wowpress/Api/Api.php @@ -71,6 +71,7 @@ abstract class Api curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $result = curl_exec($ch); if (curl_errno($ch)) { diff --git a/theme/wowpress/Api/WoWAudit.php b/theme/wowpress/Api/WoWAudit.php index 4b87a46..3b74f1c 100644 --- a/theme/wowpress/Api/WoWAudit.php +++ b/theme/wowpress/Api/WoWAudit.php @@ -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); + + + } + } \ No newline at end of file diff --git a/theme/wowpress/Database/CreateSignupTable.php b/theme/wowpress/Database/CreateSignupTable.php index effb568..b68c4df 100644 --- a/theme/wowpress/Database/CreateSignupTable.php +++ b/theme/wowpress/Database/CreateSignupTable.php @@ -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', ]; diff --git a/theme/wowpress/Frontend/ToggleButton.php b/theme/wowpress/Frontend/ToggleButton.php index a76db7d..0fb4022 100644 --- a/theme/wowpress/Frontend/ToggleButton.php +++ b/theme/wowpress/Frontend/ToggleButton.php @@ -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"; diff --git a/theme/wowpress/Frontend/Widgets/RaidSignup.php b/theme/wowpress/Frontend/Widgets/RaidSignup.php new file mode 100644 index 0000000..b007b87 --- /dev/null +++ b/theme/wowpress/Frontend/Widgets/RaidSignup.php @@ -0,0 +1,32 @@ + +

+ + +

+ 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; + + ?> +

+ + +

+ 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); } diff --git a/theme/wowpress/Models/Raid.php b/theme/wowpress/Models/Raid.php index 9273245..2531a64 100644 --- a/theme/wowpress/Models/Raid.php +++ b/theme/wowpress/Models/Raid.php @@ -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) { diff --git a/theme/wowpress/Models/SKS.php b/theme/wowpress/Models/SKS.php index 8e9e365..3407087 100644 --- a/theme/wowpress/Models/SKS.php +++ b/theme/wowpress/Models/SKS.php @@ -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; + } } \ No newline at end of file diff --git a/theme/wowpress/Models/Signup.php b/theme/wowpress/Models/Signup.php index 7c438eb..b3054d6 100644 --- a/theme/wowpress/Models/Signup.php +++ b/theme/wowpress/Models/Signup.php @@ -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); + } + } } diff --git a/theme/wowpress/Models/User.php b/theme/wowpress/Models/User.php index a66aed0..ce3ed8e 100644 --- a/theme/wowpress/Models/User.php +++ b/theme/wowpress/Models/User.php @@ -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'); + } -} \ No newline at end of file + 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"; + } +}