class vB_Api_Follow extends vB_Api

vB_Api_Follow

Traits

Constants

FOLLOWTYPE

FOLLOWTYPE_USERS

FOLLOWTYPE_CONTENT

FOLLOWTYPE_CHANNELS

FOLLOWTYPE_ALL

FOLLOWTYPE_ACTIVITY

FOLLOWFILTERTYPE_SORT

FOLLOWFILTER_SORTALL

FOLLOWFILTER_SORTMOST

FOLLOWFILTER_SORTLEAST

FOLLOWFILTER_SORTMOSTRECENT

FOLLOWFILTER_SORTOLDEST

FOLLOWFILTER_SORTPOPULAR

FOLLOWFILTER_SORTACTIVITYNEW

FOLLOWFILTER_SORTACTIVITYOLD

FOLLOWFILTERTYPE_TIME

FOLLOWFILTER_LASTDAY

FOLLOWFILTER_LASTWEEK

FOLLOWFILTER_LASTMONTH

FOLLOWFILTER_ALLTIME

FOLLOWFILTERTYPE_FOLLOW

FOLLOWING_NO

FOLLOWING_YES

FOLLOWING_PENDING

Properties

protected bool $disabled Indicates whether the API was disabled from vB_Api
protected array $disableWhiteList Contains white listed methods which act as normal when API is disabled no matter of special scenarios like forum closed, password expiry, ip ban and others. from vB_Api
protected array $disableFalseReturnOnly Contains white listed methods which return a false response when API is disabled in special scenarios like forum closed, password expiry, ip ban and others. from vB_Api
protected string $controller API Controller from vB_Api
protected vB_Database $db Database object. from vB_Api
protected $followers
protected $blocked
protected $subscriptions
protected $userFollowers
protected $userFollowing
protected $userListCache

Methods

__sleep()

No description

__wakeup()

No description

static 
getApiClassName($controller)

No description

from vB_Api
static 
getApiClassNameInternal($controller)

No description

from vB_Api
static 
getApiClass($controller, $errorCheck = true)

No description

