File Coverage

blib/lib/Labyrinth/Plugin/Survey/API.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Labyrinth::Plugin::Survey::API;
2              
3 1     1   3247 use warnings;
  1         1  
  1         33  
4 1     1   3 use strict;
  1         1  
  1         23  
5 1     1   589 use utf8;
  1         9  
  1         5  
6              
7 1     1   29 use vars qw($VERSION);
  1         1  
  1         46  
8             $VERSION = '0.08';
9              
10             =head1 NAME
11              
12             Labyrinth::Plugin::Survey::API - YAPC Surveys' API plugin via Labyrinth framework
13              
14             =head1 DESCRIPTION
15              
16             Provides all the interfaces needed by external event instances to access data
17             from the current YAPC Surveys.
18              
19             =cut
20              
21             # -------------------------------------
22             # Library Modules
23              
24 1     1   5 use base qw(Labyrinth::Plugin::Base);
  1         1  
  1         319  
25              
26             use Labyrinth::Audit;
27             use Labyrinth::DBUtils;
28             use Labyrinth::Support;
29             use Labyrinth::Users;
30             use Labyrinth::Variables;
31              
32             #----------------------------------------------------------
33             # Variables
34              
35             # -------------------------------------
36             # The Subs
37              
38             =head1 PUBLIC INTERFACE METHODS
39              
40             =head2 User Methods
41              
42             =over 4
43              
44             =item GetUserLink
45              
46             Returns the login link for a specific user.
47              
48             =item DisableUser
49              
50             Disables the user login and any communication via announcements for a specific
51             user.
52              
53             =back
54              
55             =cut
56              
57             sub GetUserLink {
58             my @users = $dbi->GetQuery('hash','FindUserByAct',$cgiparams{actuserid});
59             return unless(@users); # act user not registered
60             return unless($users[0]->{code}); # if no code, not a logged in user
61             $tvars{act}{link} = sprintf "http://%s.yapc-surveys.org/key/%s/%d", $settings{icode}, $users[0]->{code}, $users[0]->{userid};
62             }
63              
64             sub DisableUser {
65             my @users = $dbi->GetQuery('hash','FindUserByAct',$cgiparams{actuserid});
66             return unless(@users); # act user not registered
67             $dbi->DoQuery('hash','DisableUser',$cgiparams{actuserid});
68             $tvars{act}{disabled} = 1;
69             }
70              
71             =head2 Talk Methods
72              
73             =over 4
74              
75             =item GetTalkLink
76              
77             Returns the talk link for a specific talk/course.
78              
79             For an open user, i.e. for anyone watching the video stream, these users will
80             need to register and login. Feedback from these users is stored separately.
81              
82             =item DisableTalk
83              
84             Disables the ability to receive evaluations for the given talk.
85              
86             =back
87              
88             =cut
89              
90             sub GetTalkLink {
91             my @talks = $dbi->GetQuery('hash','FindCourseByAct',$cgiparams{acttalkid});
92             return unless(@talks); # act talk not registered
93             $tvars{act}{link} = sprintf "http://%s.yapc-surveys.org/talk/%d", $settings{icode}, $talks[0]->{talkid};
94             }
95              
96             sub DisableTalk {
97             my @talks = $dbi->GetQuery('hash','FindCourseByAct',$cgiparams{acttalkid});
98             return unless(@talks); # act talk not registered
99             $dbi->DoQuery('hash','DisableTalk',$cgiparams{acttalkid});
100             $tvars{act}{disabled} = 1;
101             }
102              
103             1;
104              
105             __END__