@ 2014-09-14T21:00:30Z <?php
require_once(WCF_DIR.'lib/system/event/EventListener.class.php');
/**
* Loads thank'o'mat data for the Threadpage.
*
* @author Christian "Plunts" Grubert
* @copyright 2010 Duetschi Kreativagentur
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package de.wbb3mods.wbb.thankbot
*/
class ThreadPageThankBotListener implements EventListener {
/**
* @see EventListener::execute()
* @param ThreadPage $eventObj
*/
public function execute($eventObj, $className, $eventName) {
if (empty($eventObj->postList->postIDs)) return;
$thankdata = array();
$thankedFor = array();
$sql = "SELECT *
FROM wbb".WBB_N."_thank_guests
WHERE postID IN (".$eventObj->postList->postIDs.")";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if (isset($thankdata[$row['postID']]['guests']))
$thankdata[$row['postID']]['guests']++;
else
$thankdata[$row['postID']]['guests'] = 1;
}
//$canUseOnlineMarking = version_compare(PACKAGE_VERSION, '3.1.0') >= 0;
$sql = "SELECT thank_user.*, user.username" . ($canUseOnlineMarking ? ", g.userOnlineMarking usernameStyle" : "") . "
FROM wbb" . WBB_N . "_thank_user thank_user
LEFT JOIN wcf" . WCF_N . "_user user USING (userID)
" . ($canUseOnlineMarking ? "LEFT JOIN wcf" . WCF_N . "_group g ON (user.userOnlineGroupID = g.groupID)" : "") . "
WHERE thank_user.postID IN (" . $eventObj->postList->postIDs . ")
ORDER BY " . THANKS_SORT;
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if ($row['username'] == null) {
if (isset($thankdata[$row['postID']]['guests']))
$thankdata[$row['postID']]['guests']++;
else
$thankdata[$row['postID']]['guests'] = 1;
} else {
if ($canUseOnlineMarking && !empty($row['usernameStyle']) && $row['usernameStyle'] != '%s') {
$styledUsername = sprintf($row['usernameStyle'], StringUtil::encodeHTML($row['username']));
} else {
$styledUsername = StringUtil::encodeHTML($row['username']);
}
$thankdata[$row['postID']]['users'][$row['userID']] = array('userID' => $row['userID'],
'username' => $row['username'],
'styledUsername' => $styledUsername,
'time' => $row['time']);
}
}
if ($eventObj->board->getPermission('canThank') && !WCF::getSession()->spiderID) {
$sql = "SELECT
post.postID, post.userID,
GROUP_CONCAT(DISTINCT thank_user.userID) AS userIDs,
GROUP_CONCAT(DISTINCT thank_guests.iphash) AS iphashes
FROM wbb".WBB_N."_post post
LEFT JOIN wbb".WBB_N."_thank_user thank_user ON (post.postID=thank_user.postID)
LEFT JOIN wbb".WBB_N."_thank_guests thank_guests ON (post.postID=thank_guests.postID AND thank_guests.time > ".(TIME_NOW-86400).")
WHERE post.postID IN (".$eventObj->postList->postIDs.") AND post.hasThank = 1
GROUP BY post.postID
ORDER BY post.time";
$result = WCF::getDB()->sendQuery($sql);
$additionalSmallButtons = WCF::getTPL()->get('additionalSmallButtons');
$showLargeThankLink = array();
while ($row = WCF::getDB()->fetchArray($result)) {
$row['userIDs'] = explode(',', $row['userIDs']);
if ($row['userIDs'][0] == '') $row['userIDs'] = array();
$row['iphashes'] = explode(',', $row['iphashes']);
if ($row['iphashes'][0] == '') $row['iphashes'] = array();
if ($row['userID'] != WCF::getUser()->userID) { // @todo autor = gast und user = gast sollte auch gehen
$hasThanked = (in_array(WCF::getUser()->userID, $row['userIDs']) || in_array(sha1(UserUtil::getIpAddress()), $row['iphashes']));
WCF::getTPL()->assign(array(
'postID' => $row['postID'],
'hasThanked' => $hasThanked
));
if (THANKS_BIGBUTTON && $row['postID'] == $eventObj->thread->firstPostID) {
WCF::getTPL()->append('additionalLargeButtons', WCF::getTPL()->fetch('threadThankButton'));
}
elseif (THANKS_LINKPOS == 1) {
$thankedFor[$row['postID']] = $hasThanked;
}
else {
if (!isset($additionalSmallButtons[$row['postID']]))
$additionalSmallButtons[$row['postID']] = '';
$additionalSmallButtons[$row['postID']] .= WCF::getTPL()->fetch('postThankButton');
}
}
}
WCF::getTPL()->assign('additionalSmallButtons', $additionalSmallButtons);
}
if (THANKS_SHOWCOUNT) {
$additionalSidebarUserCredits = WCF::getTPL()->get('additionalSidebarUserCredits');
foreach ($eventObj->sidebarFactory->messageSidebars AS $sidebar) {
if (!isset($additionalSidebarUserCredits[$sidebar->getMessageID()]))
$additionalSidebarUserCredits[$sidebar->getMessageID()] = '';
WCF::getTPL()->assign(array(
'thanks_got' => $sidebar->getUser()->thanks_got,
'thanks_given' => $sidebar->getUser()->thanks_given,
'userID' => $sidebar->getUser()->userID,
'postID' => $sidebar->getMessageID()
));
$additionalSidebarUserCredits[$sidebar->getMessageID()] .= WCF::getTPL()->fetch('postThankCredits');
}
WCF::getTPL()->assign('additionalSidebarUserCredits', $additionalSidebarUserCredits);
}
$additionalMessageFooter = WCF::getTPL()->get('additionalMessageFooter');
foreach ($eventObj->postList->posts AS $key=>$post) {
if ($post->hasThank) {
WCF::getTPL()->assign(array(
'postID' => $post->postID,
'postThanks' => isset($thankdata[$post->postID]) ? $thankdata[$post->postID] : null,
'isAuthor' => $post->userID == WCF::getUser()->userID && $post->userID != 0,
'hasThanked' => isset($thankedFor[$post->postID]) ? $thankedFor[$post->postID] : false
));
$template = WCF::getTPL()->fetch('postThankStats');
if (!isset($additionalMessageFooter[$post->postID])) {
$additionalMessageFooter[$post->postID] = $template;
} else {
$additionalMessageFooter[$post->postID] .= $template;
}
}
}
WCF::getTPL()->assign('additionalMessageFooter', $additionalMessageFooter);
WCF::getTPL()->append('specialStyles', "\n".'<script src="' . RELATIVE_WBB_DIR . 'js/ThankOmat.class.js" type="text/javascript"></script>'."\n");
}
private function isAuthor(Post $post) {
if (WCF::getUser()->userID == 0) {
return (UserUtil::getIpAddress() == $post->ipAddress && $post->userID == 0 && $post->time > TIME_NOW-86400);
} else {
return (WCF::getUser()->userID == $post->userID);
}
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught Error: Undefined constant "WCF_DIR" in /in/bAK0j:2
Stack trace:
#0 {main}
thrown in /in/bAK0j on line 2
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
39.25 ms | 401 KiB | 8 Q