Merge pull request #4920 from pratikshad/Fixed-webtests
[civicrm-core.git] / CRM / Utils / System.php
index 2aef7f37258190dad4dcbc34b56687fe6e63ea8d..353d59351cad325278a9f55aae808a2c27e5db60 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -65,9 +65,8 @@ class CRM_Utils_System {
    *
    * @return string
    *   The URL fragment.
-   * @access public
    */
-  static function makeURL($urlVar, $includeReset = FALSE, $includeForce = TRUE, $path = NULL, $absolute = FALSE) {
+  public static function makeURL($urlVar, $includeReset = FALSE, $includeForce = TRUE, $path = NULL, $absolute = FALSE) {
     if (empty($path)) {
       $config = CRM_Core_Config::singleton();
       $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET);
@@ -103,13 +102,12 @@ class CRM_Utils_System {
    *   (optional)
    *
    * @return string
-   * @access public
    */
-  static function getLinksUrl($urlVar, $includeReset = FALSE, $includeForce = TRUE, $skipUFVar = TRUE) {
+  public static function getLinksUrl($urlVar, $includeReset = FALSE, $includeForce = TRUE, $skipUFVar = TRUE) {
     // Sort out query string to prevent messy urls
     $querystring = array();
-    $qs          = array();
-    $arrays      = array();
+    $qs = array();
+    $arrays = array();
 
     if (!empty($_SERVER['QUERY_STRING'])) {
       $qs = explode('&', str_replace('&amp;', '&', $_SERVER['QUERY_STRING']));
@@ -184,12 +182,10 @@ class CRM_Utils_System {
    *   (optional) For maintenance mode.
    *
    * @return string
-   *
-   * @access public
    */
-  static function theme(
+  public static function theme(
     &$content,
-    $print       = FALSE,
+    $print = FALSE,
     $maintenance = FALSE
   ) {
     $config = &CRM_Core_Config::singleton();
@@ -202,7 +198,7 @@ class CRM_Utils_System {
    * @param array|string $query
    * @return string
    */
-  static function makeQueryString($query) {
+  public static function makeQueryString($query) {
     if (is_array($query)) {
       $buf = '';
       foreach ($query as $key => $value) {
@@ -232,14 +228,13 @@ class CRM_Utils_System {
    * @param bool $forceBackend
    * @return string
    *   An HTML string containing a link to the given path.
-   * @access public
    */
-  static function url(
+  public static function url(
     $path = NULL,
-    $query    = NULL,
+    $query = NULL,
     $absolute = FALSE,
     $fragment = NULL,
-    $htmlize  = TRUE,
+    $htmlize = TRUE,
     $frontend = FALSE,
     $forceBackend = FALSE
   ) {
@@ -266,7 +261,8 @@ class CRM_Utils_System {
    *
    * @return string
    */
-  static function href($text, $path = NULL, $query = NULL, $absolute = TRUE,
+  public static function href(
+    $text, $path = NULL, $query = NULL, $absolute = TRUE,
     $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE
   ) {
     $url = self::url($path, $query, $absolute, $fragment, $htmlize, $frontend, $forceBackend);
@@ -276,7 +272,7 @@ class CRM_Utils_System {
   /**
    * @return mixed
    */
-  static function permissionDenied() {
+  public static function permissionDenied() {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->permissionDenied();
   }
@@ -284,13 +280,15 @@ class CRM_Utils_System {
   /**
    * @return mixed
    */
-  static function logout() {
+  public static function logout() {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->logout();
   }
 
-  // this is a very drupal specific function for now
-  static function updateCategories() {
+  /**
+   * this is a very drupal specific function for now
+   */
+  public static function updateCategories() {
     $config = CRM_Core_Config::singleton();
     if ($config->userSystem->is_drupal) {
       $config->userSystem->updateCategories();
@@ -300,24 +298,24 @@ class CRM_Utils_System {
   /**
    * What menu path are we currently on. Called for the primary tpl
    *
-   * @return string the current menu path
-   * @access public
+   * @return string
+   *   the current menu path
    */
-  static function currentPath() {
+  public static function currentPath() {
     $config = CRM_Core_Config::singleton();
     return trim(CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET), '/');
   }
 
   /**
-   * This function is called from a template to compose a url.
+   * called from a template to compose a url.
    *
    * @param array $params
    *   List of parameters.
    *
-   * @return string url
-   * @access public
+   * @return string
+   *   url
    */
-  static function crmURL($params) {
+  public static function crmURL($params) {
     $p = CRM_Utils_Array::value('p', $params);
     if (!isset($p)) {
       $p = self::currentPath();
@@ -339,10 +337,8 @@ class CRM_Utils_System {
    *
    * @param string $title
    * @param string $pageTitle
-   *
-   * @access public
    */
-  static function setTitle($title, $pageTitle = NULL) {
+  public static function setTitle($title, $pageTitle = NULL) {
     self::$title = $title;
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->setTitle($title, $pageTitle);
@@ -357,10 +353,8 @@ class CRM_Utils_System {
    *   Refererer should match any str in this array.
    * @param string $default
    *   (optional) The default userContext if no match found.
-   *
-   * @access public
    */
-  static function setUserContext($names, $default = NULL) {
+  public static function setUserContext($names, $default = NULL) {
     $url = $default;
 
     $session = CRM_Core_Session::singleton();
@@ -388,10 +382,8 @@ class CRM_Utils_System {
    *
    * @return string
    *   The class name of the object.
-   *
-   * @access public
    */
-  static function getClassName($object) {
+  public static function getClassName($object) {
     return get_class($object);
   }
 
@@ -400,10 +392,8 @@ class CRM_Utils_System {
    *
    * @param string $url
    *   The URL to provide to the browser via the Location header.
-   *
-   * @access public
    */
-  static function redirect($url = NULL) {
+  public static function redirect($url = NULL) {
     if (!$url) {
       $url = self::url('civicrm/dashboard', 'reset=1');
     }
@@ -436,12 +426,10 @@ class CRM_Utils_System {
    *   (optional) The page title to use for the redirect page.
    * @param string $message
    *   (optional) The message to provide in the body of the redirect page.
-   *
-   * @access public
    */
-  static function jsRedirect(
-    $url     = NULL,
-    $title   = NULL,
+  public static function jsRedirect(
+    $url = NULL,
+    $title = NULL,
     $message = NULL
   ) {
     if (!$url) {
@@ -476,20 +464,16 @@ class CRM_Utils_System {
    * Append an additional breadcrumb tag to the existing breadcrumbs.
    *
    * @param $breadCrumbs
-   *
-   * @access public
    */
-  static function appendBreadCrumb($breadCrumbs) {
+  public static function appendBreadCrumb($breadCrumbs) {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->appendBreadCrumb($breadCrumbs);
   }
 
   /**
    * Reset an additional breadcrumb tag to the existing breadcrumb.
-   *
-   * @access public
    */
-  static function resetBreadCrumb() {
+  public static function resetBreadCrumb() {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->resetBreadCrumb();
   }
@@ -498,10 +482,8 @@ class CRM_Utils_System {
    * Append a string to the head of the HTML file.
    *
    * @param string $bc
-   *
-   * @access public
    */
-  static function addHTMLHead($bc) {
+  public static function addHTMLHead($bc) {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->addHTMLHead($bc);
   }
@@ -514,24 +496,21 @@ class CRM_Utils_System {
    *
    * @return string
    *   The URL to post the form.
-   * @access public
    */
-  static function postURL($action) {
+  public static function postURL($action) {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->postURL($action);
   }
 
   /**
    * Rewrite various system URLs to https.
-   *
-   * @access public
    */
-  static function mapConfigToSSL() {
+  public static function mapConfigToSSL() {
     $config = CRM_Core_Config::singleton();
     $config->userFrameworkResourceURL = str_replace('http://', 'https://', $config->userFrameworkResourceURL);
     $config->resourceBase = $config->userFrameworkResourceURL;
 
-    if (! empty($config->extensionsURL)) {
+    if (!empty($config->extensionsURL)) {
       $config->extensionsURL = str_replace('http://', 'https://', $config->extensionsURL);
     }
 
@@ -542,16 +521,15 @@ class CRM_Utils_System {
    * Get the base URL of the system.
    *
    * @return string
-   * @access public
    */
-  static function baseURL() {
+  public static function baseURL() {
     $config = CRM_Core_Config::singleton();
     return $config->userFrameworkBaseURL;
   }
 
   /**
    */
-  static function authenticateAbort($message, $abort) {
+  public static function authenticateAbort($message, $abort) {
     if ($abort) {
       echo $message;
       self::civiExit(0);
@@ -567,7 +545,7 @@ class CRM_Utils_System {
    *
    * @return bool
    */
-  static function authenticateKey($abort = TRUE) {
+  public static function authenticateKey($abort = TRUE) {
     // also make sure the key is sent and is valid
     $key = trim(CRM_Utils_Array::value('key', $_REQUEST));
 
@@ -616,7 +594,7 @@ class CRM_Utils_System {
    *
    * @return bool
    */
-  static function authenticateScript($abort = TRUE, $name = NULL, $pass = NULL, $storeInSession = TRUE, $loadCMSBootstrap = TRUE, $requireKey = TRUE) {
+  public static function authenticateScript($abort = TRUE, $name = NULL, $pass = NULL, $storeInSession = TRUE, $loadCMSBootstrap = TRUE, $requireKey = TRUE) {
     // auth to make sure the user has a login/password to do a shell operation
     // later on we'll link this to acl's
     if (!$name) {
@@ -648,7 +626,7 @@ class CRM_Utils_System {
       list($userID, $ufID, $randomNumber) = $result;
       if ($userID && $ufID) {
         $config = CRM_Core_Config::singleton();
-        $config->userSystem->setUserSession( array($userID, $ufID) );
+        $config->userSystem->setUserSession(array($userID, $ufID));
       }
       else {
         return self::authenticateAbort(
@@ -676,9 +654,8 @@ class CRM_Utils_System {
    * @param $realPath
    *
    * @return false|array
-   * @access public
    */
-  static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
+  public static function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
     $config = CRM_Core_Config::singleton();
 
     /* Before we do any loading, let's start the session and write to it.
@@ -687,7 +664,7 @@ class CRM_Utils_System {
      * process typically done in CLI and cron scripts. See: CRM-12648
      */
     $session = CRM_Core_Session::singleton();
-    $session->set( 'civicrmInitSession', TRUE );
+    $session->set('civicrmInitSession', TRUE);
 
     $dbDrupal = DB::connect($config->userFrameworkDSN);
     return $config->userSystem->authenticate($name, $password, $loadCMSBootstrap, $realPath);
@@ -698,10 +675,8 @@ class CRM_Utils_System {
    *
    * @param string $message
    *   The message to set.
-   *
-   * @access public
    */
-  static function setUFMessage($message) {
+  public static function setUFMessage($message) {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->setMessage($message);
   }
@@ -714,12 +689,13 @@ class CRM_Utils_System {
    *   The value to check for null.
    * @return bool
    */
-  static function isNull($value) {
+  public static function isNull($value) {
     // FIXME: remove $value = 'null' string test when we upgrade our DAO code to handle passing null in a better way.
     if (!isset($value) || $value === NULL || $value === '' || $value === 'null') {
       return TRUE;
     }
     if (is_array($value)) {
+      // @todo Reuse of the $value variable = asking for trouble.
       foreach ($value as $key => $value) {
         if (!self::isNull($value)) {
           return FALSE;
@@ -740,7 +716,7 @@ class CRM_Utils_System {
    * @return string
    *   The obscured credit card number.
    */
-  static function mungeCreditCard($number, $keep = 4) {
+  public static function mungeCreditCard($number, $keep = 4) {
     $number = trim($number);
     if (empty($number)) {
       return NULL;
@@ -760,17 +736,17 @@ class CRM_Utils_System {
     $s = ob_get_contents();
     ob_end_clean();
 
-    $s        = strip_tags($s, '<h2><th><td>');
-    $s        = preg_replace('/<th[^>]*>([^<]+)<\/th>/', "<info>\\1</info>", $s);
-    $s        = preg_replace('/<td[^>]*>([^<]+)<\/td>/', "<info>\\1</info>", $s);
-    $vTmp     = preg_split('/(<h2>[^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
+    $s = strip_tags($s, '<h2><th><td>');
+    $s = preg_replace('/<th[^>]*>([^<]+)<\/th>/', "<info>\\1</info>", $s);
+    $s = preg_replace('/<td[^>]*>([^<]+)<\/td>/', "<info>\\1</info>", $s);
+    $vTmp = preg_split('/(<h2>[^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
     $vModules = array();
     for ($i = 1; $i < count($vTmp); $i++) {
       if (preg_match('/<h2>([^<]+)<\/h2>/', $vTmp[$i], $vMat)) {
         $vName = trim($vMat[1]);
         $vTmp2 = explode("\n", $vTmp[$i + 1]);
-        foreach ($vTmp2 AS $vOne) {
-          $vPat  = '<info>([^<]+)<\/info>';
+        foreach ($vTmp2 as $vOne) {
+          $vPat = '<info>([^<]+)<\/info>';
           $vPat3 = "/$vPat\s*$vPat\s*$vPat/";
           $vPat2 = "/$vPat\s*$vPat/";
           // 3cols
@@ -801,7 +777,7 @@ class CRM_Utils_System {
    *
    * @return mixed|string
    */
-  static function memory($title = NULL) {
+  public static function memory($title = NULL) {
     static $pid = NULL;
     if (!$pid) {
       $pid = posix_getpid();
@@ -823,7 +799,8 @@ class CRM_Utils_System {
    * @param bool $output
    * @param string $disposition
    */
-  static function download($name, $mimeType, &$buffer,
+  public static function download(
+    $name, $mimeType, &$buffer,
     $ext = NULL,
     $output = TRUE,
     $disposition = 'attachment'
@@ -864,8 +841,8 @@ class CRM_Utils_System {
    * @param bool $log
    *   (optional) Whether to log the memory usage information.
    */
-  static function xMemory($title = NULL, $log = FALSE) {
-    $mem = (float ) xdebug_memory_usage() / (float )(1024);
+  public static function xMemory($title = NULL, $log = FALSE) {
+    $mem = (float ) xdebug_memory_usage() / (float ) (1024);
     $mem = number_format($mem, 5) . ", " . time();
     if ($log) {
       echo "<p>$title: $mem<p>";
@@ -889,7 +866,7 @@ class CRM_Utils_System {
    * @return string
    *   The fixed URL.
    */
-  static function fixURL($url) {
+  public static function fixURL($url) {
     $components = parse_url($url);
 
     if (!$components) {
@@ -909,7 +886,7 @@ class CRM_Utils_System {
    *
    * @return bool
    */
-  static function validCallback($callback) {
+  public static function validCallback($callback) {
     if (self::$_callbacks === NULL) {
       self::$_callbacks = array();
     }
@@ -919,7 +896,7 @@ class CRM_Utils_System {
         list($className, $methodName) = explode('::', $callback);
         $fileName = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
         // ignore errors if any
-        @include_once ($fileName);
+        @include_once $fileName;
         if (!class_exists($className)) {
           self::$_callbacks[$callback] = FALSE;
         }
@@ -953,7 +930,7 @@ class CRM_Utils_System {
    * @param int $limit
    * @return string[]
    */
-  static function explode($separator, $string, $limit) {
+  public static function explode($separator, $string, $limit) {
     $result = explode($separator, $string, $limit);
     for ($i = count($result); $i < $limit; $i++) {
       $result[$i] = NULL;
@@ -969,7 +946,7 @@ class CRM_Utils_System {
    *
    * @return mixed
    */
-  static function checkURL($url, $addCookie = FALSE) {
+  public static function checkURL($url, $addCookie = FALSE) {
     // make a GET request to $url
     $ch = curl_init($url);
     if ($addCookie) {
@@ -979,7 +956,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);
 
     // CRM-13227, CRM-14744: only return the SSL error status
     return (curl_exec($ch) !== FALSE);
@@ -998,7 +975,7 @@ class CRM_Utils_System {
    *   met and we're not aborting due to the failed requirement. If $abort is
    *   TRUE and the requirement fails, this function does not return.
    */
-  static function checkPHPVersion($ver = 5, $abort = TRUE) {
+  public static function checkPHPVersion($ver = 5, $abort = TRUE) {
     $phpVersion = substr(PHP_VERSION, 0, 1);
     if ($phpVersion >= $ver) {
       return TRUE;
@@ -1006,8 +983,8 @@ class CRM_Utils_System {
 
     if ($abort) {
       CRM_Core_Error::fatal(ts('This feature requires PHP Version %1 or greater',
-          array(1 => $ver)
-        ));
+        array(1 => $ver)
+      ));
     }
     return FALSE;
   }
@@ -1018,7 +995,7 @@ class CRM_Utils_System {
    *
    * @return string
    */
-  static function formatWikiURL($string, $encode = FALSE) {
+  public static function formatWikiURL($string, $encode = FALSE) {
     $items = explode(' ', trim($string), 2);
     if (count($items) == 2) {
       $title = $items[1];
@@ -1037,7 +1014,7 @@ class CRM_Utils_System {
    *
    * @return null|string
    */
-  static function urlEncode($url) {
+  public static function urlEncode($url) {
     $items = parse_url($url);
     if ($items === FALSE) {
       return NULL;
@@ -1072,9 +1049,8 @@ class CRM_Utils_System {
    *
    * @return string
    *   civicrm version
-   * @access public
    */
-  static function version() {
+  public static function version() {
     static $version;
 
     if (!$version) {
@@ -1082,7 +1058,7 @@ class CRM_Utils_System {
         array(dirname(__FILE__), '..', '..', 'civicrm-version.php')
       );
       if (file_exists($verFile)) {
-        require_once ($verFile);
+        require_once $verFile;
         if (function_exists('civicrmVersion')) {
           $info = civicrmVersion();
           $version = $info['version'];
@@ -1094,8 +1070,8 @@ class CRM_Utils_System {
           array(dirname(__FILE__), '..', '..', 'xml', 'version.xml')
         );
         if (file_exists($verFile)) {
-          $str     = file_get_contents($verFile);
-          $xmlObj  = simplexml_load_string($str);
+          $str = file_get_contents($verFile);
+          $xmlObj = simplexml_load_string($str);
           $version = (string) $xmlObj->version_no;
         }
       }
@@ -1116,14 +1092,14 @@ class CRM_Utils_System {
    *   Version string to be checked.
    * @return bool
    */
-  static function isVersionFormatValid($version) {
+  public static function isVersionFormatValid($version) {
     return preg_match("/^(\d{1,2}\.){2,3}(\d{1,2}|(alpha|beta)\d{1,2})(\.upgrade)?$/", $version);
   }
 
   /**
    * Wraps or emulates PHP's getallheaders() function.
    */
-  static function getAllHeaders() {
+  public static function getAllHeaders() {
     if (function_exists('getallheaders')) {
       return getallheaders();
     }
@@ -1136,10 +1112,10 @@ class CRM_Utils_System {
         $headers[str_replace(' ',
           '-',
           ucwords(strtolower(str_replace('_',
-                ' ',
-                substr($name, 5)
-              )
-            ))
+              ' ',
+              substr($name, 5)
+            )
+          ))
         )] = $value;
       }
     }
@@ -1148,7 +1124,7 @@ class CRM_Utils_System {
 
   /**
    */
-  static function getRequestHeaders() {
+  public static function getRequestHeaders() {
     if (function_exists('apache_request_headers')) {
       return apache_request_headers();
     }
@@ -1163,7 +1139,7 @@ class CRM_Utils_System {
    * Note that we inline this function in install/civicrm.php, so if you change
    * this function, please go and change the code in the install script as well.
    */
-  static function isSSL( ) {
+  public static function isSSL() {
     return
       (isset($_SERVER['HTTPS']) &&
         !empty($_SERVER['HTTPS']) &&
@@ -1172,7 +1148,7 @@ class CRM_Utils_System {
 
   /**
    */
-  static function redirectToSSL($abort = FALSE) {
+  public static function redirectToSSL($abort = FALSE) {
     $config = CRM_Core_Config::singleton();
     $req_headers = self::getRequestHeaders();
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL') &&
@@ -1186,7 +1162,7 @@ class CRM_Utils_System {
           CRM_Core_Error::fatal('HTTPS is not set up on this machine');
         }
         else {
-      CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert');
+          CRM_Core_Session::setStatus(ts('HTTPS is not set up on this machine'), ts('Warning'), 'alert');
           // admin should be the only one following this
           // since we dont want the user stuck in a bad place
           return;
@@ -1196,7 +1172,7 @@ class CRM_Utils_System {
     }
   }
 
-  /*
+  /**
    * Get logged in user's IP address.
    *
    * Get IP address from HTTP REMOTE_ADDR header. If the CMS is Drupal then use
@@ -1209,19 +1185,14 @@ class CRM_Utils_System {
    * @return string
    *   IP address of logged in user.
    */
-  /**
-   * @param bool $strictIPV4
-   *
-   * @return mixed|string
-   */
-  static function ipAddress($strictIPV4 = TRUE) {
+  public static function ipAddress($strictIPV4 = TRUE) {
     $address = CRM_Utils_Array::value('REMOTE_ADDR', $_SERVER);
 
     $config = CRM_Core_Config::singleton();
     if ($config->userSystem->is_drupal && function_exists('ip_address')) {
       //drupal function handles the server being behind a proxy securely. We still have legacy ipn methods
       // that reach this point without bootstrapping hence the check that the fn exists
-        $address = ip_address();
+      $address = ip_address();
     }
 
     // hack for safari
@@ -1246,9 +1217,8 @@ class CRM_Utils_System {
    *
    * @return string
    *   The previous page URL
-   * @access public
    */
-  static function refererPath() {
+  public static function refererPath() {
     return CRM_Utils_Array::value('HTTP_REFERER', $_SERVER);
   }
 
@@ -1257,9 +1227,8 @@ class CRM_Utils_System {
    *
    * @return string
    *   Base URL of the CRM documentation.
-   * @access public
    */
-  static function getDocBaseURL() {
+  public static function getDocBaseURL() {
     // FIXME: move this to configuration at some stage
     return 'http://book.civicrm.org/';
   }
@@ -1267,10 +1236,10 @@ class CRM_Utils_System {
   /**
    * Returns wiki (alternate) documentation URL base.
    *
-   * @return string documentation url
-   * @access public
+   * @return string
+   *   documentation url
    */
-  static function getWikiBaseURL() {
+  public static function getWikiBaseURL() {
     // FIXME: move this to configuration at some stage
     return 'http://wiki.civicrm.org/confluence/display/CRMDOC/';
   }
@@ -1284,7 +1253,7 @@ class CRM_Utils_System {
    *
    * @param string $page
    *   Title of documentation wiki page.
-   * @param boolean $URLonly
+   * @param bool $URLonly
    *   (optional) Whether to return URL only or full HTML link (default).
    * @param string $text
    *   (optional) Text of HTML link (no effect if $URLonly = false).
@@ -1297,15 +1266,15 @@ class CRM_Utils_System {
    *
    * @return string
    *   URL or link to documentation page, based on provided parameters.
-   * @access public
    */
-  static function docURL2($page, $URLonly = FALSE, $text = NULL, $title = NULL, $style = NULL, $resource = NULL) {
+  public static function docURL2($page, $URLonly = FALSE, $text = NULL, $title = NULL, $style = NULL, $resource = NULL) {
     // if ts function doesn't exist, it means that CiviCRM hasn't been fully initialised yet -
     // return just the URL, no matter what other parameters are defined
     if (!function_exists('ts')) {
       if ($resource == 'wiki') {
-          $docBaseURL = self::getWikiBaseURL();
-      } else {
+        $docBaseURL = self::getWikiBaseURL();
+      }
+      else {
         $docBaseURL = self::getDocBaseURL();
       }
       return $docBaseURL . str_replace(' ', '+', $page);
@@ -1331,11 +1300,10 @@ class CRM_Utils_System {
    * @param array $params
    *   An array of parameters (see CRM_Utils_System::docURL2 method for names)
    *
-   * @return string
+   * @return string|void
    *   URL or link to documentation page, based on provided parameters.
-   * @access public
    */
-  static function docURL($params) {
+  public static function docURL($params) {
 
     if (!isset($params['page'])) {
       return;
@@ -1343,7 +1311,8 @@ class CRM_Utils_System {
 
     if (CRM_Utils_Array::value('resource', $params) == 'wiki') {
       $docBaseURL = self::getWikiBaseURL();
-    } else {
+    }
+    else {
       $docBaseURL = self::getDocBaseURL();
     }
 
@@ -1378,7 +1347,7 @@ class CRM_Utils_System {
    * @return string
    *   The used locale or null for none.
    */
-  static function getUFLocale() {
+  public static function getUFLocale() {
     $config = CRM_Core_Config::singleton();
     return $config->userSystem->getUFLocale();
   }
@@ -1394,7 +1363,7 @@ class CRM_Utils_System {
    * @return string
    *   Response from URL.
    */
-  static function getServerResponse($url, $addCookie = TRUE) {
+  public static function getServerResponse($url, $addCookie = TRUE) {
     CRM_Core_TemporaryErrorScope::ignoreException();
     require_once 'HTTP/Request.php';
     $request = new HTTP_Request($url);
@@ -1422,7 +1391,7 @@ class CRM_Utils_System {
 
   /**
    */
-  static function isDBVersionValid(&$errorMessage) {
+  public static function isDBVersionValid(&$errorMessage) {
     $dbVersion = CRM_Core_BAO_Domain::version();
 
     if (!$dbVersion) {
@@ -1453,8 +1422,8 @@ class CRM_Utils_System {
       // if db.ver > code.ver, sth really wrong
       if (version_compare($dbVersion, $codeVersion) > 0) {
         $errorMessage = '<p>' . ts('Your database is marked with an unexpected version number: %1. The v%2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase you were using until you resolve this problem.',
-          array(1 => $dbVersion, 2 => $codeVersion)
-        ) . '</p>';
+            array(1 => $dbVersion, 2 => $codeVersion)
+          ) . '</p>';
         $errorMessage .= "<p>" . ts('OR if this is a manual install from git, you might want to fix civicrm-version.php file.') . "</p>";
         return FALSE;
       }
@@ -1470,7 +1439,7 @@ class CRM_Utils_System {
    * @param int $status
    *   (optional) Code with which to exit.
    */
-  static function civiExit($status = 0) {
+  public static function civiExit($status = 0) {
     // move things to CiviCRM cache as needed
     CRM_Core_Session::storeSessionObjects();
 
@@ -1480,7 +1449,7 @@ class CRM_Utils_System {
   /**
    * Reset the various system caches and some important static variables.
    */
-  static function flushCache( ) {
+  public static function flushCache() {
     // flush out all cache entries so we can reload new data
     // a bit aggressive, but livable for now
     $cache = CRM_Utils_Cache::singleton();
@@ -1495,15 +1464,16 @@ class CRM_Utils_System {
     CRM_ACL_BAO_Cache::resetCache();
 
     // reset various static arrays used here
-    CRM_Contact_BAO_Contact::$_importableFields =
-      CRM_Contact_BAO_Contact::$_exportableFields =
-      CRM_Contribute_BAO_Contribution::$_importableFields =
-      CRM_Contribute_BAO_Contribution::$_exportableFields =
-      CRM_Pledge_BAO_Pledge::$_exportableFields =
-      CRM_Contribute_BAO_Query::$_contributionFields =
-      CRM_Core_BAO_CustomField::$_importFields =
-      CRM_Core_BAO_Cache::$_cache =
-      CRM_Core_DAO::$_dbColumnValueCache = NULL;
+    CRM_Contact_BAO_Contact::$_importableFields
+      = CRM_Contact_BAO_Contact::$_exportableFields
+      = CRM_Contribute_BAO_Contribution::$_importableFields
+      = CRM_Contribute_BAO_Contribution::$_exportableFields
+      = CRM_Pledge_BAO_Pledge::$_exportableFields
+      = CRM_Contribute_BAO_Query::$_contributionFields
+      = CRM_Core_BAO_CustomField::$_importFields
+      = CRM_Core_BAO_Cache::$_cache
+      = CRM_Core_DAO::$_dbColumnValueCache
+      = NULL;
 
     CRM_Core_OptionGroup::flushAll();
     CRM_Utils_PseudoConstant::flushAll();
@@ -1519,8 +1489,7 @@ class CRM_Utils_System {
    * @param bool $throwError
    * @param $realPath
    */
-  static function loadBootStrap($params = array(
-    ), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
+  public static function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
     if (!is_array($params)) {
       $params = array();
     }
@@ -1551,7 +1520,7 @@ class CRM_Utils_System {
 
   /**
    */
-  static function baseCMSURL() {
+  public static function baseCMSURL() {
     static $_baseURL = NULL;
     if (!$_baseURL) {
       $config = CRM_Core_Config::singleton();
@@ -1569,7 +1538,8 @@ class CRM_Utils_System {
             DIRECTORY_SEPARATOR . 'sites' .
             DIRECTORY_SEPARATOR . 'all' .
             DIRECTORY_SEPARATOR . 'modules'
-          ) === FALSE) {
+          ) === FALSE
+        ) {
           $startPos = strpos($civicrm_root,
             DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR
           );
@@ -1597,7 +1567,7 @@ class CRM_Utils_System {
    * @param string $url
    * @return string
    */
-  static function relativeURL($url) {
+  public static function relativeURL($url) {
     // check if url is relative, if so return immediately
     if (substr($url, 0, 4) != 'http') {
       return $url;
@@ -1622,10 +1592,9 @@ class CRM_Utils_System {
    * @param string $url
    * @param bool $removeLanguagePart
    *
-   * @internal param bool $remoteLanguagePart
    * @return string
    */
-  static function absoluteURL($url, $removeLanguagePart = FALSE) {
+  public static function absoluteURL($url, $removeLanguagePart = FALSE) {
     // check if url is already absolute, if so return immediately
     if (substr($url, 0, 4) == 'http') {
       return $url;
@@ -1644,13 +1613,14 @@ class CRM_Utils_System {
   }
 
   /**
-   * Function to clean url, replaces first '&' with '?'
+   * Clean url, replaces first '&' with '?'
    *
    * @param string $url
    *
-   * @return string $url, clean url
+   * @return string
+   *   , clean url
    */
-  static function cleanUrl($url) {
+  public static function cleanUrl($url) {
     if (!$url) {
       return NULL;
     }
@@ -1670,9 +1640,11 @@ class CRM_Utils_System {
    * @param bool $addLanguagePart
    * @param bool $removeLanguagePart
    *
-   * @return string $url, formatted url.
+   * @return string
+   *   , formatted url.
    */
-  static function languageNegotiationURL($url,
+  public static function languageNegotiationURL(
+    $url,
     $addLanguagePart = TRUE,
     $removeLanguagePart = FALSE
   ) {
@@ -1693,7 +1665,8 @@ class CRM_Utils_System {
    *   (optional) Sent by contribution/event reg/profile pages which uses a id
    *   specific extra file name if present.
    */
-  static function appendTPLFile($fileName,
+  public static function appendTPLFile(
+    $fileName,
     &$content,
     $overideFileName = NULL
   ) {
@@ -1725,9 +1698,8 @@ class CRM_Utils_System {
    *   An array of files that exist in one or more of the directories that are
    *   referenced by the relative path when appended to each element of the PHP
    *   include path.
-   * @access public
    */
-  static function listIncludeFiles($relpath) {
+  public static function listIncludeFiles($relpath) {
     $file_list = array();
     $inc_dirs = explode(PATH_SEPARATOR, get_include_path());
     foreach ($inc_dirs as $inc_dir) {
@@ -1764,12 +1736,10 @@ class CRM_Utils_System {
    * @return array
    *   List of plugins, where the plugin name is both the key and the value of
    *   each element.
-   * @access public
    */
-  static function getPluginList($relpath, $fext = '.php', $skipList = array(
-    )) {
-    $fext_len  = strlen($fext);
-    $plugins   = array();
+  public static function getPluginList($relpath, $fext = '.php', $skipList = array()) {
+    $fext_len = strlen($fext);
+    $plugins = array();
     $inc_files = CRM_Utils_System::listIncludeFiles($relpath);
     foreach ($inc_files as $inc_file) {
       if (substr($inc_file, 0 - $fext_len) == $fext) {
@@ -1784,9 +1754,8 @@ class CRM_Utils_System {
   // getPluginList()
 
   /**
-   *
    */
-  static function executeScheduledJobs() {
+  public static function executeScheduledJobs() {
     $facility = new CRM_Core_JobManager();
     $facility->execute(FALSE);
 
@@ -1833,7 +1802,7 @@ class CRM_Utils_System {
    *
    * @return bool
    */
-  static function isDevelopment() {
+  public static function isDevelopment() {
     static $cache = NULL;
     if ($cache === NULL) {
       global $civicrm_root;
@@ -1845,7 +1814,7 @@ class CRM_Utils_System {
   /**
    * @return bool
    */
-  static function isInUpgradeMode() {
+  public static function isInUpgradeMode() {
     $args = explode('/', $_GET['q']);
     $upgradeInProcess = CRM_Core_Session::singleton()->get('isUpgradePending');
     if ((isset($args[1]) && $args[1] == 'upgrade') || $upgradeInProcess) {
@@ -1862,17 +1831,19 @@ class CRM_Utils_System {
    * 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) {
+   * @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
+   */
+  public 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) {