summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-11-11 14:02:57 -0500
committerCraig Andrews <candrews@integralblue.com>2009-11-11 14:04:44 -0500
commit014d6b1d19b6ae5de8d87f055397993f80579f74 (patch)
tree55faca777c7ef1f8576b21f98dc4e3f74e99ac4d /lib/util.php
parent086759f32ab6d2c5aadecb57941e7e14015b8bd6 (diff)
Redid how URL shorteners work. This way is much more like how Evan wants events to work (and more like how the rest of SN works).
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php25
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/util.php b/lib/util.php
index 7aca4af8d..68f3520db 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1423,25 +1423,18 @@ function common_shorten_url($long_url)
if (empty($user)) {
// common current user does not find a user when called from the XMPP daemon
// therefore we'll set one here fix, so that XMPP given URLs may be shortened
- $svc = 'ur1.ca';
+ $shortenerName = 'ur1.ca';
} else {
- $svc = $user->urlshorteningservice;
+ $shortenerName = $user->urlshorteningservice;
}
- global $_shorteners;
- if (!isset($_shorteners[$svc])) {
- //the user selected service doesn't exist, so default to ur1.ca
- $svc = 'ur1.ca';
- }
- if (!isset($_shorteners[$svc])) {
- // no shortener plugins installed.
- return $long_url;
- }
-
- $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
- $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
- $short_url = $short_url_service->shorten($long_url);
- return $short_url;
+ if(Event::handle('StartShortenUrl', array($long_url,$shortenerName,&$shortenedUrl))){
+ //URL wasn't shortened, so return the long url
+ return $long_url;
+ }else{
+ //URL was shortened, so return the result
+ return $shortenedUrl;
+ }
}
function common_client_ip()