X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem.php;h=94fc2b69b93aa79a6d158edf10cc7981e1c0e000;hb=4464ba1a00029982312455fd0f063debf281e942;hp=76a2c1dfabd33da78cb47266957046209bf477a9;hpb=03298d98322f2da05e2ab30cb0e2d5b90df47ab3;p=civicrm-core.git diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 76a2c1dfab..94fc2b69b9 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -183,6 +183,8 @@ class CRM_Utils_System { * @param bool $maintenance * (optional) For maintenance mode. * + * @return string + * * @access public */ static function theme( @@ -977,7 +979,7 @@ class CRM_Utils_System { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // lets capture the return stuff rather than echo - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE ); return curl_exec($ch); } @@ -1164,7 +1166,7 @@ class CRM_Utils_System { return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && - strtolower($_SERVER['HTTPS']) != 'off') ? true : false; + strtolower($_SERVER['HTTPS']) != 'off') ? TRUE : FALSE; } /** @@ -1392,7 +1394,7 @@ class CRM_Utils_System { * Response from URL. */ static function getServerResponse($url, $addCookie = TRUE) { - $errorScope = CRM_Core_TemporaryErrorScope::ignoreException(); + CRM_Core_TemporaryErrorScope::ignoreException(); require_once 'HTTP/Request.php'; $request = new HTTP_Request($url); @@ -1852,4 +1854,54 @@ class CRM_Utils_System { return FALSE; } } + + /** + * Determine the standard URL for viewing or editing the specified link + * + * This function delegates the decision-making to (a) the hook system and + * (b) the BAO system. + * + * @param array $crudLinkSpec with keys: + * - action: int, CRM_Core_Action::UPDATE or CRM_Core_Action::VIEW [default: VIEW] + * - entity_table: string, eg "civicrm_contact" + * - entity_id: int + * @return array|NULL NULL if unavailable, or an array. array has keys: + * - path: string + * - query: array + * - title: string + * - url: string + */ + static function createDefaultCrudLink($crudLinkSpec) { + $crudLinkSpec['action'] = CRM_Utils_Array::value('action', $crudLinkSpec, CRM_Core_Action::VIEW); + $daoClass = CRM_Core_DAO_AllCoreTables::getClassForTable($crudLinkSpec['entity_table']); + if (!$daoClass) { + return NULL; + } + + $baoClass = str_replace('_DAO_', '_BAO_', $daoClass); + if (!class_exists($baoClass)) { + return NULL; + } + + $bao = new $baoClass(); + $bao->id = $crudLinkSpec['entity_id']; + if (!$bao->find(TRUE)) { + return NULL; + } + + $link = array(); + CRM_Utils_Hook::crudLink($crudLinkSpec, $bao, $link); + if (empty($link) && is_callable(array($bao, 'createDefaultCrudLink'))) { + $link = $bao->createDefaultCrudLink($crudLinkSpec); + } + + if (!empty($link)) { + if (!isset($link['url'])) { + $link['url'] = self::url($link['path'], $link['query'], TRUE, NULL, FALSE); + } + return $link; + } + + return NULL; + } }