<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
*/
/**
*/
class CRM_Utils_Address_BatchUpdate {
- var $start = NULL;
- var $end = NULL;
- var $geocoding = 1;
- var $parse = 1;
- var $throttle = 0;
+ public $start = NULL;
+ public $end = NULL;
+ public $geocoding = 1;
+ public $parse = 1;
+ public $throttle = 0;
- var $returnMessages = array();
- var $returnError = 0;
+ public $returnMessages = [];
+ public $returnError = 0;
/**
* Class constructor.
*/
public function processContacts($processGeocode, $parseStreetAddress) {
// build where clause.
- $clause = array('( c.id = a.contact_id )');
- $params = array();
+ $clause = ['( c.id = a.contact_id )'];
+ $params = [];
if ($this->start) {
$clause[] = "( c.id >= %1 )";
- $params[1] = array($this->start, 'Integer');
+ $params[1] = [$this->start, 'Integer'];
}
if ($this->end) {
$clause[] = "( c.id <= %2 )";
- $params[2] = array($this->end, 'Integer');
+ $params[2] = [$this->end, 'Integer'];
}
if ($processGeocode) {
$dao = CRM_Core_DAO::executeQuery($query, $params);
- $unparseableContactAddress = array();
+ $unparseableContactAddress = [];
while ($dao->fetch()) {
$totalAddresses++;
- $params = array(
+ $params = [
'street_address' => $dao->street_address,
'postal_code' => $dao->postal_code,
'city' => $dao->city,
'state_province' => $dao->state,
'country' => $dao->country,
'country_id' => $dao->country_id,
- );
+ ];
- $addressParams = array();
+ $addressParams = [];
// process geocode.
if ($processGeocode) {
$address->id = $dao->address_id;
$address->copyValues($addressParams);
$address->save();
- $address->free();
}
}
- $this->returnMessages[] = ts("Addresses Evaluated: %1", array(
+ $this->returnMessages[] = ts("Addresses Evaluated: %1", [
1 => $totalAddresses,
- )) . "\n";
+ ]) . "\n";
if ($processGeocode) {
- $this->returnMessages[] = ts("Addresses Geocoded: %1", array(
- 1 => $totalGeocoded,
- )) . "\n";
+ $this->returnMessages[] = ts("Addresses Geocoded: %1", [
+ 1 => $totalGeocoded,
+ ]) . "\n";
}
if ($parseStreetAddress) {
- $this->returnMessages[] = ts("Street Addresses Parsed: %1", array(
- 1 => $totalAddressParsed,
- )) . "\n";
+ $this->returnMessages[] = ts("Street Addresses Parsed: %1", [
+ 1 => $totalAddressParsed,
+ ]) . "\n";
if ($unparseableContactAddress) {
$this->returnMessages[] = "<br />\n" . ts("Following is the list of contacts whose address is not parsed:") . "<br />\n";
foreach ($unparseableContactAddress as $contactLink) {
* @return array
*/
public function returnResult() {
- $result = array();
+ $result = [];
$result['is_error'] = $this->returnError;
$result['messages'] = '';
// Pad message size to allow for prefix added by CRM_Core_JobManager.