]> git.mxchange.org Git - friendica.git/commitdiff
add nicknames to contact records (going forward and retroactive)
authorMike Macgirvin <mike@macgirvin.com>
Sat, 23 Oct 2010 08:20:26 +0000 (01:20 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Sat, 23 Oct 2010 08:20:26 +0000 (01:20 -0700)
boot.php
database.sql
include/Scrape.php
mod/dfrn_request.php
mod/profile.php
mod/register.php
update.php

index c8649f2d6d12ac010e1b335caf9faa30551362e3..7885bb4ea466f6592e10e74193283fa8776ea638 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
 
 set_time_limit(0);
 
-define ( 'BUILD_ID',               1011   );
+define ( 'BUILD_ID',               1012   );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.0'  );
 
 define ( 'EOL',                    "<br />\r\n"     );
index a3d78d79a3201396bb9cb4eed4c54a75e7d5e120..36c578961a98e5a2076ad2277dcae0903c074206 100644 (file)
@@ -56,6 +56,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
   `duplex` tinyint(1) NOT NULL DEFAULT '0',
   `network` char(255) NOT NULL,
   `name` char(255) NOT NULL,
+  `nick` char(255) NOT NULL,
   `photo` text NOT NULL, 
   `thumb` text NOT NULL,
   `site-pubkey` text NOT NULL,
index b4a5dd8496b9f2962ed68283b10c9b3ec5a9363f..0272dde129cd89c83d918ac2f9d6cbd5c3ceb86b 100644 (file)
@@ -33,6 +33,11 @@ function scrape_dfrn($url) {
                $x = $item->getAttribute('rel');
                if(substr($x,0,5) == "dfrn-")
                        $ret[$x] = $item->getAttribute('href');
+               if($x === 'lrdd') {
+                       $decoded = urldecode($item->getAttribute('href'));
+                       if(preg_match('/acct:([^@]*)@/',$decoded,$matches))
+                               $ret['nick'] = $matches[1];
+               }
        }
 
        // Pull out hCard profile elements
index 6e8171d50ae28ea0cd7813c6b2e874565349953a..ddf495986d842433bdb414507b67ccae058df1fe 100644 (file)
@@ -96,13 +96,14 @@ function dfrn_request_post(&$a) {
                                        dbesc_array($parms);
 
 
-                                       $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `name`, `photo`, `site-pubkey`,
+                                       $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `name`, `nick`, `photo`, `site-pubkey`,
                                                `request`, `confirm`, `notify`, `poll`, `aes_allow`) 
-                                               VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', %d)",
+                                               VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
                                                intval(local_user()),
                                                datetime_convert(),
                                                dbesc($dfrn_url),
                                                $parms['fn'],
+                                               $parms['nick'],
                                                $parms['photo'],
                                                $parms['key'],
                                                $parms['dfrn-request'],
@@ -271,13 +272,14 @@ function dfrn_request_post(&$a) {
 
 
                                dbesc_array($parms);
-                               $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `issued-id`, `photo`, `site-pubkey`,
+                               $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
                                        `request`, `confirm`, `notify`, `poll` )
-                                       VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
+                                       VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
                                        intval($uid),
                                        datetime_convert(),
                                        $parms['url'],
                                        $parms['fn'],
+                                       $parms['nick'],
                                        $parms['issued-id'],
                                        $parms['photo'],
                                        $parms['key'],
index f99a3c4f2a8b578729982b11f696a5fa0d204464..6c60ea8ac1ca90c423a11b1fe89caa2da1f2a280 100644 (file)
@@ -65,7 +65,7 @@ function profile_init(&$a) {
 
        $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
        $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
-       $uri = urlencode('acct:' . $a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
+       $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
        $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
        header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"');
   
index 6f0469db8e498f58b1bbec5d1e53d5bbda0692e3..52c3863ebdf92361c349a43ddaa2c7401792d6c6 100644 (file)
@@ -161,12 +161,13 @@ function register_post(&$a) {
                                intval($newuid));
                        return;
                }
-               $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `photo`, `thumb`, `blocked`, `pending`, `url`,
+               $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `blocked`, `pending`, `url`,
                        `request`, `notify`, `poll`, `confirm`, `name-date`, `uri-date`, `avatar-date` )
-                       VALUES ( %d, '%s', 1, '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+                       VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
                        intval($newuid),
                        datetime_convert(),
                        dbesc($username),
+                       dbesc($nickname),
                        dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"),
                        dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"),
                        dbesc($a->get_baseurl() . "/profile/$nickname"),
index 65713583b3caaf43289707057c9e73c6a376abf9..f0d72ef1670abeca3e0dc8f75773065317bb121e 100644 (file)
@@ -80,3 +80,16 @@ function update_1009() {
 function update_1010() {
        q("ALTER TABLE `contact` ADD `lrdd` CHAR( 255 ) NOT NULL AFTER `url` ");
 }
+
+function update_1011() {
+       q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
+       $r = q("SELECT * FROM `contact` WHERE 1");
+       if(count($r)) {
+               foreach($r as $rr) {
+                               q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d LIMIT 1",
+                                       dbesc(basename($rr['url'])),
+                                       intval($rr['id'])
+                               );
+               }
+       }
+}
\ No newline at end of file