summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-06-02 13:57:25 -0400
committerEvan Prodromou <evan@prodromou.name>2008-06-02 13:57:25 -0400
commit326def19652fc6946a53989f80dd88be940d0f8e (patch)
tree384429c5ef9028c13569587ea6827397ec455cbc
parent03677f1a81bcde5541bda6322e0dd0b0fb847ecd (diff)
move service-matching callbacks to library
darcs-hash:20080602175725-84dde-c8b3abaedcb8667130da2a080a09630d91969b5c.gz
-rw-r--r--actions/remotesubscribe.php24
-rw-r--r--lib/omb.php13
2 files changed, 16 insertions, 21 deletions
diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php
index 84bd63263..d3420f888 100644
--- a/actions/remotesubscribe.php
+++ b/actions/remotesubscribe.php
@@ -129,7 +129,7 @@ class RemotesubscribeAction extends Action {
# XXX: the following code could probably be refactored to eliminate dupes
- $oauth_service = $xrds->services(array($this, 'matchOAuth'));
+ $oauth_service = $xrds->services(omb_match_service(OAUTH_DISCOVERY));
if (!$oauth_service) {
return NULL;
@@ -138,7 +138,7 @@ class RemotesubscribeAction extends Action {
$xrd = $this->getXRD($oauth_service, $xrds);
$this->addServices($xrd, $oauth_endpoints, $omb);
- $omb_service = $xrds->services(array($this, 'matchOMB'));
+ $omb_service = $xrds->services(omb_match_service(OMB_NAMESPACE));
if (!$omb_service) {
return NULL;
@@ -183,9 +183,7 @@ class RemotesubscribeAction extends Action {
function addServices($xrd, $types, &$omb) {
foreach ($types as $type) {
- $filter = create_function('$s',
- 'return RemotesubscribeAction::matchService($s, \''.$type.'\'');
- $matches = $xrd->services($filter);
+ $matches = $xrd->services(omb_match_service($type));
if ($matches) {
$omb[$type] = $services[0];
} else {
@@ -196,22 +194,6 @@ class RemotesubscribeAction extends Action {
return true;
}
- function matchOAuth($service) {
- return $this->matchService($service, OAUTH_DISCOVERY);
- }
-
- function matchOMB($service) {
- return $this->matchService($service, OMB_VERSION_01);
- }
-
- function matchService($service, $type) {
- if ($service && $service->matchTypes(array($type))) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
function request_token($omb) {
$con = omb_oauth_consumer();
diff --git a/lib/omb.php b/lib/omb.php
index 91c1906e3..9efdaff62 100644
--- a/lib/omb.php
+++ b/lib/omb.php
@@ -61,6 +61,19 @@ function omb_hmac_sha1() {
return $hmac_method;
}
+function omb_service_filter($type) {
+ return create_function('$s',
+ 'return omb_match_service($s, \''.$type.'\'');
+}
+
+function omb_match_service($service, $type) {
+ if ($service && $service->matchTypes(array($type))) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
function omb_service_uri($service) {
$uris = $service->getURIs();
if (!$uris) {