Don't depend on a User being available when looking up Design and timezone

for a profile (because some profiles are remote, etc.)
This commit is contained in:
Zach Copley 2009-12-04 22:40:07 +00:00
parent eb0a5977ff
commit 4881be47c7

View File

@ -134,19 +134,17 @@ class ApiAction extends Action
$twitter_user['protected'] = false; # not supported by StatusNet yet $twitter_user['protected'] = false; # not supported by StatusNet yet
$twitter_user['followers_count'] = $profile->subscriberCount(); $twitter_user['followers_count'] = $profile->subscriberCount();
$design = null;
$user = $profile->getUser(); $user = $profile->getUser();
$design = null;
// Note: some profiles don't have an associated user // Note: some profiles don't have an associated user
$defaultDesign = Design::siteDesign();
if (!empty($user)) { if (!empty($user)) {
$design = $user->getDesign(); $design = $user->getDesign();
} }
if (empty($design)) {
$design = Design::siteDesign();
}
$color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor); $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
$twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue(); $twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue();
$color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor); $color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor);
@ -165,7 +163,7 @@ class ApiAction extends Action
$timezone = 'UTC'; $timezone = 'UTC';
if ($user->timezone) { if (!empty($user) && !empty($user->timezone)) {
$timezone = $user->timezone; $timezone = $user->timezone;
} }