1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Smallworld; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* You may not change or alter any portion of this comment or credits |
7
|
|
|
* of supporting developers from this source code or any supporting source code |
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
use XoopsModules\Smallworld\Constants; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* SmallWorld |
19
|
|
|
* |
20
|
|
|
* @copyright The XOOPS Project (https://xoops.org) |
21
|
|
|
* @copyright 2011 Culex |
22
|
|
|
* @license GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/) |
23
|
|
|
* @package SmallWorld |
24
|
|
|
* @since 1.0 |
25
|
|
|
* @author Michael Albertsen (http://culex.dk) <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class Friends |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Show friends of ID |
31
|
|
|
* |
32
|
|
|
* @deprecated - DO NOT USE |
33
|
|
|
* @todo unfinished - needs completion |
34
|
|
|
* |
35
|
|
|
* @param int $id |
36
|
|
|
* @return string |
|
|
|
|
37
|
|
|
*/ |
38
|
|
|
public function showFriends($id) |
39
|
|
|
{ |
40
|
|
|
if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
41
|
|
|
$user = new \XoopsUser($id); |
42
|
|
|
$myName = $user->getUnameFromId((int)$id); // My name |
43
|
|
|
$swDB = new SwDatabase(); |
44
|
|
|
$check = new User(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return [(int)$id => $myName]; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get friends array of ID |
52
|
|
|
* |
53
|
|
|
* must be registered user to call this function |
54
|
|
|
* |
55
|
|
|
* @param int $id |
56
|
|
|
* @param string $action |
57
|
|
|
* @return array - empty if nothing found or not authorized |
58
|
|
|
*/ |
59
|
|
|
public function getFriends($id, $action) |
60
|
|
|
{ |
61
|
|
|
$id = (int)$id; |
62
|
|
|
$data = []; |
63
|
|
|
if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
64
|
|
|
switch ($action) { |
65
|
|
View Code Duplication |
case 'pending': |
66
|
|
|
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . $id . "' AND status = " . Constants::FRIEND_STATUS_PENDING; |
67
|
|
|
break; |
68
|
|
View Code Duplication |
case 'friends': |
69
|
|
|
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . $id . "' AND status = " . Constants::FRIEND_STATUS_APPROVED; |
70
|
|
|
break; |
71
|
|
View Code Duplication |
case 'following': |
72
|
|
|
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_followers') . " WHERE me = '" . $id . "'"; |
73
|
|
|
break; |
74
|
|
View Code Duplication |
case 'followingme': |
75
|
|
|
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_followers') . " WHERE you = '" . $id . "'"; |
76
|
|
|
break; |
77
|
|
|
default: |
78
|
|
|
return $data; |
79
|
|
|
} |
80
|
|
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
81
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
82
|
|
|
$data[] = $row; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $data; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.