Cheetah
ChWsbXMLRPCFriends.php
Go to the documentation of this file.
1 <?php
2 
9 {
10  function getFriends($sUser, $sPwd, $sNick, $sLang)
11  {
13  if (!$iIdProfile || !($iId = ChWsbXMLRPCUtil::checkLogin ($sUser, $sPwd)))
14  return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));
15 
17 
18  $sFriendsSQL = "
19  SELECT `p`.*, `f`.`ID`
20  FROM (
21  SELECT `ID` AS `ID` FROM `sys_friend_list` WHERE `Profile` = '{$iIdProfile}' AND `Check` =1
22  UNION
23  SELECT `Profile` AS `ID` FROM `sys_friend_list` WHERE `ID` = '{$iIdProfile}' AND `Check` =1
24  ) AS `f`
25  INNER JOIN `Profiles` AS `p` ON `p`.`ID` = `f`.`ID`
26  ORDER BY p.`Avatar` DESC
27  ";
28  $r = db_res($sFriendsSQL);
29 
30  /*$r = db_res ("SELECT `Profiles`.* FROM `sys_friend_list`
31  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')
32  WHERE (`sys_friend_list`.`Profile` = '$iIdProfile' OR `sys_friend_list`.`ID` = '$iIdProfile') AND `sys_friend_list`.`Check` = '1'
33  ORDER BY `Profiles`.`Avatar` DESC");*/
34 
35  $aProfiles = array ();
36  while ($aRow = $r->fetch())
37  $aProfiles[] = new xmlrpcval(ChWsbXMLRPCUtil::fillProfileArray($aRow, 'thumb'), 'struct');
38 
39  return new xmlrpcval ($aProfiles, "array");
40  }
41 
42  function getFriendRequests($sUser, $sPwd, $sLang)
43  {
45  return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));
46 
48 
49  $r = db_res ("
50  SELECT `Profiles`.* FROM `sys_friend_list`
51  LEFT JOIN `Profiles` ON `Profiles`.`ID` = `sys_friend_list`.`ID`
52  WHERE `sys_friend_list`.`Profile` = $iId AND `Check` = 0
53  ORDER BY `Profiles`.`NickName` ASC");
54 
55  $aProfiles = array ();
56  while ($aRow = $r->fetch())
57  $aProfiles[] = new xmlrpcval(ChWsbXMLRPCUtil::fillProfileArray($aRow, 'thumb'), 'struct');
58 
59  return new xmlrpcval ($aProfiles, "array");
60  }
61 
63  {
65  if (!$iIdProfile || !($iId = ChWsbXMLRPCUtil::checkLogin ($sUser, $sPwd)))
66  return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));
67 
68  ch_import('ChTemplCommunicator');
69  $oCommunicator = new ChTemplCommunicator(array('member_id' => $iId));
70 
71  $aMembersList = array($iIdProfile);
72  $oCommunicator->execFunction('_deleteRequest', 'sys_friend_list', $aMembersList);
73 
74  return new xmlrpcval ('ok');
75  }
76 
78  {
80  if (!$iIdProfile || !($iId = ChWsbXMLRPCUtil::checkLogin ($sUser, $sPwd)))
81  return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));
82 
83  ch_import('ChTemplCommunicator');
84  $aCommunicatorSettings = array ('member_id' => $iId);
85  $aMembersList = array ($iIdProfile);
87  $oCommunicator->execFunction('_acceptFriendInvite', 'sys_friend_list', $aMembersList);
88 
89  return new xmlrpcval ('ok');
90  }
91 
93  {
95  if (!$iIdProfile || !($iId = ChWsbXMLRPCUtil::checkLogin ($sUser, $sPwd)))
96  return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));
97 
98  ch_import('ChTemplCommunicator');
99  $aCommunicatorSettings = array ('member_id' => $iId);
100  $aMembersList = array ($iIdProfile);
102  $oCommunicator->execFunction( '_deleteRequest', 'sys_friend_list', $aMembersList, array(1, 1));
103 
104  return new xmlrpcval ('ok');
105  }
106 
107  function addFriend($sUser, $sPwd, $sNick, $sLang)
108  {
110  if (!$iIdProfile || !($iId = ChWsbXMLRPCUtil::checkLogin ($sUser, $sPwd)))
111  return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));
112 
114 
115  ob_start();
116  $_GET['action'] = '1';
117  require_once( CH_DIRECTORY_PATH_ROOT . 'list_pop.php' );
118  ob_end_clean();
119 
120  $sRet = PageListFriend ($iId, $iIdProfile);
121 
122  return new xmlrpcval (trim(strip_tags($sRet)));
123  }
124 }
ChWsbXMLRPCFriends\addFriend
addFriend($sUser, $sPwd, $sNick, $sLang)
Definition: ChWsbXMLRPCFriends.php:107
$aMembersList
$aMembersList
Definition: communicator.php:22
ChWsbXMLRPCFriends
Definition: ChWsbXMLRPCFriends.php:9
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
xmlrpcval
Definition: xmlrpc.inc:2696
$oCommunicator
$oCommunicator
Definition: communicator.php:68
php
$iId
$iId
Definition: license.php:15
$sPwd
$sPwd
Definition: r.php:14
ChWsbXMLRPCUtil\getIdByNickname
static getIdByNickname($sUser)
Definition: ChWsbXMLRPCUtil.php:233
PageListFriend
PageListFriend($iProfileId, $iMemberId=0)
Definition: list_pop.php:321
$_GET
$_GET['debug']
Definition: index.php:67
ChWsbXMLRPCFriends\acceptFriendRequest
acceptFriendRequest($sUser, $sPwd, $sNick)
Definition: ChWsbXMLRPCFriends.php:77
ChWsbXMLRPCFriends\declineFriendRequest
declineFriendRequest($sUser, $sPwd, $sNick)
Definition: ChWsbXMLRPCFriends.php:62
ChTemplCommunicator
Definition: ChTemplCommunicator.php:11
ChWsbXMLRPCFriends\getFriends
getFriends($sUser, $sPwd, $sNick, $sLang)
Definition: ChWsbXMLRPCFriends.php:10
ChWsbXMLRPCFriends\getFriendRequests
getFriendRequests($sUser, $sPwd, $sLang)
Definition: ChWsbXMLRPCFriends.php:42
ChWsbXMLRPCUtil\setLanguage
static setLanguage($sLang)
Definition: ChWsbXMLRPCUtil.php:256
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
ChWsbXMLRPCUtil\fillProfileArray
static fillProfileArray($a, $sImage='icon', $iIdViewer=0)
Definition: ChWsbXMLRPCUtil.php:141
xmlrpcresp
Definition: xmlrpc.inc:1911
ChWsbXMLRPCUtil\checkLogin
static checkLogin($sUser, $sPwd)
Definition: ChWsbXMLRPCUtil.php:239
$aCommunicatorSettings
$aCommunicatorSettings
Definition: communicator.php:32
$sNick
$sNick
Definition: actions.inc.php:9
ChWsbXMLRPCFriends\removeFriend
removeFriend($sUser, $sPwd, $sNick)
Definition: ChWsbXMLRPCFriends.php:92
$sUser
$sUser
Definition: r.php:13