public static function getForUser($user, $opts = array())
{
global $injector, $registry;
$opts = array_merge(array('json' => false, 'start' => null, 'end' => null), $opts);
$prefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create('kronolith', array('cache' => false, 'user' => $user));
$registry->setTimeZone();
$cals = @unserialize($prefs->getValue('fb_cals'));
// If the free/busy calendars preference is empty, default to the
// user's default_share preference, and if that's empty, to their
// username.
if (!$cals) {
$cal = $prefs->getValue('default_share');
if (!$cal) {
$cal = $user;
}
$cals = array('internal_' . $cal);
}
try {
$fb = self::generate($cals, $opts['start'], $opts['end'], true, $user);
} catch (Kronolith_Exception $e) {
throw new Kronolith_Exception(sprintf(_("The free/busy data for %s cannot be retrieved."), $user));
}
return $opts['json'] ? self::toJson($fb) : $fb;
}