line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pikeo::API::Photo; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13612
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
103
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use base qw( Pikeo::API::Base ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
926
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Pikeo::API::Comment; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
551
|
use Pikeo::API::User; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
24
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
11
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
72
|
|
12
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
950
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Pikeo::API::Photo - Abstraction of a pikeo photo |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
|
|
sub _info_fields { qw( title is_family is_contact is_friend owner_username |
22
|
|
|
|
|
|
|
original_file_size original width secret url_prefix |
23
|
|
|
|
|
|
|
description height mime_type date_posted date_taken |
24
|
|
|
|
|
|
|
owner_id title tags |
25
|
|
|
|
|
|
|
) } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 FUNCTIONS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head3 new( \%args ) |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Returns a Pikeo::API::Contact object. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Required args are: |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over 4 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item * api |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Pikeo::API object |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * from_xml |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
XML::LibXML node containing the contacts definitions |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
sub new { |
51
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
52
|
0
|
|
|
|
|
|
my $params = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($params); |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if ( $params->{id} ) { |
57
|
0
|
|
|
|
|
|
$self->{id} = $params->{id}; |
58
|
0
|
|
|
|
|
|
$self->{_init} = 0; |
59
|
0
|
|
|
|
|
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
croak "Need an id"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head3 id() |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Photo id |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
0
|
|
|
0
|
1
|
|
sub id { return shift->{id} } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head3 comments() |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
List of Pikeo::API::Comment objects representing the photo comments. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
sub comments { |
77
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.comments.getList', { |
79
|
|
|
|
|
|
|
photo_id => $self->{id}, |
80
|
|
|
|
|
|
|
} ); |
81
|
0
|
|
|
|
|
|
my $nodes = $doc->findnodes("response/value/array/comment"); |
82
|
0
|
|
|
|
|
|
my @comments = (); |
83
|
0
|
|
|
|
|
|
for my $c ($nodes->get_nodelist()) { |
84
|
0
|
0
|
|
|
|
|
next unless $c; |
85
|
0
|
|
|
|
|
|
push @comments, Pikeo::API::Comment->new({ |
86
|
|
|
|
|
|
|
api => $self->api, |
87
|
|
|
|
|
|
|
from_xml => $c, |
88
|
|
|
|
|
|
|
}); |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
|
return \@comments; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head3 setPrivacy(\%args) |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Change the privacy level of the photo. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Required args: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * access_type |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The "access_type" is chosen from : |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
0 for private |
106
|
|
|
|
|
|
|
2 for friends only |
107
|
|
|
|
|
|
|
4 for family only |
108
|
|
|
|
|
|
|
6 for friends and family only |
109
|
|
|
|
|
|
|
7 for publicAuthentication is required. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Optional args: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * force_quit_group |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
force_quit_group allow you to decide if photos can quit groups automatically. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
It happens when photo privacy change to a more private level that does not correspond to group accessibility. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub setPrivacy { |
128
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
129
|
0
|
|
|
|
|
|
my $params = shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
croak "missing param 'access_type'" |
132
|
|
|
|
|
|
|
unless $params->{access_type}; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $req_params = { |
135
|
|
|
|
|
|
|
photo_id_list => "[".$self->id."]", |
136
|
|
|
|
|
|
|
access_type => $params->{access_type}, |
137
|
|
|
|
|
|
|
}; |
138
|
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
if ( $params->{force_quit_group} ) { |
140
|
0
|
0
|
|
|
|
|
$req_params->{force_quit_group} = ( $params->{force_quit_group} ? 1 : 0 ); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$self->api->request_parsed( 'pikeo.photos.setPrivacy', $req_params ); |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
return 1; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head3 addComment(\%args) |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Adds a comment to the photo |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Required args: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * text |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The text of the comment |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Optional args: |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=over 4 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * in_reply_to |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Pikeo::API::Comment parent comment |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * parent_id |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
id of the parent comment |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=back |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
sub addComment { |
178
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
179
|
0
|
|
|
|
|
|
my $params = shift; |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
croak "missing param 'text'" |
182
|
|
|
|
|
|
|
unless $params->{text}; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
my $req_params = { |
185
|
|
|
|
|
|
|
photo_id => $self->id, |
186
|
|
|
|
|
|
|
text => $params->{text}, |
187
|
|
|
|
|
|
|
}; |
188
|
|
|
|
|
|
|
|
189
|
0
|
0
|
|
|
|
|
if ( $params->{in_reply_to} ) { |
190
|
0
|
0
|
|
|
|
|
croak "invalid param type 'in_reply_to'" |
191
|
|
|
|
|
|
|
unless ref( $params->{in_reply_to} ) eq 'Pikeo::API::Comment'; |
192
|
0
|
|
|
|
|
|
$req_params->{parent_id} = $params->{in_reply_to}->id; |
193
|
|
|
|
|
|
|
} |
194
|
0
|
0
|
|
|
|
|
if ( $params->{parent_id} ) { |
195
|
0
|
|
|
|
|
|
$req_params->{parent_id} = $params->{parent_id}; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
my $d = $self->api->request_parsed( 'pikeo.comments.addComment', $req_params ); |
199
|
0
|
|
|
|
|
|
return $d->findvalue("//value"); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head3 owner() |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Pikeo::API::User that owns the photo |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub owner { |
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
211
|
0
|
|
|
|
|
|
return Pikeo::API::User->new({ id => $self->owner_id, api => $self->api }); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head3 thumbnail_url($size) |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Returns the url for the photo thumbnail of the given size. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Size can be one of the following: |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
1016x762 |
221
|
|
|
|
|
|
|
500x400 |
222
|
|
|
|
|
|
|
200x150 |
223
|
|
|
|
|
|
|
96x72 |
224
|
|
|
|
|
|
|
75x75 |
225
|
|
|
|
|
|
|
50x50 |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=cut |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub thumbnail_url { |
230
|
|
|
|
|
|
|
#urlPrefix/thumb/secret/thumbnail.jpg |
231
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
232
|
0
|
|
|
|
|
|
my $size = shift; |
233
|
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
|
$self->_init unless $self->_init_done(); |
235
|
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
return $self->url_prefix."thumb/".$self->secret.$size.".jpg"; |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head3 original_url() |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Return full url to the original photo file |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=cut |
245
|
|
|
|
|
|
|
sub original_url { |
246
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
247
|
0
|
0
|
|
|
|
|
$self->_init unless $self->_init_done(); |
248
|
|
|
|
|
|
|
|
249
|
0
|
|
|
|
|
|
return $self->url_prefix."upload/".$self->original; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
sub _init { |
253
|
0
|
|
|
0
|
|
|
my $self = shift; |
254
|
0
|
|
|
|
|
|
my $doc = $self->api->request_parsed( 'pikeo.photos.getInfo', { |
255
|
|
|
|
|
|
|
'photo_id' => $self->{id}, |
256
|
|
|
|
|
|
|
} ); |
257
|
0
|
|
|
|
|
|
$self->_init_from_xml( $doc ); |
258
|
0
|
|
|
|
|
|
$self->{_init} = 1; |
259
|
0
|
|
|
|
|
|
$self->{_dirty} = 0; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub _init_from_xml { |
263
|
0
|
|
|
0
|
|
|
my $self = shift; |
264
|
0
|
|
|
|
|
|
my $doc = shift; |
265
|
0
|
|
|
|
|
|
my $nodes = $doc->findnodes("response/photo/*"); |
266
|
0
|
|
|
|
|
|
for ($nodes->get_nodelist()) { |
267
|
0
|
0
|
|
|
|
|
next if $_->nodeName eq 'value'; |
268
|
0
|
0
|
|
|
|
|
$self->{$_->nodeName} = ( $_->to_literal eq 'null' ? undef : $_->to_literal ); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
my @parsed_tags = (); |
272
|
0
|
|
|
|
|
|
my $tags = $doc->findnodes("//tag"); |
273
|
0
|
|
|
|
|
|
for my $tag ($tags->get_nodelist()) { |
274
|
0
|
|
|
|
|
|
push @parsed_tags, { |
275
|
|
|
|
|
|
|
id => $tag->findvalue("./id"), |
276
|
|
|
|
|
|
|
category => $tag->findvalue("./category"), |
277
|
|
|
|
|
|
|
name => $tag->findvalue("./name"), |
278
|
|
|
|
|
|
|
}; |
279
|
|
|
|
|
|
|
} |
280
|
0
|
|
|
|
|
|
$self->{tags} = \@parsed_tags; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
=head3 title() |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head4 is_family() |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head4 is_contact() |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=head4 is_friend() |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head4 owner_username() |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head3 original_file_size() |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head3 original() |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head3 secret() |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head3 url_prefix() |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head3 description() |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head3 height() |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head3 width() |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head3 mime_type() |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head3 date_posted() |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=head3 date_taken() |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head3 owner_id() |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head3 title() |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head3 tags() |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=cut |
320
|
|
|
|
|
|
|
1; |