mirror of
https://github.com/friendica/friendica
synced 2024-11-09 23:02:54 +00:00
add nicknames to contact records (going forward and retroactive)
This commit is contained in:
parent
d850badf2b
commit
b8b227b328
7 changed files with 30 additions and 8 deletions
2
boot.php
2
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" );
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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"');
|
||||
|
||||
|
|
|
@ -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"),
|
||||
|
|
13
update.php
13
update.php
|
@ -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'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue