Constants

DEBUG

DEBUG

INFO

INFO

WARN

WARN

ERROR

ERROR

FATAL

FATAL

Properties

$needUpgradeCache

$needUpgradeCache : 

Type

$shareManager

$shareManager : 

\OCP\Share\IManager

Type

$token

$token : string

Cached encrypted CSRF token. Some static unit-tests of ownCloud compare multiple OC_Template elements which invoke `callRegister`. If the value would not be cached these unit-tests would fail.

Type

string

Methods

getVersion()

getVersion() : array

get the current installed version of ownCloud

Returns

array

setChannel()

setChannel(string  $channel) 

Set current update channel

Parameters

string $channel

getChannel()

getChannel() : string

Get current update channel

Returns

string

sendMail()

sendMail(string  $toaddress, string  $toname, string  $subject, string  $mailtext, string  $fromaddress, string  $fromname, integer  $html, string  $altbody = '', string  $ccaddress = '', string  $ccname = '', string  $bcc = '') 

send an email

Parameters

string $toaddress
string $toname
string $subject
string $mailtext
string $fromaddress
string $fromname
integer $html
string $altbody
string $ccaddress
string $ccname
string $bcc

writeLog()

writeLog(string  $app, string  $message, integer  $level) 

write a message in the log

Parameters

string $app
string $message
integer $level

logException()

logException(string  $app, \Exception  $ex, integer  $level = \OCP\Util::FATAL) 

write exception into the log

Parameters

string $app

app name

\Exception $ex

exception to log

integer $level

log level, defaults to \OCP\Util::FATAL

isSharingDisabledForUser()

isSharingDisabledForUser() : boolean

check if sharing is disabled for the current user

Returns

boolean

getL10N()

getL10N(string  $application, string|null  $language = null) : \OCP\IL10N

get l10n object

Parameters

string $application
string|null $language

Returns

\OCP\IL10N

addStyle()

addStyle(string  $application, string  $file = null) 

add a css file

Parameters

string $application
string $file

addScript()

addScript(string  $application, string  $file = null) 

add a javascript file

Parameters

string $application
string $file

addTranslations()

addTranslations(string  $application, string  $languageCode = null) 

Add a translation JS file

Parameters

string $application

application id

string $languageCode

language code, defaults to the current locale

addHeader()

addHeader(string  $tag, array  $attributes, string  $text = null) 

Add a custom element to the header If $text is null then the element will be written as empty element.

So use "" to get a closing tag.

Parameters

string $tag

tag name of the element

array $attributes

array of attributes for the element

string $text

the text content for the element

formatDate()

formatDate(integer  $timestamp, boolean  $dateOnly = false, \DateTimeZone|string  $timeZone = null) : string

formats a timestamp in the "right" way

Parameters

integer $timestamp

$timestamp

boolean $dateOnly

option to omit time from the result

\DateTimeZone|string $timeZone

where the given timestamp shall be converted to

Returns

string —

timestamp

encryptedFiles()

encryptedFiles() : boolean

check if some encrypted files are stored

Returns

boolean

linkToAbsolute()

linkToAbsolute(string  $app, string  $file, array  $args = array()) : string

Creates an absolute url to the given app and file.

Parameters

string $app

app

string $file

file

array $args

array with param=>value, will be appended to the returned url The value of $args will be urlencoded

Returns

string —

the url

linkToRemote()

linkToRemote(string  $service) : string

Creates an absolute url for remote use.

Parameters

string $service

id

Returns

string —

the url

linkToPublic()

linkToPublic(string  $service) : string

Creates an absolute url for public use

Parameters

string $service

id

Returns

string —

the url

linkTo()

linkTo(string  $app, string  $file, array  $args = array()) : string

Creates an url to the given app and file

Parameters

string $app

app

string $file

file

array $args

array with param=>value, will be appended to the returned url The value of $args will be urlencoded

Returns

string —

the url

getServerHost()

getServerHost() : string

Returns the server host, even if the website uses one or more reverse proxy

Returns

string —

the server host

getServerHostName()

getServerHostName() : string

Returns the server host name without an eventual port number

Returns

string —

the server hostname

getDefaultEmailAddress()

getDefaultEmailAddress(string  $user_part) : string

Returns the default email address

Parameters

string $user_part

the user part of the address

Returns

string —

the default email address

