about summary refs log tree commit diff stats
path: root/update/plugin/mediawiki/trunk/extensions/instadisc.php
blob: dec5a2858a52741c285c6ae66417bac3850d651e (plain) (blame)
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
56
57
58
59
60
61
62
63
64
<?php

/* InstaDisc Update - A Four Island Project */

$wgExtensionCredits['other'][] = array(
	'name' => 'InstaDisc',
	'author' => 'Starla Insigna',
	'url' => 'http://fourisland.com/projects/instadisc/wiki/Update/MediaWiki',
	'description' => 'This plugin provides an InstaDisc feed for your MediaWiki wiki, a page-change subscription.'
);

$wgHooks['ArticleSaveComplete'][] = 'instaDisc_sendItem';

function instaDisc_sendItem(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, &$revision)
{
	global $instaDisc_password, $instaDisc_subscriptionPersonal, $instaDisc_seriesURL, $instaDisc_seriesUsername, $instaDisc_seriesPassword, $instaDisc_subscriptionID, $instaDisc_subscriptionURL, $instaDisc_subscriptionTitle, $instaDisc_subscriptionCategory;

	if (!isset($instaDisc_password) || !isset($instaDisc_subscriptionPersonal) || !isset($instaDisc_seriesURL) || !isset($instaDisc_seriesUsername) || !isset($instaDisc_seriesPassword) || !isset($instaDisc_subscriptionID) || !isset($instaDisc_subscriptionURL) || !isset($instaDisc_subscriptionTitle) || !isset($instaDisc_subscriptionCategory))
	{
		return false;
	}

	$title = $article->getTitle()->getText();
	$author = $user->getName();
	$url = $article->getTitle()->getFullURL();

	$encID = 0;
	if ($instaDisc_password != '')
	{
		$encID = encryptData($title, $author, $url, $instaDisc_password);
	}

	$instaDisc_subscriptionPersonal = ($instaDisc_subscriptionPersonal == 'true' ? 'true' : 'false');

	$verID = rand(1,2147483647);

	$client = new xmlrpc_client($instaDisc_seriesURL);
	$msg = new xmlrpcmsg("InstaDisc.sendFromUpdate", array(	new xmlrpcval($instaDisc_seriesUsername, 'string'),
								new xmlrpcval(md5($instaDisc_seriesUsername . ':' . md5($instaDisc_seriesPassword) . ':' . $verID), 'string'),
								new xmlrpcval($verID, 'int'),
								new xmlrpcval($instaDisc_seriesURL, 'string'),
								new xmlrpcval($instaDisc_subscriptionID, 'string'),
								new xmlrpcval($instaDisc_subscriptionURL, 'string'),
								new xmlrpcval($instaDisc_subscriptionTitle, 'string'),
								new xmlrpcval($instaDisc_subscriptionCategory, 'string'),
								new xmlrpcval($instaDisc_subscriptionPersonal, 'string'),
								new xmlrpcval($title, 'string'),
								new xmlrpcval($author, 'string'),
								new xmlrpcval($url, 'string'),
								new xmlrpcval(serialize(array()), 'string'),
								new xmlrpcval($encID, 'int')));
	$resp = $client->send($msg);
	$val = $resp->value()->scalarVal();

	if ($val == 2)
	{
		instaDisc_sendItem($article, $user, $text, $summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision);
	} else if ($val == 0)
	{
		return true;
	} else {
		return false;
	}
}