Changeset 10257


Ignore:
Timestamp:
Apr 23, 2009, 8:39:20 AM (16 years ago)
Author:
Andrey Prikaznov
Message:
 
Location:
tags/6.1.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/6.1.5/inc/profiles.inc.php

    r10242 r10257  
    8787        $aMutualFriends = array(); 
    8888     
    89     $id = (int)$id; 
    90     $friend_list_query = "SELECT `Profiles`.* FROM `FriendList` 
    91                                  LEFT JOIN `Profiles` ON (`Profiles`.`ID` = `FriendList`.`Profile` AND `FriendList`.`ID` = '$id' OR `Profiles`.`ID` = `FriendList`.`ID` AND `FriendList`.`Profile` = '$id') 
    92                                  WHERE (`FriendList`.`Profile` = '$id' OR `FriendList`.`ID` = '$id') AND `FriendList`.`Check` = '1' ORDER BY `Profiles`.`Picture` DESC LIMIT 12"; 
     89    $iID = (int)$id; 
     90 
     91    $friend_list_query = " 
     92        SELECT p.* 
     93        FROM `Profiles` AS p 
     94        LEFT JOIN `FriendList` AS f1 ON (f1.`ID` = p.`ID` AND f1.`Profile` ='{$iID}' AND `f1`.`Check` = 1) 
     95        LEFT JOIN `FriendList` AS f2 ON (f2.`Profile` = p.`ID` AND f2.`ID` ='{$iID}' AND `f2`.`Check` = 1) 
     96        WHERE 1 
     97        AND (f1.`ID` IS NOT NULL OR f2.`ID` IS NOT NULL) 
     98        ORDER BY p.`Picture` DESC 
     99        LIMIT 12 
     100    "; 
     101 
     102    // $friend_list_query = "SELECT `Profiles`.* FROM `FriendList` 
     103                                 // LEFT JOIN `Profiles` ON (`Profiles`.`ID` = `FriendList`.`Profile` AND `FriendList`.`ID` = '$id' OR `Profiles`.`ID` = `FriendList`.`ID` AND `FriendList`.`Profile` = '$id') 
     104                                 // WHERE (`FriendList`.`Profile` = '$id' OR `FriendList`.`ID` = '$id') AND `FriendList`.`Check` = '1' ORDER BY `Profiles`.`Picture` DESC LIMIT 12"; 
    93105 
    94106    $friend_list_res = db_res("$friend_list_query"); 
     
    117129 
    118130    return $ret; 
     131} 
     132 
     133function getMyFriendsEx($iID, $sWhereParam = '', $sSortParam = '', $sqlLimit = '') { 
     134    $sJoin = $sOrderBy = ''; 
     135 
     136    switch($sSortParam) { 
     137        case 'activity' : 
     138            // DateLastLogin 
     139            $sOrderBy = 'ORDER BY p.`DateLastLogin`'; 
     140        break; 
     141        case 'activity_desc' : 
     142            // DateLastLogin 
     143            $sOrderBy = 'ORDER BY p.`DateLastLogin` DESC'; 
     144        break; 
     145        case 'last_nav' : 
     146            // DateLastNav 
     147            $sOrderBy = 'ORDER BY p.`DateLastNav`'; 
     148        break; 
     149        case 'last_nav_desc' : 
     150            // DateLastNav 
     151            $sOrderBy = 'ORDER BY p.`DateLastNav` DESC'; 
     152        break; 
     153        case 'date_reg' :    
     154            // DateReg 
     155            $sOrderBy = 'ORDER BY p.`DateReg`'; 
     156        break; 
     157        case 'date_reg_desc' :   
     158            // DateReg 
     159            $sOrderBy = 'ORDER BY p.`DateReg` DESC'; 
     160        break; 
     161        case 'image' :   
     162            // Picture 
     163            $sOrderBy = 'ORDER BY p.`Picture` DESC'; 
     164        break;   
     165        case 'rate' :    
     166            // `sys_profile_rating`.`pr_rating_sum 
     167            $sOrderBy = 'ORDER BY `sys_profile_rating`.`pr_rating_sum`'; 
     168            $sJoin = 'LEFT JOIN `sys_profile_rating` ON p.`ID` = `sys_profile_rating`.`pr_id`'; 
     169        break; 
     170        default : 
     171            // DateLastLogin 
     172            $sOrderBy = 'ORDER BY p.`DateLastLogin`'; 
     173        break;       
     174    } 
     175 
     176    $sLimit = ($sqlLimit == '') ? '' : /*"LIMIT 0, " .*/ $sqlLimit; 
     177 
     178    $sqlQuery = " 
     179        SELECT p.*, UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg' 
     180        FROM `Profiles` AS p 
     181        LEFT JOIN `FriendList` AS f1 ON (f1.`ID` = p.`ID` AND f1.`Profile` ='{$iID}' AND `f1`.`Check` = 1) 
     182        LEFT JOIN `FriendList` AS f2 ON (f2.`Profile` = p.`ID` AND f2.`ID` ='{$iID}' AND `f2`.`Check` = 1) 
     183        {$sJoin} 
     184        WHERE 1 
     185        AND (f1.`ID` IS NOT NULL OR f2.`ID` IS NOT NULL) 
     186        {$sWhereParam} 
     187        {$sOrderBy} 
     188        {$sLimit} 
     189    "; 
     190 
     191    $aFriends = array(); 
     192 
     193    $vProfiles = db_res($sqlQuery); 
     194    while ($aProfiles = mysql_fetch_assoc($vProfiles)) { 
     195        $aFriends[$aProfiles['ID']] = array($aProfiles['ID'], $aProfiles['TS_DateLastLogin'], $aProfiles['TS_DateReg'], $aProfiles['Rate'], $aProfiles['DateLastNav']); 
     196    } 
     197 
     198    return $aFriends; 
    119199} 
    120200 
     
    710790} 
    711791 
    712 function getFriendNumber ($iID) 
    713 { 
    714     $sqlQuery = "SELECT COUNT(*) FROM `FriendList` WHERE ( `ID`='$iID' OR `Profile`='$iID' ) AND `Check`='1'"; 
    715      
    716     return db_value($sqlQuery); 
     792/*function for inner using only  
     793    $ID - profile ID 
     794    $iFrStatus - friend status (1 - approved, 0 - wait) 
     795    $iOnline - filter for last nav moment (in minutes) 
     796    $sqlWhere - add sql Conditions, should beginning from AND 
     797*/ 
     798     /*get_user_friends_count*/ //($iID, $iFrStatus = 1, $iOnline = 0, $sqlWhere = '')  
     799function getFriendNumber($iID, $iFrStatus = 1, $iOnline = 0, $sqlWhere = '') { 
     800    $sqlAdd = ''; 
     801 
     802    if ($iOnline > 0)  
     803        $sqlAdd = " AND (p.`DateLastNav` > SUBDATE(NOW(), INTERVAL " . $iOnline . " MINUTE))"; 
     804     
     805    if (strlen($sqlWhere) > 0) 
     806        $sqlAdd .= $sqlWhere; 
     807 
     808    $sqlQuery = " 
     809        SELECT COUNT(p.`ID`) 
     810        FROM `Profiles` AS p 
     811        LEFT JOIN `FriendList` AS f1 ON (f1.`ID` = p.`ID` AND f1.`Profile` ='{$iID}' AND `f1`.`Check` = {$iFrStatus}) 
     812        LEFT JOIN `FriendList` AS f2 ON (f2.`Profile` = p.`ID` AND f2.`ID` ='{$iID}' AND `f2`.`Check` = {$iFrStatus}) 
     813        WHERE 1 
     814        AND (f1.`ID` IS NOT NULL OR f2.`ID` IS NOT NULL) 
     815        {$sqlAdd} 
     816    "; 
     817 
     818    return (int)db_value($sqlQuery); 
    717819} 
    718820 
  • TabularUnified tags/6.1.5/viewFriends.php

    r10242 r10257  
    5656    global $max_thumb_height; 
    5757 
    58     $id = (int)$id; 
    59     $friend_list_query = "SELECT `Profiles`.* FROM `FriendList` 
    60                                  LEFT JOIN `Profiles` ON (`Profiles`.`ID` = `FriendList`.`Profile` AND `FriendList`.`ID` = '$id' OR `Profiles`.`ID` = `FriendList`.`ID` AND `FriendList`.`Profile` = '$id') 
    61                                  WHERE (`FriendList`.`Profile` = '$id' OR `FriendList`.`ID` = '$id') AND `FriendList`.`Check` = '1' ORDER BY `Profiles`.`Picture` DESC"; 
     58    $iID = (int)$id; 
     59 
     60    $friend_list_query = " 
     61        SELECT p.* 
     62        FROM `Profiles` AS p 
     63        LEFT JOIN `FriendList` AS f1 ON (f1.`ID` = p.`ID` AND f1.`Profile` ='{$iID}' AND `f1`.`Check` = 1) 
     64        LEFT JOIN `FriendList` AS f2 ON (f2.`Profile` = p.`ID` AND f2.`ID` ='{$iID}' AND `f2`.`Check` = 1) 
     65        WHERE 1 
     66        AND (f1.`ID` IS NOT NULL OR f2.`ID` IS NOT NULL) 
     67        ORDER BY p.`Picture` DESC 
     68    "; 
    6269 
    6370    $friend_list_res = db_res("$friend_list_query"); 
Note: See TracChangeset for help on using the changeset viewer.
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub