View | Details | Raw Unified | Return to bug 22358
Collapse All | Expand All

(-)a/Koha/SharedContent.pm (-12 / +50 lines)
Lines 26-40 use Koha::Serials; Link Here
26
use Koha::Reports;
26
use Koha::Reports;
27
use C4::Context;
27
use C4::Context;
28
28
29
=head1 DESCRIPTION
29
=head1 SharedContent
30
31
Koha::SharedContent - Set of methods to quering Mana KB server
30
32
31
Package for accessing shared content via Mana
33
=head1 DESCRIPTION
32
34
33
=head2 Package Functions
35
Package for accessing shared content via Mana KB. Methods here are intended
36
to build and process queries for requesting Mana KB server.
34
37
35
=cut
38
=cut
36
39
37
=head3 process_request
40
=head2 process_request
41
42
Koha::SharedContent::process_request($request);
43
44
Send a request to Mana KB server. URL is defined in koha-conf.xml in mana_config
45
tag. $request parameter must be a HTTP::Request object. See build_request method.
38
46
39
=cut
47
=cut
40
48
Lines 63-69 sub process_request { Link Here
63
    return $result ;
71
    return $result ;
64
}
72
}
65
73
66
=head3 increment_entity_value
74
=head2 increment_entity_value
75
76
Koha::SharedContent::increment_entity_value($entity_type, $mana_entity_id, $field);
77
78
Increment of 1 the field $field of a Mana entity. I.e, this is used to count the number
79
of Koha instance using a specific entity.
67
80
68
=cut
81
=cut
69
82
Lines 71-77 sub increment_entity_value { Link Here
71
    return process_request(build_request('increment', @_));
84
    return process_request(build_request('increment', @_));
72
}
85
}
73
86
74
=head3 send_entity
87
=head2 send_entity
88
89
my $result = Koha::SharedContent::send_entity($language, $borrowernumber, $mana_entity_id, $entity_type);
90
91
Share a Koha entity (i.e subscription or report) to Mana KB.
75
92
76
=cut
93
=cut
77
94
Lines 92-98 sub send_entity { Link Here
92
    return $result;
109
    return $result;
93
}
110
}
94
111
95
=head3 prepare_entity_data
112
=head2 prepare_entity_data
113
114
$data = prepare_entity_data($language, $borrowernumber, $mana_entity_id, $entity_type);
115
116
Prepare Koha entity data to be sent to Mana KB.
96
117
97
=cut
118
=cut
98
119
Lines 126-132 sub prepare_entity_data { Link Here
126
    return $ressource_mana_info;
147
    return $ressource_mana_info;
127
}
148
}
128
149
129
=head3 get_entity_by_id
150
=head2 get_entity_by_id
151
152
my $entity = Koha::SharedContent::get_entity_by_id($entity_type, $mana_entity_id, [{usecomments => 1}]);
153
154
Retrieve a Mana entity to be imported into Koha. Add {usecomments => 1} to tell Mana to
155
embed all user reviews.
130
156
131
=cut
157
=cut
132
158
Lines 134-140 sub get_entity_by_id { Link Here
134
    return process_request(build_request('getwithid', @_));
160
    return process_request(build_request('getwithid', @_));
135
}
161
}
136
162
137
=head3 search_entities
163
=head2 search_entities
164
165
my $result = Koha::SharedContent::search_entities( $entity_type, $search_params );
166
my $entities = $result->{data};
167
168
Search entities on ManaKB.
138
169
139
=cut
170
=cut
140
171
Lines 142-148 sub search_entities { Link Here
142
    return process_request(build_request('get', @_));
173
    return process_request(build_request('get', @_));
143
}
174
}
144
175
145
=head3 build_request
176
=head2 build_request
177
178
$request = build_request($mana_method, [$param1, $param2, ...]);
179
180
Create a HTTP::Request object to be passed to process_request.
146
181
147
=cut
182
=cut
148
183
Lines 201-207 sub build_request { Link Here
201
    }
236
    }
202
}
237
}
203
238
204
=head3 get_sharing_url
239
=head2 get_sharing_url
240
241
my $mana_url = get_sharing_url();
242
243
Get the Mana KB server URL set in koha config file.
205
244
206
=cut
245
=cut
207
246
208
- 

Return to bug 22358