]> git.mxchange.org Git - friendica.git/commitdiff
Add support for profile_*_color in API
authorPierre Rudloff <contact@rudloff.pro>
Mon, 18 Dec 2017 19:39:35 +0000 (20:39 +0100)
committerPierre Rudloff <contact@rudloff.pro>
Mon, 18 Dec 2017 20:57:30 +0000 (21:57 +0100)
include/api.php

index 2aa8fc645cf1816a24dcbd5d9ce36c1405e15dd1..7a2d411a8d74ee77b724762ff933e0ee1b951057 100644 (file)
@@ -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;
 }