Hallo zusammen,
Als Rollenspielforum müssen sich User im Spielbereich an eine Reihenfolge halten, nach der sie posten sollen. Das funktionierte bisher im WBB 4.1 wie in den Quellcodes steht. Eingebunden wurde das ganze über die Custom Pages. ich habe folgende PHP Skripte, die nun auf WBB 5.1 umgeschrieben werden müssen. Wie finde ich nun die Unterschiede der Forenstrukturen heraus und setze die neue Strukturen ein? Anbei der Code. Es handelt sich dabei um sogenannte Playlisten. Was sie genau unter WBB 4.1 tun erklärt das folgende Video ziemlich gut. Ich habe ein Plugin gesehen, bei dem die eigenen Beiträge alle in einer Liste gesammelt werden könnten. Damit könnten wir zumindest eine unserer Playlisten tatsächlich erst einmal abfangen und es geht um die Entwicklung der unten beiden stehenden. Im Prinzip geht es um das Abgreifen einer Reihenfolge, in der User in einem Thema posten sollen. Sobald der User in dieses Thema schreibt, wird er in die Reihenfolge eingebunden. Das Skript soll nur für bestimmte Forenbereiche aktiv sein.
Idealerweise informiert das Forum auch den User, wenn er mit dem Posten in dem Thema dran ist. Falls das CMS des WBB 5.1 nicht in der Lage ist, so etwas abzubilden, stünde noch WordPress bereit.
<?php
namespace wcf\page;
use wbb\data\thread\Thread;
use wcf\data\user\User;
use wcf\system\WCF;
class CustomPageScript {
private static $boardIDs =
array(8,9,10,11,12,13,24,25,26,27,28,53,54,55,56,57,58,59,60,61,62,64,65,66,67,69,70,71,73,74,75,76,77,78,80,81,83,84,85,87,88,89,90,91,92,93,94,96,97,98,99,100,101,105,106,107,116,93,119,122,124,127,130,203,204,205,206,207,208,209,210,211,212,213,214,215,229,231,232,243,256,257,264,304,305,309,311,320, 324, 329);
public static function getBoardIdsAsString(){
$queryOpenGames = "";
foreach(CustomPageScript::$boardIDs AS $key => $val){
$queryOpenGames .= "t1.boardID = ".$val." OR ";
}
$queryOpenGames = substr($queryOpenGames, 0, -3);
return $queryOpenGames;
}
public static $monate = array(1 => "Januar",
2 => "Februar",
3 => "März",
4 => "April",
5 => "Mai",
6 => "Juni",
7 => "Juli",
8 => "August",
9 => "September",
10 => "Oktober",
11 => "November",
12 => "Dezember");
public static function hasUserLeaved($threadid, $userid) {
$hasLeaved = false;
$queryLeave = "SELECT
t1.message AS postcontent
FROM
wbb" .\WCF_N . "_post AS t1
WHERE
t1.threadID = " . $threadid . " AND
t1.userid = " . $userid . "
ORDER BY
t1.time DESC LIMIT 1";
$statementB = WCF::getDB()->prepareStatement($queryLeave);
$statementB->execute();
$rs3 = $statementB->fetchAll();
$statementB->closeCursor();
if (count($rs3) > 0) {
foreach ($rs3 as $message) {
$pos = strpos($message['postcontent'], "[verlassen]");
if ($pos === false) {
;
} else {
$hasLeaved = true;
}
}
}
return $hasLeaved;
}
public static function getNextPoster($threadid, $lastPosterID){
$nextPoster = "";
$posterArray = array();
// $posters = "SELECT DISTINCT(userid) AS posterId
// FROM wbb".WCF_N."_post
// WHERE threadID = " . $threadid . "
// ORDER BY wbb".WCF_N."_post.time DESC ";
$posters = "SELECT MAX( wbb".WCF_N."_post.time ) AS timefield, userid AS posterId
FROM wbb".WCF_N."_post
WHERE threadID =" . $threadid . "
GROUP BY userid
ORDER BY timefield DESC ";
$statement = WCF::getDB()->prepareStatement($posters);
$statement->execute();
$rs2 = $statement->fetchAll();
$statement->closeCursor();
foreach($rs2 AS $posterID){
if($posterID['posterId'] != "" && CustomPageScript::hasUserLeaved($threadid, $posterID['posterId']) == false){
$posterArray[] = $posterID['posterId'];
$nextPoster .= $posterID['posterId'] . ", ";
}
}
$keyLastPoster = array_search($lastPosterID, $posterArray);
$keyNextPoster = $keyLastPoster - 1;
if($keyNextPoster < 0){
$keyNextPoster = count($posterArray) - 1;
}
if(count($posterArray) > 0){
$idNextPoster = $posterArray[$keyNextPoster];
$nextUser = new User($idNextPoster);
return $nextUser->getTitle();
}else{
return "";
}
}
public static function execute() {
$trTrenner = "<tr><td colspan='5'><p style='border-color:#c9cfc9; border-width:1px; border-style:solid'></p></td></tr>";
$arraySearch = array("[playtime]", "[/playtime]", "[handlung]", "[/handlung]");
$arrayReplace = array("", "","", "");
$arrayGames = array();
$queryOpenGames = "SELECT
t1.topic AS topic,
t1.threadID AS threadID,
t1.lastPosterID AS lastPosterID,
t2.message AS message
FROM wbb".WCF_N."_thread AS t1
LEFT JOIN wbb".WCF_N."_post AS t2 ON t2.postID = t1.firstPostID
WHERE (
". CustomPageScript::getBoardIdsAsString()."
)
AND t1.isClosed =0
ORDER BY t1.topic ASC";
$statement = WCF::getDB()->prepareStatement($queryOpenGames, 1000);
$statement->execute();
while ($rowGame = $statement->fetchArray()) {
$insertGame = true;
preg_match_all("/\[playtime\](.*?)\[\/playtime\]/ism", $rowGame['message'], $match);
if(isset($match[0][0])){
$rowGame['playtime'] = str_replace($arraySearch, $arrayReplace, $match[0][0]);
$rowGame['playtimeTS'] = strtotime($rowGame['playtime']);
}
else{
$insertGame = false;
$rowGame['playtime'] = date('d.m.Y');
$rowGame['playtimeTS'] = strtotime($rowGame['playtime']);
}
preg_match_all("/\[handlung\](.*?)\[\/handlung\]/ism", $rowGame['message'], $matchA);
if(isset($matchA[0][0])){
$rowGame['handlung'] = str_replace($arraySearch, $arrayReplace, $matchA[0][0]);
}
else{
$rowGame['handlung'] = "<i>Keine Handlung gefunden</i>";
}
if($insertGame){
$arrayGames[] = $rowGame;
}
}
$statement->closeCursor();
$anz = count($arrayGames);
for ($a = 0; $a < $anz; $a++) {
$queryChars = "SELECT DISTINCT(t1.userid) AS posterID
FROM wbb".WCF_N."_post AS t1
WHERE t1.threadID = " . $arrayGames[$a]['threadID'] . " ORDER BY t1.username ASC";
$chars = "";
$statementB = WCF::getDB()->prepareStatement($queryChars);
$statementB->execute();
$rs2 = $statementB->fetchAll();
$statementB->closeCursor();
foreach($rs2 AS $rowChar){
$user = new User($rowChar['posterID']);
$hasLeaved = false;
if($rowChar['posterID'] == ""){
}
else{
$hasLeaved = CustomPageScript::hasUserLeaved($arrayGames[$a]['threadID'], $rowChar['posterID']);
}
$chars .= ($hasLeaved ? "<span class=\"leaver\">" : "") . $user->getTitle().($hasLeaved ? "</span>" : "").", ";
}
$arrayGames[$a]['characters'] = substr($chars, 0, -2);
}
$arrayGames = CustomPageScript::sortByDate($arrayGames);
/**
* Ausgabe HTML
*/
echo "<script data-relocate=\"true\">
$(function() {
$('.wbbBoardNode').mouseenter(function(){
$(this).addClass( 'hover');
}).mouseleave(function(){
$(this).removeClass( 'hover');
});
});
</script>";
echo "<table class='wbbBoardList' cellspacing='2'>";
echo $trTrenner;
echo "<tr class='default'>";
echo "<td><b>Datum</b></td>";
echo "<td><b>Playname</b></td>";
echo "<td><b>Charaktere</b></td>";
echo "<td><b>Nächster Poster</b></td>";
echo "<td><b>Handlung</b></td>";
echo "</tr>";
$oldDate = "";
for($x =0; $x < $anz; $x++){
$threadObj = new Thread($arrayGames[$x]['threadID']);
if($oldDate == ""){
$oldDate = $arrayGames[$x]['playtimeTS'];
}
else if($oldDate != $arrayGames[$x]['playtimeTS']){
echo $trTrenner;
$oldDate = $arrayGames[$x]['playtimeTS'];
}
echo "<tr class='wbbBoardNode".($x % 2 == 0 ? '1' : '2')."'>";
echo "<td valign='top' width='75px'>".$arrayGames[$x]['playtime']."</td>";
echo "<td valign='top' width='300px'><a href='".$threadObj->getLink()."?action=firstNew' target='_blank'>".$arrayGames[$x]['topic']."</a></td>";
echo "<td valign='top' width='200px'>".(isset($arrayGames[$x]['characters']) ? $arrayGames[$x]['characters'] : "- not found -")."</td>";
echo "<td valign='top' width='150px'>". CustomPageScript::getNextPoster($arrayGames[$x]['threadID'], $arrayGames[$x]['lastPosterID'])."</td>";
echo "<td valign='top' width='*'><div style='padding-bottom: 10px;'>".$arrayGames[$x]['handlung']."</div></td>";
echo "</tr>";
}
echo "</table>";
}
public static function sortByDate($bubblesort_array){
$anz = count($bubblesort_array);
$temp=null;
for ($a = 0; $a < $anz; $a++) {
for ($b = 0; $b < $anz -1; $b++) {
if ($bubblesort_array[$b +1]['playtimeTS'] < $bubblesort_array[$b]['playtimeTS']) {
$temp = $bubblesort_array[$b];
$bubblesort_array[$b] = $bubblesort_array[$b +1];
$bubblesort_array[$b +1] = $temp;
}
}
}
return $bubblesort_array;
}
}
?>
Display More
<?php
namespace wcf\page;
use wbb\data\thread\Thread;
use wcf\system\WCF;
class CustomPageScript {
public static $arraySearch = array("[playtime]", "[/playtime]", "[handlung]", "[/handlung]");
public static $arrayReplace = array("", "", "", "");
public static $minDate = null;
public static $maxDate = null;
public static $calendarPostsArray = array();
public static $trTrenner = "<tr><td colspan='4'><p style='border-color:#c9cfc9; border-width:1px; border-style:solid'></p></td></tr>";
private static $boardIDs = array(8,9,10,11,12,13,24,25,26,27,28,53,54,55,56,57,58,59,60,61,62,64,65,66,67,69,70,71,73,74,75,76,77,78,80,81,83,84,85,87,88,89,90,91,92,93,94,98,99,100,101,105,106,107,116,92,93,119,122,124,127,130,202,203,204,205,206,207,208,209,210,211,212,213,214,215,229,231,232,243,256,257,264,304,305,309,311,320, 324, 329);
public static function getBoardIdsAsString() {
$queryOpenGames = "";
foreach(CustomPageScript::$boardIDs AS $key => $val){
$queryOpenGames .= "t1.boardID = ".$val." OR ";
}
$queryOpenGames = substr($queryOpenGames, 0, -3);
return $queryOpenGames;
}
public static $monate = array(1 => "Januar",
2 => "Februar",
3 => "März",
4 => "April",
5 => "Mai",
6 => "Juni",
7 => "Juli",
8 => "August",
9 => "September",
10 => "Oktober",
11 => "November",
12 => "Dezember");
/**
* Sortierte nach Handlungsdatum und lese die Mitspieler
* @param type $arrayGames
* @return type
*/
public static function getCharactersAndSort($arrayGames) {
$anz = count($arrayGames);
for ($cb = 0; $cb < $anz; $cb++) {
$queryChars = "SELECT DISTINCT(t1.username) AS charname
FROM wbb" . WCF_N . "_post AS t1
WHERE t1.threadID = " . $arrayGames[$cb]['threadID'] . " ORDER BY t1.username ASC";
$chars = "";
$statementB = WCF::getDB()->prepareStatement($queryChars);
$statementB->execute();
$rs2 = $statementB->fetchAll();
$statementB->closeCursor();
if (count($rs2) > 0) {
foreach ($rs2 AS $rowChar) {
$chars .= $rowChar['charname'] . ", ";
}
}
$arrayGames[$cb]['characters'] = substr($chars, 0, -2);
}
for ($a = 0; $a < $anz; $a++) {
for ($b = 0; $b < $anz - 1; $b++) {
if ($arrayGames[$b + 1]['playtimeTS'] < $arrayGames[$b]['playtimeTS']) {
CustomPageScript::$minDate = $arrayGames[$b + 1]['playtimeTS'];
$temp = $arrayGames[$b];
$arrayGames[$b] = $arrayGames[$b + 1];
$arrayGames[$b + 1] = $temp;
} else {
CustomPageScript::$maxDate = $arrayGames[$b + 1]['playtimeTS'];
}
}
}
return $arrayGames;
}
/**
* Lese alles geschlossenen Threads aus
* @return type
*/
public static function getClosedGames() {
$arrayGames = array();
$queryOpenGames = "SELECT
t1.topic AS topic,
t1.threadID AS threadID,
t2.message AS message
FROM wbb" . WCF_N . "_thread AS t1
LEFT JOIN wbb" . WCF_N . "_post AS t2 ON t2.postID = t1.firstPostID
WHERE (
" . CustomPageScript::getBoardIdsAsString() . "
)
AND t1.isClosed =1
ORDER BY t1.topic ASC ;";
$statement = WCF::getDB()->prepareStatement($queryOpenGames);
$statement->execute();
while ($rowGame = $statement->fetchArray()) {
$insertGame = true;
preg_match_all("/\[playtime\](.*?)\[\/playtime\]/ism", $rowGame['message'], $match);
if (isset($match[0][0])) {
$rowGame['playtime'] = str_replace(CustomPageScript::$arraySearch, CustomPageScript::$arrayReplace, $match[0][0]);
$rowGame['playtimeTS'] = strtotime($rowGame['playtime']);
} else {
$insertGame = false;
$rowGame['playtime'] = date('d.m.Y');
$rowGame['playtimeTS'] = strtotime($rowGame['playtime']);
}
preg_match_all("/\[handlung\](.*?)\[\/handlung\]/ism", $rowGame['message'], $matchA);
if (isset($matchA[0][0])) {
$rowGame['handlung'] = str_replace(CustomPageScript::$arraySearch, CustomPageScript::$arrayReplace, $matchA[0][0]);
} else {
$rowGame['handlung'] = "<i>Keine Handlung gefunden</i>";
}
if ($insertGame) {
$arrayGames[] = $rowGame;
}
}
$statement->closeCursor();
return CustomPageScript::getCharactersAndSort($arrayGames);
}
/**
* Sortiere die Spiele zu den möglichen Monaten
* @param type $arrayGames
*/
public static function sortPosts($arrayGames) {
$startMonthYear = new \DateTime(date('Y-m-d', CustomPageScript::$minDate));
$startMonthYear->setDate($startMonthYear->format("Y"), $startMonthYear->format("m"), 1);
$endMonthYear = new \DateTime(date('Y-m-d', CustomPageScript::$maxDate));
$diff = $startMonthYear->diff($endMonthYear);
$manuel = $startMonthYear;
$fullMonthDifference = (($diff->format('%y') * 12) + $diff->format('%m'));
for ($x = 0; $x <= $fullMonthDifference; $x++) {
$monthStart = $date = new \DateTime($manuel->format('Y') . '-' . $manuel->format('m') . '-01');
$monthStart->modify("+" . $x . " month");
$monthEnd = $date = new \DateTime($manuel->format('Y') . '-' . $manuel->format('m') . '-01');
$monthEnd->modify("+ " . $x . " month");
$monthEnd->modify("+ 1 month");
$monthEnd->modify("- 1 day");
$anz = count($arrayGames);
if ($anz > 0) {
echo "<div class='listgamescontainer gamescontainer" . $x . "' " . ($x > 0 ? " style='display: none;' " : "" ) . ">";
echo "<table class='wbbBoardList' cellspacing='2' width='100%'>";
// echo "<table class='playlistData' cellspacing='2' width='100%'>";
//echo $trTrenner;
echo "<tr class='default'>";
echo "<td width='75px'><b>Datum</b></td>";
echo "<td width='300px'><b>Playname</b></td>";
echo "<td width='200px'><b>Charaktere</b></td>";
echo "<td width='*'><b>Handlung</b></td>";
echo "</tr>";
$oldDate = "";
for ($y = 0; $y < $anz; $y++) {
$gameDateTime = new \DateTime(date("Y-m-d", $arrayGames[$y]['playtimeTS']));
if ($gameDateTime >= $monthStart && $gameDateTime <= $monthEnd) {
if ($oldDate == "") {
$oldDate = $arrayGames[$y]['playtimeTS'];
} else if ($oldDate != $arrayGames[$y]['playtimeTS']) {
echo CustomPageScript::$trTrenner;
$oldDate = $arrayGames[$y]['playtimeTS'];
}
$threadObj = new Thread($arrayGames[$y]['threadID']);
// echo "<tr class='playlistDataRow ".($y % 2 == 0 ? 'unnorm' : '')."'>";
echo "<tr class='wbbBoardNode" . ($x % 2 == 0 ? '1' : '2') . "'>";
echo "<td valign='top'>" . $arrayGames[$y]['playtime'] . "</td>";
echo "<td valign='top'><a href='" . $threadObj->getLink() . "' target='_blank'>" . $arrayGames[$y]['topic'] . "</a></td>";
echo "<td valign='top'>" . (isset($arrayGames[$y]['characters']) ? $arrayGames[$y]['characters'] : '' ) . "</td>";
echo "<td valign='top'><div style='padding-bottom: 10px;'>" . $arrayGames[$y]['handlung'] . "</div></td>";
echo "</tr>";
}
}
echo "</table>";
echo "</div>";
}
}
}
public static function calculateCalendar() {
//date_default_timezone_set("Europe/Berlin");
$elementeProReihe = 6;
$startMonthYear = new \DateTime(date('Y-m-d', CustomPageScript::$minDate));
$startMonthYear->setDate($startMonthYear->format("Y"), $startMonthYear->format("m"), 1);
$endMonthYear = new \DateTime(date('Y-m-d', CustomPageScript::$maxDate));
$startMonthYear->modify("-1 month");
$manuel = $startMonthYear;
$diff = $startMonthYear->diff($endMonthYear);
$fullMonthDifference = (($diff->format('%y') * 12) + $diff->format('%m'));
$reihen = round($fullMonthDifference / $elementeProReihe);
$rest = $fullMonthDifference % $elementeProReihe;
$manuelTds = $elementeProReihe - $rest;
echo "<table width='100%' class='calendarData' cellspacing='2'>";
$counter = 0;
for ($x = 0; $x < $reihen; $x++) {
echo "<tr>";
for ($y = 0; $y < 6; $y++) {
$manuel->modify("+ 1 month");
echo "<td width='16%'><div class=\"clicker btnDefaultClicker\" showtarget=\"gamescontainer" . $counter . "\" >" . CustomPageScript::$monate[$manuel->format("n")] . " " . $manuel->format("Y") . "</div></td>";
$counter++;
}
echo "</tr>";
}
//letzte reihe : Rest und manuelle (leere) TDs zeichnen
if ($rest > 0) {
echo "<tr>";
for ($y = 0; $y < $rest; $y++) {
$manuel->modify("+ 1 month");
echo "<td width='16%'><div class=\"clicker btnDefaultClicker\" showtarget=\"gamescontainer" . $counter . "\" >" . CustomPageScript::$monate[$manuel->format("n")] . " " . $manuel->format("Y") . "</div></td>";
$counter++;
}
for ($a = $rest; $a <= $manuelTds; $a++) {
echo "<td width='16%'> </td>";
}
echo "</tr>";
}
echo "</table>";
}
public static function execute() {
$arrayGames = CustomPageScript::getClosedGames();
CustomPageScript::calculateCalendar();
CustomPageScript::sortPosts($arrayGames);
/**
* Ausgabe HTML
*/
echo "<script data-relocate=\"true\">
$(function() {
$('.playlistDataRow').mouseenter(function(){
$(this).addClass( 'hover');
}).mouseleave(function(){
$(this).removeClass( 'hover');
});
$(\".calendarData\").on(\"click\", \".clicker\", function(){
var targetClass = $(this).attr(\"showtarget\");
if($(\".\"+targetClass).is(\":visible\")){
}
else{
$(\".listgamescontainer:visible\").each(function(index){
$(this).hide(200);
});
$(\".\"+targetClass).show(200);
}
});
});
</script>";
}
}
?>
Display More
<?php
namespace wcf\page;
use wbb\data\thread\Thread;
use wcf\system\WCF;
class NextPosting{
protected $currentUser;
public function getBoardIdsAsString(){
$queryOpenGames = "";
//Testplayforum
$queryOpenGames .= "(
t1.boardID = 5
) OR ";
//Hogwarts
//Untergeschoss
$queryOpenGames .= "
t1.boardID =53
OR t1.boardID =8
OR t1.boardID =80
OR t1.boardID =54
OR t1.boardID =55
OR t1.boardID =59
OR t1.boardID =57
OR t1.boardID =58
OR t1.boardID =56
OR t1.boardID =60
OR t1.boardID =61
OR t1.boardID =62
OR t1.boardID = 137
OR t1.boardID = 139
OR t1.boardID = 145
OR t1.boardID = 149
OR t1.boardID = 136
OR t1.boardID = 14
OR t1.boardID = 330
";
//Erdgeschoss
$queryOpenGames .= "
OR t1.boardID =69
OR t1.boardID =70
OR t1.boardID =71
OR t1.boardID = 152
OR t1.boardID = 151
OR t1.boardID = 153
";
//Erster Stock
$queryOpenGames .= "
OR t1.boardID = 73
OR t1.boardID = 74
OR t1.boardID = 75
OR t1.boardID = 76
OR t1.boardID = 77
OR t1.boardID = 154
OR t1.boardID = 157
OR t1.boardID = 161
OR t1.boardID = 162
OR t1.boardID = 163
OR t1.boardID = 130
OR t1.boardID = 320
OR t1.boardID = 324
OR t1.boardID = 329
";
//Zweiter Stock
$queryOpenGames .= "
OR t1.boardID = 81
OR t1.boardID = 78
OR t1.boardID = 165
OR t1.boardID = 166
OR t1.boardID = 257
";
//Dritter Stock
$queryOpenGames .= "
OR t1.boardID = 83
OR t1.boardID = 84
OR t1.boardID = 85
OR t1.boardID = 169
OR t1.boardID = 170
OR t1.boardID = 171
";
//Vierter, fünfter und sechster Stock
$queryOpenGames .= "
OR t1.boardID = 87
OR t1.boardID = 88
OR t1.boardID = 89
OR t1.boardID = 98
OR t1.boardID = 99
OR t1.boardID = 100
OR t1.boardID = 101
OR t1.boardID = 94
OR t1.boardID = 90
OR t1.boardID = 93
OR t1.boardID =96
OR t1.boardID =97
OR t1.boardID =98
OR t1.boardID = 173
OR t1.boardID = 174
OR t1.boardID = 175
OR t1.boardID = 176
OR t1.boardID = 177
OR t1.boardID = 178
OR t1.boardID = 180
OR t1.boardID = 181
OR t1.boardID = 182
OR t1.boardID = 92
OR t1.boardID = 256
";
//Länderein & Quidditchfeld
$queryOpenGames .= "
OR t1.boardID = 64
OR t1.boardID = 65
OR t1.boardID = 66
OR t1.boardID = 67
OR t1.boardID = 106
OR t1.boardID = 183
OR t1.boardID = 184
OR t1.boardID = 185
OR t1.boardID = 186
OR t1.boardID = 187
";
//Hogsmeade
$queryOpenGames .= "
OR t1.boardID = 9
OR t1.boardID = 167
OR t1.boardID = 229
OR ";
//London
$queryOpenGames .= "
t1.boardID =10
OR t1.boardID =11
OR t1.boardID =12
OR t1.boardID =107
OR t1.boardID =116
OR t1.boardID =124
OR t1.boardID =156
OR t1.boardID =158
OR t1.boardID = 159
OR t1.boardID = 160
OR t1.boardID = 311
";
//weitere Schauplätze
$queryOpenGames .= "
OR t1.boardID =13
OR t1.boardID =24
OR t1.boardID =28
OR t1.boardID =26
OR t1.boardID =25
OR t1.boardID =27
OR t1.boardID =105
OR t1.boardID =138
OR t1.boardID =140
OR t1.boardID =142
OR t1.boardID =143
OR t1.boardID =144
OR t1.boardID =146
OR t1.boardID =147
OR t1.boardID =202
OR t1.boardID =203
OR t1.boardID =204
OR t1.boardID =205
OR t1.boardID =206
OR t1.boardID =207
OR t1.boardID =208
OR t1.boardID =209
OR t1.boardID =210
OR t1.boardID =211
OR t1.boardID =212
OR t1.boardID =213
OR t1.boardID =214
OR t1.boardID =215
OR t1.boardID =216
OR t1.boardID =217
OR t1.boardID =218
OR t1.boardID =219
OR t1.boardID =220
OR t1.boardID =221
OR t1.boardID =222
OR t1.boardID =223
OR t1.boardID =224
OR t1.boardID =225
OR t1.boardID =226
OR t1.boardID =227
OR t1.boardID =228
OR t1.boardID = 231
OR t1.boardID = 232
OR t1.boardID = 243
OR t1.boardID = 252
OR t1.boardID = 264
OR t1.boardID = 308
OR t1.boardID = 309
";
return $queryOpenGames;
}
public function __construct(){
$this->currentUser = WCF::getUser();
}
public function hasUserLeaved($threadid, $userid) {
$hasLeaved = false;
$queryLeave = "SELECT
t1.message AS postcontent
FROM
wbb" . WCF_N . "_post AS t1
WHERE
t1.threadID = " . $threadid . " AND
t1.userid = " . $userid . "
ORDER BY
t1.time DESC LIMIT 1";
$statementB = WCF::getDB()->prepareStatement($queryLeave);
$statementB->execute();
$rs3 = $statementB->fetchAll();
$statementB->closeCursor();
if (count($rs3) > 0) {
foreach ($rs3 as $message) {
$pos = strpos($message['postcontent'], "[verlassen]");
if ($pos === false) {
;
} else {
$hasLeaved = true;
}
}
}
return $hasLeaved;
}
private function getNextPoster($threadid, $lastPosterID){
$allPoster = "";
$posterArray = array();
$posters = "SELECT MAX( wbb".WCF_N."_post.time ) AS timefield, userid AS posterId
FROM wbb".WCF_N."_post
WHERE threadID =" . $threadid . "
GROUP BY userid
ORDER BY timefield DESC ";
$statement = WCF::getDB()->prepareStatement($posters);
$statement->execute();
$rs2 = $statement->fetchAll();
$statement->closeCursor();
foreach($rs2 AS $posterID){
if($posterID['posterId'] != "" && $this->hasUserLeaved($threadid, $posterID['posterId']) == false){
$posterArray[] = $posterID['posterId'];
$allPoster .= $posterID['posterId'] . ", ";
}
}
$keyLastPoster = array_search($lastPosterID, $posterArray);
$keyNextPoster = $keyLastPoster - 1;
if($keyNextPoster < 0){
$keyNextPoster = count($posterArray) - 1;
}
if(count($posterArray) > 0){
$idNextPoster = $posterArray[$keyNextPoster];
}else{
$idNextPoster = 0;
}
return $idNextPoster;
}
/**
*
* @param type $threadList
* @return array of Threads were User posted
*/
private function areYouPlaying($threadList){
$searchResult = array();
$anz = count($threadList);
if($anz > 0){
for ($x = 0; $x < $anz; $x++) {
//echo $threadList[$x]['threadID'] . " -- " . $threadList[$x]['topic'] . " <br />";
$queryLookForMyself = "SELECT COUNT(t1.userid) AS posts
FROM wbb" . WCF_N . "_post AS t1
WHERE t1.threadID = " . $threadList[$x]['threadID'] . " AND t1.userID = " . $this->currentUser->getObjectID() . " ";
$statement = WCF::getDB()->prepareStatement($queryLookForMyself, 1);
$statement->execute();
$result = $statement->fetchArray();
$statement->closeCursor();
if ($result['posts'] > 0) {
$searchResult[] = $threadList[$x];
}
}
}
return $searchResult;
}
private function callThreads(){
$queryOpenGames = "SELECT
t1.threadID AS threadID,
t1.topic AS topic,
t1.lastPosterID AS lastPosterID
FROM wbb".WCF_N."_thread AS t1
WHERE (
".$this->getBoardIdsAsString()."
)
AND t1.isClosed = 0
ORDER BY t1.topic ASC ";
$statementA = WCF::getDB()->prepareStatement($queryOpenGames);
$statementA->execute();
$result = $statementA->fetchAll();
$statementA->closeCursor();
return $result;
}
public function execute(){
$StringNFO = "";
$ThreadObjects = array();
$threadsArray = $this->areYouPlaying( $this->callThreads() );
$anz = count($threadsArray);
for($x = 0; $x < $anz; $x++){
if($this->getNextPoster($threadsArray[$x]['threadID'], $threadsArray[$x]['lastPosterID']) == $this->currentUser->getObjectID()){
$thread = new Thread($threadsArray[$x]['threadID']);
$ThreadObjects[] = $thread;
}
}
if(count($ThreadObjects) > 0){
echo "<div>Du bist im Spiel dran:</div>";
foreach($ThreadObjects AS $thread){
echo "<div><a href='".$thread->getLink()."?action=firstNew' target='_blank'>".$thread->getTitle()."</a></div>";
}
}
else{
echo "<div><i>Du hast keine offenen Plays</i></div>";
}
}
}
$posting = new NextPosting();
$posting->execute();
?>
Display More