class vB_Api_Content_Attach extends vB_Api_Content

vB_Api_Content_Attach

Traits

Properties

protected bool $disabled Indicates whether the API was disabled from vB_Api
protected array $disableWhiteList List of methods that which can still be called as normal even when the API is disabled due to forum being closed, password expired, IP ban, etc. from vB_Api_Content
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 vB_UserContext $usercontext from vB_Api_Content
protected vB_dB_Assertor $assertor from vB_Api_Content
protected vB_Api_Node $nodeApi from vB_Api_Content
protected array $options from vB_Api_Content
protected bool $doFloodCheck from vB_Api_Content
protected vB_Library_Content $library from vB_Api_Content
protected $types
protected $extension_map
protected string $contenttype
protected string $tablename
protected int $inlist
protected object $imageHandler

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

Returns textCountChange property

integer
add(mixed $data, array $options = array())

Adds a new node

cleanOptions(array $options)

Clean unallowed options from user request, only cleans 'skipFloodCheck' for now

cleanInput(mixed $data, int|false $nodeid = false)

Cleans the input in the $data array, directly updating $data.

boolean
delete(integer $nodeid)

Remove an attachment

static mixed
getContentApi(int $contenttypeid)

Returns a content api of the appropriate type

bool
isPublished(array $data)

Determines if this record is in a published state

bool
update(mixed $nodeid, mixed $data)

Updates a record

getContent($nodeid, $permissions = false)

Alias for @getFullContent

array
getFullContent(integer $nodeid, array $permissions = false)

Returns the node content plus the channel routeid and title, and starter route and title, and permissions and other data

cleanPreviewContent(mixed $record)

Takes a node record and removes the data cannot be viewed based on public_preview.

mixed
getBareContent(int $nodeid, array $permissions = false)

Returns the node content, channel routeid and title, and starter route and title, but no permissions or other subsidiary data

array|false
getConversationParent(int $nodeid)

Gets the conversation starter for a node. If the node is a channel it returns the channel array.

array
getIndexableContent($nodeId, $include_attachments = true)

The classes that inherit this should implement this function It should return the content that should be indexed If there is a title field, the array key for that field should be 'title', the rest of the text can have any key

getBbcodeOptions(int $nodeId)

Returns an array with bbcode options for the node.

int
getTimeNow()

Gives the current board time- needed to set publishdate.

string
getQuoteText(int $nodeid)

This returns the text to quote a node. Used initially for private messaging.

string
createQuoteText($nodeid, $pageText)

This returns the text to quote a node. Used initially for private messaging.

array
fetchTableName()

Returns the tables used by this content type.

bool
isVisitorMessage(int $nodeid)

Determines whether a specific node is a visitor message

mixed
extractMedia(string $rawtext)

Extracts the video and photo content from text.

bool
verify_limits(array $data)

Checks the "limit" permissions for this content item

getGenericChannelAttachmentPermissions($nodeid)

No description

checkPermission(int $userid)

This validates that a user can upload attachments. Currently that's just verifying that they are logged in.

mixed
fetchImage(int $id, string $type = vB_Api_Filedata::SIZE_FULL, bool $includeData = true)

Fetch image information about an attachment

mixed
setLogo(int $filedataid, string $styleselection = 'current')

Sets the main logo for a file

array
upload(array $file)

Uploads a file

array
uploadPhoto(array $file)

Uploads a photo. Only use for images.

array
uploadProfilePicture(array $file)

Uploads a file without dimension check - to be cropped later. Only use for images.

array
uploadAttachment(array $file, bool $checkperms = true, bool $imageOnly = false)

Uploads an attachment

mixed
uploadUrl(string $url, bool $attachment = false, string $uploadfrom = '')

Upload an image based on the url

fetchImageByFiledataid($id, $type = vB_Api_Filedata::SIZE_FULL, $includeData = true, $attachmentnodeid = 0)

Alias for vB_Api_Filedata::fetchImageByFiledataid

array
fetchAttachByFiledataids(array $filedataids)

Fetch information of attachments without data

deleteAttachment(int $id)

Remove an attachment

array
getAttachmentPermissions($data)

Retrieves the permissions for the specified file type and upload method

string
cleanSettings(array $settings, int $nodeid)

Performs permission checks and cleaning for the 'settings' attach data and returns the serialized string that can be saved.

array
getAvailableSettings()

Returns an array of settings that can be saved.

array
isImage(string $extension, string $type = vB_Api_Filedata::SIZE_FULL)

