root/profile.lastvisitors/files/lib/system/event/listener/ProfilelastVisitorsListener.class.php @ 382

Revision 382, 3.1 kB (checked in by MDMAN, 5 years ago)

bugfix in removing the tab menu by profile lastvisitors

RevLine 
[278]1<?php
2require_once(WCF_DIR.'lib/system/event/EventListener.class.php');
3
4class ProfilelastVisitorsListener implements EventListener {
5   
6    public $visitorCount = 0;
7    public $visitors = array();
8    public $profileID = 0;
9
10    /**
11    * @see EventListener::execute()
12    */
13    public function execute($eventObj, $className, $eventName){
14
15        //Mit dieser IF Abfrage wird geschaut, ob der Visitor ein GAST oder ob er INVISIBLE ist. Sollte eines zustreffen, wird die Eingabe in die Datenbank nicht ausgefᅵhrt
16        if (WCF::getUser()->userID != 0 && $eventObj->userID != WCF::getUser()->userID && WCF::getUser()->getPermission('admin.profile.lastvisitor.isinvisible') != 1){
17            $sql = "INSERT INTO wcf".WCF_N."_profile_lastvisitors (profileID, userID, username, time)
18            VALUES ('".$eventObj->userID."', '".WCF::getUser()->userID."', '".WCF::getUser()->username."', '".TIME_NOW."')
19            ON DUPLICATE KEY
20            UPDATE time = VALUES(time)";
21            WCF::getDB()->sendQuery($sql);
22        }
23        // Ab hier wird die Anzeige gemacht. Es werden keine Daten mehr in die Datenbank eingespielt
24        // Hier werden die Daten der Besucher des angeschauten Profils gesammelt
25
26        $sql = "SELECT userID, username, time FROM wcf".WCF_N."_profile_lastvisitors WHERE profileID = '".$eventObj->userID."' ORDER BY time DESC LIMIT 0,".SHOW_LASTVISITOR_AMOUNT."";
27        $result = WCF::getDB()->sendQuery($sql);
28
29        while ($row = WCF::getDB()->fetchArray($result)) {
30                $this->visitors[] = $row;
31        }
32        if(count($this->visitors) > 0) $this->visitorCount = count($this->visitors);
33
34        //Hier werden die Variablen in den Template-Variabeln registriert
35
36        WCF::getTPL()->assign(array(
37                'visitors' => $this->visitors,
38                'visitorCount' => $this->visitorCount,
39                                'profileID' => $eventObj->userID,
40                ));
[282]41        //Datenbank wird hier aufgeraeumt... Hier werden alle Visitors geloescht, die nicht mehr angezeigt werden koennen (Visitors groesser 100)
[278]42        $sql = "SELECT userID FROM wcf".WCF_N."_profile_lastvisitors WHERE profileID = '".$eventObj->userID."' ORDER BY time DESC";
43        $result = WCF::getDB()->sendQuery($sql);
44        $skipCount = 0;
[382]45        $anz = 10;
46        if (SHOW_LASTVISITOR_MOREVISITOR == 1) $anz = 100;
[278]47        $deleteIDs = array();
48        while ($row = WCF::getDB()->fetchArray($result)){
[374]49            if($skipCount > $anz) $deleteIDs[] = $row['userID'];
[278]50            $skipCount++;
51        }
52        if(count($deleteIDs) > 0) {
53            $deleteIDString = implode(',', $deleteIDs);
54            $sql = "DELETE FROM wcf".WCF_N."_profile_lastvisitors WHERE userID IN (".$deleteIDString.") AND profileID = '".$eventObj->userID."'";
55            WCF::getDB()->sendQuery($sql);
56        }
57       
58        //Hier werden die Templates in die Platzhalter der userProfile.tpl geladen
[358]59        WCF::getTPL()->append('additionalBoxes5', WCF::getTPL()->fetch('profilelastVisitorSmall'));
60        WCF::getTPL()->append('additionalContents3', WCF::getTPL()->fetch('profilelastVisitor'));
[278]61       
62    }
63}
64?>
Note: See TracBrowser for help on using the browser.