File Coverage

blib/lib/Elive/View/Session.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             package Elive::View::Session;
2 3     3   2346 use warnings; use strict;
  3     3   7  
  3         121  
  3         17  
  3         6  
  3         101  
3              
4 3     3   18 use Mouse;
  3         5  
  3         24  
5 3     3   1124 use Mouse::Util::TypeConstraints;
  3         6  
  3         32  
6              
7             extends 'Elive::Entity::Session';
8             has 'id' => (is => 'rw', isa => 'Int', required => 1);
9             __PACKAGE__->primary_key('id');
10              
11 3     3   2223 use Elive::Entity::Preloads;
  0            
  0            
12              
13             =head1 NAME
14              
15             Elive::View::Session - Session view and insert/update via ELM 2.x
16              
17             =head1 DESCRIPTION
18              
19             A session is a consolidated view of meetings, meeting parameters, server parameters and participants.
20              
21             =cut
22              
23             =head1 METHODS
24              
25             =cut
26              
27             =head2 insert
28              
29             Creates a new session on an Elluminate server.
30              
31             use Elive::View::Session;
32              
33             my $session_start = time();
34             my $session_end = $session_start + 900;
35              
36             $session_start .= '000';
37             $session_end .= '000';
38              
39             my $preload = Elive::Entity::Preload->upload('c:\\Documents\intro.wbd');
40              
41             my %session_data = (
42             name => 'An example session',
43             facilitatorId => Elive->login->userId,
44             password => 'example', # what else?
45             start => $session_start,
46             end => $session_end,
47             privateMeeting => 1,
48             costCenter => 'example',
49             recordingStatus => 'remote',
50             raiseHandOnEnter => 1,
51             maxTalkers => 2,
52             inSessionInvitation => 1,
53             boundaryMinutes => 15,
54             fullPermissions => 1,
55             supervised => 1,
56             seats => 2,
57             participants => [
58             -moderators => [qw(alice bob)],
59             -others => '*staff_group'
60             ],
61             add_preload => $preload
62             );
63              
64             my $session = Elive::View::Session->insert( \%session_data );
65              
66             A series of sessions can be created using the C and C parameters.
67              
68             #
69             # create three weekly sessions
70             #
71             my @sessions = Elive::View::Session->insert({
72             ...,
73             recurrenceCount => 3,
74             recurrenceDays => 7,
75             });
76              
77             =cut
78              
79             sub insert {
80             my $class = shift;
81             my %data = %{ shift() };
82             my %opts = @_;
83              
84             my $preloads = delete $data{add_preload};
85             #
86             # start by inserting the meeting
87             #
88             my @meeting_props = $class->_data_owned_by('Elive::Entity::Meeting' => (sort keys %data));
89              
90             my %meeting_data = map {
91             $_ => delete $data{$_}
92             } @meeting_props;
93              
94             #
95             # recurrenceCount, and recurrenceDays may result in multiple meetings
96             #
97             my @meetings = Elive::Entity::Meeting->insert(\%meeting_data, %opts);
98              
99             my @objs = map {
100             my $meeting = $_;
101              
102             my $self = Elive::Entity::Session->new( {id => $meeting->meetingId,
103             meeting => $meeting} );
104             bless $self, $class;
105              
106             $self->connection( $meeting->connection );
107             #
108             # from here on in, it's just a matter of updating attributes owned by
109             # the other entities. We need to do this for each meeting instance
110             #
111             $self->update(\%data, %opts)
112             if keys %data;
113              
114             $self->__add_preloads( $preloads ) if $preloads;
115              
116             $self;
117              
118             } @meetings;
119              
120             return wantarray? @objs : $objs[0];
121             }
122              
123             =head2 update
124              
125             Updates a previously created session.
126              
127             $session->seats(5);
128             $session->update;
129              
130             ...or equivalently...
131              
132             $session->update({seats => 5});
133              
134             =cut
135              
136             sub update {
137             my $self = shift;
138             my %data = %{ shift() || {} };
139             my %opts = @_;
140              
141             my $preloads = delete $data{add_preload};
142             my $delegates = $self->_delegates;
143              
144             foreach my $delegate (sort keys %$delegates) {
145              
146             my $delegate_class = $delegates->{$delegate};
147             my @delegate_props = $self->_data_owned_by($delegate_class => sort keys %data);
148             next unless @delegate_props
149             || ($self->{$delegate} && $self->{$delegate}->is_changed);
150              
151             my %delegate_data = map {$_ => delete $data{$_}} @delegate_props;
152              
153             $self->$delegate->update( \%delegate_data, %opts );
154             }
155              
156             $self->__add_preloads( $preloads ) if $preloads;
157              
158             return $self;
159             }
160              
161             sub __add_preloads {
162             my $self = shift;
163             my $preloads = shift;
164              
165             if ($preloads) {
166             $preloads = Elive::Entity::Preloads->_build_array( $preloads );
167              
168             foreach my $preload (@$preloads) {
169             $self->meeting->add_preload( $preload );
170             }
171             }
172             }
173              
174             =head2 list retrieve buildJNLP check_preload add_preload remove_preload is_participant is_moderator list_preloads list_recordings
175              
176             These methods are available from the base class L.
177              
178             =head2 adapter allModerators boundaryMinutes costCenter deleted enableTelephony end facilitatorId followModerator fullPermissions id inSessionInvitation maxTalkers moderatorNotes moderatorTelephonyAddress moderatorTelephonyPIN name participantTelephonyAddress participantTelephonyPIN participants password privateMeeting profile raiseHandOnEnter recordingObfuscation recordingResolution recordingStatus redirectURL restrictedMeeting seats serverTelephonyAddress serverTelephonyPIN start supervised telephonyType userNotes videoWindow
179              
180             These attributes are available from the base class L.
181              
182             =cut
183              
184             sub properties {
185             my $class = shift;
186              
187             my %seen = (meetingId => 1);
188             my $delegates = $class->_delegates;
189              
190             my @delegate_properties = sort grep {! $seen{$_}++} (
191             'id',
192             map {$_->properties} sort values %$delegates,
193             );
194              
195             return @delegate_properties;
196             }
197              
198             sub property_types {
199             my $class = shift;
200              
201             my $id = $class->SUPER::property_types->{id};
202             my $delegates = $class->_delegates;
203              
204             my %property_types = (
205             id => $id,
206             map { %{$_->property_types} } sort values %$delegates,
207             );
208              
209             delete $property_types{meetingId};
210              
211             return \%property_types;
212             }
213              
214             sub property_doco {
215             my $class = shift;
216              
217             my $delegates = $class->_delegates;
218              
219             return {
220             map { %{$_->property_doco} } sort values %$delegates,
221             };
222             }
223              
224             sub derivable {
225             my $class = shift;
226              
227             my $delegates = $class->_delegates;
228              
229             return (
230             map { $_->derivable } sort values %$delegates,
231             );
232             }
233              
234             =head1 BUGS AND LIMITATIONS
235              
236             The C and C methods in this class rely on older ELM 2.x
237             commands. These do not support newer ELM 3.x features including
238             restricted meetings, invited guests, groups, exit URLs and a number of other
239             newer options and flags - these are listed in L.
240              
241             Sites running ELM 3.0 / Elluminate Live 9.5 or newer may want to consider
242             using L, which implements the newer C
243             and C commands.
244              
245             =cut
246              
247             1;