# Copyright (c) 2005 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: RealmEmailList.pm,v 1.8 2011/02/06 01:45:15 nagler Exp $ package Bivio::Biz::Model::RealmEmailList; use strict; use Bivio::Base 'Model.RealmUserList'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.8 $ =~ /\d+/g); my($_E) = Bivio::Biz::Model->get_instance('Email')->get_field_type('email'); sub get_recipients { my($self, $iterate_handler) = @_; my($method) = 'map_' . ($self->is_loaded ? 'rows' : 'iterate'); my($t) = $self->get_field_type('Email.email'); return $self->$method(sub { my($e) = $self->get('Email.email'); return $t->is_ignore($e) ? () : $iterate_handler ? $iterate_handler->($self) : $e; }); } sub internal_get_roles { return [Bivio::Auth::Role->MAIL_RECIPIENT]; } sub internal_initialize { my($self) = @_; return $self->merge_initialize_info( $self->field_decl_exclude( 'RealmUser.role', $self->SUPER::internal_initialize, ), { order_by => [qw( Email.email )], other => [ 'Email.location', [qw(RealmUser.user_id Email.realm_id(+))], { name => 'RealmUser.role', in_select => 0, }, ], group_by => [qw( Email.email Email.location RealmOwner.display_name RealmOwner.name RealmUser.realm_id RealmUser.user_id )], }, ); } sub internal_post_load_row { my($self, $row) = @_; return $_E->is_ignore($row->{'Email.email'}) ? 0 : 1; } sub is_ignore { my($self) = @_; return $self->get_field_type('Email.email') ->is_ignore($self->get('Email.email')); } 1;