diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-06-15 10:45:50 -0700 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-06-15 10:45:50 -0700 |
commit | c077ad0775218e6aa8660ba97129ad74b5d54773 (patch) | |
tree | 665f2f378c585de2c16e70bf8accd2f6cc6aebe9 /classes | |
parent | eb6a60ef8833d0a34768f2717f2a34fdcd52e5ce (diff) |
Configurable avatar directory
Avatar directory and path are configurable.
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Avatar.php | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/classes/Avatar.php b/classes/Avatar.php index db9d78e47..5e8b315fe 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -55,19 +55,43 @@ class Avatar extends Memcached_DataObject static function path($filename) { - return INSTALLDIR . '/avatar/' . $filename; + $dir = common_config('avatar', 'dir'); + + if ($dir[strlen($dir)-1] != '/') { + $dir .= '/'; + } + + return $dir . $filename; } static function url($filename) { - return common_path('avatar/'.$filename); + $path = common_config('avatar', 'path'); + + if ($path[strlen($path)-1] != '/') { + $path .= '/'; + } + + if ($path[0] != '/') { + $path = '/'.$path; + } + + $server = common_config('avatar', 'server'); + + if (empty($server)) { + $server = common_config('site', 'server'); + } + + // XXX: protocol + + return 'http://'.$server.$path.$filename; } function displayUrl() { $server = common_config('avatar', 'server'); if ($server) { - return 'http://'.$server.'/'.$this->filename; + return Avatar::url($this->filename); } else { return $this->url; } |