aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorZvi ben Yaakov (a.k.a rdc) <coderzvi@infosoc.net>2012-06-18 21:12:13 +0300
committerfriendica <info@friendica.com>2012-06-19 16:05:37 -0700
commit9058029eef611846e705bdac77bb92cdf86eb92a (patch)
tree619f146688011c5584a8edce99caa9b7a01ff3c0 /boot.php
parent9c844e3bbe3fc3f215bac71fa3ab380fc32432f0 (diff)
downloadvolse-hubzilla-9058029eef611846e705bdac77bb92cdf86eb92a.tar.gz
volse-hubzilla-9058029eef611846e705bdac77bb92cdf86eb92a.tar.bz2
volse-hubzilla-9058029eef611846e705bdac77bb92cdf86eb92a.zip
Added get_cached_avatar_image to App class for shared profile image access and reduced sql queries/load
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index 94714f85a..ab71c7e7d 100644
--- a/boot.php
+++ b/boot.php
@@ -332,6 +332,9 @@ if(! class_exists('App')) {
private $curl_code;
private $curl_headers;
+ private $cached_profile_image;
+ private $cached_profile_picdate;
+
function __construct() {
global $default_timezone;
@@ -543,6 +546,28 @@ if(! class_exists('App')) {
return $this->curl_headers;
}
+ function get_cached_avatar_image($avatar_image){
+ if($this->cached_profile_image[$avatar_image])
+ return $this->cached_profile_image[$avatar_image];
+
+ $path_parts = explode("/",$avatar_image);
+ $common_filename = $path_parts[count($path_parts)-1];
+
+ if($this->cached_profile_picdate[$common_filename]){
+ $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
+ } else {
+ $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like \"%%/%s\"",
+ $common_filename);
+ if(! count($r)){
+ $this->cached_profile_image[$avatar_image] = $avatar_image;
+ } else {
+ $this->cached_profile_picdate[$common_filename] = "?rev=" . urlencode($r[0]['picdate']);
+ $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
+ }
+ }
+ return $this->cached_profile_image[$avatar_image];
+ }
+
}
}