Changeset 323

Show
Ignore:
Timestamp:
03/12/08 22:32:09 (5 years ago)
Author:
d0nut
Message:

buddyloo can do caching

Location:
buddyloo/files/lib/system
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • buddyloo/files/lib/system/event/listener/BuddylooAbstractPageListener.class.php

    r217 r323  
    1919 
    2020                self::$check = true; 
     21                 
     22                WCF::getCache()->addResource('buddyloo.whitelist',  
     23                        WCF_DIR.'cache/cache.buddyloo.whitelist.php', 
     24                        WCF_DIR.'lib/system/cache/CacheBuilderBuddylooWhiteList.class.php'); 
    2125 
    22                 $sql = "SELECT  COUNT(*) as c 
    23                         FROM    wcf".WCF_N."_buddyloo 
    24                         WHERE   whiteUserID = ".WCF::getUser()->userID; 
    25                 $row = WCF::getDB()->getFirstRow($sql); 
     26                $cache = WCF::getCache()->get('buddyloo.whitelist'); 
    2627 
    27                 if($row['c'] > 0) { 
    28                         $text = $row['c'] > 1 ?  
    29                                 WCF::getLanguage()->get('wcf.buddyloo.awaitingconfirmations', array('$count'=>$row['c'])) :  
     28                if(isset($cache[WCF::getUser()->userID])) { 
     29                        $text = $cache[WCF::getUser()->userID] > 1 ?  
     30                                WCF::getLanguage()->get('wcf.buddyloo.awaitingconfirmations', array('$count'=>$cache[WCF::getUser()->userID])) :  
    3031                                WCF::getLanguage()->get('wcf.buddyloo.awaitingconfirmation'); 
    3132 
  • buddyloo/files/lib/system/event/listener/BuddylooRegisterFormListener.class.php

    r319 r323  
    9090                                WHERE                   email = '".escapeString($this->eventObj->user->email)."'; "; 
    9191                        WCF::getDB()->sendQuery($sql); 
     92                         
     93                        $this->updateCache(); 
    9294                } 
     95        } 
     96         
     97                 
     98 
     99        /** 
     100         * updates cache 
     101         */ 
     102        protected function updateCache() { 
     103                // clear cache 
     104                WCF::getCache()->clear(WBB_DIR.'cache', 'cache.buddyloo.*.php'); 
     105 
     106                // add resource 
     107                WCF::getCache()->addResource('buddyloo.whitelist',  
     108                        WCF_DIR.'cache/cache.buddyloo.whitelist.php', 
     109                        WCF_DIR.'lib/system/cache/CacheBuilderBuddylooWhiteList.class.php'); 
    93110        } 
    94111} 
  • buddyloo/files/lib/system/event/listener/BuddylooWhiteListEditFormListener.class.php

    r319 r323  
    7777         
    7878        /** 
    79          * validation method 
    80          */ 
    81         protected function myValidate($id) { 
    82                 $user = new User(intval($id)); 
    83                 $u = 0; 
    84                 if (isset($_GET['u'])) $u = intval($_GET['u']); 
    85                 if ($u != WCF::getUser()->userID || !$user->userID) { 
    86                         throw new IllegalLinkException(); 
    87                 } 
    88                 return $user; 
    89         } 
    90          
    91         /** 
    9279         * we want a friendship accepted from both sides.  
    9380         *      if this user cancels his friendship, the other will do same 
     
    11097                                                AND ".$this->eventObj->listType."UserID = ".WCF::getUser()->userID; 
    11198                        WCF::getDB()->sendQuery($sql); 
     99                        $this->updateCache(); 
    112100                         
    113101                        // show success message 
     
    125113                                AND             ".$this->eventObj->listType."UserID = ".WCF::getUser()->userID; 
    126114                        WCF::getDB()->sendQuery($sql); 
     115                        $this->updateCache(); 
    127116                         
    128117                        // show success message 
     
    137126                                                AND ".$this->eventObj->listType."UserID = ".$user->userID; 
    138127                        WCF::getDB()->sendQuery($sql); 
     128                        $this->updateCache(); 
    139129                         
    140130                        // show success message 
     
    175165                        VALUES                  ".$inserts; 
    176166                WCF::getDB()->sendQuery($sql); 
     167                $this->updateCache(); 
    177168                 
    178169                $this->sendNotification(); 
     
    180171                // reset session 
    181172                Session::resetSessions(WCF::getUser()->userID, true, false); 
    182         }        
     173        } 
     174         
     175        /** 
     176         * validation method 
     177         */ 
     178        protected function myValidate($id) { 
     179                $user = new User(intval($id)); 
     180                $u = 0; 
     181                if (isset($_GET['u'])) $u = intval($_GET['u']); 
     182                if ($u != WCF::getUser()->userID || !$user->userID) { 
     183                        throw new IllegalLinkException(); 
     184                } 
     185                return $user; 
     186        } 
    183187         
    184188        /** 
     
    271275                // enable user language 
    272276                WCF::getLanguage()->setLocale(); 
     277        }        
     278 
     279        /** 
     280         * updates cache 
     281         */ 
     282        protected function updateCache() { 
     283                // clear cache 
     284                WCF::getCache()->clear(WBB_DIR.'cache', 'cache.buddyloo.*.php'); 
     285 
     286                // add resource 
     287                WCF::getCache()->addResource('buddyloo.whitelist',  
     288                        WCF_DIR.'cache/cache.buddyloo.whitelist.php', 
     289                        WCF_DIR.'lib/system/cache/CacheBuilderBuddylooWhiteList.class.php'); 
    273290        } 
    274291}