summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Diekershoff <tobias.diekershoff@gmx.net>2009-04-18 19:00:20 +0200
committerTobias Diekershoff <tobias.diekershoff@gmx.net>2009-04-18 19:00:20 +0200
commit7196410bb0398c15fbab767a9b7cedc513e6520b (patch)
treea23e3d3447040e1bdebae3a82b6380625c6bdff9 /lib
parent4277a6818c6ac66158dfba3b94bdc1b2eb06b594 (diff)
shortening links in notices from XMPP
This patch enables shortening of links, that where send from XMPP. The problem was, that in util.php common_current_user() is not finding the user account from which is posted, so the service to shorten is not known, so no shortening at all... This patch cleans up the xmppdaemon a little bit and hard codes ur1.ca as shortening service _if_ the user is not set. Ugly but working.
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php20
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/util.php b/lib/util.php
index 675ff51f0..ab5e99593 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -519,11 +519,16 @@ function common_shorten_links($text)
function common_shorten_link($url, $reverse = false)
{
+
static $url_cache = array();
if ($reverse) return isset($url_cache[$url]) ? $url_cache[$url] : $url;
$user = common_current_user();
-
+ if (!isset($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
+ $user->urlshorteningservice = 'ur1.ca';
+ }
$curlh = curl_init();
curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
@@ -1321,16 +1326,3 @@ function common_compatible_license($from, $to)
// XXX: better compatibility check needed here!
return ($from == $to);
}
-
-/**
- * returns a quoted table name, if required according to config
- */
-function common_database_tablename($tablename)
-{
-
- if(common_config('db','quote_identifiers')) {
- $tablename = '"'. $tablename .'"';
- }
- //table prefixes could be added here later
- return $tablename;
-} \ No newline at end of file