X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FFile_redirection.php;h=53c15bf8b213b95e43a78e937eee634151cfd973;hb=2e2519afee87009165c97026737f72634461e82b;hp=1976e3439cf0525bca9ab4aaa284d97c682cb8ca;hpb=bd566b6f855a19efb1d74eeaa39ab4e621903b12;p=quix0rs-gnu-social.git diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 1976e3439c..53c15bf8b2 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -139,6 +139,7 @@ class File_redirection extends Memcached_DataObject * reached. * * @param string $in_url + * @param boolean $discover true to attempt dereferencing the redirect if we don't know it already * @return mixed one of: * string - target URL, if this is a direct link or a known redirect * array - redirect info if this is an *unknown* redirect: @@ -150,7 +151,7 @@ class File_redirection extends Memcached_DataObject * size (optional): byte size from Content-Length header * time (optional): timestamp from Last-Modified header */ - public function where($in_url) { + public function where($in_url, $discover=true) { // let's see if we know this... $a = File::staticGet('url', $in_url); @@ -166,8 +167,13 @@ class File_redirection extends Memcached_DataObject } } - $ret = File_redirection::lookupWhere($in_url); - return $ret; + if ($discover) { + $ret = File_redirection::lookupWhere($in_url); + return $ret; + } else { + // No manual dereferencing; leave the unknown URL as is. + return $in_url; + } } /** @@ -181,13 +187,14 @@ class File_redirection extends Memcached_DataObject * may be saved. * * @param string $long_url + * @param User $user whose shortening options to use; defaults to the current web session user * @return string */ - function makeShort($long_url) { + function makeShort($long_url, $user=null) { $canon = File_redirection::_canonUrl($long_url); - $short_url = File_redirection::_userMakeShort($canon); + $short_url = File_redirection::_userMakeShort($canon, $user); // Did we get one? Is it shorter? if (!empty($short_url) && mb_strlen($short_url) < mb_strlen($long_url)) { @@ -197,8 +204,8 @@ class File_redirection extends Memcached_DataObject } } - function _userMakeShort($long_url) { - $short_url = common_shorten_url($long_url); + function _userMakeShort($long_url, User $user=null) { + $short_url = common_shorten_url($long_url, $user); if (!empty($short_url) && $short_url != $long_url) { $short_url = (string)$short_url; // store it