From 3e9bc61bbf4b62665da0e0c9e22d1f90742d0ae0 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 18 Dec 2017 20:39:35 +0100 Subject: [PATCH 1/3] 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; } From 35c4a7940a8868e111f09b5a4f873c1e3d44326f Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 19 Dec 2017 01:31:32 +0100 Subject: [PATCH 2/3] Use dba::select() instead of dba::p() in api_get_user --- include/api.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/api.php b/include/api.php index 7a2d411a8d..3a5247e019 100644 --- a/include/api.php +++ b/include/api.php @@ -782,11 +782,7 @@ function api_get_user(App $a, $contact_id = null) // 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(); + $theme_info = dba::select('user', ['theme'], ['uid' => $ret['uid']], ['limit' => 1]); if ($theme_info['theme'] === 'frio') { $schema = PConfig::get($ret['uid'], 'frio', 'schema'); if (($schema) && ($schema != '---')) { From 27646cc4ad8d715317a2ca055b6c3318ddf555a9 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 19 Dec 2017 11:33:59 +0100 Subject: [PATCH 3/3] Code standards in api_get_user --- include/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/api.php b/include/api.php index 3a5247e019..7b1fee733c 100644 --- a/include/api.php +++ b/include/api.php @@ -785,10 +785,10 @@ function api_get_user(App $a, $contact_id = null) $theme_info = dba::select('user', ['theme'], ['uid' => $ret['uid']], ['limit' => 1]); if ($theme_info['theme'] === 'frio') { $schema = PConfig::get($ret['uid'], 'frio', 'schema'); - if (($schema) && ($schema != '---')) { + if ($schema && ($schema != '---')) { if (file_exists('view/theme/frio/schema/'.$schema.'.php')) { $schemefile = 'view/theme/frio/schema/'.$schema.'.php'; - require_once($schemefile); + require_once $schemefile; } } else { $nav_bg = PConfig::get($ret['uid'], 'frio', 'nav_bg');