codespell: CRM/*
[civicrm-core.git] / CRM / Core / BAO / Block.php
index 72043e6528c60111baee7c954c87dd429fe54781..31317569558d2857811272d010fd224a45665f9f 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  * add static functions to include some common functionality
@@ -38,7 +38,7 @@
 class CRM_Core_BAO_Block {
 
   /**
-   * Fields that are required for a valid block
+   * Fields that are required for a valid block.
    */
   static $requiredBlockFields = array(
     'email' => array('email'),
@@ -57,8 +57,7 @@ class CRM_Core_BAO_Block {
    *   Input parameters to find object.
    *
    * @return array
-   *   of $block objects.
-   * @static
+   *   Array of $block objects.
    */
   public static function &getValues($blockName, $params) {
     if (empty($params)) {
@@ -104,8 +103,7 @@ class CRM_Core_BAO_Block {
    *   Name of the above object.
    *
    * @return array
-   *   of $block objects.
-   * @static
+   *   Array of $block objects.
    */
   public static function retrieveBlock(&$block, $blockName) {
     // we first get the primary location due to the order by clause
@@ -128,16 +126,15 @@ class CRM_Core_BAO_Block {
   }
 
   /**
-   * Check if the current block object has any valid data
+   * Check if the current block object has any valid data.
    *
    * @param array $blockFields
    *   Array of fields that are of interest for this object.
    * @param array $params
    *   Associated array of submitted fields.
    *
-   * @return boolean
+   * @return bool
    *   true if the block has data, otherwise false
-   * @static
    */
   public static function dataExists($blockFields, &$params) {
     foreach ($blockFields as $field) {
@@ -149,16 +146,15 @@ class CRM_Core_BAO_Block {
   }
 
   /**
-   * Check if the current block exits
+   * Check if the current block exits.
    *
    * @param string $blockName
    *   Bloack name.
    * @param array $params
    *   Associated array of submitted fields.
    *
-   * @return boolean
+   * @return bool
    *   true if the block exits, otherwise false
-   * @static
    */
   public static function blockExists($blockName, &$params) {
     // return if no data present
@@ -170,7 +166,7 @@ class CRM_Core_BAO_Block {
   }
 
   /**
-   * Get all block ids for a contact
+   * Get all block ids for a contact.
    *
    * @param string $blockName
    *   Block name.
@@ -183,7 +179,6 @@ class CRM_Core_BAO_Block {
    * @return array
    *   formatted array of block ids
    *
-   * @static
    */
   public static function getBlockIds($blockName, $contactId = NULL, $entityElements = NULL, $updateBlankLocInfo = FALSE) {
     $allBlocks = array();
@@ -215,7 +210,7 @@ class CRM_Core_BAO_Block {
   }
 
   /**
-   * Takes an associative array and creates a block
+   * Takes an associative array and creates a block.
    *
    * @param string $blockName
    *   Block name.
@@ -226,7 +221,6 @@ class CRM_Core_BAO_Block {
    *
    * @return object
    *   CRM_Core_BAO_Block object on success, null otherwise
-   * @static
    */
   public static function create($blockName, &$params, $entity = NULL, $contactId = NULL) {
     if (!self::blockExists($blockName, $params)) {
@@ -398,7 +392,7 @@ class CRM_Core_BAO_Block {
   }
 
   /**
-   * Delete block
+   * Delete block.
    *
    * @param string $blockName
    *   Block name.
@@ -406,7 +400,6 @@ class CRM_Core_BAO_Block {
    *   Associates array.
    *
    * @return void
-   * @static
    */
   public static function blockDelete($blockName, $params) {
     $name = ucfirst($blockName);
@@ -421,9 +414,8 @@ class CRM_Core_BAO_Block {
     $block = new $baoString();
 
     $block->copyValues($params);
-    /*
-     * CRM-11006 add call to pre and post hook for delete action
-     */
+
+    // CRM-11006 add call to pre and post hook for delete action
     CRM_Utils_Hook::pre('delete', $name, $block->id, CRM_Core_DAO::$_nullArray);
     $block->delete();
     CRM_Utils_Hook::post('delete', $name, $block->id, $block);
@@ -447,7 +439,6 @@ class CRM_Core_BAO_Block {
    * @param $class
    *
    * @throws API_Exception
-   * @static
    */
   public static function handlePrimary(&$params, $class) {
     $table = CRM_Core_DAO_AllCoreTables::getTableForClass($class);
@@ -473,7 +464,7 @@ class CRM_Core_BAO_Block {
     if (!empty($params['is_primary'])) {
       $sql = "UPDATE $table SET is_primary = 0 WHERE contact_id = %1";
       $sqlParams = array(1 => array($contactId, 'Integer'));
-      // we don't want to create unecessary entries in the log_ tables so exclude the one we are working on
+      // we don't want to create unnecessary entries in the log_ tables so exclude the one we are working on
       if (!empty($params['id'])) {
         $sql .= " AND id <> %2";
         $sqlParams[2] = array($params['id'], 'Integer');
@@ -514,7 +505,7 @@ class CRM_Core_BAO_Block {
   }
 
   /**
-   * Sort location array so primary element is first
+   * Sort location array so primary element is first.
    *
    * @param array $locations
    */
@@ -527,7 +518,7 @@ class CRM_Core_BAO_Block {
    * (sort function for sortPrimaryFirst)
    * @param array $location1
    * @param array $location2
-   * @return number
+   * @return int
    */
   public static function primaryComparison($location1, $location2) {
     $l1 = CRM_Utils_Array::value('is_primary', $location1);
@@ -537,4 +528,5 @@ class CRM_Core_BAO_Block {
     }
     return ($l1 < $l2) ? -1 : 1;
   }
+
 }