コード例 #1
0
 public function checkFriends()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("user > checkFriends > start userId : " . $this->userId);
     $user = GameUsers::getGameUserById($this->userId);
     if (!empty($user)) {
         $userId = $user->userId;
         if (!empty($userId)) {
             $fbFriends = FriendUtils::getUserFacebookFriends($user);
             if (!empty($fbFriends) && sizeof($fbFriends) > 0) {
                 $fbFriendIds = null;
                 foreach ($fbFriends as $fbFriend) {
                     if (!empty($fbFriend) && isset($fbFriend["id"])) {
                         if (empty($fbFriendIds)) {
                             $fbFriendIds = $fbFriend["id"];
                         } else {
                             $fbFriendIds = $fbFriendIds . "," . $fbFriend["id"];
                         }
                     }
                 }
                 $fbFriendUserIds = FriendUtils::getUserIdsFromFacebookIds($fbFriendIds);
                 if (!empty($fbFriendUserIds)) {
                     $friendIds = FriendUtils::getUserFriendIds($userId);
                     foreach ($fbFriendUserIds as $fbFriendId) {
                         if (!empty($fbFriendId)) {
                             $add = false;
                             if (!empty($friendIds) && sizeof($friendIds) > 0) {
                                 if (!in_array($fbFriendId, $friendIds)) {
                                     $add = true;
                                 }
                             } else {
                                 $add = true;
                             }
                             if ($add) {
                                 $friend = new GameUserFriends();
                                 $friend->setUserId($this->userId);
                                 $friend->setType("facebook");
                                 $friend->setFriendId($fbFriendId);
                                 try {
                                     $friend->insertIntoDatabase(DBUtils::getConnection());
                                 } catch (Exception $exc) {
                                     error_log("userclass>checkFriends userId : " . $this->userId . " friend Id : " . $fbFriendId . " Error : " . $exc->getMessage() . " Trace :" . $exc->getTraceAsString());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $log->logInfo("user > checkFriends > end userId : " . $this->userId);
 }
コード例 #2
0
 /**
  * get single GameUserFriends instance from a DOMElement
  *
  * @param DOMElement $node
  * @return GameUserFriends
  */
 public static function fromDOMElement(DOMElement $node)
 {
     $o = new GameUserFriends();
     $o->assignByHash(self::domNodeToHash($node, self::$FIELD_NAMES, self::$DEFAULT_VALUES, self::$FIELD_TYPES));
     $o->notifyPristine();
     return $o;
 }