INFRA-132 - Docblock formatting fixes
[civicrm-core.git] / CRM / Utils / System / Drupal6.php
index 5d8f9f36ebf21705d3879885b28d3c7d564ddc0f..1d2cf0fdd79047972183b912cecaedf459b3dd5f 100644 (file)
@@ -49,7 +49,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * @param bool $maintenance
    *   For maintenance mode.
    *
-   * @return void           prints content on stdout
+   * @return void
+   *   prints content on stdout
    */
   public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
     // TODO: Simplify; this was copied verbatim from CiviCRM 3.4's multi-UF theming function, but that's more complex than necessary
@@ -78,12 +79,11 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * Create a user in Drupal.
    *
    * @param array $params
-   *   Associated array.
    * @param string $mail
    *   Email id for cms user.
    *
-   * @return uid if user exists, false otherwise
-   *
+   * @return int|bool
+   *   uid if user exists, false otherwise
    */
   public function createUser(&$params, $mail) {
     $form_state = array();
@@ -121,15 +121,11 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
     return $form_state['user']->uid;
   }
 
-  /*
-   *  Change user name in host CMS
-   *
-   *  @param integer $ufID User ID in CMS
-   *  @param string $ufName User name
-   */
   /**
-   * @param int $ufID
-   * @param string $ufName
+   * Change user name in host CMS
+   *
+   * @param int $ufID User ID in CMS
+   * @param string $ufName User name
    */
   public function updateCMSName($ufID, $ufName) {
     // CRM-5555
@@ -157,8 +153,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
     $config = CRM_Core_Config::singleton();
 
-    $dao   = new CRM_Core_DAO();
-    $name  = $dao->escape(CRM_Utils_Array::value('name', $params));
+    $dao = new CRM_Core_DAO();
+    $name = $dao->escape(CRM_Utils_Array::value('name', $params));
     $email = $dao->escape(CRM_Utils_Array::value('mail', $params));
     _user_edit_validate(NULL, $params);
     $errors = form_get_errors();
@@ -207,7 +203,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
             array(1 => $email)
           );
         }