Assembles a default email address (using the server hostname and the given user part, and returns it Example: when given lostpassword-noreply as $user_part param, and is currently accessed via http(s)://example.com/, it would return 'lostpassword-noreply@example.com'

If the configuration value 'mail_from_address' is set in config.php, this value will override the $user_part that is passed to this function

getServerProtocol()

getServerProtocol() : string

Returns the server protocol. It respects reverse proxy servers and load balancers

Returns

string —

the server protocol

getRequestUri()

getRequestUri() : string

Returns the request uri, even if the website uses one or more reverse proxies

Returns

string —

the request uri

getScriptName()

getScriptName() : string

Returns the script name, even if the website uses one or more reverse proxies

Returns

string —

the script name

imagePath()

imagePath(string  $app, string  $image) : string

Creates path to an image

Parameters

string $app

app

string $image

image name

Returns

string —

the url

humanFileSize()

humanFileSize(integer  $bytes) : string

Make a human file size (2048 to 2 kB)

Parameters

integer $bytes

file size in bytes

Returns

string —

a human readable file size

connectHook()

connectHook(string  $signalClass, string  $signalName, string|object  $slotClass, string  $slotName) : boolean

connects a function to a hook

Parameters

string $signalClass

class name of emitter

string $signalName

name of signal

string|object $slotClass

class name of slot

string $slotName

name of slot

Returns

boolean —

This function makes it very easy to connect to use hooks.

TODO: write example

emitHook()

emitHook(string  $signalclass, string  $signalname, array  $params = array()) : boolean

Emits a signal. To get data from the slot use references!

Parameters

string $signalclass

class name of emitter

string $signalname

name of signal

array $params

default: array() array with additional data

Returns

boolean —

true if slots exists or false if not

TODO: write example

callRegister()

callRegister() 

Register an get/post call. This is important to prevent CSRF attacks

callCheck()

callCheck() 

Check an ajax get/post call if the request token is valid. exit if not.

sanitizeHTML()

sanitizeHTML(string|array  $value) : string|array

Used to sanitize HTML

This function is used to sanitize HTML and should be applied on any string or array of strings before displaying it on a web page.

Parameters

string|array $value

Returns

string|array —

an array of sanitized strings or a single sanitized string, depends on the input parameter.

encodePath()

encodePath(string  $component) : string

Public function to encode url parameters

This function is used to encode path to file before output. Encoding is done according to RFC 3986 with one exception: Character '/' is preserved as is.

Parameters

string $component

part of URI to encode

Returns

string

mb_array_change_key_case()

mb_array_change_key_case(array  $input, integer  $case = MB_CASE_LOWER, string  $encoding = 'UTF-8') : array

Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.

Parameters

array $input

The array to work on

integer $case

Either MB_CASE_UPPER or MB_CASE_LOWER (default)

string $encoding

The encoding parameter is the character encoding. Defaults to UTF-8

Returns

array

mb_substr_replace()

mb_substr_replace(string  $string, string  $replacement, integer  $start, integer  $length = null, string  $encoding = 'UTF-8') : string

replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.

Parameters

string $string

The input string. Opposite to the PHP build-in function does not accept an array.

string $replacement

The replacement string.

integer $start

If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.

integer $length

Length of the part to be replaced

string $encoding

The encoding parameter is the character encoding. Defaults to UTF-8

Returns

string

mb_str_replace()

mb_str_replace(string  $search, string  $replace, string  $subject, string  $encoding = 'UTF-8', integer  $count = null) : string

Replace all occurrences of the search string with the replacement string

Parameters

string $search

The value being searched for, otherwise known as the needle. String.

string $replace

The replacement string.

string $subject

The string or array being searched and replaced on, otherwise known as the haystack.

string $encoding

The encoding parameter is the character encoding. Defaults to UTF-8

integer $count

If passed, this will be set to the number of replacements performed.

Returns

string

recursiveArraySearch()

recursiveArraySearch(array  $haystack, string  $needle, integer  $index = null) : mixed

performs a search in a nested array

Parameters

array $haystack

the array to be searched

string $needle

the search string

integer $index

optional, only search this key name

Returns

mixed —

the key of the matching field, otherwise false

maxUploadFilesize()

maxUploadFilesize(string  $dir, integer  $free = null) : integer

calculates the maximum upload size respecting system settings, free space and user quota

Parameters

string $dir

the current folder where the user currently operates

integer $free

the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly

Returns

integer —

number of bytes representing

freeSpace()

freeSpace(string  $dir) : integer

Calculate free space left within user quota

Parameters

string $dir

the current folder where the user currently operates

Returns

integer —

number of bytes representing

uploadLimit()

uploadLimit() : integer

Calculate PHP upload limit

Returns

integer —

number of bytes representing

isValidFileName()

isValidFileName(string  $file) : boolean

Returns whether the given file name is valid

Parameters

string $file

file name to check

Returns

boolean —

true if the file name is valid, false otherwise

generateRandomBytes()

generateRandomBytes(integer  $length = 30) : string

Generates a cryptographic secure pseudo-random string

Parameters

integer $length

of the random string

Returns

string

naturalSortCompare()

naturalSortCompare(string  $a, string  $b) : \OCP\-1

Compare two strings to provide a natural sort

Parameters

string $a

first string to compare

string $b

second string to compare

Returns

\OCP\-1 —

if $b comes before $a, 1 if $a comes before $b or 0 if the strings are identical

isPublicLinkPasswordRequired()

isPublicLinkPasswordRequired() : boolean

check if a password is required for each public link

Returns

boolean

isDefaultExpireDateEnforced()

isDefaultExpireDateEnforced() : boolean

check if share API enforces a default expire date

Returns

boolean

needUpgrade()

needUpgrade() : boolean

Checks whether the current version needs upgrade.

Returns

boolean —

true if upgrade is needed, false otherwise

getStatusInfo()

getStatusInfo(boolean  $includeVersion = false) : array

Collects all status infos.

Parameters

boolean $includeVersion

Returns

array