* @return array
*/
public static function relTables() {
- static $relTables;
- // Setting these merely prevents enotices - but it may be more appropriate not to add the user table below
- // if the url can't be retrieved. A more standardised way to retrieve them is.
- // CRM_Core_Config::singleton()->userSystem->getUserRecordUrl() - however that function takes a contact_id &
- // we may need a different function when it is not known.
- $title = $userRecordUrl = '';
+ if (!isset(Civi::$statics[__CLASS__]['relTables'])) {
- $config = CRM_Core_Config::singleton();
- if ($config->userSystem->is_drupal) {
- $userRecordUrl = CRM_Utils_System::url('user/%ufid');
- $title = ts('%1 User: %2; user id: %3', array(1 => $config->userFramework, 2 => '$ufname', 3 => '$ufid'));
- }
- elseif ($config->userFramework == 'Joomla') {
- $userRecordUrl = $config->userSystem->getVersion() > 1.5 ? $config->userFrameworkBaseURL . "index.php?option=com_users&view=user&task=user.edit&id=" . '%ufid' : $config->userFrameworkBaseURL . "index2.php?option=com_users&view=user&task=edit&id[]=" . '%ufid';
- $title = ts('%1 User: %2; user id: %3', array(1 => $config->userFramework, 2 => '$ufname', 3 => '$ufid'));
- }
+ // Setting these merely prevents enotices - but it may be more appropriate not to add the user table below
+ // if the url can't be retrieved. A more standardised way to retrieve them is.
+ // CRM_Core_Config::singleton()->userSystem->getUserRecordUrl() - however that function takes a contact_id &
+ // we may need a different function when it is not known.
+ $title = $userRecordUrl = '';
+
+ $config = CRM_Core_Config::singleton();
+ if ($config->userSystem->is_drupal) {
+ $userRecordUrl = CRM_Utils_System::url('user/%ufid');
+ $title = ts('%1 User: %2; user id: %3', array(1 => $config->userFramework, 2 => '$ufname', 3 => '$ufid'));
+ }
+ elseif ($config->userFramework == 'Joomla') {
+ $userRecordUrl = $config->userSystem->getVersion() > 1.5 ? $config->userFrameworkBaseURL . "index.php?option=com_users&view=user&task=user.edit&id=" . '%ufid' : $config->userFrameworkBaseURL . "index2.php?option=com_users&view=user&task=edit&id[]=" . '%ufid';
+ $title = ts('%1 User: %2; user id: %3', array(1 => $config->userFramework, 2 => '$ufname', 3 => '$ufid'));
+ }
- if (!$relTables) {
$relTables = array(
'rel_table_contributions' => array(
'title' => ts('Contributions'),
// Allow hook_civicrm_merge() to adjust $relTables
CRM_Utils_Hook::merge('relTables', $relTables);
+
+ // Cache the results in a static variable
+ Civi::$statics[__CLASS__]['relTables'] = $relTables;
}
- return $relTables;
+
+ return Civi::$statics[__CLASS__]['relTables'];
}
/**
* We treat multi-valued custom sets as "related tables" similar to activities, contributions, etc.
* @param string $request
* 'relTables' or 'cidRefs'.
+ * @return array
* @see CRM-13836
*/
public static function getMultiValueCustomSets($request) {
- static $data = NULL;
- if ($data === NULL) {
+
+ if (!isset(Civi::$statics[__CLASS__]['multiValueCustomSets'])) {
$data = array(
'relTables' => array(),
'cidRefs' => array(),
'url' => CRM_Utils_System::url('civicrm/contact/view', 'reset=1&force=1&cid=$cid' . $urlSuffix),
);
}
+
+ // Store the result in a static variable cache
+ Civi::$statics[__CLASS__]['multiValueCustomSets'] = $data;
}
- return $data[$request];
+
+ return Civi::$statics[__CLASS__]['multiValueCustomSets'][$request];
}
/**