diff --git a/administrator/components/com_users/src/Model/LevelModel.php b/administrator/components/com_users/src/Model/LevelModel.php index f511143d530a3..70da764533b8e 100644 --- a/administrator/components/com_users/src/Model/LevelModel.php +++ b/administrator/components/com_users/src/Model/LevelModel.php @@ -78,12 +78,15 @@ protected function canDelete($record) $tables = $db->getTableList(); $prefix = $db->getPrefix(); + // Collect table names for error message + $inTables = []; + foreach ($tables as $table) { // Get all of the columns in the table $fields = $db->getTableColumns($table); /** - * We are looking for the access field. If custom tables are using something other + * We are looking for the access field. If custom tables are using something other * than the 'access' field they are on their own unfortunately. * Also make sure the table prefix matches the live db prefix (eg, it is not a "bak_" table) */ @@ -103,8 +106,10 @@ protected function canDelete($record) $this->levelsInUse = array_merge($this->levelsInUse, $values); - // @todo Could assemble an array of the tables used by each view level list those, - // giving the user a clue in the error where to look. + // Check if the table uses this access level + if (in_array($record->id, $values)) { + $inTables[] = $table; + } } } diff --git a/administrator/language/en-GB/com_users.ini b/administrator/language/en-GB/com_users.ini index 16f622a8c5871..ccfd4dd0095cc 100644 --- a/administrator/language/en-GB/com_users.ini +++ b/administrator/language/en-GB/com_users.ini @@ -104,7 +104,7 @@ COM_USERS_ERROR_LEVELS_NOLEVELS_SELECTED="No View Permission Level(s) selected." COM_USERS_ERROR_NO_ADDITIONS="The selected user(s) are already assigned to the selected group." COM_USERS_ERROR_NOT_IN_GROUP="The selected user(s) are not in the selected group." COM_USERS_ERROR_ONLY_ONE_GROUP="A user must belong to at least one group." -COM_USERS_ERROR_VIEW_LEVEL_IN_USE="You can't delete the view access level '%d:%s' because it is being used by content." +COM_USERS_ERROR_VIEW_LEVEL_IN_USE="You can't delete the view access level '%s' because it is being used in the database tables: %s." COM_USERS_FIELDS_USER_FIELDS_TITLE="Users: Fields" COM_USERS_FIELDS_USER_FIELD_ADD_TITLE="Users: New Field" COM_USERS_FIELDS_USER_FIELD_EDIT_TITLE="Users: Edit Field"