From: Coleman Watts Date: Sat, 21 Nov 2015 20:30:31 +0000 (-0500) Subject: CRM-17609 - Sycnronize contacts form cleanup X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7a0f31f9efd9a826715d51fdfd20faa9f510e431;p=civicrm-core.git CRM-17609 - Sycnronize contacts form cleanup --- diff --git a/CRM/Admin/Form/CMSUser.php b/CRM/Admin/Form/CMSUser.php index 03dd5e866b..b2251817ad 100644 --- a/CRM/Admin/Form/CMSUser.php +++ b/CRM/Admin/Form/CMSUser.php @@ -59,7 +59,31 @@ class CRM_Admin_Form_CMSUser extends CRM_Core_Form { * Process the form submission. */ public function postProcess() { - CRM_Core_BAO_CMSUser::synchronize(); + $result = CRM_Core_BAO_CMSUser::synchronize(); + + $status = ts('Checked one user record.', + array( + 'count' => $result['contactCount'], + 'plural' => 'Checked %count user records.', + ) + ); + if ($result['contactMatching']) { + $status .= '
' . ts('Found one matching contact record.', + array( + 'count' => $result['contactMatching'], + 'plural' => 'Found %count matching contact records.', + ) + ); + } + + $status .= '
' . ts('Created one new contact record.', + array( + 'count' => $result['contactCreated'], + 'plural' => 'Created %count new contact records.', + ) + ); + CRM_Core_Session::setStatus($status, ts('Synchronize Complete'), 'success'); + CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); } } diff --git a/CRM/Admin/Page/CMSUser.php b/CRM/Admin/Page/CMSUser.php deleted file mode 100644 index 6c7b3c56b2..0000000000 --- a/CRM/Admin/Page/CMSUser.php +++ /dev/null @@ -1,68 +0,0 @@ -pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); - - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - - return parent::run(); - } - -} diff --git a/CRM/Core/BAO/CMSUser.php b/CRM/Core/BAO/CMSUser.php index bd6233e886..2b9dbab19c 100644 --- a/CRM/Core/BAO/CMSUser.php +++ b/CRM/Core/BAO/CMSUser.php @@ -43,15 +43,11 @@ require_once 'DB.php'; class CRM_Core_BAO_CMSUser { /** - * Synchronizing cms users with CiviCRM contacts. + * Synchronize CMS users with CiviCRM contacts. * - * @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 array */ - public static function synchronize($is_interactive = TRUE) { + public static function synchronize() { $config = CRM_Core_Config::singleton(); // Build an array of rows from UF users table. @@ -187,34 +183,12 @@ class CRM_Core_BAO_CMSUser { } } } - //end of synchronization code - - if ($is_interactive) { - $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.', - 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')); - } + return array( + 'contactCount' => $contactCount, + 'contactMatching' => $contactMatching, + 'contactCreated' => $contactCreated, + ); } /** diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index cdd615205f..da445a8be5 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -419,7 +419,7 @@ civicrm/admin/synchUser Synchronize Users to Contacts Automatically create a CiviCRM contact record for each CMS user record. - CRM_Admin_Page_CMSUser + CRM_Admin_Form_CMSUser Users and Permissions admin/small/Synch_user.png 20 diff --git a/templates/CRM/Admin/Page/CMSUser.tpl b/templates/CRM/Admin/Page/CMSUser.tpl deleted file mode 100644 index c2c205652a..0000000000 --- a/templates/CRM/Admin/Page/CMSUser.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.7 | - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | - +--------------------------------------------------------------------+ - | 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. | - | | - | 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 template is for synchronizing CMS user*} -{include file="CRM/Admin/Form/CMSUser.tpl"} -