/**
* Deprecated property to check if this is a drupal 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
+ *
* @deprecated
* @var bool
+ * TRUE, if the CMS is Drupal.
*/
var $is_drupal = FALSE;
/**
* 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
+ *
* @deprecated
* @var bool
+ * TRUE, if the CMS is Joomla!.
*/
var $is_joomla = FALSE;
- /**
- * 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
- * @deprecated
- * @var bool
- */
+ /**
+ * 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
+ *
+ * @deprecated
+ * @var bool
+ * TRUE, if the CMS is WordPress.
+ */
var $is_wordpress = FALSE;
/**
*/
var $supports_UF_Logging = FALSE;
- /*
- * Does the CMS allow CMS forms to be extended by hooks
+ /**
+ * @var bool
+ * TRUE, if the CMS allows CMS forms to be extended by hooks.
*/
var $supports_form_extensions = FALSE;
* If we are using a theming system, invoke theme, else just print the
* content
*
- * @param string $content the content that will be themed
- * @param boolean $print are we displaying to the screen or bypassing theming?
- * @param boolean $maintenance for maintenance mode
+ * @param string $content
+ * The content that will be themed.
+ * @param bool $print
+ * Are we displaying to the screen or bypassing theming?.
+ * @param bool $maintenance
+ * For maintenance mode.
+ *
+ * @throws Exception
+ * @return string|null
+ * NULL, If $print is FALSE, and some other criteria match up.
+ * The themed string, otherwise.
*
- * @return void prints content on stdout
- * @access public
+ * @todo The return value is inconsistent.
+ * @todo Better to always return, and never print.
*/
- function theme(&$content, $print = FALSE, $maintenance = FALSE) {
+ public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
$ret = FALSE;
// TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function
!$print &&
$config->userFramework == 'WordPress'
) {
+ if (!function_exists('is_admin')) {
+ throw new \Exception('Function "is_admin()" is missing, even though WordPress is the user framework.');
+ }
+ if (!defined('ABSPATH')) {
+ throw new \Exception('Constant "ABSPATH" is not defined, even though WordPress is the user framework.');
+ }
if (is_admin()) {
- require_once (ABSPATH . 'wp-admin/admin-header.php');
+ require_once ABSPATH . 'wp-admin/admin-header.php';
}
else {
- // FIX ME: we need to figure out to replace civicrm content on the frontend pages
+ // FIXME: we need to figure out to replace civicrm content on the frontend pages
}
}
}
else {
print $out;
+ return NULL;
}
}
/**
* @return string
*/
- function getDefaultBlockLocation() {
+ public function getDefaultBlockLocation() {
return 'left';
}
/**
* @return string
*/
- function getVersion() {
+ public function getVersion() {
return 'Unknown';
}
* Format the url as per language Negotiation.
*
* @param string $url
- *
* @param bool $addLanguagePart
* @param bool $removeLanguagePart
*
- * @return string $url, formatted url.
+ * @return string
+ * Formatted url.
* @static
*/
function languageNegotiationURL(
/**
* Determine the location of the CMS root.
*
- * @return string|NULL local file system path to CMS root, or NULL if it cannot be determined
+ * @return string|null
+ * Local file system path to CMS root, or NULL if it cannot be determined
*/
- function cmsRootPath() {
+ public function cmsRootPath() {
return NULL;
}
/**
* Get user login URL for hosting CMS (method declared in each CMS system class)
*
- * @param string $destination - if present, add destination to querystring (works for Drupal only)
+ * @param string $destination
+ * If present, add destination to querystring (works for Drupal only).
*
* @return string - loginURL for the current CMS
* @static
* @throws CRM_Core_Exception
* @return int|NULL
*/
- function getUfId($username) {
+ public function getUfId($username) {
$className = get_class($this);
throw new CRM_Core_Exception("Not implemented: {$className}->getUfId");
}
/**
* Set a init session with user object
*
- * @param array $data array with user specific data
- *
- * @access public
+ * @param array $data
+ * Array with user specific data
*/
- function setUserSession($data) {
+ public function setUserSession($data) {
list($userID, $ufID) = $data;
$session = CRM_Core_Session::singleton();
$session->set('ufID', $ufID);
* Reset any system caches that may be required for proper CiviCRM
* integration.
*/
- function flush() {
+ public function flush() {
// nullop by default
}
/**
* Flush css/js caches
*/
- function clearResourceCache() {
+ public function clearResourceCache() {
// nullop by default
}
/**
* Return default Site Settings
*
- * @param $dir
+ * @param string $dir
*
- * @return array array
+ * @return array
* - $url, (Joomla - non admin url)
* - $siteName,
* - $siteRoot
*/
- function getDefaultSiteSettings($dir) {
+ public function getDefaultSiteSettings($dir) {
$config = CRM_Core_Config::singleton();
$url = $config->userFrameworkBaseURL;
return array($url, NULL, NULL);
* e.g. for drupal: records a watchdog message about the new session, saves the login timestamp,
* calls hook_user op 'login' and generates a new session.
*
- * @param array params
+ * @param array $params
*
* FIXME: Document values accepted/required by $params
*/
- function userLoginFinalize($params = array()){
+ public function userLoginFinalize($params = array()) {
}
/**
* Set timezone in mysql so that timestamp fields show the correct time
*/
- function setMySQLTimeZone(){
+ public function setMySQLTimeZone() {
$timeZoneOffset = $this->getTimeZoneOffset();
- if($timeZoneOffset){
+ if ($timeZoneOffset) {
$sql = "SET time_zone = '$timeZoneOffset'";
CRM_Core_DAO::executequery($sql);
}
/**
* Get timezone from CMS
- * @return boolean|string
- */
- /**
- * Get timezone from Drupal
- * @return boolean|string
+ *
+ * @return string|false|null
*/
- function getTimeZoneOffset(){
+ public function getTimeZoneOffset() {
$timezone = $this->getTimeZoneString();
- if($timezone){
+ if ($timezone) {
$tzObj = new DateTimeZone($timezone);
$dateTime = new DateTime("now", $tzObj);
$tz = $tzObj->getOffset($dateTime);
- if(empty($tz)){
- return false;
+ if (empty($tz)) {
+ return FALSE;
}
- $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz/60)%60));
+ $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz / 60) % 60));
- if($timeZoneOffset > 0){
+ if ($timeZoneOffset > 0) {
$timeZoneOffset = '+' . $timeZoneOffset;
}
return $timeZoneOffset;
}
+ return NULL;
}
/**
* Over-ridable function to get timezone as a string eg.
- * @return string Timezone e.g. 'America/Los_Angeles'
+ *
+ * @return string
+ * Time zone, e.g. 'America/Los_Angeles'
*/
- function getTimeZoneString() {
+ public function getTimeZoneString() {
return date_default_timezone_get();
}
/**
* Get Unique Identifier from UserFramework system (CMS)
- * @param object $user object as described by the User Framework
+ * @param object $user
+ * Object as described by the User Framework.
* @return mixed $uniqueIdentifer Unique identifier from the user Framework system
*
*/
- function getUniqueIdentifierFromUserObject($user) {}
+ public function getUniqueIdentifierFromUserObject($user) {
+ }
/**
* Get User ID from UserFramework system (CMS)
- * @param object $user object as described by the User Framework
+ * @param object $user
+ * Object as described by the User Framework.
* @return mixed <NULL, number>
*
*/
- function getUserIDFromUserObject($user) {}
+ public function getUserIDFromUserObject($user) {
+ }
/**
* Get currently logged in user uf id.
*
* @return int $userID logged in user uf id.
*/
- function getLoggedInUfID() {}
+ public function getLoggedInUfID() {
+ }
/**
* Get currently logged in user unique identifier - this tends to be the email address or user name.
*
* @return string $userID logged in user unique identifier
*/
- function getLoggedInUniqueIdentifier() {}
+ public function getLoggedInUniqueIdentifier() {
+ }
/**
* Return a UFID (user account ID from the UserFramework / CMS system being based on the user object
* @param object $user
* @return int $ufid - user ID of UF System
*/
- function getBestUFID($user = NULL) {
- if($user) {
+ public function getBestUFID($user = NULL) {
+ if ($user) {
return $this->getUserIDFromUserObject($user);
}
return $this->getLoggedInUfID();
* @param object $user
* @return string $uniqueIdentifier - unique identifier from the UF System
*/
- function getBestUFUniqueIdentifier($user = NULL) {
- if($user) {
+ public function getBestUFUniqueIdentifier($user = NULL) {
+ if ($user) {
return $this->getUniqueIdentifierFromUserObject($user);
}
return $this->getLoggedInUniqueIdentifier();
/**
* Get Url to view user record
- * @param integer $contactID Contact ID
+ * @param int $contactID
+ * Contact ID.
*
* @return string
*/
- function getUserRecordUrl($contactID) {
+ public function getUserRecordUrl($contactID) {
return NULL;
}
/**
* Is the current user permitted to add a user
* @return bool
*/
- function checkPermissionAddUser() {
+ public function checkPermissionAddUser() {
return FALSE;
}
* Output code from error function
* @param string $content
*/
- function outputError($content) {
+ public function outputError($content) {
echo CRM_Utils_System::theme($content);
}
/**
* Log error to CMS
*/
- function logger($message) {
+ public function logger($message) {
}
/**
* Append to coreResourcesList
*/
- function appendCoreResources(&$list) {}
+ public function appendCoreResources(&$list) {
+ }
}
-