class CRM_Utils_System_Backdrop extends CRM_Utils_System_DrupalBase

Backdrop-specific logic that differs from Drupal.

Properties

bool $is_drupal Deprecated property to check if this is a drupal install. from CRM_Utils_System_Base
bool $is_joomla Deprecated property to check if this is a joomla install. The correct method is to have functions on the UF classes for all UF specific functions and leave the codebase oblivious to the type of CMS from CRM_Utils_System_Base
bool $is_wordpress deprecated property to check if this is a wordpress install. The correct method is to have functions on the UF classes for all UF specific functions and leave the codebase oblivious to the type of CMS from CRM_Utils_System_Base
bool $supports_UF_Logging Does this CMS / UF support a CMS specific logging mechanism? from CRM_Utils_System_DrupalBase
bool $supports_form_extensions from CRM_Utils_System_Base

Methods

initialize()

No description

appendBreadCrumb(array $breadCrumbs)

No description

resetBreadCrumb()

No description

addHTMLHead($header)

No description

mapConfigToSSL()

No description

string
postURL(string $action)

Fixme: Why are we overriding the parent function? Seems inconsistent.

string
url(string $path = NULL, string $query = NULL, bool $absolute = FALSE, string $fragment = NULL, bool $frontend = FALSE, bool $forceBackend = FALSE)

Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)

array|bool
authenticate(string $name, string $password, bool $loadCMSBootstrap = FALSE, string $realPath = NULL)

No description

setMessage(string $message)

No description

bool
loadUser($username)

No description

logout()

No description

string|null
getUFLocale()

No description

string|null
theme(string $content, bool $print = FALSE, bool $maintenance = FALSE)

If we are using a theming system, invoke theme, else just print the content.

string
getDefaultBlockLocation()

Get the default location for CiviCRM blocks.

bool|mixed|string
getAbsoluteBaseURL()

Get the absolute path to the site's base url.

bool
getRelativeBaseURL()

Get the relative path to the sites base url.

string
getVersion()

No description

string
languageNegotiationURL(string $url, bool $addLanguagePart = TRUE, bool $removeLanguagePart = FALSE)

No description

string|null
cmsRootPath($scriptFilename = NULL)

No description

int|bool
createUser(array $params, string $mail)

No description

updateCMSName(int $ufID, string $email)

No description

bool
isUserLoggedIn()

No description

string
getLoginURL(string $destination = '')

No description

string|NULL
getLoginDestination(CRM_Core_Form $form)

No description

getUfId(string $username)

Determine the native ID of the CMS user.

bool
setUFLocale(string $civicrm_language)

No description

setUserSession(array $data)

Set a init session with user object.

flush()

No description

clearResourceCache()

No description

bool
addScriptUrl(string $url, string $region)

No description

bool
addScript(string $code, string $region)

No description

bool
addStyleUrl(string $url, string $region)

No description

bool
addStyle(string $code, string $region)

No description

setTitle(string $title, string|null $pageTitle = NULL)

No description

array
getDefaultSiteSettings(string $dir)

No description

array
getDefaultFileStorage()

Determine the default location for file storage.

array
getCiviSourceStorage()

Determine the location of the CiviCRM source tree.

userLoginFinalize(array $params = array())

Perform any post login activities required by the UF - For Backdrop this could mean recording a watchdog message about the new session, saving the login timestamp, calling hook_user_login(), etc.

setMySQLTimeZone()

Set timezone in mysql so that timestamp fields show the correct time.

string|false|null
getTimeZoneOffset()

Get timezone from CMS.

string
getTimeZoneString()

No description

mixed
getUniqueIdentifierFromUserObject(object $user)

No description

null|int
getUserIDFromUserObject(object $user)

No description

array
getUser(int $contactID)

Get an array of user details for a contact, containing at minimum the user ID & name.

int|null
getLoggedInUfID()

No description

string|null
getLoggedInUniqueIdentifier()

No description

int
getBestUFID(object $user = NULL)

Return a UFID (user account ID from the UserFramework / CMS system.

string
getBestUFUniqueIdentifier(object $user = NULL)

Return a unique identifier (usually an email address or username) from the UserFramework / CMS system.

array
getModules()

No description

string|null
getUserRecordUrl(int $contactID)

No description

outputError(string $content)

Output code from error function.

logger(string $message)

No description

appendCoreResources(array $list)

Append Drupal js to coreResourcesList.

setHttpHeader(string $name, string $value)

No description

array
synchronizeUsers()

No description

__construct()

No description

bool
formatResourceUrl($url)

Check if a resource url is within the drupal directory and format appropriately.

string
appendCoreDirectoryToResourceBase(string $url)

In instance where civicrm folder has a drupal folder & a civicrm core folder @ the same level append the civicrm folder name to the url See CRM-13737 for discussion of how this allows implementers to alter the folder structure

void
replacePermission(string $oldPerm, array $newPerms)

Find any users/roles/security-principals with the given permission and replace it with one or more permissions.

object
getUserObject($userID)

Load the user object.

null|string
parseDrupalSiteName(string $civicrm_root)

Parse the name of the drupal site.

static 
checkUserNameEmailExists(array $params, array $errors, string $emailName = 'email')

Check if username and email exists in the drupal db.

string
getUsersTableName()

Get the name of the table that stores the user details.

bool
loadBootStrap(array $params = array(), bool $loadUser = TRUE, bool $throwError = TRUE, bool|string $realPath = NULL)

Load Backdrop bootstrap.

og_membership_create(int $ogID, int $userID)

Wrapper for og_membership creation.

og_membership_delete(int $ogID, int $userID)

Wrapper for og_membership deletion.

string
permissionEmails(string $permissionName)

Get all the contact emails for users that have a specific permission.

Details

in CRM_Utils_System_Base at line 53
initialize()

at line 174
appendBreadCrumb(array $breadCrumbs)

Parameters

array $breadCrumbs

at line 199
resetBreadCrumb()

at line 207
addHTMLHead($header)

Parameters

$header

at line 286
mapConfigToSSL()

string postURL(string $action)

Fixme: Why are we overriding the parent function? Seems inconsistent.

This version supplies slightly different params to $this->url (not absolute and html encoded) but why?

Parameters

string $action The default url if one is pre-specified.

Return Value

string The url to post the form.

string url(string $path = NULL, string $query = NULL, bool $absolute = FALSE, string $fragment = NULL, bool $frontend = FALSE, bool $forceBackend = FALSE)

Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)

Parameters

string $path The path being linked to, such as "civicrm/add".
string $query A query string to append to the link.
bool $absolute Whether to force the output to be an absolute link (beginning with http). Useful for links that will be displayed outside the site, such as in an RSS feed.
string $fragment A fragment identifier (named anchor) to append to the link.
bool $frontend This link should be to the CMS front end (applies to WP & Joomla).
bool $forceBackend This link should be to the CMS back end (applies to WP & Joomla).

Return Value

string

at line 307
array|bool authenticate(string $name, string $password, bool $loadCMSBootstrap = FALSE, string $realPath = NULL)

Parameters

string $name The user name.
string $password The password for the above user.
bool $loadCMSBootstrap Load cms bootstrap?.
string $realPath Filename of script

Return Value

array|bool [contactID, ufID, unique string] else false if no auth

setMessage(string $message)

Parameters

string $message The message to set.

at line 382
bool loadUser($username)

Parameters

$username

Return Value

bool

permissionDenied()

at line 481
logout()

updateCategories()

at line 416
string|null getUFLocale()

Return Value

string|null Locale or null for none

in CRM_Utils_System_Base at line 230
string|null theme(string $content, bool $print = FALSE, bool $maintenance = FALSE)

If we are using a theming system, invoke theme, else just print the content.

Parameters

string $content The content that will be themed.
bool $print Are we displaying to the screen or bypassing theming?.
bool $maintenance For maintenance mode.

Return Value

string|null NULL, If $print is FALSE, and some other criteria match up. The themed string, otherwise.

Exceptions

Exception

at line 491
string getDefaultBlockLocation()

Get the default location for CiviCRM blocks.

Return Value

string

in CRM_Utils_System_Base at line 295
bool|mixed|string getAbsoluteBaseURL()

Get the absolute path to the site's base url.

Return Value

bool|mixed|string

in CRM_Utils_System_Base at line 317
bool getRelativeBaseURL()

Get the relative path to the sites base url.

Return Value

bool

string getVersion()

Return Value

string

at line 678
string languageNegotiationURL(string $url, bool $addLanguagePart = TRUE, bool $removeLanguagePart = FALSE)

Parameters

string $url
bool $addLanguagePart
bool $removeLanguagePart

Return Value

string Formatted url.

at line 608
string|null cmsRootPath($scriptFilename = NULL)

Parameters

$scriptFilename

Return Value

string|null Local file system path to CMS root, or NULL if it cannot be determined

at line 42
int|bool createUser(array $params, string $mail)

Parameters

array $params
string $mail Email id for cms user.

Return Value

int|bool uid if user exists, false otherwise

at line 94
updateCMSName(int $ufID, string $email)

Parameters

int $ufID User ID in CMS.
string $email Primary contact email address.

at line 651
bool isUserLoggedIn()

Return Value

bool

at line 153
string getLoginURL(string $destination = '')

Parameters

string $destination If present, add destination to querystring (works for Drupal only).

Return Value

string loginURL for the current CMS

string|NULL getLoginDestination(CRM_Core_Form $form)

Parameters

CRM_Core_Form $form Form object representing the 'current' form - to which the user will be returned.

Return Value

string|NULL destination value for URL

at line 470
getUfId(string $username)

Determine the native ID of the CMS user.

Parameters

string $username

at line 444
bool setUFLocale(string $civicrm_language)

Parameters

string $civicrm_language

Return Value

bool

in CRM_Utils_System_Base at line 453
setUserSession(array $data)

Set a init session with user object.

Parameters

array $data Array with user specific data

flush()

at line 870
clearResourceCache()

at line 222
bool addScriptUrl(string $url, string $region)

Parameters

string $url absolute path to file
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

at line 242
bool addScript(string $code, string $region)

Parameters

string $code javascript code
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

at line 260
bool addStyleUrl(string $url, string $region)

Parameters

string $url absolute path to file
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

at line 274
bool addStyle(string $code, string $region)

Parameters

string $code css code
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

at line 161
setTitle(string $title, string|null $pageTitle = NULL)

Parameters

string $title Title to set in html header
string|null $pageTitle Title to set in html body (if different)

array getDefaultSiteSettings(string $dir)

Parameters

string $dir

Return Value

array
  • $url, (Joomla - non admin url)
    • $siteName,
    • $siteRoot

in CRM_Utils_System_Base at line 582
array getDefaultFileStorage()

Determine the default location for file storage.

FIXME: 1. This was pulled out from a bigger function. It should be split into even smaller pieces and marked abstract. 2. This would be easier to compute by a calling a CMS API, but for whatever reason Civi gets it from config data.

Return Value

array
  • url: string. ex: "http://example.com/sites/foo.com/files/civicrm"
    • path: string. ex: "/var/www/sites/foo.com/files/civicrm"

in CRM_Utils_System_Base at line 631
array getCiviSourceStorage()

Determine the location of the CiviCRM source tree.

FIXME: 1. This was pulled out from a bigger function. It should be split into even smaller pieces and marked abstract. 2. This would be easier to compute by a calling a CMS API, but for whatever reason we take the hard way.

Return Value

array
  • url: string. ex: "http://example.com/sites/all/modules/civicrm"
    • path: string. ex: "/var/www/sites/all/modules/civicrm"

at line 409
userLoginFinalize(array $params = array())

Perform any post login activities required by the UF - For Backdrop this could mean recording a watchdog message about the new session, saving the login timestamp, calling hook_user_login(), etc.

Parameters

array $params FIXME: Document values accepted/required by $params

in CRM_Utils_System_Base at line 694
setMySQLTimeZone()

Set timezone in mysql so that timestamp fields show the correct time.

in CRM_Utils_System_Base at line 708
string|false|null getTimeZoneOffset()

Get timezone from CMS.

Return Value

string|false|null

at line 803
string getTimeZoneString()

Return Value

string Timezone string e.g. 'America/Los_Angeles'

mixed getUniqueIdentifierFromUserObject(object $user)

Parameters

object $user Object as described by the User Framework.

Return Value

mixed Unique identifier from the user Framework system

null|int getUserIDFromUserObject(object $user)

Parameters

object $user Object as described by the User Framework.

Return Value

null|int

array getUser(int $contactID)

Get an array of user details for a contact, containing at minimum the user ID & name.

Parameters

int $contactID

Return Value

array CMS user details including - id - name (ie the system user name.

at line 663
int|null getLoggedInUfID()

Return Value

int|null logged in user uf id.

string|null getLoggedInUniqueIdentifier()

Return Value

string|null logged in user unique identifier

in CRM_Utils_System_Base at line 824
int getBestUFID(object $user = NULL)

Return a UFID (user account ID from the UserFramework / CMS system.

ID is based on the user object passed, defaulting to the logged in user if not passed.

Note that ambiguous situation occurs in CRM_Core_BAO_UFMatch::synchronize - a cleaner approach would seem to be resolving the user id before calling the function.

Note there is already a function getUFId which takes $username as a param - we could add $user as a second param to it but it seems messy - just overloading it because the name is taken.

Parameters

object $user

Return Value

int User ID of UF System

in CRM_Utils_System_Base at line 844
string getBestUFUniqueIdentifier(object $user = NULL)

Return a unique identifier (usually an email address or username) from the UserFramework / CMS system.

This is based on the user object passed, defaulting to the logged in user if not passed.

Note that ambiguous situation occurs in CRM_Core_BAO_UFMatch::synchronize - a cleaner approach would seem to be resolving the unique identifier before calling the function.

Parameters

object $user

Return Value

string unique identifier from the UF System

array getModules()

Return Value

array [CRM_Core_Module]

string|null getUserRecordUrl(int $contactID)

Parameters

int $contactID Contact ID.

Return Value

string|null

bool checkPermissionAddUser()

Return Value

bool

in CRM_Utils_System_Base at line 887
outputError(string $content)

Output code from error function.

Parameters

string $content

logger(string $message)

Parameters

string $message

appendCoreResources(array $list)

Append Drupal js to coreResourcesList.

Parameters

array $list

at line 821
setHttpHeader(string $name, string $value)

Parameters

string $name
string $value

at line 828
array synchronizeUsers()

Return Value

array

__construct()

bool formatResourceUrl($url)

Check if a resource url is within the drupal directory and format appropriately.

Parameters

$url (reference)

Return Value

bool TRUE for internal paths, FALSE for external. The drupal_add_js fn is able to add js more efficiently if it is known to be in the drupal site

string appendCoreDirectoryToResourceBase(string $url)

In instance where civicrm folder has a drupal folder & a civicrm core folder @ the same level append the civicrm folder name to the url See CRM-13737 for discussion of how this allows implementers to alter the folder structure

Parameters

string $url Potential resource url based on standard folder assumptions.

Return Value

string with civicrm-core directory appended if not standard civi dir

at line 746
void replacePermission(string $oldPerm, array $newPerms)

Find any users/roles/security-principals with the given permission and replace it with one or more permissions.

Parameters

string $oldPerm
array $newPerms Array, strings.

Return Value

void

object getUserObject($userID)

Load the user object.

Note this function still works in drupal 6, 7 & 8 but is deprecated in Drupal 8.

Parameters

$userID

Return Value

object

null|string parseDrupalSiteName(string $civicrm_root)

Parse the name of the drupal site.

Parameters

string $civicrm_root

Return Value

null|string

at line 115
static checkUserNameEmailExists(array $params, array $errors, string $emailName = 'email')

Check if username and email exists in the drupal db.

Parameters

array $params Array of name and mail values.
array $errors Array of errors.
string $emailName Field label for the 'email'.

at line 296
protected string getUsersTableName()

Get the name of the table that stores the user details.

Return Value

string

at line 508
bool loadBootStrap(array $params = array(), bool $loadUser = TRUE, bool $throwError = TRUE, bool|string $realPath = NULL)

Load Backdrop bootstrap.

Parameters

array $params Either uid, or name & pass.
bool $loadUser Boolean Require CMS user load.
bool $throwError If true, print error on failure and exit.
bool|string $realPath path to script

Return Value

bool

at line 764
og_membership_create(int $ogID, int $userID)

Wrapper for og_membership creation.

Parameters

int $ogID Organic Group ID.
int $userID Backdrop User ID.

at line 787
og_membership_delete(int $ogID, int $userID)

Wrapper for og_membership deletion.

Parameters

int $ogID Organic Group ID.
int $userID Backdrop User ID.

at line 883
string permissionEmails(string $permissionName)

Get all the contact emails for users that have a specific permission.

Parameters

string $permissionName Name of the permission we are interested in.

Return Value

string a comma separated list of email addresses