Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * This class generates form components for Synchronizing CMS Users | |
6a488035 TO |
20 | */ |
21 | class CRM_Admin_Form_CMSUser extends CRM_Core_Form { | |
22 | ||
88aae6d4 A |
23 | /** |
24 | * @var bool | |
25 | */ | |
26 | public $submitOnce = TRUE; | |
27 | ||
6a488035 | 28 | /** |
eceb18cc | 29 | * Build the form object. |
6a488035 TO |
30 | */ |
31 | public function buildQuickForm() { | |
32 | ||
be2fb01f | 33 | $this->addButtons([ |
0d48f1cc TO |
34 | [ |
35 | 'type' => 'next', | |
36 | 'name' => ts('OK'), | |
37 | 'isDefault' => TRUE, | |
38 | ], | |
39 | [ | |
40 | 'type' => 'cancel', | |
41 | 'name' => ts('Cancel'), | |
42 | ], | |
43 | ]); | |
6a488035 TO |
44 | } |
45 | ||
46 | /** | |
eceb18cc | 47 | * Process the form submission. |
6a488035 TO |
48 | */ |
49 | public function postProcess() { | |
091db908 | 50 | $result = CRM_Utils_System::synchronizeUsers(); |
7a0f31f9 CW |
51 | |
52 | $status = ts('Checked one user record.', | |
be2fb01f | 53 | [ |
7a0f31f9 CW |
54 | 'count' => $result['contactCount'], |
55 | 'plural' => 'Checked %count user records.', | |
be2fb01f | 56 | ] |
7a0f31f9 CW |
57 | ); |
58 | if ($result['contactMatching']) { | |
59 | $status .= '<br />' . ts('Found one matching contact record.', | |
be2fb01f | 60 | [ |
7a0f31f9 CW |
61 | 'count' => $result['contactMatching'], |
62 | 'plural' => 'Found %count matching contact records.', | |
be2fb01f | 63 | ] |
7a0f31f9 CW |
64 | ); |
65 | } | |
66 | ||
67 | $status .= '<br />' . ts('Created one new contact record.', | |
be2fb01f | 68 | [ |
7a0f31f9 CW |
69 | 'count' => $result['contactCreated'], |
70 | 'plural' => 'Created %count new contact records.', | |
be2fb01f | 71 | ] |
7a0f31f9 CW |
72 | ); |
73 | CRM_Core_Session::setStatus($status, ts('Synchronize Complete'), 'success'); | |
74 | CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); | |
6a488035 | 75 | } |
96025800 | 76 | |
6a488035 | 77 | } |