1: <?php
2: /**
3: * @copyright Copyright (c) 2009-2012 NADEO (http://www.nadeo.com)
4: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
5: * @version $Revision: 7307 $:
6: * @author $Author: gwendal $:
7: * @date $Date: 2012-06-01 11:05:31 +0200 (ven., 01 juin 2012) $:
8: */
9:
10: namespace Maniaplanet\WebServices;
11:
12: class TrustCircles extends HTTPClient
13: {
14: /**
15: * Get how many times a player has been blacklisted and whitelisted within a circle
16: * @param string $circle
17: * @param string $player
18: * @return object Numbers of blacklistings and whitelistings
19: * @throws Exception
20: */
21: function getKarma($circle, $player)
22: {
23: if(!$circle)
24: {
25: throw new Exception('Invalid circle');
26: }
27: if(!$player)
28: {
29: throw new Exception('Invalid player');
30: }
31:
32: return $this->execute('GET', '/trust/%s/karma/%s/', array($circle, $player));
33: }
34:
35: /**
36: * Get your own blacklist or a shared one
37: * @param string|null $circle A circle name or null to get your own
38: * @return string[]|object[] An array of strings for your own blacklist or an array of objects with 2 fields:
39: * login of the player, number of blacklistings
40: */
41: function getBlackList($circle = null)
42: {
43: if($circle)
44: {
45: return $this->execute('GET', '/trust/%s/black/', array($circle));
46: }
47: else
48: {
49: return $this->execute('GET', '/trust/black/');
50: }
51: }
52:
53: /**
54: * Get your own whitelist or a shared one
55: * @param string|null $circle A circle name or null to get your own
56: * @return string[]|object[] An array of strings for your own whitelist or an array of objects with 2 fields:
57: * login of the player, number of whitelistings
58: */
59: function getWhiteList($circle = null)
60: {
61: if($circle)
62: {
63: return $this->execute('GET', '/trust/%s/white/', array($circle));
64: }
65: else
66: {
67: return $this->execute('GET', '/trust/white/');
68: }
69: }
70:
71: /**
72: * Blacklist a player
73: * @param string $player
74: * @throws Exception
75: */
76: function blackList($player)
77: {
78: if(!$player)
79: {
80: throw new Exception('Invalid player');
81: }
82:
83: return $this->execute('POST', '/trust/black/', array($player));
84: }
85:
86: /**
87: * Whitelist a player
88: * @param string $player
89: * @throws Exception
90: */
91: function whiteList($player)
92: {
93: if(!$player)
94: {
95: throw new Exception('Invalid player');
96: }
97:
98: return $this->execute('POST', '/trust/white/', array($player));
99: }
100:
101: /**
102: * Unblacklist a player
103: * @param string $player
104: * @throws Exception
105: */
106: function unBlackList($player)
107: {
108: if(!$player)
109: {
110: throw new Exception('Invalid player');
111: }
112:
113: return $this->execute('POST', '/trust/unblack/', array($player));
114: }
115:
116: /**
117: * Unwhitelist a player
118: * @param string $player
119: * @throws Exception
120: */
121: function unWhiteList($player)
122: {
123: if(!$player)
124: {
125: throw new Exception('Invalid player');
126: }
127:
128: return $this->execute('POST', '/trust/unwhite/', array($player));
129: }
130: }
131:
132: ?>
133: