Changeset 1335

Show
Ignore:
Timestamp:
03/20/11 12:02:41 (2 years ago)
Author:
Torben Brodt
Message:

automatically add feeds for twitter system user

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • twitter/files/lib/system/cronjob/TwitterUpdateJob.class.php

    r1333 r1335  
    2222                        WHERE           ti.failcount < 5"; 
    2323                $result = WCF::getDB()->sendQuery($sql); 
     24                $i = 0; 
    2425                while ($row = WCF::getDB()->fetchArray($result)) { 
    2526                        $this->load($row); 
     27                        $i++; 
    2628                } 
     29 
     30                // try to active system user feeds 
     31                if($i == 0) { 
     32                        $user = $this->getSystemUser(); 
     33                        if($user) { 
     34                                $sql = "INSERT INTO 
     35                                                        wcf".WCF_N."_twitter_feed 
     36                                                        (accountID, action) 
     37                                        VALUES          (".intval($user['accountID']).", 'user_timeline'), 
     38                                                        (".intval($user['accountID']).", 'mentions') 
     39                                        ON DUPLICATE KEY UPDATE 
     40                                                        failcount = IF(failcount > 1, failcount - 1, 0)"; 
     41                                $result = WCF::getDB()->sendQuery($sql); 
     42                        } 
     43                } 
     44        } 
     45 
     46        protected function getSystemUser() { 
     47                $sql = "SELECT          * 
     48                        FROM            wcf".WCF_N."_twitter_account ta 
     49                        INNER JOIN      wcf".WCF_N."_user_to_twitter utt ON utt.accountID = ta.accountID 
     50                        WHERE           ta.screen_name = '".escapeString(TWITTER_USER)."'"; 
     51                return WCF::getDB()->getFirstRow($sql); 
    2752        } 
    2853