Elive
view release on metacpan or search on metacpan
lib/Elive/Entity/ParticipantList.pm view on Meta::CPAN
As a list of hashrefs:
$participant_list->participants([
{user => 'alice', role => 2},
{user => 'bob', role => 2},
{group => 'cookery_class', role => 3},
]);
$participant_list->update;
=head2 Command Selection
By default this command uses the C<setParticipantList> SOAP command, which
doesn't handle groups. If any groups are specified, it will switch to using
C<updateSession>, which does handle groups.
=cut
=head1 METHODS
=cut
sub _retrieve_all {
my ($class, $vals, %opt) = @_;
#
# No getXxxx command use listXxxx
#
return $class->SUPER::_retrieve_all($vals,
command => 'listParticipants',
%opt);
}
=head2 retrieve
my $meeting_participants = Elive::Entity::ParticipantList->retrieve($meeting_id);
Retrieves the participant list for a meeting.
=head2 update
This method updates meeting participants.
my $participant_list
= Elive::Entity::ParticipantList->retrieve($meeting_id);
$participant_list->participants->add($alice->userId, $bob->userId);
$participant_list->update;
Note:
=over 4
=item if you specify an empty list, C<reset> method will be called. The
resultant list wont be empty, but will have the moderator as the sole
participant.
=back
=cut
sub update {
my ($self, $update_data, %opt) = @_;
if (defined $update_data) {
die 'usage: $obj->update( \%data, %opt )'
unless (Elive::Util::_reftype($update_data) eq 'HASH');
$self->set( %$update_data )
if (keys %$update_data);
}
my $meeting_id = $self->meetingId
or die "unable to get meetingId";
my $meeting = Elive::Entity::Meeting
->retrieve($meeting_id,
reuse => 1,
connection => $self->connection,
) or die "meeting not found: ".$meeting_id;
my ($users, $groups, $guests) = $self->participants->_group_by_type;
$self->_build_elm2x_participants ($users, $groups, $guests);
#
# make sure that the facilitator is included with a moderator role
#
$users->{ $meeting->facilitatorId } = ${Elive::Entity::Role::MODERATOR};
my $participants = $self->_set_participant_list( $users, $groups, $guests );
#
# do our own readback and reread from the database (The setParticipantList
# command doesn't return a response object.)
#
$self->revert;
my $class = ref($self);
$self = $class->retrieve($self->id, connection => $self->connection);
$class->_readback_check({meetingId => $self->meetingId,
participants => $participants},
[$self]);
return $self;
}
#
# _readback_check reimplementation of our validation rule
# -- warn when input participants are omitted
# -- error when output contains participants that weren't in the input
#
sub _readback_check {
my $class = shift;
my $_data = shift;
my $rows = shift;
my %opt = @_;
my %data = %{ $_data };
if (my $participants = delete $data{participants}) {
( run in 1.406 second using v1.01-cache-2.11-cpan-99c4e6809bf )