+ def list_domains()
+ # Compute the domains from a list of users. Obviously much worse
+ # than getting the domains the "smart" way, if such a way exists.
+ users = list_users()
+ domains = users.map{ |u| u.domain() }
+ return domains.uniq()
+ end
+
+ def user_exists(user)
+ # Does the given username exist for this plugin? We use a naive
+ # implementation here based on list_users() which is required to
+ # exist above. Plugins can override this with something fast.
+ users = list_users()
+ return users.include?(user)
+ end
+
+ def domain_exists(domain)
+ # Does the given domain exist for this plugin? We use a naive
+ # implementation here based on list_domains() which is required to
+ # exist above. Plugins can override this with something fast.
+ domains = list_domains()
+ return domains.include?(domain)
+ end
+
+ def list_domains_users(domains)
+ # Get all users belonging to the given domains. If a user has
+ # domainpart "example.com" then it belongs to the domain
+ # "example.com".
+ #
+ # This uses a naive loop, but relies only on the existence of a
+ # list_users() method which is guaranteed above. More efficient
+ # implementations can usually be made within the plugin.
+ domains_users = []
+
+ users = list_users();
+ domains.each do |d|
+ matches = users.select do |user|
+ user.domainpart() == d.to_s()
+ end
+
+ domains_users += matches
+ end
+
+ return domains_users
+ end
+