| | 172 | } |
|---|
| | 173 | |
|---|
| | 174 | /** |
|---|
| | 175 | * Export all profile's friends; |
|---|
| | 176 | * |
|---|
| | 177 | * @param $iProfileId integer; |
|---|
| | 178 | * @return string - error message if needed; |
|---|
| | 179 | */ |
|---|
| | 180 | function _exportFriends($iProfileId) |
|---|
| | 181 | { |
|---|
| | 182 | $iProfileId = (int) $iProfileId; |
|---|
| | 183 | |
|---|
| | 184 | $sQuery = "SELECT * FROM `FriendList` WHERE `ID` = {$iProfileId} OR `Profile` = {$iProfileId}"; |
|---|
| | 185 | $rResult = mysql_query($sQuery, $this -> rOldDb); |
|---|
| | 186 | |
|---|
| | 187 | while( $aRow = mysql_fetch_assoc($rResult) ) |
|---|
| | 188 | { |
|---|
| | 189 | if( !$this -> isFriendExisting($aRow['ID'], $aRow['Profile'])) { |
|---|
| | 190 | // build query; |
|---|
| | 191 | $sQuery = |
|---|
| | 192 | " |
|---|
| | 193 | INSERT INTO |
|---|
| | 194 | `sys_friend_list` |
|---|
| | 195 | SET |
|---|
| | 196 | `ID` = '{$aRow['ID']}', |
|---|
| | 197 | `Profile` = '{$aRow['Profile']}', |
|---|
| | 198 | `Check` = '{$aRow['Check']}', |
|---|
| | 199 | `When` = NOW() |
|---|
| | 200 | "; |
|---|
| | 201 | |
|---|
| | 202 | $iResult = (int) $this -> oMigrationModule -> _oDb -> query($sQuery); |
|---|
| | 203 | if($iResult <= 0) { |
|---|
| | 204 | return 'Database error. Cannot insert friend list in the database.'; |
|---|
| | 205 | } |
|---|
| | 206 | } |
|---|
| | 207 | } |
|---|
| | 259 | |
|---|
| | 260 | /** |
|---|
| | 261 | * Check friends pair; |
|---|
| | 262 | * |
|---|
| | 263 | * @param $iProfileId integer |
|---|
| | 264 | * @param $iFriendId integer |
|---|
| | 265 | * @return boolean - true if already existing |
|---|
| | 266 | */ |
|---|
| | 267 | function isFriendExisting($iProfileId, $iFriendId) |
|---|
| | 268 | { |
|---|
| | 269 | $iProfileId = (int) $iProfileId; |
|---|
| | 270 | $iFriendId = (int) $iFriendId; |
|---|
| | 271 | |
|---|
| | 272 | $sQuery = |
|---|
| | 273 | " |
|---|
| | 274 | SELECT |
|---|
| | 275 | COUNT(*) |
|---|
| | 276 | FROM |
|---|
| | 277 | `sys_friend_list` |
|---|
| | 278 | WHERE |
|---|
| | 279 | ( |
|---|
| | 280 | (`ID` = {$iProfileId} AND `Profile` = {$iFriendId}) |
|---|
| | 281 | OR |
|---|
| | 282 | (`ID` = {$iFriendId} AND `Profile` = {$iProfileId}) |
|---|
| | 283 | ) |
|---|
| | 284 | AND |
|---|
| | 285 | `Check` = 1 |
|---|
| | 286 | "; |
|---|
| | 287 | |
|---|
| | 288 | return $this -> oMigrationModule -> _oDb -> getOne($sQuery) ? true : false; |
|---|
| | 289 | } |
|---|