class vB_Api_Blog extends vB_Api

vB_Api_Blog

Traits

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 object $assertor
protected object $library

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()

Constructor

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
array
createBlog(array $input)

Creates a blog channel

int
createChannel(array $input, int $channelid, int $channelConvTemplateid, int $channelPgTemplateId, int $ownerSystemGroupId)

Check validity of data passed in and create a blog or group channel

int
getBlogChannel()

No description

bool
isBlogNode($nodeId, $node = false)

Determines if the given node is a blog-related node (blog entry).

mixed
getBlogInfo(int $from = 1, int $perpage = 20, int $authorid = 0)

No description

array
getChannelAdminPerms(int $nodeid)

Returns a list of channel owner permissions and their values

int
fetchOwner(int $nodeid)

Returns the userid of the channel owner

array
fetchContributors(int $nodeid, int $count = false)

Returns the userids of the channel contributors (moderators)

mixed
fetchSubscribers(int $nodeid, int $pageno = 1, int $perpage = 20, bool $thumb = false)

Fetches information about members (subscribers) for a blog.

subscribeChannel($channelId)

Handles subscription in special channels for the current user.

leaveChannel($channelId, $leavingUser = 0)

Handles leave in special channels for the current or specified user.

removeChannelMember($channelId, $userId)

Handles removing a channel member

removeChannelModerator($channelId, $userId)

Handles removing a channel moderator

cancelChannelTransfer($channelId, $userId)

Cancels a channel transfer request

isChannelModerator($channelId, $checkUser = 0)

Indicates if the given user or current user is owner or mod from given channel.

int
isChannelMember(int $channelId)

Indicates if the current user is member of a given channelid

array
userCanComment(array $blogPosts)

Returns whether current user can comment in the blog or not

array
getBlogSidebarModules(int $channelId = 0)

Returns the widget instances that are used for blog sidebar.

saveBlogSidebarModules(int $blogId, array $modules)

Saves channel configuration for blog sidebar

int
getMembersCount(int $nodeid)

Gets the number of members for the given blog channel

int
doMembersCount(int $nodeid)

Returns the number of members for the channel (blog or group)

array
fetchMembers($nodeid, $pageno = 1, $perpage = 20, $thumb = false, $includeOwnersAndMods = false)

Lists channel members

bool
canCreateBlog(int $parentid)

Checks if the user can create a new Blog

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 34
protected __construct()

Constructor

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 49
array createBlog(array $input)

Creates a blog channel

Parameters

array $input Array of input

Return Value

array

at line 79
protected int createChannel(array $input, int $channelid, int $channelConvTemplateid, int $channelPgTemplateId, int $ownerSystemGroupId)

Check validity of data passed in and create a blog or group channel

Parameters

array $input
int $channelid
int $channelConvTemplateid
int $channelPgTemplateId
int $ownerSystemGroupId

Return Value

int The nodeid of the new blog channel.

at line 162
int getBlogChannel()

Return Value

int nodeid of actual Main Blog Channel

at line 174
bool isBlogNode($nodeId, $node = false)

Determines if the given node is a blog-related node (blog entry).

Parameters

$nodeId
$node

Return Value

bool

at line 215
mixed getBlogInfo(int $from = 1, int $perpage = 20, int $authorid = 0)

Parameters

int $from Page number
int $perpage Per page
int $authorid The userid of the owner or author of the blog channels to fetch. If 0, blog channels for all users are fetched.

Return Value

mixed array containing the blog channel info we need

at line 345
array getChannelAdminPerms(int $nodeid)

Returns a list of channel owner permissions and their values

Parameters

int $nodeid Channel Node ID

Return Value

array List of permissions and their values: canmanageusers (value from moderatorpermissions:canaddowners) canmoderate (value from moderatorpermissions:canmoderateposts) canconfig (value from forumpermissions2:canconfigchannel) canmanagechannel (value from forumpermissions2:candeletechannel) canstats true

at line 369
int fetchOwner(int $nodeid)

Returns the userid of the channel owner

Parameters

int $nodeid Channel Node ID

Return Value

int Channel owner user ID

at line 394
array fetchContributors(int $nodeid, int $count = false)

Returns the userids of the channel contributors (moderators)

Parameters

int $nodeid Channel Node ID
int $count (optional) Max number of userids to return

Return Value

array Array of channel contributor user IDs

at line 429
mixed fetchSubscribers(int $nodeid, int $pageno = 1, int $perpage = 20, bool $thumb = false)

