From 82d5547b8f6eac0aa430abfd6024bcc47859eb18 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Tue, 19 May 2020 11:54:53 +0200 Subject: [PATCH] MDL-68294 tool_mobile: Fix custom strings and limits calculation --- .../mobile/classes/output/subscription.php | 24 +++++++++++++++++-- admin/tool/mobile/lang/en/tool_mobile.php | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/admin/tool/mobile/classes/output/subscription.php b/admin/tool/mobile/classes/output/subscription.php index c483dc926ce..d8deaca2d7e 100644 --- a/admin/tool/mobile/classes/output/subscription.php +++ b/admin/tool/mobile/classes/output/subscription.php @@ -115,13 +115,33 @@ class subscription implements \renderable, \templatable { break; // Check menu items. case 'custommenuitems': + $custommenuitems = []; $els = rtrim($ms->custommenuitems, "\n"); - $feature['status'] = empty($ms->custommenuitems) ? 0 : count(explode("\n", $els)); + if (!empty($els)) { + $custommenuitems = explode("\n", $els); + // Get unique custom menu urls. + $custommenuitems = array_flip( + array_map(function($val) { + return explode('|', $val)[1]; + }, $custommenuitems) + ); + } + $feature['status'] = count($custommenuitems); break; // Check language strings. case 'customlanguagestrings': + $langstrings = []; $els = rtrim($ms->customlangstrings, "\n"); - $feature['status'] = empty($ms->customlangstrings) ? 0 : count(explode("\n", $els)); + if (!empty($els)) { + $langstrings = explode("\n", $els); + // Get unique language string ids. + $langstrings = array_flip( + array_map(function($val) { + return explode('|', $val)[0]; + }, $langstrings) + ); + } + $feature['status'] = count($langstrings); break; // Check disabled features strings. case 'disabledfeatures': diff --git a/admin/tool/mobile/lang/en/tool_mobile.php b/admin/tool/mobile/lang/en/tool_mobile.php index 3f270eab9b3..e56f280b49a 100644 --- a/admin/tool/mobile/lang/en/tool_mobile.php +++ b/admin/tool/mobile/lang/en/tool_mobile.php @@ -98,7 +98,7 @@ $string['notifications'] = 'Notifications'; $string['notificationsactivedevices'] = 'Active devices'; $string['notificationsignorednotifications'] = 'Notifications not sent'; $string['notificationslimitreached'] = 'The monthly active user devices limit has been exceeded. Notifications for some users will not be sent. It is recommended that you upgrade your app plan in the Moodle Apps Portal.'; -$string['notificationsmissingwarning'] = 'Moodle app notification statistics could not be retrieved. This is most likely because mobile notifications are not yet enabled on the site. You can enable them in Site Administration / Notifications / Mobile.'; +$string['notificationsmissingwarning'] = 'Moodle app notification statistics could not be retrieved. This is most likely because mobile notifications are not yet enabled on the site. You can enable them in Site Administration / Messaging / Mobile.'; $string['notificationsnewdevices'] = 'New devices'; $string['notificationsseemore'] = 'Note: Moodle app usage statistics are not calculated in real time. To access more detailed statistics, including data from previous months, please log in to the Moodle Apps Portal.'; $string['notificationssentnotifications'] = 'Notifications sent';