+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Utils_Migrate_ExportJSON {
const CHUNK_SIZE = 128;
public function &splitContactIDs(&$contactIDs) {
// contactIDs could be a real large array, so we split it up into
// smaller chunks and then general xml for each chunk
- $chunks = array();
+ $chunks = [];
$current = 0;
- $chunks[$current] = array();
+ $chunks[$current] = [];
$count = 0;
foreach ($contactIDs as $k => $v) {
if ($count == self::CHUNK_SIZE) {
$current++;
- $chunks[$current] = array();
+ $chunks[$current] = [];
$count = 0;
}
}
}
public function metaData() {
- $optionGroupVars = array(
+ $optionGroupVars = [
'prefix_id' => 'individual_prefix',
'suffix_id' => 'individual_suffix',
'gender_id' => 'gender',
'email_greeting' => 'email_greeting',
'postal_greeting' => 'postal_greeting',
'addressee_id' => 'addressee',
- );
+ ];
$this->optionGroup($optionGroupVars);
- $auxilaryTables = array(
+ $auxilaryTables = [
'civicrm_location_type' => 'CRM_Core_DAO_LocationType',
'civicrm_relationship_type' => 'CRM_Contact_DAO_RelationshipType',
- );
+ ];
$this->auxTable($auxilaryTables);
}
*/
public function optionGroup($optionGroupVars) {
$names = array_values($optionGroupVars);
- $str = array();
+ $str = [];
foreach ($names as $name) {
$str[] = "'$name'";
}
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
- $value = array();
+ $value = [];
foreach ($fields as $name) {
if (empty($dao->$name)) {
$value[$name] = NULL;
*/
public function group(&$contactIDs) {
// handle groups only once
- static $_groupsHandled = array();
+ static $_groupsHandled = [];
$ids = implode(',', $contactIDs);
WHERE contact_id IN ( $ids )
";
$dao = CRM_Core_DAO::executeQuery($sql);
- $groupIDs = array();
+ $groupIDs = [];
while ($dao->fetch()) {
if (!isset($_groupsHandled[$dao->group_id])) {
$groupIDs[] = $dao->group_id;
*/
public function tag(&$contactIDs) {
// handle tags only once
- static $_tagsHandled = array();
+ static $_tagsHandled = [];
$ids = implode(',', $contactIDs);
AND entity_table = 'civicrm_contact'
";
$dao = CRM_Core_DAO::executeQuery($sql);
- $tagIDs = array();
+ $tagIDs = [];
while ($dao->fetch()) {
if (!isset($_tagsHandled[$dao->tag_id])) {
$tagIDs[] = $dao->tag_id;
*/
public function relationship(&$contactIDs, &$additionalContacts) {
// handle relationships only once
- static $_relationshipsHandled = array();
+ static $_relationshipsHandled = [];
$ids = implode(',', $contactIDs);
}
$_relationshipsHandled[$dao->id] = $dao->id;
- $relationship = array();
+ $relationship = [];
foreach ($fields as $fld) {
if (empty($dao->$fld)) {
$relationship[$fld] = NULL;
}
$this->appendValue($dao->id, 'civicrm_relationship', $relationship);
- $this->addAdditionalContacts(array(
- $dao->contact_id_a,
- $dao->contact_id_b,
- ),
+ $this->addAdditionalContacts([
+ $dao->contact_id_a,
+ $dao->contact_id_b,
+ ],
$additionalContacts
);
}
* @param $additionalContacts
*/
public function activity(&$contactIDs, &$additionalContacts) {
- static $_activitiesHandled = array();
+ static $_activitiesHandled = [];
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
// adding source, target and assignee contacts in additional contacts array
- $this->addAdditionalContacts(array($dao->contact_id),
+ $this->addAdditionalContacts([$dao->contact_id],
$additionalContacts
);
// append values of activity contacts
- $activityContacts = array(
+ $activityContacts = [
'id' => $dao->acID,
'contact_id' => $dao->contact_id,
'activity_id' => $dao->activity_id,
'record_type_id' => $dao->record_type_id,
- );
+ ];
$this->appendValue($dao->acID, 'civicrm_activity_contact', $activityContacts);
if (isset($_activitiesHandled[$dao->id])) {
}
$_activitiesHandled[$dao->id] = $dao->id;
- $activity = array();
+ $activity = [];
foreach ($fields as $fld) {
if (empty($dao->$fld)) {
$activity[$fld] = NULL;
}
if (!isset($this->_values[$name])) {
- $this->_values[$name] = array();
+ $this->_values[$name] = [];
$this->_values[$name][] = array_keys($value);
}
$this->_values[$name][] = array_values($value);
* @return array
*/
public function dbFields($daoName, $onlyKeys = FALSE) {
- static $_fieldsRetrieved = array();
+ static $_fieldsRetrieved = [];
if (!isset($_fieldsRetrieved[$daoName])) {
- $_fieldsRetrieved[$daoName] = array();
+ $_fieldsRetrieved[$daoName] = [];
$daoFile = str_replace('_',
DIRECTORY_SEPARATOR,
$daoName
$daoFields = &$daoName::fields();
foreach ($daoFields as $key => & $value) {
- $_fieldsRetrieved[$daoName][$value['name']] = array(
+ $_fieldsRetrieved[$daoName][$value['name']] = [
'uniqueName' => $key,
'type' => $value['type'],
'title' => CRM_Utils_Array::value('title', $value, NULL),
- );
+ ];
}
}
public function export(&$contactIDs) {
$chunks = &$this->splitContactIDs($contactIDs);
- $additionalContactIDs = array();
+ $additionalContactIDs = [];
foreach ($chunks as $chunk) {
$this->getValues($chunk, $additionalContactIDs);
$dao = &CRM_Core_DAO::executeQuery($sql);
- $contactIDs = array();
+ $contactIDs = [];
while ($dao->fetch()) {
$contactIDs[$dao->id] = $dao->id;
}
$this->_allContactIDs = $contactIDs;
- $this->_values = array();
+ $this->_values = [];
$this->metaData();