MDL-68294 tool_mobile: Fix custom strings and limits calculation
authorJuan Leyva <juanleyvadelgado@gmail.com>
Tue, 19 May 2020 09:54:53 +0000 (11:54 +0200)
committerSara Arjona <sara@moodle.com>
Tue, 19 May 2020 10:19:37 +0000 (12:19 +0200)
admin/tool/mobile/classes/output/subscription.php
admin/tool/mobile/lang/en/tool_mobile.php

index c483dc9..d8deaca 100644 (file)
@@ -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':
index 3f270ea..e56f280 100644 (file)
@@ -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 <a href="{$a}" target="_blank">Moodle Apps Portal</a>.';
-$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 <a href="{$a}" target="_blank">Moodle Apps Portal</a>.';
 $string['notificationssentnotifications'] = 'Notifications sent';