summaryrefslogtreecommitdiff
path: root/plugins/OStatus/OStatusPlugin.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-10 17:00:05 -0800
committerBrion Vibber <brion@pobox.com>2010-03-10 17:00:05 -0800
commit66518df4356ea878bfd8693191f0354caebfb549 (patch)
tree1d281cf5ec0dba7ec28da10b61538fd1bfb8a523 /plugins/OStatus/OStatusPlugin.php
parent5cd020bf299619ca2844f4d14418891a59a0dd22 (diff)
OStatus: reject attempts to create a remote profile for a local user or group.
Some stray shadow entries were ending up getting created, which would steal group posts from remote users. Run plugins/OStatus/scripts/fixup-shadow.php for each site to remove any existing ones.
Diffstat (limited to 'plugins/OStatus/OStatusPlugin.php')
-rw-r--r--plugins/OStatus/OStatusPlugin.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index a97f3475b..ef28ab22e 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -929,4 +929,41 @@ class OStatusPlugin extends Plugin
return true;
}
+
+ /**
+ * Utility function to check if the given URL is a canonical group profile
+ * page, and if so return the ID number.
+ *
+ * @param string $url
+ * @return mixed int or false
+ */
+ 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]);
+ }
+ return false;
+ }
+
+ /**
+ * Utility function to check if the given URL is a canonical user profile
+ * page, and if so return the ID number.
+ *
+ * @param string $url
+ * @return mixed int or false
+ */
+ public static function localProfileFromUrl($url)
+ {
+ $template = common_local_url('userbyid', 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;
+ }
+
}