From 377f991ac5b1e8c3c679fbbc5e138256bc24715b Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 1 Mar 2011 20:18:47 -0800 Subject: [PATCH] switch identities to manage pages --- boot.php | 1 + include/auth.php | 17 ++++++++++++++++- include/nav.php | 7 ++++++- mod/openid.php | 12 ++++++++++-- view/theme/duepuntozero/style.css | 13 +++++++++++++ view/theme/loozah/style.css | 14 ++++++++++++++ 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/boot.php b/boot.php index 06cf5b7605..3cf01b4a0d 100644 --- a/boot.php +++ b/boot.php @@ -197,6 +197,7 @@ class App { public $interactive = true; public $plugins; public $apps; + public $identities; private $scheme; private $hostname; diff --git a/include/auth.php b/include/auth.php index a0244571b3..e8cee3918c 100644 --- a/include/auth.php +++ b/include/auth.php @@ -61,6 +61,13 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $a->user['nickname']; + $r = q("SELECT `uid`,`username` FROM `user` WHERE `password` = '%s' AND `email` = '%s'", + dbesc($a->user['password']), + dbesc($a->user['email']) + ); + if(count($r)) + $a->identities = $r; + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); if(count($r)) { @@ -192,7 +199,15 @@ else { $a->timezone = $a->user['timezone']; } - $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", + $r = q("SELECT `uid`,`username` FROM `user` WHERE `password` = '%s' AND `email` = '%s'", + dbesc($a->user['password']), + dbesc($a->user['email']) + ); + if(count($r)) + $a->identities = $r; + + + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); if(count($r)) { $a->contact = $r[0]; diff --git a/include/nav.php b/include/nav.php index bfbc10f5a7..043cf0f7fa 100644 --- a/include/nav.php +++ b/include/nav.php @@ -25,7 +25,9 @@ function nav(&$a) { * */ - $a->page['nav'] .= '
' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'//') + 2 ) . '
'; + $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : ''); + + $a->page['nav'] .= '
' . $myident . substr($a->get_baseurl(),strpos($a->get_baseurl(),'//') + 2 ) . '
'; /** @@ -98,6 +100,9 @@ function nav(&$a) { $a->page['nav'] .= '' . t('Messages') . '' . "\r\n"; + if(is_array($a->identities) && count($a->identities) > 1) { + $a->page['nav'] .= '' . t('Manage') . '' . "\r\n"; + } $a->page['nav'] .= '' . t('Settings') . "\r\n"; diff --git a/mod/openid.php b/mod/openid.php index 2e1025692d..6ccd28e5b6 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -78,8 +78,16 @@ function openid_content(&$a) { $a->timezone = $a->user['timezone']; } - $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", - intval($_SESSION['uid'])); + $r = q("SELECT `uid`,`username` FROM `user` WHERE `password` = '%s' AND `email` = '%s'", + dbesc($a->user['password']), + dbesc($a->user['email']) + ); + if(count($r)) + $a->identities = $r; + + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + intval($_SESSION['uid']) + ); if(count($r)) { $a->contact = $r[0]; $a->cid = $r[0]['id']; diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 3877fb2ea6..1586499338 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -2040,3 +2040,16 @@ a.mail-list-link { margin: 10px; } +#identity-manage-desc { + margin-top:15px; + margin-bottom: 15px; +} + +#identity-manage-choose { + margin-bottom: 15px; +} + +#identity-submit { + margin-top: 20px; +} + diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index 7e8299eb56..902e71be8f 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -2086,3 +2086,17 @@ a.mail-list-link { margin: 10px; } + +#identity-manage-desc { + margin-top:15px; + margin-bottom: 15px; +} + +#identity-manage-choose { + margin-bottom: 15px; +} + +#identity-submit { + margin-top: 20px; +} +