| 2195 | | /* ************************************************************* |
| 2196 | | * |
| 2197 | | * FRIEND FUNCTIONS |
| 2198 | | * |
| 2199 | | * *********************************************************** */ |
| 2200 | | |
| 2201 | | /** |
| 2202 | | * count followers |
| 2203 | | * |
| 2204 | | * @param int $user_id - get people following this user |
| 2205 | | * @return int |
| 2206 | | */ |
| 2207 | | public function countFollowers($user_id = 0) |
| 2208 | | { |
| 2209 | | $friends = new Friends(); |
| 2210 | | return $friends->countFriends($this, $user_id, 'follower'); |
| 2211 | | } |
| 2212 | | |
| 2213 | | |
| 2214 | | /** |
| 2215 | | * count following |
| 2216 | | * |
| 2217 | | * @param int $user_id - get people following this user |
| 2218 | | * @return int |
| 2219 | | */ |
| 2220 | | public function countFollowing($user_id = 0) |
| 2221 | | { |
| 2222 | | $friends = new Friends(); |
| 2223 | | return $friends->countFriends($this, $user_id, 'following'); |
| 2224 | | } |
| 2225 | | |
| 2226 | | |
| 2227 | | /** |
| 2228 | | * get followers |
| 2229 | | * |
| 2230 | | * @param int $user_id - get this user's followers |
| 2231 | | * @param string $return - return 'array' of users of prepared 'query' |
| 2232 | | * @return array|string |
| 2233 | | */ |
| 2234 | | public function getFollowers($user_id = 0, $return = 'array') |
| 2235 | | { |
| 2236 | | $friends = new Friends(); |
| 2237 | | return $friends->getFriends($this, $user_id, 'follower', $return); |
| 2238 | | } |
| 2239 | | |
| 2240 | | |
| 2241 | | /** |
| 2242 | | * get people this user is following |
| 2243 | | * |
| 2244 | | * @param int $user_id |
| 2245 | | * @param string $return - return 'array' of users of prepared 'query' |
| 2246 | | * @return array|string |
| 2247 | | */ |
| 2248 | | public function getFollowing($user_id = 0, $return = 'array') |
| 2249 | | { |
| 2250 | | $friends = new Friends(); |
| 2251 | | return $friends->getFriends($this, $user_id, 'following', $return); |
| 2252 | | } |
| 2253 | | |
| 2254 | | |
| 2255 | | /** |
| 2256 | | * Is current user being followed by user X? |
| 2257 | | * |
| 2258 | | * @param int $user_id - user X |
| 2259 | | * @return bool |
| 2260 | | */ |
| 2261 | | public function isFollower($user_id = 0) |
| 2262 | | { |
| 2263 | | $friends = new Friends(); |
| 2264 | | return $friends->checkFriends($this, $user_id, 'follower'); |
| 2265 | | } |
| 2266 | | |
| 2267 | | |
| 2268 | | /** |
| 2269 | | * Is current user following user X? |
| 2270 | | * |
| 2271 | | * @param int $user_id - user X |
| 2272 | | * @return bool |
| 2273 | | */ |
| 2274 | | public function isFollowing($user_id = 0) |
| 2275 | | { |
| 2276 | | $friends = new Friends(); |
| 2277 | | return $friends->checkFriends($this, $user_id, 'following'); |
| 2278 | | } |
| 2279 | | |
| 2280 | | |
| 2281 | | /** |
| 2282 | | * Follow / become a fan of user X |
| 2283 | | * |
| 2284 | | * @param int $follow - user to follow |
| 2285 | | * @return bool |
| 2286 | | */ |
| 2287 | | public function follow($user_id = 0) |
| 2288 | | { |
| 2289 | | $friends = new Friends(); |
| 2290 | | return $friends->updateFriends($this, $user_id, 'follow'); |
| 2291 | | } |
| 2292 | | |
| 2293 | | |
| 2294 | | /** |
| 2295 | | * Unfollow / stop being a fan of user X |
| 2296 | | * |
| 2297 | | * @param int $unfollow - user to stop following |
| 2298 | | * @return bool |
| 2299 | | */ |
| 2300 | | public function unfollow($user_id = 0) |
| 2301 | | { |
| 2302 | | $friends = new Friends(); |
| 2303 | | return $friends->updateFriends($this, $user_id, 'unfollow'); |
| 2304 | | } |
| 2305 | | |
| 2306 | | |