diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-10 17:04:51 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-10 17:04:51 -0800 |
commit | c6f09306b1c72296db8b55500a5d6a2ea8cd5dd2 (patch) | |
tree | d623c7b98c2d99ddac3116b8114b90c1db4e18c6 /plugins/OStatus/OStatusPlugin.php | |
parent | 2a426f24c0599710ef170b01f7f7124b7166e12e (diff) | |
parent | 66518df4356ea878bfd8693191f0354caebfb549 (diff) |
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/OStatus/OStatusPlugin.php')
-rw-r--r-- | plugins/OStatus/OStatusPlugin.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 38042803f..b472ae242 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; + } + } |