From fa756ffcb987a37dae888bf84c9519d55a484da5 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Thu, 23 Dec 2010 21:32:13 +0100 Subject: [PATCH] OpenID delegation in profile page --- database.sql | 1 + mod/profile.php | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/database.sql b/database.sql index 5b86f60eca..bb151da27c 100644 --- a/database.sql +++ b/database.sql @@ -377,6 +377,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `allow_gid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL, `deny_gid` mediumtext NOT NULL, + `openidserver` text NOT NULL, PRIMARY KEY (`uid`), KEY `nickname` (`nickname`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/mod/profile.php b/mod/profile.php index b1f0209307..000e955eae 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -18,6 +18,31 @@ function profile_init(&$a) { profile_load($a,$which,$profile); + if (!get_config('system','no_openid') && $a->profile['openid']!=""){ + if (!isset($a->profile['openidserver'])){ + die('friendika user table must be updated. `openidserver` field is missing'); + } + if ($a->profile['openidserver']==''){ + require_once('library/openid.php'); + $openid = new LightOpenID; + $openid->identity = $a->profile['openid']; + $a->profile['openidserver'] = $openid->discover($openid->identity); + + q("UPDATE `user` SET `openidserver` = '%s' WHERE `uid` = %d LIMIT 1", + dbesc($a->profile['openidserver']), + intval($a->profile['uid']) + ); + } + + + $a->page['htmlhead'] .= ''. "\r\n"; + $a->page['htmlhead'] .= ''. "\r\n"; + + + } + + + $a->page['htmlhead'] .= '' . "\r\n" ; $a->page['htmlhead'] .= '' . "\r\n" ; $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); @@ -365,4 +390,4 @@ function profile_content(&$a, $update = 0) { $o .= paginate($a); return $o; -} \ No newline at end of file +}