| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | class BxDolXMLRPCFriends |
|---|
| 4 | { |
|---|
| 5 | function getFriends($sUser, $sPwd, $sNick, $sLang) |
|---|
| 6 | { |
|---|
| 7 | $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); |
|---|
| 8 | if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) |
|---|
| 9 | return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); |
|---|
| 10 | |
|---|
| 11 | BxDolXMLRPCUtil::setLanguage ($sLang); |
|---|
| 12 | |
|---|
| 13 | $sFriendsSQL = " |
|---|
| 14 | SELECT `p`.*, `f`.`ID` |
|---|
| 15 | FROM ( |
|---|
| 16 | SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '{$iIdProfile}' AND `Check` =1 |
|---|
| 17 | UNION |
|---|
| 18 | SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '{$iIdProfile}' AND `Check` =1 |
|---|
| 19 | ) AS `f` |
|---|
| 20 | INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID` |
|---|
| 21 | ORDER BY p.`Avatar` DESC |
|---|
| 22 | "; |
|---|
| 23 | $r = db_res($sFriendsSQL); |
|---|
| 24 | |
|---|
| 25 | /*$r = db_res ("SELECT `Profiles`.* FROM `sys_friend_list` |
|---|
| 26 | LEFT JOIN `Profiles` ON (`Profiles`.`ID` = `sys_friend_list`.`Profile` AND `sys_friend_list`.`ID` = '$iIdProfile' OR `Profiles`.`ID` = `sys_friend_list`.`ID` AND `sys_friend_list`.`Profile` = '$iIdProfile') |
|---|
| 27 | WHERE (`sys_friend_list`.`Profile` = '$iIdProfile' OR `sys_friend_list`.`ID` = '$iIdProfile') AND `sys_friend_list`.`Check` = '1' |
|---|
| 28 | ORDER BY `Profiles`.`Avatar` DESC");*/ |
|---|
| 29 | |
|---|
| 30 | $aProfiles = array (); |
|---|
| 31 | while ($aRow = mysql_fetch_array ($r)) |
|---|
| 32 | $aProfiles[] = new xmlrpcval(BxDolXMLRPCUtil::fillProfileArray($aRow, 'thumb'), 'struct'); |
|---|
| 33 | |
|---|
| 34 | return new xmlrpcval ($aProfiles, "array"); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | function getFriendRequests($sUser, $sPwd, $sLang) |
|---|
| 38 | { |
|---|
| 39 | if (!($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) |
|---|
| 40 | return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); |
|---|
| 41 | |
|---|
| 42 | BxDolXMLRPCUtil::setLanguage ($sLang); |
|---|
| 43 | |
|---|
| 44 | $r = db_res (" |
|---|
| 45 | SELECT `Profiles`.* FROM `sys_friend_list` |
|---|
| 46 | LEFT JOIN `Profiles` ON `Profiles`.`ID` = `sys_friend_list`.`ID` |
|---|
| 47 | WHERE `sys_friend_list`.`Profile` = $iId AND `Check` = 0 |
|---|
| 48 | ORDER BY `Profiles`.`NickName` ASC"); |
|---|
| 49 | |
|---|
| 50 | $aProfiles = array (); |
|---|
| 51 | while ($aRow = mysql_fetch_array ($r)) |
|---|
| 52 | $aProfiles[] = new xmlrpcval(BxDolXMLRPCUtil::fillProfileArray($aRow, 'thumb'), 'struct'); |
|---|
| 53 | |
|---|
| 54 | return new xmlrpcval ($aProfiles, "array"); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | function declineFriendRequest($sUser, $sPwd, $sNick) |
|---|
| 58 | { |
|---|
| 59 | $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); |
|---|
| 60 | if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) |
|---|
| 61 | return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); |
|---|
| 62 | |
|---|
| 63 | require_once( BX_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $GLOBALS['tmpl'] . '/scripts/BxTemplCommunicator.php'); |
|---|
| 64 | $aCommunicatorSettings = array ('member_id' => $iId); |
|---|
| 65 | $aMembersList = array ($iIdProfile); |
|---|
| 66 | $oCommunicator = &new BxTemplCommunicator('communicator_page', $aCommunicatorSettings); |
|---|
| 67 | $oCommunicator->execFunction('_deleteRequest', 'sys_friend_list', $aMembersList); |
|---|
| 68 | |
|---|
| 69 | return new xmlrpcval ('ok'); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | function acceptFriendRequest($sUser, $sPwd, $sNick) |
|---|
| 73 | { |
|---|
| 74 | $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); |
|---|
| 75 | if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) |
|---|
| 76 | return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); |
|---|
| 77 | |
|---|
| 78 | require_once( BX_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $GLOBALS['tmpl'] . '/scripts/BxTemplCommunicator.php'); |
|---|
| 79 | $aCommunicatorSettings = array ('member_id' => $iId); |
|---|
| 80 | $aMembersList = array ($iIdProfile); |
|---|
| 81 | $oCommunicator = &new BxTemplCommunicator('communicator_page', $aCommunicatorSettings); |
|---|
| 82 | $oCommunicator->execFunction('_acceptFriendInvite', 'sys_friend_list', $aMembersList); |
|---|
| 83 | |
|---|
| 84 | return new xmlrpcval ('ok'); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | function removeFriend($sUser, $sPwd, $sNick) |
|---|
| 88 | { |
|---|
| 89 | $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); |
|---|
| 90 | if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) |
|---|
| 91 | return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); |
|---|
| 92 | |
|---|
| 93 | require_once( BX_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $GLOBALS['tmpl'] . '/scripts/BxTemplCommunicator.php'); |
|---|
| 94 | $aCommunicatorSettings = array ('member_id' => $iId); |
|---|
| 95 | $aMembersList = array ($iIdProfile); |
|---|
| 96 | $oCommunicator = &new BxTemplCommunicator('communicator_page', $aCommunicatorSettings); |
|---|
| 97 | $oCommunicator->execFunction( '_deleteRequest', 'sys_friend_list', $aMembersList, array(1, 1)); |
|---|
| 98 | |
|---|
| 99 | return new xmlrpcval ('ok'); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | function addFriend($sUser, $sPwd, $sNick, $sLang) |
|---|
| 103 | { |
|---|
| 104 | $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick); |
|---|
| 105 | if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd))) |
|---|
| 106 | return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct")); |
|---|
| 107 | |
|---|
| 108 | BxDolXMLRPCUtil::setLanguage ($sLang); |
|---|
| 109 | |
|---|
| 110 | ob_start(); |
|---|
| 111 | $_GET['action'] = '1'; |
|---|
| 112 | require_once( BX_DIRECTORY_PATH_ROOT . 'list_pop.php' ); |
|---|
| 113 | ob_end_clean(); |
|---|
| 114 | |
|---|
| 115 | $sRet = PageListFriend ($iId, $iIdProfile); |
|---|
| 116 | |
|---|
| 117 | return new xmlrpcval (trim(strip_tags($sRet))); |
|---|
| 118 | } |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | ?> |
|---|