Fetches information about members (subscribers) for a blog.

For actual node subscription information

Parameters

int $nodeid the nodeid
int $pageno page for which we want data
int $perpage items per page
bool $thumb whether to get the thumbnail avatar

Return Value

mixed array with 'count'=> total subscriber count 'pagecount' => total number of pages 'groupid' => id for the channel member group 'members'=> array of users: * avatarUrl * username * userid

See also

vB_Api_Follow::fetchNodeSubscribers()

at line 500
subscribeChannel($channelId)

Handles subscription in special channels for the current user.

This is used basically for social groups subscription handling the join/subscribe logical but we are implementing here in case requirements change and join/subscribe gets into blogs too.

Parameters

$channelId

at line 542
leaveChannel($channelId, $leavingUser = 0)

Handles leave in special channels for the current or specified user.

This is used basically for social groups handling the join/subscribe logical but we are implementing here in case requirements change and join/subscribe gets into blogs too.

Parameters

$channelId
$leavingUser

at line 619
removeChannelMember($channelId, $userId)

Handles removing a channel member

Parameters

$channelId
$userId

at line 642
removeChannelModerator($channelId, $userId)

Handles removing a channel moderator

Parameters

$channelId
$userId

at line 717
cancelChannelTransfer($channelId, $userId)

Cancels a channel transfer request

Parameters

$channelId
$userId

at line 773
isChannelModerator($channelId, $checkUser = 0)

Indicates if the given user or current user is owner or mod from given channel.

Owner can't leave the channel ditto for mods (managers or contributors).

Parameters

$channelId
$checkUser

at line 815
int isChannelMember(int $channelId)

Indicates if the current user is member of a given channelid

Parameters

int $channelId The channel id we are checking.

Return Value

int Values of the member status. 0 = no member 1 = member 2 = request pending

at line 864
array userCanComment(array $blogPosts)

Returns whether current user can comment in the blog or not

Parameters

array $blogPosts Either a single blog post or an array of elements containing blog posts info.The info for each blog post must have: - nodeid - parentid - nodeoptions

Return Value

array
  • Returns an array with nodeid as key and value for "user can comment"? 0 : No (Commenting is disabled for the blog post or the blog channel) -1: No (User is not logged in and Guests have no permission to comment -2: No (User is logged in but is not subscribed to the blog post - permission to comment is set for subscribers only) 1 : Yes

at line 994
array getBlogSidebarModules(int $channelId = 0)

Returns the widget instances that are used for blog sidebar.

This method should be used only for owner configuration of the blog, not rendering

Parameters

int $channelId Channel ID

Return Value

array An array of widget instances, keyed by widget instance ID

              array(
                  widget instance ID => array(
                      title
                      widgetid
                      widgetinstanceid
                      hidden (int flag)
                  )
              )
              

at line 1096
saveBlogSidebarModules(int $blogId, array $modules)

Saves channel configuration for blog sidebar

Parameters

int $blogId
array $modules An array in which each element contains: - widgetinstanceid (int) - hide (bool)

Exceptions

vB_Exception_Api no_permission

at line 1145
int getMembersCount(int $nodeid)

Gets the number of members for the given blog channel

Parameters

int $nodeid nodeid

Return Value

int number of members

Exceptions

vB_Exception_Api invalid_node_id If it is not a blog channel

at line 1163
protected int doMembersCount(int $nodeid)

Returns the number of members for the channel (blog or group)

Parameters

int $nodeid Node ID for the channel

Return Value

int Number of members

at line 1221
array fetchMembers($nodeid, $pageno = 1, $perpage = 20, $thumb = false, $includeOwnersAndMods = false)

Lists channel members

This is used for groups.

Parameters

$nodeid
$pageno
$perpage
$thumb
$includeOwnersAndMods

Return Value

array int count -- total count of members array members -- list of userid => Array int userid string username string avatarUrl -- deprecated, use avatarpath string avatarpath -- the user's avatar url path. Thumbnail path if requested int groupid -- the groupid from the channel member usergroup int pagecount -- total number of pages

Exceptions

vB_Exception_Api invalid_data
vB_Exception_Api no_permission

at line 1358
bool canCreateBlog(int $parentid)

Checks if the user can create a new Blog

Parameters

int $parentid Parentid of the blog parent

Return Value

bool

Exceptions

vB_Exception_Api invalid_blog_parent
vB_Exception_Api you_can_only_create_x_blogs