-
+
-
= $notification->note ?>
-
+
= $notification->note ?>
+
diff --git a/theme/wowpress/Database/CreateCharListItemTable.php b/theme/wowpress/Database/CreateCharListItemTable.php
new file mode 100644
index 0000000..4388849
--- /dev/null
+++ b/theme/wowpress/Database/CreateCharListItemTable.php
@@ -0,0 +1,17 @@
+ 'mediumint NOT NULL',
+ 'list_id' => 'mediumint NOT NULL',
+ 'date' => 'date NOT NULL',
+ 'count_multiplier' => 'tinyint NOT NULL',
+ 'comment' => 'text',
+ ];
+
+}
diff --git a/theme/wowpress/Database/CreateCharListsTable.php b/theme/wowpress/Database/CreateCharListsTable.php
new file mode 100644
index 0000000..e35462d
--- /dev/null
+++ b/theme/wowpress/Database/CreateCharListsTable.php
@@ -0,0 +1,16 @@
+ 'text NOT NULL',
+ 'border_color' => 'text NOT NULL',
+ 'max_count' => 'mediumint NOT NULL',
+ 'notify' => 'boolean'
+ ];
+
+}
diff --git a/theme/wowpress/Models/Character.php b/theme/wowpress/Models/Character.php
index 643b285..21479f4 100644
--- a/theme/wowpress/Models/Character.php
+++ b/theme/wowpress/Models/Character.php
@@ -29,6 +29,10 @@ class Character extends Model
$this->api = new BattleNet($id,$key);
}
+ public function lists(){
+ return $this->belongsToMany(CharacterList::class,'wowpress_charlists_item','list_id','character_id')->withPivot('comment','date','id');
+ }
+
public function user(){
return $this->belongsTo(User::class);
}
@@ -53,15 +57,25 @@ class Character extends Model
public function getRankAttribute($rank){
switch($rank){
case 0: return "Gildenmeister";
+ break;
case 1: return "Offizier";
+ break;
case 2: return "Offi-Twink";
+ break;
case 3: return "Raidlead";
+ break;
case 4: return "Ehrenmitglied";
+ break;
case 5: return "Raider";
+ break;
case 6: return "Raider-Twink";
+ break;
case 7: return "F&F";
+ break;
case 8: return "Novize";
+ break;
case 9: return "Sleeper";
+ break;
default: return "Gast";
}
}
diff --git a/theme/wowpress/Models/CharacterList.php b/theme/wowpress/Models/CharacterList.php
new file mode 100644
index 0000000..87f22c9
--- /dev/null
+++ b/theme/wowpress/Models/CharacterList.php
@@ -0,0 +1,35 @@
+belongsToMany(Character::class,'wowpress_charlists_item','character_id','list_id')->orderBy('character_id')->orderByPivot('date')->withPivot('comment','date','ID');
+ }
+
+ public function addItem(Character $char, $comment = null, $date = null, $multiplier = 1){
+ $this->characters()->attach($char->ID,[
+ 'comment' => $comment,
+ 'date' => $date?:date('Y-m-d'),
+ 'count_multiplier' => $multiplier
+ ]);
+ if($this->notify){
+ if($char->user){
+ Notification::addNotification($char->user->ID,'Neuer Eintrag in Liste: '.$this->list_name);
+ }
+ }
+ }
+
+ public function removeItem($id){
+ $this->characters()->wherePivot('id',$id)->first()->detach();
+ }
+
+}
\ No newline at end of file
diff --git a/theme/wowpress/Models/CharacterListItem.php b/theme/wowpress/Models/CharacterListItem.php
new file mode 100644
index 0000000..6670327
--- /dev/null
+++ b/theme/wowpress/Models/CharacterListItem.php
@@ -0,0 +1,35 @@
+belongsTo(CharacterList::class,'list_id');
+ }
+
+ public function character(){
+ $this->belongsTo(Character::class,'character_id');
+ }
+
+ public static function deleteOrphans(){
+ $items = static::all();
+ foreach($items as $item){
+ try{
+ $item->list;
+ }catch(LogicException $e){
+ $item->delete();
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/theme/wowpress/Models/Notification.php b/theme/wowpress/Models/Notification.php
index a7ec384..124011d 100644
--- a/theme/wowpress/Models/Notification.php
+++ b/theme/wowpress/Models/Notification.php
@@ -19,6 +19,15 @@ class Notification extends Model{
$note->save();
}
+ public static function addCapabilityNotification($capability,$note_text){
+ $users = get_users(array(
+ 'capability' => $capability,
+ ));
+ foreach($users as $user){
+ Notification::addNotification($user->ID, $note_text);
+ }
+ }
+
public static function getAll(){
return Notification::where('user_id',get_current_user_id())->get();
}
diff --git a/theme/wowpress/Models/Raid.php b/theme/wowpress/Models/Raid.php
index 358f6a5..3b3e1df 100644
--- a/theme/wowpress/Models/Raid.php
+++ b/theme/wowpress/Models/Raid.php
@@ -81,9 +81,9 @@ class Raid extends Model
if (!empty($this->id_wowaudit)) {
$raid = (object)$this->api->getRaid($this->id_wowaudit, $force);
if (!empty($raid->id)) {
- if($this->title && $raid->instance == "Custom"){
+ if ($this->title && $raid->instance == "Custom") {
//Titel nur sezten wenn kein Custom Raid
- }else{
+ } else {
$this->title = $raid->instance;
}
$this->start = $raid->date . " " . $raid->start_time;
@@ -103,7 +103,7 @@ class Raid extends Model
}
$encounters[$key]['selections'] = collect($encounter['selections']);
}
-
+
$this->partial = $partial;
foreach ($raid->signups as $signup) {
@@ -147,10 +147,10 @@ class Raid extends Model
$s->role = $signup['status'] == "Unknown" ? "Unknown" : $signup['role'];
$signups[] = $s;
}
-
+
$this->signups = collect($signups);
-
+
foreach ($encounters as &$encounter) {
foreach ($encounter['selections'] as $key => &$selection) {
$character = Character::where('id_wowaudit', $selection['character_id'])->first();
@@ -166,9 +166,9 @@ class Raid extends Model
$encounter['selections'][$key] = $s;
}
}
-
-
-
+
+
+
array_unshift($encounters, [
'name' => "Alle Bosse",
@@ -183,16 +183,17 @@ class Raid extends Model
}
$this->encounters = collect($encounters);
- }else{
+ } else {
return false;
}
}
-
+
return $this;
}
- public function setTitle($title){
+ public function setTitle($title)
+ {
$this->title = $title;
$this->save();
}
@@ -222,27 +223,28 @@ class Raid extends Model
public function getPreviousAttribute()
{
- $previous = Raid::where('start','<',$this->start)->orderBy('start','DESC')->first();
+ $previous = Raid::where('start', '<', $this->start)->orderBy('start', 'DESC')->first();
return $previous;
}
- public function getThumbnailAttribute(){
+ public function getThumbnailAttribute()
+ {
- $clean_name = str_replace([" ","'"],"-",$this->title);
+ $clean_name = str_replace([" ", "'"], "-", $this->title);
$clean_name = preg_replace('/[^a-zA-Z0-9_-]/', '', $clean_name);
$clean_name = strtolower($clean_name);
$url = "https://data.wowaudit.com/img/$clean_name-small.jpeg";
- if(file_exists($url)){
- return $url;
+ list($status) = get_headers($url);
+ if (strpos($status, '404') !== FALSE) {
+ return "https://data.wowaudit.com/img/custom-small.jpeg";
}
- return "https://data.wowaudit.com/img/custom-small.jpeg";
-
+ return $url;
}
public function getNextAttribute()
{
- $next = Raid::where('start','>',$this->start)->orderBy('start','ASC')->first();
+ $next = Raid::where('start', '>', $this->start)->orderBy('start', 'ASC')->first();
return $next;
}
@@ -254,7 +256,7 @@ class Raid extends Model
} else {
$chars = [$character];
}
- if(!empty($this->id_wowaudit)) $this->sync();
+ if (!empty($this->id_wowaudit)) $this->sync();
if (!empty($character->ID) && !empty($this->signups)) {
foreach ($this->signups as $signup) {
foreach ($chars as $character) {
@@ -268,7 +270,6 @@ class Raid extends Model
$s = new Signup();
$s->raid_id = $this->ID;
$s->character_id = $character->ID;
- return $s->showForm($showRole,$showStatus,$vertical);
-
+ return $s->showForm($showRole, $showStatus, $vertical);
}
}