# Copyright (c) 2009 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: MailSendAccess.pm,v 1.3 2011/03/02 19:32:38 nagler Exp $ package Bivio::Type::MailSendAccess; use strict; use Bivio::Base 'Type.Enum'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.3 $ =~ /\d+/g); my($_CATEGORY_PREFIX) = 'mail_send_access_'; __PACKAGE__->compile([ UNKNOWN => [0, 'Select who can send mail'], ALL_GUESTS => [1, 'Guests and members can send mail'], ALL_MEMBERS => [2, 'Only group members can send mail'], ALL_ADMINS => [3, 'Only adminstrators can send mail'], ALL_USERS => [4, 'Any registered user can send mail'], EVERYBODY => [5, 'Anybody (even non-users) can send mail'], NOBODY => [6, 'Nobody (not even admins) can send mail'], ]); sub as_realm_role_category { return $_CATEGORY_PREFIX . shift->as_realm_role_category_role_group; } sub as_realm_role_category_role_group { return lc(shift->get_name); } sub from_realm_role_enabled_categories { my($proto, $enabled_categories) = @_; my($modes) = [map( $_ =~ /^$_CATEGORY_PREFIX(.+)/o ? $1 : (), @$enabled_categories, )]; b_die($modes, ': must be exactly one enabled mode') unless @$modes == 1; return $proto->from_name($modes->[0]); } sub get_default { return shift->ALL_MEMBERS; } 1;