-        else{
+        else {
           $errors[$emailName] = ts('This email %1 is already registered. Please select another email.',
             array(1 => $email)
           );
@@ -222,8 +218,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    *
    * @param CRM_Core_Form $form
    *   Form object representing the 'current' form - to which the user will be returned.
-   * @return string $destination destination value for URL
-   *
+   * @return string
+   *   destination value for URL
    */
   public function getLoginDestination(&$form) {
     $args = NULL;
@@ -332,14 +328,15 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Add a script file
    *
-   * @param $url: string, absolute path to file
-   * @param $region
-   *   String, location within the document: 'html-header', 'page-header', 'page-footer'.
+   * @param $url : string, absolute path to file
+   * @param string $region
+   *   location within the document: 'html-header', 'page-header', 'page-footer'.
    *
    * Note: This function is not to be called directly
    * @see CRM_Core_Region::render()
    *
-   * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+   * @return bool
+   *   TRUE if we support this operation in this CMS, FALSE otherwise
    */
   public function addScriptUrl($url, $region) {
     // CRM-15450 - D6 doesn't order internal/external links correctly so we can't use drupal_add_js
@@ -349,14 +346,15 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Add an inline script
    *
-   * @param $code: string, javascript code
-   * @param $region
-   *   String, location within the document: 'html-header', 'page-header', 'page-footer'.
+   * @param $code : string, javascript code
+   * @param string $region
+   *   location within the document: 'html-header', 'page-header', 'page-footer'.
    *
    * Note: This function is not to be called directly
    * @see CRM_Core_Region::render()
    *
-   * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+   * @return bool
+   *   TRUE if we support this operation in this CMS, FALSE otherwise
    */
   public function addScript($code, $region) {
     // CRM-15450 - ensure scripts are in correct order
@@ -366,14 +364,15 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Add a css file
    *
-   * @param $url: string, absolute path to file
-   * @param $region
-   *   String, location within the document: 'html-header', 'page-header', 'page-footer'.
+   * @param $url : string, absolute path to file
+   * @param string $region
+   *   location within the document: 'html-header', 'page-header', 'page-footer'.
    *
    * Note: This function is not to be called directly
    * @see CRM_Core_Region::render()
    *
-   * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+   * @return bool
+   *   TRUE if we support this operation in this CMS, FALSE otherwise
    */
   public function addStyleUrl($url, $region) {
     if ($region != 'html-header' || !$this->formatResourceUrl($url)) {
@@ -386,14 +385,15 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Add an inline style
    *
-   * @param $code: string, css code
-   * @param $region
-   *   String, location within the document: 'html-header', 'page-header', 'page-footer'.
+   * @param $code : string, css code
+   * @param string $region
+   *   location within the document: 'html-header', 'page-header', 'page-footer'.
    *
    * Note: This function is not to be called directly
    * @see CRM_Core_Region::render()
    *
-   * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+   * @return bool
+   *   TRUE if we support this operation in this CMS, FALSE otherwise
    */
   public function addStyle($code, $region) {
     return FALSE;
@@ -417,7 +417,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * @param mix $action
    *   The default action if one is pre-specified.
    *
-   * @return string the url to post the form
+   * @return string
+   *   the url to post the form
    */
   public function postURL($action) {
     if (!empty($action)) {
@@ -438,9 +439,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    *   Load cms bootstrap?.
    * @param NULL|string $realPath filename of script
    *
-   * @return mixed false if no auth
-   *               array(
-   *  contactID, ufID, unique string ) if success
+   * @return array|bool
+   *   [contactID, ufID, uniqueString] if success else false if no auth
    */
   public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
     //@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare
@@ -460,10 +460,10 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
     }
 
     $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
-    $dbpassword   = md5($password);
-    $name       = $dbDrupal->escapeSimple($strtolower($name));
-    $sql        = 'SELECT u.* FROM ' . $config->userFrameworkUsersTableName . " u WHERE LOWER(u.name) = '$name' AND u.pass = '$dbpassword' AND u.status = 1";
-    $query      = $dbDrupal->query($sql);
+    $dbpassword = md5($password);
+    $name = $dbDrupal->escapeSimple($strtolower($name));
+    $sql = 'SELECT u.* FROM ' . $config->userFrameworkUsersTableName . " u WHERE LOWER(u.name) = '$name' AND u.pass = '$dbpassword' AND u.status = 1";
+    $query = $dbDrupal->query($sql);
 
     $user = NULL;
     // need to change this to make sure we matched only one row
@@ -473,13 +473,13 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
       if (!$contactID) {
         return FALSE;
       }
-      else{//success
+      else { //success
         if ($loadCMSBootstrap) {
           $bootStrapParams = array();
           if ($name && $password) {
             $bootStrapParams = array(
-                'name' => $name,
-                'pass' => $password,
+              'name' => $name,
+              'pass' => $password,
             );
           }
           CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
@@ -542,7 +542,6 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    *
    * @param string $message
    *   The message to set.
-   *
    */
   public function setMessage($message) {
     drupal_set_message($message);
@@ -566,7 +565,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Get the locale set in the hosting CMS
    *
-   * @return string  with the locale or null for none
+   * @return string
+   *   with the locale or null for none
    */
   public function getUFLocale() {
     // return CiviCRM’s xx_YY locale that either matches Drupal’s Chinese locale
@@ -714,7 +714,6 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   }
 
   /**
-   *
    */
   public function cmsRootPath($scriptFilename = NULL) {
     $cmsRoot = $valid = NULL;
@@ -764,7 +763,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Check is user logged in.
    *
-   * @return boolean true/false.
+   * @return boolean
    */
   public function isUserLoggedIn() {
     $isloggedIn = FALSE;
@@ -778,7 +777,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Get currently logged in user uf id.
    *
-   * @return int $userID logged in user uf id.
+   * @return int
+   *   $userID logged in user uf id.
    */
   public function getLoggedInUfID() {
     $ufID = NULL;
@@ -800,7 +800,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * @param bool $addLanguagePart
    * @param bool $removeLanguagePart
    *
-   * @return string $url, formatted url.
+   * @return string
+   *   , formatted url.
    * @static
    */
   public function languageNegotiationURL($url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE) {
@@ -823,8 +824,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
         $language->prefix &&
         in_array($mode, array(
           LANGUAGE_NEGOTIATION_PATH,
-            LANGUAGE_NEGOTIATION_PATH_DEFAULT,
-          ))
+          LANGUAGE_NEGOTIATION_PATH_DEFAULT,
+        ))
       ) {
 
         if ($addLanguagePart) {
@@ -849,11 +850,11 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
           //kinda hackish but not sure how to do it right
           //hope http_build_url() will help at some point.
           if (is_array($parseUrl) && !empty($parseUrl)) {
-            $urlParts           = explode('/', $url);
-            $hostKey            = array_search($parseUrl['host'], $urlParts);
-            $ufUrlParts         = parse_url(CIVICRM_UF_BASEURL);
+            $urlParts = explode('/', $url);
+            $hostKey = array_search($parseUrl['host'], $urlParts);
+            $ufUrlParts = parse_url(CIVICRM_UF_BASEURL);
             $urlParts[$hostKey] = $ufUrlParts['host'];
-            $url                = implode('/', $urlParts);
+            $url = implode('/', $urlParts);
           }
         }
       }
@@ -866,9 +867,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * Find any users/roles/security-principals with the given permission
    * and replace it with one or more permissions.
    *
-   * @param $oldPerm
-   *   String.
-   * @param $newPerms
+   * @param string $oldPerm
+   * @param array $newPerms
    *   Array, strings.
    *
    * @return void
@@ -894,7 +894,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
   /**
    * Get a list of all installed modules, including enabled and disabled ones
    *
-   * @return array CRM_Core_Module
+   * @return array
+   *   CRM_Core_Module
    */
   public function getModules() {
     $result = array();
@@ -911,7 +912,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * @param string $destination
    *   If present, add destination to querystring (works for Drupal only).
    *
-   * @return string - loginURL for the current CMS
+   * @return string
+   *   loginURL for the current CMS
    * @static
    */
   public function getLoginURL($destination = '') {
@@ -951,7 +953,8 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
 
   /**
    * Over-ridable function to get timezone as a string eg.
-   * @return string Timezone e.g. 'America/Los_Angeles'
+   * @return string
+   *   Timezone e.g. 'America/Los_Angeles'
    */
   public function getTimeZoneString() {
     global $user;