X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FBlock.php;h=f14d4f981eb479307437b2100616049d13d6c621;hb=97c4fe768f8f0d26eddd3a6da23d4f2700102dc0;hp=bd1b3a2e79575b70ac5c5c7e8b1103664c8c11b0;hpb=feb07870854e6e0081670f2fe33faf579b737eba;p=civicrm-core.git diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index bd1b3a2e79..f14d4f981e 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -1,9 +1,9 @@ $blockValue) { - if (CRM_Utils_Array::value('is_primary', $blockValue)) { + if (!empty($blockValue['is_primary'])) { $resetPrimaryId = $blockId; break; } @@ -294,12 +300,12 @@ class CRM_Core_BAO_Block { ); //check for update - if (!CRM_Utils_Array::value('id', $value) && + if (empty($value['id']) && is_array($blockIds) && !empty($blockIds) ) { foreach ($blockIds as $blockId => $blockValue) { if ($updateBlankLocInfo) { - if (CRM_Utils_Array::value($count, $blockIds)) { + if (!empty($blockIds[$count])) { $value['id'] = $blockIds[$count]['id']; unset($blockIds[$count]); } @@ -327,7 +333,7 @@ class CRM_Core_BAO_Block { if ($valueId) { //assigned id as first come first serve basis $value['id'] = $blockValue['id']; - if (!$primaryId && CRM_Utils_Array::value('is_primary', $blockValue)) { + if (!$primaryId && !empty($blockValue['is_primary'])) { $value['is_primary'] = $blockValue['is_primary']; } unset($blockIds[$blockId]); @@ -343,7 +349,7 @@ class CRM_Core_BAO_Block { // Note there could be cases when block info already exist ($value[id] is set) for a contact/entity // BUT info is not present at this time, and therefore we should be really careful when deleting the block. // $updateBlankLocInfo will help take appropriate decision. CRM-5969 - if (CRM_Utils_Array::value('id', $value) && !$dataExits && $updateBlankLocInfo) { + if (!empty($value['id']) && !$dataExits && $updateBlankLocInfo) { //delete the existing record self::blockDelete($blockName, array('id' => $value['id'])); continue; @@ -352,7 +358,7 @@ class CRM_Core_BAO_Block { continue; } - if ($isPrimary && CRM_Utils_Array::value('is_primary', $value)) { + if ($isPrimary && !empty($value['is_primary'])) { $contactFields['is_primary'] = $value['is_primary']; $isPrimary = FALSE; } @@ -360,7 +366,7 @@ class CRM_Core_BAO_Block { $contactFields['is_primary'] = 0; } - if ($isBilling && CRM_Utils_Array::value('is_billing', $value)) { + if ($isBilling && !empty($value['is_billing'])) { $contactFields['is_billing'] = $value['is_billing']; $isBilling = FALSE; } @@ -376,7 +382,7 @@ class CRM_Core_BAO_Block { // we need to delete blocks that were deleted during update if ($updateBlankLocInfo && !empty($blockIds)) { foreach ($blockIds as $deleteBlock) { - if (!CRM_Utils_Array::value('id', $deleteBlock)) { + if (empty($deleteBlock['id'])) { continue; } self::blockDelete($blockName, array('id' => $deleteBlock['id'])); @@ -424,13 +430,16 @@ class CRM_Core_BAO_Block { * - if no other entry is 1 change to 1 * - if one other entry exists change that to 1 * - if more than one other entry exists change first one to 1 - * @fixme - perhaps should choose by location_type + * @fixme - perhaps should choose by location_type * # empty - same as 0 as once we have checked first step * we know if it should be 1 or 0 * * if $params['id'] is set $params['contact_id'] may need to be retrieved * - * @param array $params + * @param array $params + * @param $class + * + * @throws API_Exception * @static */ public static function handlePrimary(&$params, $class) { @@ -454,7 +463,7 @@ class CRM_Core_BAO_Block { } // if params is_primary then set all others to not be primary & exit out - if (CRM_Utils_Array::value('is_primary', $params)) { + 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 @@ -499,7 +508,10 @@ class CRM_Core_BAO_Block { /** * Sort location array so primary element is first - * @param Array $location + * + * @param $locations + * + * @internal param Array $location */ static function sortPrimaryFirst(&$locations){ uasort($locations, 'self::primaryComparison');