From a1f7c05f58dbb8f19a144c73f4db69420983ce0f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 Jan 2014 21:42:00 -0800 Subject: [PATCH] CRM-14086 - CMSUser::synchronize - Allow execution of sync routine without an HTTP redirect --- CRM/Core/BAO/CMSUser.php | 52 ++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/CRM/Core/BAO/CMSUser.php b/CRM/Core/BAO/CMSUser.php index 00dd9c2d99..af59a3a0a8 100644 --- a/CRM/Core/BAO/CMSUser.php +++ b/CRM/Core/BAO/CMSUser.php @@ -43,14 +43,17 @@ class CRM_Core_BAO_CMSUser { /** * Function for synchronizing cms users with CiviCRM contacts * - * @param NULL + * @param bool $is_interactive whether to show statuses & perform redirects + * This behavior is misplaced in the BAO layer, but we'll preserve it to avoid + * contract changes in the middle of the support cycle. In the next major + * release, we should remove & document it. * * @return void * * @static * @access public */ - static function synchronize() { + static function synchronize($is_interactive = TRUE) { //start of schronization code $config = CRM_Core_Config::singleton(); @@ -183,31 +186,34 @@ class CRM_Core_BAO_CMSUser { } } } - //end of schronization code - $status = ts('Synchronize Users to Contacts completed.'); - $status .= ' ' . ts('Checked one user record.', - array( - 'count' => $contactCount, - 'plural' => 'Checked %count user records.' - ) - ); - if ($contactMatching) { - $status .= ' ' . ts('Found one matching contact record.', + //end of synchronization code + + if ($is_interactive) { + $status = ts('Synchronize Users to Contacts completed.'); + $status .= ' ' . ts('Checked one user record.', array( - 'count' => $contactMatching, - 'plural' => 'Found %count matching contact records.' + 'count' => $contactCount, + 'plural' => 'Checked %count user records.' ) ); - } + if ($contactMatching) { + $status .= ' ' . ts('Found one matching contact record.', + array( + 'count' => $contactMatching, + 'plural' => 'Found %count matching contact records.' + ) + ); + } - $status .= ' ' . ts('Created one new contact record.', - array( - 'count' => $contactCreated, - 'plural' => 'Created %count new contact records.' - ) - ); - CRM_Core_Session::setStatus($status, ts('Saved'), 'success'); - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin', 'reset=1')); + $status .= ' ' . ts('Created one new contact record.', + array( + 'count' => $contactCreated, + 'plural' => 'Created %count new contact records.' + ) + ); + CRM_Core_Session::setStatus($status, ts('Saved'), 'success'); + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin', 'reset=1')); + } } /** -- 2.25.1