aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php4
-rw-r--r--database.sql1
-rw-r--r--include/auth.php4
-rw-r--r--index.php9
-rw-r--r--mod/profile.php1
-rw-r--r--mod/settings.php33
-rw-r--r--view/acl_selectors.php3
-rw-r--r--view/head.tpl2
-rw-r--r--view/settings.tpl6
-rw-r--r--view/theme/default/style.css (renamed from view/style.css)13
10 files changed, 58 insertions, 18 deletions
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 = '<select name="theme" id="theme-select" >';
+ $files = glob('view/theme/*');
+ if($files) {
+ foreach($files as $file) {
+ $f = basename($file);
+ $selected = (($f == $_SESSION['theme']) || ($f == 'default' && (! x($_SESSION,'theme')))
+ ? ' selected="selected" ' : '' );
+ $theme_selector .= '<option val="' . basename($file) . '"' . $selected . '>' . basename($file) . '</option>';
+ }
+ }
+ $theme_selector .= '</select>';
+
$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 .= '<div id="acl-wrapper-end"></div>' . "\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 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<base href="$baseurl" />
-<link rel="stylesheet" type="text/css" href="$baseurl/view/style.css" media="all" />
+<link rel="stylesheet" type="text/css" href="$stylesheet" media="all" />
<!--[if IE]>
<script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
diff --git a/view/settings.tpl b/view/settings.tpl
index a918aefc1..b9c2c7ecb 100644
--- a/view/settings.tpl
+++ b/view/settings.tpl
@@ -25,6 +25,12 @@ $zoneselect
</div>
<div id="settings-timezone-end" ></div>
+<div id="settings-theme-select">
+<label id="settings-theme-label" for="theme-select" >Display Theme: </label>
+$theme
+</div>
+<div id="settings-theme-end"></div>
+
<div id="settings-default-perms" class="settings-default-perms" >
<div id="settings-default-perms-menu" onClick="openClose('settings-default-perms-select');" />$permissions</div>
<div id="settings-default-perms-menu-end"></div>
diff --git a/view/style.css b/view/theme/default/style.css
index 83795869b..456465a74 100644
--- a/view/style.css
+++ b/view/theme/default/style.css
@@ -301,7 +301,8 @@ input#dfrn-url {
#settings-username-end,
#settings-email-end,
#settings-nick-end,
-#settings-timezone-end,
+#settings-timezone-end,
+#settings-theme-end,
#settings-password-end,
#settings-confirm-end,
#notify1-end,
@@ -317,6 +318,7 @@ input#dfrn-url {
#settings-email-label,
#settings-nick-label,
#settings-timezone-label,
+#settings-theme-label,
#settings-password-label,
#settings-confirm-label,
#settings-label-notify1,
@@ -332,6 +334,7 @@ input#dfrn-url {
#settings-email,
#settings-nick,
#timezone-select,
+#theme-select,
#settings-password,
#settings-confirm,
#notify1,
@@ -343,6 +346,14 @@ input#dfrn-url {
margin-bottom: 20px;
}
+#settings-theme-label {
+ margin-top: 20px;
+}
+
+#theme-select {
+ margin-top: 20px;
+ width: 207px;
+}
#settings-notify-desc {
margin-top: 20px;
margin-bottom: 20px;