provide a controlling user for theme settings, not necessarily local_user() - can't test on my test site so moving into production and I'll debug it there.

This commit is contained in:
friendica 2013-07-16 22:48:05 -07:00
parent 6d447ace5c
commit 4c30cddbfc
4 changed files with 36 additions and 15 deletions

View File

@ -513,6 +513,9 @@ class App {
public $account = null; // account record public $account = null; // account record
public $channel = null; // channel record public $channel = null; // channel record
public $observer = null; // xchan record public $observer = null; // xchan record
public $profile_uid = 0; // If applicable, the uid of the person whose stuff this is.
private $perms = null; // observer permissions private $perms = null; // observer permissions
private $widgets = array(); // widgets for this page private $widgets = array(); // widgets for this page
@ -1533,7 +1536,7 @@ function profile_load(&$a, $nickname, $profile = '') {
} }
$a->profile = $r[0]; $a->profile = $r[0];
$a->profile_uid = $r[0]['profile_uid'];
$a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname(); $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname();
@ -2339,3 +2342,7 @@ function head_get_icon() {
$icon = z_root() . $icon; $icon = z_root() . $icon;
return $icon; return $icon;
} }
function get_controlling_channel_id() {
return get_app()->profile_uid;
}

View File

@ -43,6 +43,8 @@ function channelx_by_n($id) {
function vcard_from_xchan($xchan, $observer = null, $mode = '') { function vcard_from_xchan($xchan, $observer = null, $mode = '') {
$a = get_app();
$connect = false; $connect = false;
if(local_user()) { if(local_user()) {
$r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
@ -53,6 +55,9 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') {
$connect = t('Connect'); $connect = t('Connect');
} }
if(array_key_exists('channel_id',$xchan))
$a->profile_uid = $xchan['channel_id'];
$url = (($observer) $url = (($observer)
? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr']
: $xchan['xchan_url'] : $xchan['xchan_url']

View File

@ -3,6 +3,7 @@
require_once('include/settings.php'); require_once('include/settings.php');
function get_theme_config_file($theme){ function get_theme_config_file($theme){
$base_theme = get_app()->theme_info['extends']; $base_theme = get_app()->theme_info['extends'];
@ -16,6 +17,11 @@ function get_theme_config_file($theme){
return null; return null;
} }
function settings_init(&$a) {
$a->profile_uid = local_user();
}
function settings_aside(&$a) { function settings_aside(&$a) {

View File

@ -2,7 +2,10 @@
// This needs changing now, if we're going for global settings. Admin settings have been removed in preparation, You *should* just be able to remove all // This needs changing now, if we're going for global settings. Admin settings have been removed in preparation, You *should* just be able to remove all
// the get_config bits, though this is untested. // the get_config bits, though this is untested.
// We also need to eventually. Use the page owners settings for everybody - get_pconfig(page_owner()) or whatever that would look like. // We also need to eventually. Use the page owners settings for everybody - get_pconfig(page_owner()) or whatever that would look like.
load_pconfig(local_user(),'redbasic');
$uid = get_controlling_channel_id();
load_pconfig($uid,'redbasic');
$line_height = false; $line_height = false;
$redbasic_font_size = false; $redbasic_font_size = false;
@ -31,25 +34,25 @@
if($x !== false) if($x !== false)
$radius = $x; $radius = $x;
if (local_user()) { if ($uid) {
$line_height = get_pconfig(local_user(), "redbasic","line_height"); $line_height = get_pconfig($uid, "redbasic","line_height");
$redbasic_font_size = get_pconfig(local_user(), "redbasic", "font_size"); $redbasic_font_size = get_pconfig($uid, "redbasic", "font_size");
$colour = get_pconfig(local_user(), "redbasic", "colour"); $colour = get_pconfig($uid, "redbasic", "colour");
$shadows = get_pconfig(local_user(), "redbasic", "shadow"); $shadows = get_pconfig($uid, "redbasic", "shadow");
$navcolour = get_pconfig(local_user(), "redbasic", "navcolour"); $navcolour = get_pconfig($uid, "redbasic", "navcolour");
$displaystyle = get_pconfig(local_user(), "redbasic", "displaystyle"); $displaystyle = get_pconfig($uid, "redbasic", "displaystyle");
$linkcolour = get_pconfig(local_user(), "redbasic", "linkcolour"); $linkcolour = get_pconfig($uid, "redbasic", "linkcolour");
$shiny = get_pconfig(local_user(), "redbasic", "shiny"); $shiny = get_pconfig($uid, "redbasic", "shiny");
$x = get_pconfig(local_user(),'redbasic','radius'); $x = get_pconfig($uid,'redbasic','radius');
if($x !== false) if($x !== false)
$radius = $x; $radius = $x;
if (! feature_enabled(local_user(),'expert')) {$colour_scheme = get_pconfig(local_user(), "redbasic", "colour_scheme");} if (! feature_enabled($uid,'expert')) {$colour_scheme = get_pconfig($uid, "redbasic", "colour_scheme");}
} }
// In non-expert mode, we just let them choose font size, line height, and a colour scheme. A colour scheme is just a pre-defined set of the above variables. // In non-expert mode, we just let them choose font size, line height, and a colour scheme. A colour scheme is just a pre-defined set of the above variables.
// But only apply these settings in non-expert mode to prevent confusion when turning expert mode on and off. // But only apply these settings in non-expert mode to prevent confusion when turning expert mode on and off.
if(! feature_enabled(local_user(),'expert')) { if(! feature_enabled($uid,'expert')) {
if ($colour_scheme === 'fancyred') {$shadows = true; $navcolour = 'black'; $displaystyle = 'fancy'; $linkcolour = 'f00'; $shiny = "opaque";} if ($colour_scheme === 'fancyred') {$shadows = true; $navcolour = 'black'; $displaystyle = 'fancy'; $linkcolour = 'f00'; $shiny = "opaque";}
// Dark themes are very different - we need to do some of these from scratch, so don't bother setting vars for anything else // Dark themes are very different - we need to do some of these from scratch, so don't bother setting vars for anything else
if ($colour_scheme === 'dark') {$colour = 'dark'; $navcolour = 'black';} if ($colour_scheme === 'dark') {$colour = 'dark'; $navcolour = 'black';}
@ -59,7 +62,7 @@
} }
// This is probably the easiest place to apply global settings. Don't bother with site line height and such. Instead, check pconfig for global user settings. // This is probably the easiest place to apply global settings. Don't bother with site line height and such. Instead, check pconfig for global user settings.
// eg, if ($redbasic_font_size === false) {$redbasic_font_size = get_pconfig(local_user(), "global", "font_size"); If it's not set, we'll just use the CSS with no changes. // eg, if ($redbasic_font_size === false) {$redbasic_font_size = get_pconfig($uid, "global", "font_size"); If it's not set, we'll just use the CSS with no changes.
// Then all you need to do is add a "Global Settings" tab to settings/display, and make an equivalent of theme_settings.tpl and config.php to be loaded there. Easy. // Then all you need to do is add a "Global Settings" tab to settings/display, and make an equivalent of theme_settings.tpl and config.php to be loaded there. Easy.
if ($line_height === false) {$line_height = $site_line_height;} if ($line_height === false) {$line_height = $site_line_height;}