From 1b3ff91096c375ada575c8653db08041359a9c3c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 2 Apr 2022 11:52:13 -0400 Subject: [PATCH] Add system check for contact type image --- CRM/Utils/Check/Component/ContactTypes.php | 52 ++++++++++++++++++++++ CRM/Utils/Check/Message.php | 5 ++- ang/crmStatusPage/StatusPage.html | 5 ++- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 CRM/Utils/Check/Component/ContactTypes.php diff --git a/CRM/Utils/Check/Component/ContactTypes.php b/CRM/Utils/Check/Component/ContactTypes.php new file mode 100644 index 0000000000..bfd2983d1f --- /dev/null +++ b/CRM/Utils/Check/Component/ContactTypes.php @@ -0,0 +1,52 @@ +addWhere('image_URL', 'IS NOT EMPTY') + ->addWhere('icon', 'IS EMPTY') + ->execute(); + + if ($contactTypesWithImages->count()) { + $message = new CRM_Utils_Check_Message( + __FUNCTION__, + ts('Please select an icon for the following contact types using the new icon picker, as image urls will not be supported in future versions of CiviCRM.'), + ts('Contact type images are deprecated'), + \Psr\Log\LogLevel::WARNING, + 'fa-picture-o' + ); + foreach ($contactTypesWithImages as $contactType) { + $message->addAction($contactType['label'], FALSE, 'href', ['path' => 'civicrm/admin/options/subtype', 'query' => ['action' => 'update', 'id' => $contactType['id'], 'reset' => 1]], 'fa-pencil'); + } + $messages[] = $message; + } + + return $messages; + } + +} diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php index 770d14d3ea..7c425b30d7 100644 --- a/CRM/Utils/Check/Message.php +++ b/CRM/Utils/Check/Message.php @@ -155,13 +155,16 @@ class CRM_Utils_Check_Message { * Currently supports: api3 or href * @param array $params * Params to be passed to CRM.api3 or CRM.url depending on type + * @param string $icon + * Fa-icon class for the button */ - public function addAction($title, $confirmation, $type, $params) { + public function addAction($title, $confirmation, $type, $params, $icon = NULL) { $this->actions[] = [ 'title' => $title, 'confirm' => $confirmation, 'type' => $type, 'params' => $params, + 'icon' => $icon, ]; } diff --git a/ang/crmStatusPage/StatusPage.html b/ang/crmStatusPage/StatusPage.html index dfdfbdf24b..61aa40a43c 100644 --- a/ang/crmStatusPage/StatusPage.html +++ b/ang/crmStatusPage/StatusPage.html @@ -31,7 +31,10 @@ >
- +
-- 2.25.1