X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FBlock.php;h=fcf9f3324b28301a0702a5fac466490f4505a4cf;hb=725b3de6f03330ab5e310f397fc0336fe551ec6f;hp=dcffc8bd93d3423dd6073cfd87f77d350df51204;hpb=a946aa64b981cfd2738fa06fa9ce34dd5b76f5f7;p=civicrm-core.git diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index dcffc8bd93..fcf9f3324b 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -38,13 +38,13 @@ 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'), 'phone' => array('phone'), 'im' => array('name'), - 'openid' => array('openid') + 'openid' => array('openid'), ); /** @@ -56,8 +56,8 @@ class CRM_Core_BAO_Block { * @param array $params * Input parameters to find object. * - * @return array of $block objects. - * @static + * @return array + * Array of $block objects. */ public static function &getValues($blockName, $params) { if (empty($params)) { @@ -84,8 +84,8 @@ class CRM_Core_BAO_Block { $count = 1; foreach ($blockIds as $blockId) { $block = new $BAOString(); - $block->id = $blockId['id']; - $getBlocks = self::retrieveBlock($block, $blockName); + $block->id = $blockId['id']; + $getBlocks = self::retrieveBlock($block, $blockName); $blocks[$count++] = array_pop($getBlocks); } } @@ -102,8 +102,8 @@ class CRM_Core_BAO_Block { * @param string $blockName * Name of the above object. * - * @return array of $block objects. - * @static + * @return array + * Array of $block objects. */ public static function retrieveBlock(&$block, $blockName) { // we first get the primary location due to the order by clause @@ -126,15 +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 true if the block has data, otherwise false - * @static + * @return bool + * true if the block has data, otherwise false */ public static function dataExists($blockFields, &$params) { foreach ($blockFields as $field) { @@ -146,15 +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 true if the block exits, otherwise false - * @static + * @return bool + * true if the block exits, otherwise false */ public static function blockExists($blockName, &$params) { // return if no data present @@ -166,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. @@ -176,9 +176,9 @@ class CRM_Core_BAO_Block { * @param null $entityElements * @param bool $updateBlankLocInfo * - * @return array $contactBlockIds formatted array of block ids + * @return array + * formatted array of block ids * - * @static */ public static function getBlockIds($blockName, $contactId = NULL, $entityElements = NULL, $updateBlankLocInfo = FALSE) { $allBlocks = array(); @@ -210,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. @@ -219,17 +219,17 @@ class CRM_Core_BAO_Block { * @param null $entity * @param int $contactId * - * @return object CRM_Core_BAO_Block object on success, null otherwise - * @static + * @return object + * CRM_Core_BAO_Block object on success, null otherwise */ public static function create($blockName, &$params, $entity = NULL, $contactId = NULL) { if (!self::blockExists($blockName, $params)) { return NULL; } - $name = ucfirst($blockName); - $contactId = NULL; - $isPrimary = $isBilling = TRUE; + $name = ucfirst($blockName); + $contactId = NULL; + $isPrimary = $isBilling = TRUE; $entityElements = $blocks = array(); if ($entity) { @@ -392,7 +392,7 @@ class CRM_Core_BAO_Block { } /** - * Delete block + * Delete block. * * @param string $blockName * Block name. @@ -400,7 +400,6 @@ class CRM_Core_BAO_Block { * Associates array. * * @return void - * @static */ public static function blockDelete($blockName, $params) { $name = ucfirst($blockName); @@ -415,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); @@ -441,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); @@ -508,10 +505,9 @@ class CRM_Core_BAO_Block { } /** - * Sort location array so primary element is first + * Sort location array so primary element is first. * * @param array $locations - * */ public static function sortPrimaryFirst(&$locations) { uasort($locations, 'self::primaryComparison'); @@ -522,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); @@ -532,4 +528,5 @@ class CRM_Core_BAO_Block { } return ($l1 < $l2) ? -1 : 1; } + }