From 617b6f4f7d3496ad5d8b36d59f7afd761c7650b0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 27 Sep 2010 11:29:54 -0700 Subject: User user_group.uri to look up local groups for OStatus addressing checks when available. Will still fall back to the URL-scheme-checking code if there's no matching user_group record. Should help with keeping remote groups working when renaming sites -- as long as user_group.uri has been filled out on the site changing its domain and other issues with POST handling are resolved. --- plugins/OStatus/OStatusPlugin.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 6cd935c9e..dcf1b3607 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -956,7 +956,7 @@ class OStatusPlugin extends Plugin } /** - * Utility function to check if the given URL is a canonical group profile + * Utility function to check if the given URI is a canonical group profile * page, and if so return the ID number. * * @param string $url @@ -964,11 +964,22 @@ class OStatusPlugin extends Plugin */ public static function localGroupFromUrl($url) { - $template = common_local_url('groupbyid', array('id' => '31337')); - $template = preg_quote($template, '/'); - $template = str_replace('31337', '(\d+)', $template); - if (preg_match("/$template/", $url, $matches)) { - return intval($matches[1]); + $group = User_group::staticGet('uri', $url); + if ($group) { + $local = Local_group::staticGet('id', $group->id); + if ($local) { + return $group->id; + } + } else { + // To find local groups which haven't had their uri fields filled out... + // If the domain has changed since a subscriber got the URI, it'll + // be broken. + $template = common_local_url('groupbyid', array('id' => '31337')); + $template = preg_quote($template, '/'); + $template = str_replace('31337', '(\d+)', $template); + if (preg_match("/$template/", $url, $matches)) { + return intval($matches[1]); + } } return false; } -- cgit v1.2.3-54-g00ecf