from vB_Api
static vB_Api
instanceInternal(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which doesn't handle exceptions This should only be used in other API objects, not for clients of the API

from vB_Api
static vB_Api
instance(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which translates exceptions to an array Use this method for API clients.

from vB_Api
static 
clearCache()

Clears all previously loaded API objects.

from vB_Api
The
callNamed()

Call the given api function by name with a named arguments list.

from vB_Api
static string
map_vb4_input_to_vb5(string $method, array $request)

Returns vb5 api method name.

from vB_Api
static 
map_vb5_output_to_vb4(string $method, array $data)

Alters the output array in any way necessary to interface correctly with vb4.

from vB_Api
static 
map_vb5_errors_to_vb4(string $method, array $data)

Alters the error array in any way necessary to interface correctly with vb4.

from vB_Api
__construct()

No description

checkApiState($method)

This method checks whether the API method is enabled.

from vB_Api
bool
isWhiteListed(string $method)

Checks if method is white listed when API is disabled.

from vB_Api
bool
isDisableFalseReturnOnly(string $method)

Checks if method returns false response only when API is disabled.

from vB_Api
toSeoFriendly(string $str)

Replaces special characters in a given string with dashes to make the string SEO friendly

from vB_Api
none
checkHasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission, and if not throws an exception

from vB_Api
boolean
hasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission

from vB_Api
checkIsLoggedIn()

Determines if the calling user has the given admin permission, and if not throws an exception

from vB_Api
setController(string $controller)

Set controller

from vB_Api
inDebugMode()

No description

from vB_Api
getUserList(int $userid, string $direction = 'followed', string $type = 'follow')

This gets the followers.

getSubscribedDiscussion(int $userid)

This gets the subscriptions to content nodes

array
getFollowers($userid = false, $options = array())

This lists all the current followers, based userid param or current users's userid

getFollowersForCurrentUser(mixed $options = array())

Gets the followers for the current user

array
getFollowing(int $userid = false, string $type = vB_Api_Follow::FOLLOWTYPE_ALL, mixed $filters = array(vB_Api_Follow::FOLLOWFILTERTYPE_SORT => vB_Api_Follow::FOLLOWFILTER_SORTALL), mixed $contenttypeclass = null, array $options = array())

This lists what a user is following- the parameters, not the content

getFollowingChannels($options)

No description

getFollowingActivities(Options $options = array())

Get following activity

getFollowingUsers($options)

No description

getFollowingUserActivities($options = array())

Get Following User Activities

array
getFollowingContent($userid = false, $type = self::FOLLOWTYPE_ALL, $filters = array(self::FOLLOWFILTERTYPE_SORT => self::FOLLOWFILTER_SORTALL), $contenttypeclass = null, $options = array())

This lists the content for the user's set parameters

array
getContentFollowers(int $nodeid, int $currentPage = 1, int $perpage = 100, bool $includeFollowInfo = false)

Lists the users that are following the given content

array
getFollowingContentForTab($userid = false, $type = self::FOLLOWTYPE_ALL, $filters = array(self::FOLLOWFILTERTYPE_SORT => self::FOLLOWFILTER_SORTALL), $contenttypeclass = null, $options = array())

Same as getFollowingContent but implements the 'seemore' button logic.

Array
getFollowingForCurrentUser(String $type, $options = array())

Gets the following for the current user. Uses $this->getFollowing

int
add($follow_item, $type = vB_Api_Follow::FOLLOWTYPE_USERS, $follower = false, $auto_subscribe = false)

This adds a following.- ie. the current user will now follow a user, or specified user $follower will follow a node

addFollow($userId)

No description

addSubscription($nodeId, $subscriber = false)

No description

validate($followId, $type = vB_Api_Follow::FOLLOWTYPE_USERS, $subscriber = false)

No description

int
delete($follow_item = false, $type = vB_Api_Follow::FOLLOWTYPE_USERS, $userid = false)

This deletes a follower. needs userid and followerid, passed or taken from current session

Bool
validateFollowInformation(Array $data)

Validates the follow information passed.

The
removeFollowing($followingId = false, $userId = false, $type = self::FOLLOWTYPE_USERS)

Removes following from channels or users including all posts related.

bool
removeFollower(int $follower = false)

This removes a follower from user.

addFollower(int $follower = false)

This adds a user follower

validateFollower($followerId)

No description

bool
approveFollowing(int $followerid)

This approves a following request made for the current user.

bool
denyFollowing(int $followerid)

This denies a following request made for the current user.

updateUser($userid)

No description

int
isFollowingUser(int $profileUser = 0)

This indicates if user is following user's profile page.

int
isFollowingContent(int $contentId)

This indicates if user is following content.

mixed
getFollowingInfo(array $pageInfo)

This gets the params needed for the getFollowing method from the pageInfo array data (query params).

getPaginationInfo($params)

No description

int
getUnsubscribeText(int $isFollowingContent, int $isFollowingMember, int $isFollowingChannel)

Gets the message type to be displayed for the unsubscribe overlay

boolean
unsubscribeItems(mixed $unsubscribeItems)

Unsubscribe items from user.

clearFollowCache($userIds)

Clears follow in class cache

mixed
getFollowingParameters(int $userid = false)

This gets the following parameters- not the content

mixed
getNodeSubscribers(int $nodeid, mixed $options = array())

Return all the subscribers from a given nodeid.

array
getSubscribersForNotifications(int $nodeid, int[] $skipUsers = array())

Return the subscribers who should receive a notification for node $nodeid, excluding $skipUsers

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

in vB_Api at line 63
static getApiClassName($controller)

Parameters

$controller

in vB_Api at line 69
static protected getApiClassNameInternal($controller)

Parameters

$controller

in vB_Api at line 97
static protected getApiClass($controller, $errorCheck = true)

Parameters

$controller
$errorCheck

in vB_Api at line 177
static vB_Api instanceInternal(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which doesn't handle exceptions This should only be used in other API objects, not for clients of the API

Parameters

string $controller -- name of the API controller to load
bool $refresh_cache -- true if we want to force the cache to update with a new api object primarily intended for testing

Return Value

vB_Api

in vB_Api at line 203
static vB_Api instance(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which translates exceptions to an array Use this method for API clients.

Parameters

string $controller -- name of the API controller to load
bool $refresh_cache -- true if we want to force the cache to update with a new api object primarily intended for testing

Return Value

vB_Api

in vB_Api at line 237
static clearCache()

Clears all previously loaded API objects.

Intended for use in tests where the loading pattern can cause issues with objects that cache thier own data.

in vB_Api at line 259
The callNamed()

Call the given api function by name with a named arguments list.

Used primarily to translate REST requests into API calls.

Return Value

The return of the method or an error if the method doesn't exist, or is static, a constructor or destructor, or otherwise shouldn't be callable as and API method. It is also an error if the value of a paramater is not provided and that parameter doesn't have a default value.

in vB_Api at line 313
static string map_vb4_input_to_vb5(string $method, array $request)

Returns vb5 api method name.

May alter request array.

Parameters

string $method -- vb4 method name
array $request -- $_REQUEST array for this api request

Return Value

string

in vB_Api at line 497
static map_vb5_output_to_vb4(string $method, array $data)

Alters the output array in any way necessary to interface correctly with vb4.

Parameters

string $method -- vb4 method name
array $data -- output array from vb5

in vB_Api at line 545
static map_vb5_errors_to_vb4(string $method, array $data)

Alters the error array in any way necessary to interface correctly with vb4.

Parameters

string $method -- vb4 method name
array $data -- error array from vb5

at line 63
protected __construct()

in vB_Api at line 631
checkApiState($method)

This method checks whether the API method is enabled.

For extensions check make sure $controller property is already set.

Parameters

$method

in vB_Api at line 657
protected bool isWhiteListed(string $method)

Checks if method is white listed when API is disabled.

Parameters

string $method API method to check.

Return Value

bool Indicates whether method is or is not a white list.

in vB_Api at line 685
protected bool isDisableFalseReturnOnly(string $method)

Checks if method returns false response only when API is disabled.

Parameters

string $method API method to check.

Return Value

bool Indicates whether method returns false response only.

in vB_Api at line 712
protected toSeoFriendly(string $str)

Replaces special characters in a given string with dashes to make the string SEO friendly

Parameters

string $str The string to be converted

in vB_Api at line 734
protected none checkHasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission, and if not throws an exception

Checks for: * A valid CP Session * The passed adminpermission.

Parameters

string $adminPermission The admin permission to check

Return Value

none

Exceptions

inlinemodauth_required -- The current session is not a mod/admin session
nopermission_loggedin -- The user does not have the given permission
no_permission -- The user is not logged in at all.

in vB_Api at line 753
protected boolean hasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission

Useful if you need to know if the calling user but do not care why they do not have that permission. Generally useful if there is a behavior difference between admins and non admins, but the call can be processed for either.

Parameters

string $adminPermission The admin permission to check

Return Value

boolean true if checks pass, false otherwise

in vB_Api at line 807
protected checkIsLoggedIn()

Determines if the calling user has the given admin permission, and if not throws an exception

in vB_Api at line 821
protected setController(string $controller)

Set controller

Parameters

string $controller Controller name

in vB_Api at line 831
protected inDebugMode()

at line 78
getUserList(int $userid, string $direction = 'followed', string $type = 'follow')

This gets the followers.

Parameters

int $userid the userid
string $direction type- following($userid field) or followed($relationid)
string $type type- follow, pending or blocked

@return     mixed   array of userlist records

at line 165
protected getSubscribedDiscussion(int $userid)

This gets the subscriptions to content nodes

Parameters

int $userid the userid

@return     mixed   array of subscribediscussion records

at line 195
array getFollowers($userid = false, $options = array())

This lists all the current followers, based userid param or current users's userid

@param int userid- optional

Parameters

$userid
$options

Return Value

array of user records

at line 267
getFollowersForCurrentUser(mixed $options = array())

Gets the followers for the current user

Parameters

mixed $options Array of options to filters the user followers. User for pagination at the moment.

at line 289
array getFollowing(int $userid = false, string $type = vB_Api_Follow::FOLLOWTYPE_ALL, mixed $filters = array(vB_Api_Follow::FOLLOWFILTERTYPE_SORT => vB_Api_Follow::FOLLOWFILTER_SORTALL), mixed $contenttypeclass = null, array $options = array())

This lists what a user is following- the parameters, not the content

Parameters

int $userid User id. If not specified will grab from $_REQUEST or current user.
string $type The type of following to get . Use class constants for this, available are: vB_Api_Follow::FOLLOWTYPE_ALL, vB_Api_Follow::FOLLOWTYPE_USERS, vB_Api_Follow::FOLLOWTYPE_CONTENT, vB_Api_Follow::FOLLOWTYPE_CHANNEL
mixed $filters Settings to filter the following. Could be sort or/and type. Availables are: vB_Api_Follow::FOLLOWFILTERTYPE_SORT, vB_Api_Follow::FOLLOWFILTER_SORTMOST, vB_Api_Follow::FOLLOWFILTER_SORTLEAST, vB_Api_Follow::FOLLOWFILTER_SORTALL, vB_Api_Follow::FOLLOWTYPE, vB_Api_Follow::FOLLOWTYPE_USERS, vB_Api_Follow::FOLLOWTYPE_CONTENT, vB_Api_Follow::FOLLOWTYPE_CHANNELS, vB_Api_Follow::FOLLOWFILTER_TYPEALL
mixed $contenttypeclass Content types classes to filter the following. It can be a simple string or an array. The classes should contain 'vBForum_' prefix.
array $options Array of options to the following. -- page int page to return (default 1) -- perpage int page size (default 100)

Return Value

array with 2 elements- users and nodes.

at line 422
getFollowingChannels($options)

Parameters

$options

at line 454
getFollowingActivities(Options $options = array())

Get following activity

Parameters

Options $options array -- page int page to return (default 1) -- perpage int page size (default 100) -- vB_Api_Follow::FOLLOWFILTERTYPE_SORT string sort type (default vB_Api_Follow::FOLLOWFILTER_SORTALL)

at line 527
getFollowingUsers($options)

Parameters

$options

at line 654
getFollowingUserActivities($options = array())

Get Following User Activities

Parameters

$options array (optional) --filter_sort string sort direction (default 'desc') --date_from string date (m/d/Y) (default previous month) --perpage int items per page (default 100) --page int page to fetch (default 1)

at line 714
array getFollowingContent($userid = false, $type = self::FOLLOWTYPE_ALL, $filters = array(self::FOLLOWFILTERTYPE_SORT => self::FOLLOWFILTER_SORTALL), $contenttypeclass = null, $options = array())

This lists the content for the user's set parameters

Parameters

$userid
$type
$filters
$contenttypeclass
$options

Return Value

array with 2 elements- users and nodes.

at line 927
array getContentFollowers(int $nodeid, int $currentPage = 1, int $perpage = 100, bool $includeFollowInfo = false)

Lists the users that are following the given content

Parameters

int $nodeid Nodeid
int $currentPage The page (for pagination)
int $perpage The number of users per page
bool $includeFollowInfo Include the user info in the result

Return Value

array with 2 elements- totalcount (total number of users following the content) and one page of users.

at line 1027
array getFollowingContentForTab($userid = false, $type = self::FOLLOWTYPE_ALL, $filters = array(self::FOLLOWFILTERTYPE_SORT => self::FOLLOWFILTER_SORTALL), $contenttypeclass = null, $options = array())

Same as getFollowingContent but implements the 'seemore' button logic.

So basically will let the user know if there are more nodes to display using a 'seemore' flag.

This lists the content for the user's set parameters

Parameters

$userid
$type
$filters
$contenttypeclass
$options

Return Value

array with 3 elements- users and nodes and paginationinfo.

at line 1075
Array getFollowingForCurrentUser(String $type, $options = array())

Gets the following for the current user. Uses $this->getFollowing

Parameters

String $type Indicates the type of the following to fetch. vB_Api_Follow::FOLLOWTYPE_USERS or vB_Api_Follow::FOLLOWTYPE_ALL
$options array Array with options. Used for pagination and sorting at the moment. -- page int page to return (default 1) -- perpage int page size (default 100) -- vB_Api_Follow::FOLLOWFILTERTYPE_SORT string sort type (default vB_Api_Follow::FOLLOWFILTER_SORTALL)

Return Value

Array with the following info for the current user.

at line 1120
int add($follow_item, $type = vB_Api_Follow::FOLLOWTYPE_USERS, $follower = false, $auto_subscribe = false)

This adds a following.- ie. the current user will now follow a user, or specified user $follower will follow a node

@param int $follow_item The follow item id. (could be either a user or node id)

Parameters

$follow_item
$type
$follower
$auto_subscribe

Return Value

int Used to indicate the following status between users. Values meaning: 0 - Not following 1 - Following 2 - Pending

at line 1182
protected addFollow($userId)

Parameters

$userId

at line 1249
protected addSubscription($nodeId, $subscriber = false)

Parameters

$nodeId
$subscriber

at line 1273
protected validate($followId, $type = vB_Api_Follow::FOLLOWTYPE_USERS, $subscriber = false)

Parameters

$followId
$type
$subscriber

at line 1379
int delete($follow_item = false, $type = vB_Api_Follow::FOLLOWTYPE_USERS, $userid = false)

This deletes a follower. needs userid and followerid, passed or taken from current session

@param int $follow_item "optional" (but will throw an exception if not provided) nodeid or userid of the item to stop following. That is, the item that was being followed by $userid

Parameters

$follow_item
$type
$userid

Return Value

int *

at line 1458
protected Bool validateFollowInformation(Array $data)

Validates the follow information passed.

Needed for add/delete methods. We need to do some perm check and validations on the types, follow item and user.

Parameters

Array $data Follow information. Such a 'userid', vB_Api_Follow::FOLLOWTYPE and 'follow item'. For content and channel follow types you can also pass a flag 'verify_request' to verify that user specified in 'userid' has in fact requested subscription to the follow item (useful for add action).

Return Value

Bool Flag indicating if the information is valid or not.

at line 1509
The removeFollowing($followingId = false, $userId = false, $type = self::FOLLOWTYPE_USERS)

Removes following from channels or users including all posts related.

Parameters

$followingId
$userId
$type

Return Value

The number of items removed.

at line 1568
bool removeFollower(int $follower = false)

This removes a follower from user.

Parameters

int $follower The id from the follower being removed.

Return Value

bool Indicates if the removal succeeded.

at line 1613
addFollower(int $follower = false)

This adds a user follower

Parameters

int $follower Follower id.

at line 1681
protected validateFollower($followerId)

Parameters

$followerId

at line 1721
bool approveFollowing(int $followerid)

This approves a following request made for the current user.

Parameters

int $followerid the follower's id

Return Value

bool *

at line 1770
bool denyFollowing(int $followerid)

This denies a following request made for the current user.

Parameters

int $followerid the follower's id

Return Value

bool *

at line 1813
protected updateUser($userid)

Parameters

$userid

at line 1849
int isFollowingUser(int $profileUser = 0)

This indicates if user is following user's profile page.

Parameters

int $profileUser Id from the user's profile page.

Return Value

int Used to indicate the following status between users. Values meaning: 0 - Not following 1 - Following 2 - Pending

at line 1902
int isFollowingContent(int $contentId)

This indicates if user is following content.

Parameters

int $contentId Id from conent

Return Value

int Used to indicate the following status between user and content. Values meaning: 0 - Not following 1 - Following

at line 1949
mixed getFollowingInfo(array $pageInfo)

This gets the params needed for the getFollowing method from the pageInfo array data (query params).

Will use class constants

Parameters

array $pageInfo Pageinfo dragged from the query params. -- type string one of the vB_Api_Follow FOLLOWTYPE constants (default vB_Api_Follow::FOLLOWTYPE_ALL) -- sortby string on of vB_Api_Follow FOLLOWFILTER constants (vB_Api_Follow::FOLLOWFILTER_SORTALL) -- content string content type allows special value (default all); -- page int page to return (default 1) -- perpage int page size (default 100)

Return Value

mixed Array with the params needed.

at line 2004
protected getPaginationInfo($params)

Parameters

$params

at line 2074
int getUnsubscribeText(int $isFollowingContent, int $isFollowingMember, int $isFollowingChannel)

Gets the message type to be displayed for the unsubscribe overlay

Parameters

int $isFollowingContent ContentId user is subscribed to.
int $isFollowingMember UserId the user is subscribed to.
int $isFollowingChannel ChannelId user is subscribed to.

Return Value

int type number to identify the message to display.

at line 2129
boolean unsubscribeItems(mixed $unsubscribeItems)

Unsubscribe items from user.

Parameters

mixed $unsubscribeItems An array of items to unsubscribe. They should contain the type (which might be users, nodes and channels) and the item id.

Return Value

boolean A flag to indicate if the unsubscribe was successfully done.

at line 2162
clearFollowCache($userIds)

Clears follow in class cache

Parameters

$userIds

at line 2183
mixed getFollowingParameters(int $userid = false)

This gets the following parameters- not the content

Parameters

int $userid option userid

Return Value

mixed array of content, user, member. Each is an array of integers. *

at line 2266
mixed getNodeSubscribers(int $nodeid, mixed $options = array())

Return all the subscribers from a given nodeid.

Parameters

int $nodeid Nodeid we are fetching subscribers from
mixed $options Array of options to the node subscribers such as page, perpage,

Return Value

mixed Array of the subscribers with their information. Such as userid, username, avatar

at line 2363
array getSubscribersForNotifications(int $nodeid, int[] $skipUsers = array())

Return the subscribers who should receive a notification for node $nodeid, excluding $skipUsers

Example code: $nodeNine = 9; $skipUsers = array(2, 3, 4); $apiResult = vB_Api::instance('follow')->getSubscribersForNotifications($nodeNine, $skipUsers); if (!empty($apiResult['subscribers'])) { $subscribersToNine = $apiResult['subscribers']; foreach ($subscribersToNine AS $subscriberData) { echo "User " . $subscriberData['userid'] . " is subscribed to node(s) " . implode(',', $subscriberData['nodeid']) . " with email preference " . $subscriberData['emailupdate'] . "."; } }

Parameters

int $nodeid Nodeid to be associated with the subscribers
int[] $skipUsers Array of userids. Any userid specified will be left out of the returned 'subscribers' array.

Return Value

array API return array. See example below. Contains the data-type & key: array 'subscribers' Unique array containing subscriber data. Each row is keyed by integer and contains an array of data for that with data-types & keys: int 'userid' int 'emailupdate' int[int] 'nodeid' Nodeid(s) of the subscription(s). Ex. if a user has a subscription on channel 3, and $nodeid is a child of that channel, 'nodeid' => array(3 => 3) for that user. If multiple subscriptions are detected, they're all returned. Ex: array( 'subscribers' => array( 1 => array('userid' => 1, 'emailupdate' => 0, 'nodeid' => array(9 => 9)), 5 => array('userid' => 5, 'emailupdate' => 0, 'nodeid' => array(3 => 3)), 6 => array('userid' => 6, 'emailupdate' => 1, 'nodeid' => array(3 => 3, 9 => 9)), ) );