diff options
author | Craig Andrews <candrews@integralblue.com> | 2010-01-05 17:47:37 -0500 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2010-01-05 17:49:28 -0500 |
commit | 250bcfa8dc3ebf3c2c8458f363a62c529eb3a7f6 (patch) | |
tree | 4fd0fb9272a06f38bc3ba7a9522015b92fdd224f /classes/File.php | |
parent | 7e01bb8d4f9036a7e1638aa7ba325f7660b5b086 (diff) |
Require users to login to view attachments on private sites
Thank you jeff-themovie for this implementation!
Diffstat (limited to 'classes/File.php')
-rw-r--r-- | classes/File.php | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/classes/File.php b/classes/File.php index e04a9d525..6173f31d6 100644 --- a/classes/File.php +++ b/classes/File.php @@ -182,25 +182,32 @@ class File extends Memcached_DataObject static function url($filename) { - $path = common_config('attachments', 'path'); + if(common_config('site','private')) { - if ($path[strlen($path)-1] != '/') { - $path .= '/'; - } + return common_local_url('getfile', + array('filename' => $filename)); - if ($path[0] != '/') { - $path = '/'.$path; - } + } else { + $path = common_config('attachments', 'path'); - $server = common_config('attachments', 'server'); + if ($path[strlen($path)-1] != '/') { + $path .= '/'; + } - if (empty($server)) { - $server = common_config('site', 'server'); - } + if ($path[0] != '/') { + $path = '/'.$path; + } + + $server = common_config('attachments', 'server'); - // XXX: protocol + if (empty($server)) { + $server = common_config('site', 'server'); + } - return 'http://'.$server.$path.$filename; + // XXX: protocol + + return 'http://'.$server.$path.$filename; + } } function getEnclosure(){ |