From 373bb0822b2040d54fc17717840b5adfe15d1223 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sat, 27 Jun 2015 14:10:43 +0200
Subject: [PATCH 1/3] get the themes settings of foreign profiles
---
boot.php | 39 ++++++++++++++++++--
include/identity.php | 21 ++++++++++-
mod/photos.php | 87 ++++++++++++++++++++++----------------------
mod/videos.php | 11 +++---
4 files changed, 104 insertions(+), 54 deletions(-)
diff --git a/boot.php b/boot.php
index 2767709b81..200c7e794e 100644
--- a/boot.php
+++ b/boot.php
@@ -358,6 +358,7 @@ if(! class_exists('App')) {
public $config;
public $page;
public $profile;
+ public $profile_uid;
public $user;
public $cid;
public $contact;
@@ -1446,10 +1447,33 @@ if(! function_exists('current_theme')) {
$a = get_app();
+ $page_theme = null;
+
+ // Find the theme that belongs to the user whose stuff we are looking at
+
+ if($a->profile_uid && $a->profile_uid != local_user()) {
+ $r = q("select theme from user where uid = %d limit 1",
+ intval($a->profile_uid)
+ );
+ if($r)
+ $page_theme = $r[0]['theme'];
+ }
+
+ // Allow folks to over-rule user themes and always use their own on their own site.
+ // This works only if the user is on the same server
+
+ if($page_theme && local_user() && local_user() != $a->profile_url) {
+ if(get_pconfig(local_user(),'system','always_my_theme'))
+ $page_theme = null;
+ }
+
// $mobile_detect = new Mobile_Detect();
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
$is_mobile = $a->is_mobile || $a->is_tablet;
+ $standard_system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
+ $standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme);
+
if($is_mobile) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$system_theme = '';
@@ -1466,9 +1490,12 @@ if(! function_exists('current_theme')) {
}
}
}
- if(!$is_mobile || ($system_theme === '' && $theme_name === '')) {
- $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
- $theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
+ else {
+ $system_theme = $standard_system_theme;
+ $theme_name = $standard_theme_name;
+
+ if($page_theme)
+ $theme_name = $page_theme;
}
if($theme_name &&
@@ -1496,9 +1523,13 @@ if(! function_exists('current_theme')) {
if(! function_exists('current_theme_url')) {
function current_theme_url() {
global $a;
+
$t = current_theme();
+
+ $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
if (file_exists('view/theme/' . $t . '/style.php'))
- return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss');
+ return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss' . $opts);
+
return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
}
}
diff --git a/include/identity.php b/include/identity.php
index bc930a3c6f..bf5d969274 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -90,14 +90,15 @@ if(! function_exists('profile_load')) {
}
$a->profile = $r[0];
+ $a->profile_uid = $r[0]['profile_uid'];
$a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->profile['network'] = NETWORK_DFRN;
$a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
- if (!$profiledata)
- $_SESSION['theme'] = $a->profile['theme'];
+// if (!$profiledata)
+// $_SESSION['theme'] = $a->profile['theme'];
$_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
@@ -726,3 +727,19 @@ function zrl($s,$force = false) {
return $s . $achar . 'zrl=' . urlencode($mine);
return $s;
}
+
+// Used from within PCSS themes to set theme parameters. If there's a
+// puid request variable, that is the "page owner" and normally their theme
+// settings take precedence; unless a local user sets the "always_my_theme"
+// system pconfig, which means they don't want to see anybody else's theme
+// settings except their own while on this site.
+
+function get_theme_uid() {
+ $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
+ if(local_user()) {
+ if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))
+ return local_user();
+ }
+
+ return $uid;
+}
diff --git a/mod/photos.php b/mod/photos.php
index ca770d95aa..9866b2e31e 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -29,71 +29,72 @@ function photos_init(&$a) {
return;
$a->data['user'] = $r[0];
+ $a->profile_uid = $r[0]['uid'];
- $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');
+ $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');
- $tpl = get_markup_template("vcard-widget.tpl");
+ $tpl = get_markup_template("vcard-widget.tpl");
$vcard_widget .= replace_macros($tpl, array(
- '$name' => $a->data['user']['username'],
- '$photo' => $profilephoto
- ));
+ '$name' => $a->data['user']['username'],
+ '$photo' => $profilephoto
+ ));
$sql_extra = permissions_sql($a->data['user']['uid']);
$albums = q("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
- $sql_extra group by album order by created desc",
+ $sql_extra group by album order by created desc",
intval($a->data['user']['uid']),
- dbesc('Contact Photos'),
- dbesc( t('Contact Photos'))
+ dbesc('Contact Photos'),
+ dbesc( t('Contact Photos'))
);
- $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
+ $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
- // add various encodings to the array so we can just loop through and pick them out in a template
- $ret = array('success' => false);
+ // add various encodings to the array so we can just loop through and pick them out in a template
+ $ret = array('success' => false);
- if($albums) {
- $a->data['albums'] = $albums;
- if ($albums_visible)
- $ret['success'] = true;
+ if($albums) {
+ $a->data['albums'] = $albums;
+ if ($albums_visible)
+ $ret['success'] = true;
- $ret['albums'] = array();
- foreach($albums as $k => $album) {
- $entry = array(
- 'text' => $album['album'],
- 'total' => $album['total'],
- 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']),
- 'urlencode' => urlencode($album['album']),
- 'bin2hex' => bin2hex($album['album'])
- );
- $ret['albums'][] = $entry;
- }
- }
+ $ret['albums'] = array();
+ foreach($albums as $k => $album) {
+ $entry = array(
+ 'text' => $album['album'],
+ 'total' => $album['total'],
+ 'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']),
+ 'urlencode' => urlencode($album['album']),
+ 'bin2hex' => bin2hex($album['album'])
+ );
+ $ret['albums'][] = $entry;
+ }
+ }
- $albums = $ret;
+ $albums = $ret;
- if(local_user() && $a->data['user']['uid'] == local_user())
- $can_post = true;
+ if(local_user() && $a->data['user']['uid'] == local_user())
+ $can_post = true;
- if($albums['success']) {
- $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array(
- '$nick' => $a->data['user']['nickname'],
- '$title' => t('Photo Albums'),
- 'recent' => t('Recent Photos'),
- '$albums' => $albums['albums'],
- '$baseurl' => z_root(),
- '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'),
- '$can_post' => $can_post
- ));
- }
+ if($albums['success']) {
+ $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'),array(
+ '$nick' => $a->data['user']['nickname'],
+ '$title' => t('Photo Albums'),
+ 'recent' => t('Recent Photos'),
+ '$albums' => $albums['albums'],
+ '$baseurl' => z_root(),
+ '$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'),
+ '$can_post' => $can_post
+ ));
+ }
if(! x($a->page,'aside'))
$a->page['aside'] = '';
- $a->page['aside'] .= $vcard_widget;
- $a->page['aside'] .= $photo_albums_widget;
+ $a->page['aside'] .= $vcard_widget;
+ $a->page['aside'] .= $photo_albums_widget;
$tpl = get_markup_template("photos_head.tpl");
diff --git a/mod/videos.php b/mod/videos.php
index 943a9d09f2..df47262f1d 100644
--- a/mod/videos.php
+++ b/mod/videos.php
@@ -27,15 +27,16 @@ function videos_init(&$a) {
return;
$a->data['user'] = $r[0];
+ $a->profile_uid = $r[0]['uid'];
- $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');
+ $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');
- $tpl = get_markup_template("vcard-widget.tpl");
+ $tpl = get_markup_template("vcard-widget.tpl");
$vcard_widget = replace_macros($tpl, array(
- '$name' => $a->data['user']['username'],
- '$photo' => $profilephoto
- ));
+ '$name' => $a->data['user']['username'],
+ '$photo' => $profilephoto
+ ));
/*$sql_extra = permissions_sql($a->data['user']['uid']);
From 4463ae11d840e812e7cde408a272571a0f4f8bce Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sun, 28 Jun 2015 13:32:03 +0200
Subject: [PATCH 2/3] change profile_url in profile_uid
---
boot.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/boot.php b/boot.php
index 200c7e794e..6e1951bffd 100644
--- a/boot.php
+++ b/boot.php
@@ -1451,7 +1451,7 @@ if(! function_exists('current_theme')) {
// Find the theme that belongs to the user whose stuff we are looking at
- if($a->profile_uid && $a->profile_uid != local_user()) {
+ if($a->profile_uid && ($a->profile_uid != local_user())) {
$r = q("select theme from user where uid = %d limit 1",
intval($a->profile_uid)
);
@@ -1462,7 +1462,7 @@ if(! function_exists('current_theme')) {
// Allow folks to over-rule user themes and always use their own on their own site.
// This works only if the user is on the same server
- if($page_theme && local_user() && local_user() != $a->profile_url) {
+ if($page_theme && local_user() && (local_user() != $a->profile_uid)) {
if(get_pconfig(local_user(),'system','always_my_theme'))
$page_theme = null;
}
From 36abf624d8646df53a336fcf23086153949614a1 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Mon, 29 Jun 2015 23:03:44 +0200
Subject: [PATCH 3/3] make supported themes compatible with get_theme_uid
---
view/theme/duepuntozero/style.php | 20 +++++++++++++++++++-
view/theme/quattro/style.php | 14 ++++++++------
view/theme/vier/style.php | 30 ++++++++++++++++++++++++++++++
view/theme/vier/theme.php | 19 -------------------
4 files changed, 57 insertions(+), 26 deletions(-)
create mode 100644 view/theme/vier/style.php
diff --git a/view/theme/duepuntozero/style.php b/view/theme/duepuntozero/style.php
index d5f8696a79..89f44d9c04 100644
--- a/view/theme/duepuntozero/style.php
+++ b/view/theme/duepuntozero/style.php
@@ -2,10 +2,28 @@
if (file_exists("$THEMEPATH/style.css")){
echo file_get_contents("$THEMEPATH/style.css");
}
+$uid = get_theme_uid();
+
$s_colorset = get_config('duepuntozero','colorset');
-$uid = local_user();
$colorset = get_pconfig( $uid, 'duepuntozero', 'colorset');
if (!x($colorset))
$colorset = $s_colorset;
+if ($colorset) {
+ if ($colorset == 'greenzero')
+ $setcss = file_get_contents('view/theme/duepuntozero/deriv/greenzero.css');
+ if ($colorset == 'purplezero')
+ $setcss = file_get_contents('view/theme/duepuntozero/deriv/purplezero.css');
+ if ($colorset == 'easterbunny')
+ $setcss = file_get_contents('view/theme/duepuntozero/deriv/easterbunny.css');
+ if ($colorset == 'darkzero')
+ $setcss = file_get_contents('view/theme/duepuntozero/deriv/darkzero.css');
+ if ($colorset == 'comix')
+ $setcss = file_get_contents('view/theme/duepuntozero/deriv/comix.css');
+ if ($colorset == 'slackr')
+ $setcss = file_get_contents('view/theme/duepuntozero/deriv/slackr.css');
+}
+
+echo $setcss;
+
?>
diff --git a/view/theme/quattro/style.php b/view/theme/quattro/style.php
index c75091eb5b..bf0b1e0428 100644
--- a/view/theme/quattro/style.php
+++ b/view/theme/quattro/style.php
@@ -1,12 +1,14 @@
get_baseurl();
$a->theme_info = array();
-$style = get_pconfig(local_user(), 'vier', 'style');
-
-if ($style == "")
- $style = get_config('vier', 'style');
-
-if ($style == "")
- $style = "plus";
-
-if ($style == "flat")
- $a->page['htmlhead'] .= ''."\n";
-else if ($style == "netcolour")
- $a->page['htmlhead'] .= ''."\n";
-else if ($style == "breathe")
- $a->page['htmlhead'] .= ''."\n";
-else if ($style == "plus")
- $a->page['htmlhead'] .= ''."\n";
-else if ($style == "dark")
- $a->page['htmlhead'] .= ''."\n";
-
$a->page['htmlhead'] .= <<< EOT