Merge pull request #15248 from MegaphoneJon/reporting-19
[civicrm-core.git] / CRM / Utils / Check / Component / AddressParsing.php
CommitLineData
0eb2bbdf
MM
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
f299f7db 6 | Copyright CiviCRM LLC (c) 2004-2020 |
0eb2bbdf
MM
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28/**
29 *
30 * @package CRM
f299f7db 31 * @copyright CiviCRM LLC (c) 2004-2020
0eb2bbdf
MM
32 */
33class CRM_Utils_Check_Component_AddressParsing extends CRM_Utils_Check_Component {
34
35 public static function checkLocaleSupportsAddressParsing() {
36
37 $addressOptions = CRM_Core_BAO_Setting::valueOptions(
38 CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
39 'address_options'
40 );
41
42 $messages = [];
43
44 if ($addressOptions['street_address_parsing']) {
45 if (!CRM_Core_BAO_Address::isSupportedParsingLocale()) {
46 $config = CRM_Core_Config::singleton();
47 $messages[] = new CRM_Utils_Check_Message(
48 __FUNCTION__,
49 ts(
50 '<a href=' .
51 CRM_Utils_System::url('civicrm/admin/setting/preferences/address', 'reset=1') .
52 '">Street address parsing</a> is enabled but not supported by <a href="' .
53 CRM_Utils_System::url('civicrm/admin/setting/localization', 'reset=1') .
54 '">your locale</a> (%1).',
55 [1 => $config->lcMessages]
56 ),
57 ts('Street address parsing'),
58 \Psr\Log\LogLevel::WARNING,
59 'fa-address-card'
60 );
61 }
62 }
63
64 return $messages;
65 }
66
67}