Returns an true of the extension & size requested would be treated as an image attachment

array('extensions'
getImageExtensions()

Returns a string[] of accepted extensions that use the img tag for display.

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

in vB_Api_Content at line 79
int getTextCountChange()

Returns textCountChange property

Return Value

int

in vB_Api_Content at line 93
integer add(mixed $data, array $options = array())

Adds a new node

Parameters

mixed $data Array of field => value pairs which define the record.
array $options Array of options for the content being created. Understands skipTransaction, skipFloodCheck, floodchecktime, many subclasses have skipNotification. See subclasses for more info.

Return Value

integer the new nodeid

in vB_Api_Content at line 124
protected cleanOptions(array $options)

Clean unallowed options from user request, only cleans 'skipFloodCheck' for now

Parameters

array $options Array of options, may be passed in from client

at line 534
cleanInput(mixed $data, int|false $nodeid = false)

Cleans the input in the $data array, directly updating $data.

Note: This is called from the cleanInput method in the text API for all the attachments to the text node.

Parameters

mixed $data Array of fieldname => data pairs, passed by reference.
int|false $nodeid Nodeid of the node being edited, false if creating new

at line 458
boolean delete(integer $nodeid)

Remove an attachment

Parameters

integer $nodeid The nodeid of the record to be deleted

Return Value

boolean

in vB_Api_Content at line 356
static mixed getContentApi(int $contenttypeid)

Returns a content api of the appropriate type

Parameters

int $contenttypeid The content type id

Return Value

mixed Content api object

in vB_Api_Content at line 368
bool isPublished(array $data)

Determines if this record is in a published state

Parameters

array $data The standard array of data sent to the add() method

Return Value

bool

in vB_Api_Content at line 381
bool update(mixed $nodeid, mixed $data)

Updates a record

Parameters

mixed $nodeid array of nodeids
mixed $data array of permissions that should be checked.

Return Value

bool

in vB_Api_Content at line 428
getContent($nodeid, $permissions = false)

Alias for @getFullContent

Parameters

$nodeid
$permissions

in vB_Api_Content at line 441
array getFullContent(integer $nodeid, array $permissions = false)

Returns the node content plus the channel routeid and title, and starter route and title, and permissions and other data

Parameters

integer $nodeid The node id
array $permissions Permissions

Return Value

array The standard array of node data

in vB_Api_Content at line 468
cleanPreviewContent(mixed $record)

Takes a node record and removes the data cannot be viewed based on public_preview.

It's called from the search Api, which avoids using the content APIs

Parameters

mixed $record The node record, normally from getNodeFullContent, by reference

in vB_Api_Content at line 541
mixed getBareContent(int $nodeid, array $permissions = false)

Returns the node content, channel routeid and title, and starter route and title, but no permissions or other subsidiary data

Parameters

int $nodeid The Node ID
array $permissions Permissions

Return Value

mixed

in vB_Api_Content at line 581
array|false getConversationParent(int $nodeid)

Gets the conversation starter for a node. If the node is a channel it returns the channel array.

Parameters

int $nodeid

Return Value

array|false The starter node array. False when the node lookup fails

Exceptions

vB_Exception_Api('no_permission')

in vB_Api_Content at line 612
array getIndexableContent($nodeId, $include_attachments = true)

The classes that inherit this should implement this function It should return the content that should be indexed If there is a title field, the array key for that field should be 'title', the rest of the text can have any key

Parameters

$nodeId
$include_attachments

Return Value

array $indexableContent

in vB_Api_Content at line 622
getBbcodeOptions(int $nodeId)

Returns an array with bbcode options for the node.

Parameters

int $nodeId

in vB_Api_Content at line 633
int getTimeNow()

Gives the current board time- needed to set publishdate.

Return Value

int

in vB_Api_Content at line 645
string getQuoteText(int $nodeid)

This returns the text to quote a node. Used initially for private messaging.

Parameters

int $nodeid The nodeid of the quoted item

Return Value

string Quote text

in vB_Api_Content at line 659
string createQuoteText($nodeid, $pageText)

This returns the text to quote a node. Used initially for private messaging.

Parameters

$nodeid
$pageText

Return Value

string Quote text.

in vB_Api_Content at line 671
array fetchTableName()

Returns the tables used by this content type.

Return Value

array Array of table names

in vB_Api_Content at line 684
bool isVisitorMessage(int $nodeid)

Determines whether a specific node is a visitor message

Parameters

int $nodeid NodeID

Return Value

bool

in vB_Api_Content at line 696
mixed extractMedia(string $rawtext)

Extracts the video and photo content from text.

Parameters

string $rawtext

Return Value

mixed Array of "photo", "video". Each is an array of images.

in vB_Api_Content at line 713
protected bool verify_limits(array $data)

Checks the "limit" permissions for this content item

Parameters

array $data Info about the content that needs to be added

Return Value

bool Either true if all the tests passed or thrown exception

at line 62
getGenericChannelAttachmentPermissions($nodeid)

Parameters

$nodeid

at line 119
protected checkPermission(int $userid)

This validates that a user can upload attachments. Currently that's just verifying that they are logged in.

Parameters

int $userid User ID

at line 142
mixed fetchImage(int $id, string $type = vB_Api_Filedata::SIZE_FULL, bool $includeData = true)

Fetch image information about an attachment

Parameters

int $id Node ID
string $type Thumbnail version/size requested (SIZE_* constanst in vB_Api_Filedata)
bool $includeData Should we include the image content

Return Value

mixed Array of data, includes: filesize, dateline, htmltype, filename, extension, and filedataid

Sets the main logo for a file

Parameters

int $filedataid Filedataid
string $styleselection Which style (or styles) to update. 'current', 'default', or 'all'. see switch case in implementation for details.

Return Value

mixed Array of data, includes error message or an int- normally 1.

at line 341
array upload(array $file)

Uploads a file

Parameters

array $file Data from $_FILES

Return Value

array Array of data, which will include either error info or a filedataid

at line 353
array uploadPhoto(array $file)

Uploads a photo. Only use for images.

Parameters

array $file Data from $_FILES

Return Value

array Array of data, which will include either error info or a filedataid

at line 365
array uploadProfilePicture(array $file)

Uploads a file without dimension check - to be cropped later. Only use for images.

Parameters

array $file Data from $_FILES

Return Value

array Array of data, which will include either error info or a filedataid

at line 383
protected array uploadAttachment(array $file, bool $checkperms = true, bool $imageOnly = false)

Uploads an attachment

For parameters & return data see vB_Library_Content_Attach::uploadAttachment()

Parameters

array $file
  • Data from $_FILES
bool $checkperms
  • Whether or not to check permissions
bool $imageOnly
  • Whether or not this is an image only attachment

Return Value

array Array of attachment data see vB_Library_Content_Attach::saveUpload()

at line 401
mixed uploadUrl(string $url, bool $attachment = false, string $uploadfrom = '')

Upload an image based on the url

Parameters

string $url Remote url
bool $attachment Save as attachment
string $uploadfrom The name of the upload form

Return Value

mixed Array of data, includes filesize, dateline, htmltype, filename, extension, and filedataid

at line 415
fetchImageByFiledataid($id, $type = vB_Api_Filedata::SIZE_FULL, $includeData = true, $attachmentnodeid = 0)

Alias for vB_Api_Filedata::fetchImageByFiledataid

Parameters

$id
$type
$includeData
$attachmentnodeid

See also

vB_Api_Filedata::fetchImageByFiledataid

at line 427
array fetchAttachByFiledataids(array $filedataids)

Fetch information of attachments without data

Parameters

array $filedataids Array of file data ID

Return Value

array The attachment data array

at line 473
deleteAttachment(int $id)

Remove an attachment

Parameters

int $id Nodeid

at line 508
array getAttachmentPermissions($data)

Retrieves the permissions for the specified file type and upload method

Parameters

$data

Return Value

array $results

at line 565
protected string cleanSettings(array $settings, int $nodeid)

Performs permission checks and cleaning for the 'settings' attach data and returns the serialized string that can be saved.

Assumes that the current user is the user trying to save the settings

Parameters

array $settings Array with keys as specified in getAvailableSettings() {see getavailablesettings}
int $nodeid Nodeid of attachment or attachment's parent, used to check permissions

Return Value

string String containing the cleaned, serialized data

at line 643
array getAvailableSettings()

Returns an array of settings that can be saved.

Return Value

array Key 'settings' => array of available setting names

at line 668
array isImage(string $extension, string $type = vB_Api_Filedata::SIZE_FULL)

Returns an true of the extension & size requested would be treated as an image attachment

Parameters

string $extension File extension of attachment
string $type 'icon'|'thumb'|'small'|'medium'|'large'|'full'

Return Value

array Key 'settings' => array of available setting names

at line 681
array('extensions' getImageExtensions()

Returns a string[] of accepted extensions that use the img tag for display.

Return Value

array('extensions' => string[])