protected $_user;
/**
+ * String cache reference
+ *
+ * @var Horde_Cache
+ */
+ protected $_cache;
+
+ /**
* Attempts to return a concrete Folks_Friends instance based on $friends.
*
* @param string $friends The type of the concrete Folks_Friends subclass
public function __construct($params)
{
$this->_user = empty($params['user']) ? Auth::getAuth() : $params['user'];
+
+ $this->_cache = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
+ Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
}
/**
*/
public function getBlacklist()
{
- $blacklist = $GLOBALS['cache']->get('folksBlacklist' . $this->_user, $GLOBALS['conf']['cache']['default_lifetime']);
+ $blacklist = $this->_cache->get('folksBlacklist' . $this->_user, $GLOBALS['conf']['cache']['default_lifetime']);
if ($blacklist) {
return unserialize($blacklist);
} else {
if ($blacklist instanceof PEAR_Error) {
return $blacklist;
}
- $GLOBALS['cache']->set('folksBlacklist' . $this->_user, serialize($blacklist));
+ $this->_cache->set('folksBlacklist' . $this->_user, serialize($blacklist));
return $blacklist;
}
}
return $result;
}
- $GLOBALS['cache']->expire('folksBlacklist' . $this->_user);
+ $this->_cache->expire('folksBlacklist' . $this->_user);
return true;
}
return $result;
}
- $GLOBALS['cache']->expire('folksBlacklist' . $this->_user);
+ $this->_cache->expire('folksBlacklist' . $this->_user);
return true;
}
// If we do not need an approval just expire cache
if (!$this->needsApproval($friend)) {
- $GLOBALS['cache']->expire('folksFriends' . $this->_user . $group);
+ $this->_cache->expire('folksFriends' . $this->_user . $group);
}
return true;
*/
public function removeFriend($friend, $group = null)
{
- $GLOBALS['cache']->expire('folksFriends' . $this->_user . $group);
+ $this->_cache->expire('folksFriends' . $this->_user . $group);
return $this->_removeFriend($friend, $group);
}
*/
public function getFriends($group = null)
{
- $friends = $GLOBALS['cache']->get('folksFriends' . $this->_user . $group, $GLOBALS['conf']['cache']['default_lifetime']);
+ $friends = $this->_cache->get('folksFriends' . $this->_user . $group, $GLOBALS['conf']['cache']['default_lifetime']);
if ($friends) {
return unserialize($friends);
} else {
if ($friends instanceof PEAR_Error) {
return $friends;
}
- $GLOBALS['cache']->set('folksFriends' . $this->_user . $group, serialize($friends));
+ $this->_cache->set('folksFriends' . $this->_user . $group, serialize($friends));
return $friends;
}
}
return $result;
}
- $GLOBALS['cache']->expire('folksFriends' . $friend);
- $GLOBALS['cache']->expire('folksFriends' . $this->_user);
+ $this->_cache->expire('folksFriends' . $friend);
+ $this->_cache->expire('folksFriends' . $this->_user);
return true;
}