From 3e9bc61bbf4b62665da0e0c9e22d1f90742d0ae0 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 18 Dec 2017 20:39:35 +0100 Subject: [PATCH] Add support for profile_*_color in API --- include/api.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/api.php b/include/api.php index 2aa8fc645c..7a2d411a8d 100644 --- a/include/api.php +++ b/include/api.php @@ -10,6 +10,7 @@ use Friendica\Content\Feature; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\NotificationsManager; +use Friendica\Core\PConfig; use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Model\Contact; @@ -779,6 +780,41 @@ function api_get_user(App $a, $contact_id = null) 'network' => $uinfo[0]['network'], ); + // If this is a local user and it uses Frio, we can get its color preferences. + if ($ret['self']) { + $r = dba::p( + "select theme from user where uid = ? limit 1", + $ret['uid'] + ); + $theme_info = $r->fetch(); + if ($theme_info['theme'] === 'frio') { + $schema = PConfig::get($ret['uid'], 'frio', 'schema'); + if (($schema) && ($schema != '---')) { + if (file_exists('view/theme/frio/schema/'.$schema.'.php')) { + $schemefile = 'view/theme/frio/schema/'.$schema.'.php'; + require_once($schemefile); + } + } else { + $nav_bg = PConfig::get($ret['uid'], 'frio', 'nav_bg'); + $link_color = PConfig::get($ret['uid'], 'frio', 'link_color'); + $bgcolor = PConfig::get($ret['uid'], 'frio', 'background_color'); + } + if (!$nav_bg) { + $nav_bg = "#708fa0"; + } + if (!$link_color) { + $link_color = "#6fdbe8"; + } + if (!$bgcolor) { + $bgcolor = "#ededed"; + } + + $ret['profile_sidebar_fill_color'] = str_replace('#', '', $nav_bg); + $ret['profile_link_color'] = str_replace('#', '', $link_color); + $ret['profile_background_color'] = str_replace('#', '', $bgcolor); + } + } + return $ret; } -- 2.39.5