diff --git a/boot.php b/boot.php index 75ea5346e..7754ad1f4 100644 --- a/boot.php +++ b/boot.php @@ -131,7 +131,9 @@ class App { function init_pagehead() { if(file_exists("view/head.tpl")) $s = file_get_contents("view/head.tpl"); - $this->page['htmlhead'] = replace_macros($s,array('$baseurl' => $this->get_baseurl())); + $this->page['htmlhead'] = replace_macros($s,array( + '$baseurl' => $this->get_baseurl() + )); } }} diff --git a/database.sql b/database.sql index a275f39b3..0cbfc754d 100644 --- a/database.sql +++ b/database.sql @@ -328,6 +328,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `nickname` char(255) NOT NULL, `email` char(255) NOT NULL, `timezone` char(128) NOT NULL, + `theme` char(255) NOT NULL, `pubkey` text NOT NULL, `prvkey` text NOT NULL, `verified` tinyint(1) unsigned NOT NULL DEFAULT '0', diff --git a/include/auth.php b/include/auth.php index 8d2a0e2d0..745285ef0 100644 --- a/include/auth.php +++ b/include/auth.php @@ -10,6 +10,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) { unset($_SESSION['is_visitor']); unset($_SESSION['administrator']); unset($_SESSION['cid']); + unset($_SESSION['theme']); notice( t('Logged out.') . EOL); goaway($a->get_baseurl()); } @@ -20,6 +21,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) { goaway($a->get_baseurl()); } $a->user = $r[0]; + $_SESSION['theme'] = $a->user['theme']; if(strlen($a->user['timezone'])) date_default_timezone_set($a->user['timezone']); @@ -54,7 +56,7 @@ else { goaway($a->get_baseurl()); } $_SESSION['uid'] = $r[0]['uid']; - $_SESSION['admin'] = $r[0]['admin']; + $_SESSION['theme'] = $r[0]['theme']; $_SESSION['authenticated'] = 1; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname']; diff --git a/index.php b/index.php index 52ea58374..c3933dc8b 100644 --- a/index.php +++ b/index.php @@ -26,6 +26,7 @@ $a->init_pagehead(); session_start(); + if((x($_SESSION,'authenticated')) || (x($_POST['auth-params']))) require("auth.php"); @@ -106,12 +107,18 @@ $a->page['content'] .= $debug_text; if($a->module != 'install') require_once("nav.php"); +$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array( + '$stylesheet' => $a->get_baseurl() . '/view/theme/' + . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default') + . '/style.css' + )); + $page = $a->page; $profile = $a->profile; header("Content-type: text/html; charset=utf-8"); + $template = "view/" - . ((x($a->page,'theme')) ? $a->page['theme'] . '/' : "" ) . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . ".php"; diff --git a/mod/profile.php b/mod/profile.php index 1b37d31bc..119b523a6 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -34,6 +34,7 @@ function profile_load(&$a, $username, $profile = 0) { $a->page['template'] = 'profile'; $a->page['title'] = $a->profile['name']; + $_SESSION['theme'] = $a->profile['theme']; return; }} diff --git a/mod/settings.php b/mod/settings.php index 10336e771..0d65bf9ba 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -52,6 +52,7 @@ function settings_post(&$a) { } } + $theme = notags(trim($_POST['theme'])); $username = notags(trim($_POST['username'])); $email = notags(trim($_POST['email'])); $timezone = notags(trim($_POST['timezone'])); @@ -131,9 +132,7 @@ function settings_post(&$a) { $str_contact_deny = implode('',$contact_deny); } - - - $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d WHERE `uid` = %d LIMIT 1", + $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `theme` = '%s' WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), dbesc($timezone), @@ -142,24 +141,19 @@ function settings_post(&$a) { dbesc($str_contact_deny), dbesc($str_group_deny), intval($notify), + dbesc($theme), intval($_SESSION['uid']) ); if($r) notice( t('Settings updated.') . EOL); - + $_SESSION['theme'] = $theme; if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) { // FIXME - set to un-verified, blocked and redirect to logout } - - // Refresh the content display with new data - - $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", - intval($_SESSION['uid'])); - if(count($r)) - $a->user = $r[0]; + goaway($a->get_baseurl() . '/settings' ); } @@ -179,6 +173,8 @@ function settings_content(&$a) { $timezone = $a->user['timezone']; $notify = $a->user['notify-flags']; + if(! strlen($a->user['timezone'])) + $timezone = date_default_timezone_get(); $nickname_block = file_get_contents("view/settings_nick_set.tpl"); @@ -193,6 +189,18 @@ function settings_content(&$a) { )); } + $theme_selector = ''; + $nickname_block = replace_macros($nickname_block,array( '$nickname' => $nickname, @@ -217,7 +225,8 @@ function settings_content(&$a) { '$sel_notify2' => (($notify & NOTIFY_CONFIRM) ? ' checked="checked" ' : ''), '$sel_notify3' => (($notify & NOTIFY_WALL) ? ' checked="checked" ' : ''), '$sel_notify4' => (($notify & NOTIFY_COMMENT) ? ' checked="checked" ' : ''), - '$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : '') + '$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : ''), + '$theme' => $theme_selector )); return $o; diff --git a/view/acl_selectors.php b/view/acl_selectors.php index ac34fab3a..b22099ddf 100644 --- a/view/acl_selectors.php +++ b/view/acl_selectors.php @@ -128,4 +128,5 @@ function populate_acl($user = null) { $o .= '
' . "\r\n"; return $o; -} \ No newline at end of file +} + diff --git a/view/head.tpl b/view/head.tpl index d0fea606c..d3c17d926 100644 --- a/view/head.tpl +++ b/view/head.tpl @@ -1,6 +1,6 @@