-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbeaconhandler.php
55 lines (37 loc) · 1.34 KB
/
beaconhandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Habari;
class BeaconHandler extends ActionHandler {
public function __construct ( ) {
}
public function act_request ( ) {
// @todo limit this to GUIDs POST'd
$plugins = Posts::get( array( 'content_type' => 'addon', 'nolimit' => true, 'status' => Post::status('published') ) );
$xml = new SimpleXMLElement( '<updates></updates>' );
foreach ( $plugins as $plugin ) {
// if we don't have any versions, skip this plugin
if ( empty( $plugin->info->versions ) ) {
//continue;
}
// create the beacon's node
$beacon = $xml->addChild( 'beacon' );
$beacon['id'] = $plugin->info->guid;
$beacon['name'] = $plugin->title;
$beacon['url'] = $plugin->permalink;
$beacon['type'] = $plugin->info->type;
foreach ( $plugin->info->versions as $version ) {
// @todo limit this to only versions older than the one POST'd
$update = $beacon->addChild( 'update', $version['description'] );
$update['severity'] = $version['severity'];
$update['version'] = $version['version'];
$update['habari_version'] = $version['habari_version'];
$update['url'] = $version['url'];
$update['date'] = HabariDateTime::date_create( $version->date )->format('c');
}
}
// spit out the xml
ob_clean(); // clean the output buffer
header( 'Content-type: application/xml' );
echo $xml->asXML();
}
}
?>