mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
name change continued, social graph tools and stuctures, fix for spanish province name
This commit is contained in:
parent
d5ce13ee12
commit
d4644d7339
11 changed files with 199 additions and 18 deletions
8
boot.php
8
boot.php
|
@ -8,10 +8,10 @@ require_once("include/pgettext.php");
|
|||
require_once('include/nav.php');
|
||||
require_once('include/cache.php');
|
||||
|
||||
define ( 'FRIENDIKA_PLATFORM', 'Free Friendika');
|
||||
define ( 'FRIENDIKA_PLATFORM', 'Friendica');
|
||||
define ( 'FRIENDIKA_VERSION', '2.3.1151' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
|
||||
define ( 'DB_UPDATE_VERSION', 1099 );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.22' );
|
||||
define ( 'DB_UPDATE_VERSION', 1100 );
|
||||
|
||||
define ( 'EOL', "<br />\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
@ -94,7 +94,7 @@ define ( 'PAGE_FREELOVE', 3 );
|
|||
*/
|
||||
|
||||
define ( 'NETWORK_ZOT', 'zot!'); // Zot!
|
||||
define ( 'NETWORK_DFRN', 'dfrn'); // Friendika, Mistpark, other DFRN implementations
|
||||
define ( 'NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations
|
||||
define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations
|
||||
define ( 'NETWORK_FEED', 'feed'); // RSS/Atom feeds with no known "post/notify" protocol
|
||||
define ( 'NETWORK_DIASPORA', 'dspr'); // Diaspora
|
||||
|
|
21
database.sql
21
database.sql
|
@ -75,6 +75,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
|||
`notify` text NOT NULL,
|
||||
`poll` text NOT NULL,
|
||||
`confirm` text NOT NULL,
|
||||
`poco` text NOT NULL,
|
||||
`aes_allow` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`ret-aes` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`usehub` tinyint(1) NOT NULL DEFAULT '0',
|
||||
|
@ -658,3 +659,23 @@ CREATE TABLE IF NOT EXISTS `fserver` (
|
|||
INDEX ( `server` )
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gcontact` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`name` CHAR( 255 ) NOT NULL ,
|
||||
`url` CHAR( 255 ) NOT NULL ,
|
||||
`nurl` CHAR( 255 ) NOT NULL ,
|
||||
`photo` CHAR( 255 ) NOT NULL,
|
||||
INDEX ( `nurl` ),
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `glink` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`cid` INT NOT NULL ,
|
||||
`uid` INT NOT NULL ,
|
||||
`gcid` INT NOT NULL,
|
||||
`updated` DATETIME NOT NULL,
|
||||
INDEX ( `cid` ),
|
||||
INDEX ( `uid` ),
|
||||
INDEX ( `gcid` ),
|
||||
INDEX ( `updated` )
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -369,6 +369,8 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
|||
$hcard = unamp($link['@attributes']['href']);
|
||||
if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
|
||||
$profile = unamp($link['@attributes']['href']);
|
||||
if($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0')
|
||||
$poco = unamp($link['@attributes']['href']);
|
||||
if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') {
|
||||
$diaspora_base = unamp($link['@attributes']['href']);
|
||||
$diaspora = true;
|
||||
|
@ -684,6 +686,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
|||
$result['poll'] = $poll;
|
||||
$result['request'] = $request;
|
||||
$result['confirm'] = $confirm;
|
||||
$result['poco'] = $poco;
|
||||
$result['photo'] = $vcard['photo'];
|
||||
$result['priority'] = $priority;
|
||||
$result['network'] = $network;
|
||||
|
|
|
@ -298,6 +298,13 @@ function poller_run($argv, $argc){
|
|||
if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
|
||||
continue;
|
||||
|
||||
if(((float) $res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
|
||||
q("update contact set poco = '%s' where id = %d limit 1",
|
||||
dbesc(str_replace('/profile/','/poco/', $contact['url'])),
|
||||
intval($contact['id'])
|
||||
);
|
||||
}
|
||||
|
||||
$postvars = array();
|
||||
|
||||
$sent_dfrn_id = hex2bin((string) $res->dfrn_id);
|
||||
|
|
125
include/socgraph.php
Normal file
125
include/socgraph.php
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* poco_load
|
||||
*
|
||||
* Given a contact-id (minimum), load the PortableContacts friend list for that contact,
|
||||
* and add the entries to the gcontact (Global Contact) table, or update existing entries
|
||||
* if anything (name or photo) has changed.
|
||||
* We use normalised urls for comparison which ignore http vs https and www.domain vs domain
|
||||
*
|
||||
* Once the global contact is stored add (if necessary) the contact linkage which associates
|
||||
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
|
||||
* pointing to the same global contact id.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
function poco_load($cid,$uid = 0,$url = null) {
|
||||
$a = get_app();
|
||||
if((! $url) || (! $uid)) {
|
||||
$r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1",
|
||||
intval($cid)
|
||||
);
|
||||
if(count($r)) {
|
||||
$url = $r[0]['poco'];
|
||||
$uid = $r[0]['uid'];
|
||||
}
|
||||
}
|
||||
if((! $url) || (! $uid))
|
||||
return;
|
||||
$s = fetch_url($url . '/@me/@all?fields=displayName,urls,photos');
|
||||
|
||||
if(($a->get_curl_code() > 299) || (! $s))
|
||||
return;
|
||||
$j = json_decode($s);
|
||||
foreach($j->entry as $entry) {
|
||||
|
||||
$profile_url = '';
|
||||
$profile_photo = '';
|
||||
$name = '';
|
||||
|
||||
$name = $entry->displayName;
|
||||
|
||||
foreach($entry->urls as $url) {
|
||||
if($url->type == 'profile') {
|
||||
$profile_url = $url->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach($entry->photos as $photo) {
|
||||
if($photo->type == 'profile') {
|
||||
$profile_photo = $photo->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if((! $name) || (! $profile_url) || (! $profile_photo))
|
||||
continue;
|
||||
|
||||
$x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
if(count($x)) {
|
||||
$gcid = $x[0]['id'];
|
||||
|
||||
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
|
||||
q("update gcontact set `name` = '%s', `photo` = '%s' where
|
||||
`nurl` = '%s' limit 1",
|
||||
dbesc($name),
|
||||
dbesc($profile_photo),
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`)
|
||||
values ( '%s', '%s', '%s', '%s') ",
|
||||
dbesc($name),
|
||||
dbesc($profile_url),
|
||||
dbesc(normalise_link($profile_url)),
|
||||
dbesc($profile_photo)
|
||||
);
|
||||
$x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
if(count($x))
|
||||
$gcid = $x[0]['id'];
|
||||
}
|
||||
if(! $gcid)
|
||||
return;
|
||||
|
||||
$r = q("select * from glink where `cid` = %d and `uid` = %d and `gcid` = %d limit 1",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid)
|
||||
);
|
||||
if(! count($r)) {
|
||||
q("insert into glink ( `cid`,`uid`,`gcid`,`updated`) values (%d,%d,%d,'%s') ",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
}
|
||||
else {
|
||||
q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d limit 1",
|
||||
dbesc(datetime_convert()),
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($gcid)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
q("delete from gcid where `cid` = %d and `uid` = %d and `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY",
|
||||
intval($cid),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
}
|
|
@ -233,7 +233,7 @@ aStates[207]="|Bellona|Central|Choiseul (Lauru)|Guadalcanal|Honiara|Isabel|Makir
|
|||
aStates[208]="|Awdal|Bakool|Banaadir|Bari|Bay|Galguduud|Gedo|Hiiraan|Jubbada Dhexe|Jubbada Hoose|Mudug|Nugaal|Sanaag|Shabeellaha Dhexe|Shabeellaha Hoose|Sool|Togdheer|Woqooyi Galbeed";
|
||||
aStates[209]="|Eastern Cape|Free State|Gauteng|KwaZulu-Natal|Mpumalanga|North-West|Northern Cape|Northern Province|Western Cape";
|
||||
aStates[210]="|Bird Island|Bristol Island|Clerke Rocks|Montagu Island|Saunders Island|South Georgia|Southern Thule|Traversay Islands";
|
||||
aStates[211]="|Andalucia|Aragon|Asturias|Baleares (Balearic Islands)|Canarias (Canary Islands)|Cantabria|Castilla y Leon|Castilla-La Mancha|Cataluna|Ceuta|Communidad Valencian|Extremadura|Galicia|Islas Chafarinas|La Rioja|Madrid|Melilla|Murcia|Navarra|Pais Vasco (Basque Country)|Penon de Alhucemas|Penon de Velez de la Gomera";
|
||||
aStates[211]="|Andalucia|Aragon|Asturias|Baleares (Balearic Islands)|Canarias (Canary Islands)|Cantabria|Castilla y Leon|Castilla-La Mancha|Catalunya|Ceuta|Communidad Valencian|Extremadura|Galicia|Islas Chafarinas|La Rioja|Madrid|Melilla|Murcia|Navarra|Pais Vasco (Basque Country)|Penon de Alhucemas|Penon de Velez de la Gomera";
|
||||
aStates[212]="|Spratly Islands";
|
||||
aStates[213]="|Central|Eastern|North Central|North Eastern|North Western|Northern|Sabaragamuwa|Southern|Uva|Western";
|
||||
aStates[214]="|A'ali an Nil|Al Bahr al Ahmar|Al Buhayrat|Al Jazirah|Al Khartum|Al Qadarif|Al Wahdah|An Nil al Abyad|An Nil al Azraq|Ash Shamaliyah|Bahr al Jabal|Gharb al Istiwa'iyah|Gharb Bahr al Ghazal|Gharb Darfur|Gharb Kurdufan|Janub Darfur|Janub Kurdufan|Junqali|Kassala|Nahr an Nil|Shamal Bahr al Ghazal|Shamal Darfur|Shamal Kurdufan|Sharq al Istiwa'iyah|Sinnar|Warab";
|
||||
|
|
|
@ -143,8 +143,8 @@ function dfrn_request_post(&$a) {
|
|||
*/
|
||||
|
||||
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `name`, `nick`, `photo`, `site-pubkey`,
|
||||
`request`, `confirm`, `notify`, `poll`, `network`, `aes_allow`)
|
||||
VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
|
||||
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`)
|
||||
VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
|
||||
intval(local_user()),
|
||||
datetime_convert(),
|
||||
dbesc($dfrn_url),
|
||||
|
@ -156,6 +156,7 @@ function dfrn_request_post(&$a) {
|
|||
$parms['dfrn-confirm'],
|
||||
$parms['dfrn-notify'],
|
||||
$parms['dfrn-poll'],
|
||||
$parms['dfrn-poco'],
|
||||
dbesc(NETWORK_DFRN),
|
||||
intval($aes_allow)
|
||||
);
|
||||
|
@ -371,8 +372,8 @@ function dfrn_request_post(&$a) {
|
|||
|
||||
dbesc_array($parms);
|
||||
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
|
||||
`request`, `confirm`, `notify`, `poll`, `network` )
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
|
||||
`request`, `confirm`, `notify`, `poll`, `poco`, `network` )
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
|
||||
intval($uid),
|
||||
datetime_convert(),
|
||||
$parms['url'],
|
||||
|
@ -385,6 +386,7 @@ function dfrn_request_post(&$a) {
|
|||
$parms['dfrn-confirm'],
|
||||
$parms['dfrn-notify'],
|
||||
$parms['dfrn-poll'],
|
||||
$parms['dfrn-poco'],
|
||||
dbesc(NETWORK_DFRN)
|
||||
);
|
||||
|
||||
|
@ -635,14 +637,14 @@ function dfrn_request_content(&$a) {
|
|||
|
||||
$o .= replace_macros($tpl,array(
|
||||
'$header' => t('Friend/Connection Request'),
|
||||
'$desc' => t('Examples: jojo@demo.friendika.com, http://demo.friendika.com/profile/jojo, testuser@identi.ca'),
|
||||
'$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'),
|
||||
'$pls_answer' => t('Please answer the following:'),
|
||||
'$does_know' => sprintf( t('Does %s know you?'),$a->profile['name']),
|
||||
'$yes' => t('Yes'),
|
||||
'$no' => t('No'),
|
||||
'$add_note' => t('Add a personal note:'),
|
||||
'$page_desc' => $page_desc,
|
||||
'$friendika' => t('Friendika'),
|
||||
'$friendika' => t('Friendica'),
|
||||
'$statusnet' => t('StatusNet/Federated Social Web'),
|
||||
'$diaspora' => t('Diaspora'),
|
||||
'$diasnote' => t('- please share from your own site as noted above'),
|
||||
|
|
|
@ -100,9 +100,9 @@ function follow_post(&$a) {
|
|||
$new_relation = CONTACT_IS_FOLLOWER;
|
||||
|
||||
// create contact record
|
||||
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `batch`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
|
||||
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
|
||||
`writable`, `blocked`, `readonly`, `pending` )
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
|
||||
intval(local_user()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($ret['url']),
|
||||
|
@ -111,6 +111,7 @@ function follow_post(&$a) {
|
|||
dbesc($ret['batch']),
|
||||
dbesc($ret['notify']),
|
||||
dbesc($ret['poll']),
|
||||
dbesc($ret['poco']),
|
||||
dbesc($ret['name']),
|
||||
dbesc($ret['nick']),
|
||||
dbesc($ret['photo']),
|
||||
|
|
|
@ -98,11 +98,11 @@ function poco_init(&$a) {
|
|||
if($fields_ret['displayName'])
|
||||
$entry['displayName'] = $rr['name'];
|
||||
if($fields_ret['urls'])
|
||||
$entry['urls'] = array('value' => $rr['url'], 'type' => 'profile');
|
||||
$entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile'));
|
||||
if($fields_ret['preferredUsername'])
|
||||
$entry['preferredUsername'] = $rr['nick'];
|
||||
if($fields_ret['photos'])
|
||||
$entry['photos'] = array('value' => $rr['photo'], 'type' => 'profile');
|
||||
$entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile'));
|
||||
$ret['entry'][] = $entry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ function profile_init(&$a) {
|
|||
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
|
||||
foreach($dfrn_pages as $dfrn)
|
||||
$a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
|
||||
$a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".$a->get_baseurl()."/poco/{$which}\" />\r\n";
|
||||
|
||||
}
|
||||
|
||||
|
|
27
update.php
27
update.php
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define( 'UPDATE_VERSION' , 1099 );
|
||||
define( 'UPDATE_VERSION' , 1100 );
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -822,8 +822,29 @@ function update_1098() {
|
|||
");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function update_1099() {
|
||||
q("CREATE TABLE IF NOT EXISTS `gcontact` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`name` CHAR( 255 ) NOT NULL ,
|
||||
`url` CHAR( 255 ) NOT NULL ,
|
||||
`nurl` CHAR( 255 ) NOT NULL ,
|
||||
`photo` CHAR( 255 ) NOT NULL
|
||||
) ENGINE = MYISAM ");
|
||||
|
||||
q("CREATE TABLE IF NOT EXISTS `glink` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`cid` INT NOT NULL ,
|
||||
`uid` INT NOT NULL ,
|
||||
`gcid` INT NOT NULL,
|
||||
`updated` DATETIME NOT NULL,
|
||||
) ENGINE = MYISAM ");
|
||||
|
||||
q("ALTER TABLE `gcontact` ADD INDEX (`nurl`) ");
|
||||
q("ALTER TABLE `glink` ADD INDEX (`cid`), ADD INDEX (`uid`), ADD INDEX (`gcid`), ADD INDEX (`updated`) ");
|
||||
|
||||
q("ALTER TABLE `contact` ADD `poco` TEXT NOT NULL AFTER `confirm` ");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue