Merge remote-tracking branch 'friendica/master'

This commit is contained in:
Fabio Comuni 2011-11-21 13:52:15 +01:00
commit cb05e677a9
9 changed files with 132 additions and 16 deletions

View file

@ -9,9 +9,9 @@ require_once('include/nav.php');
require_once('include/cache.php');
define ( 'FRIENDIKA_PLATFORM', 'Friendica');
define ( 'FRIENDIKA_VERSION', '2.3.1167' );
define ( 'FRIENDIKA_VERSION', '2.3.1170' );
define ( 'DFRN_PROTOCOL_VERSION', '2.22' );
define ( 'DB_UPDATE_VERSION', 1104 );
define ( 'DB_UPDATE_VERSION', 1105 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View file

@ -226,6 +226,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`unseen` tinyint(1) NOT NULL DEFAULT '1',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`origin` tinyint(1) NOT NULL DEFAULT '0',
`forum_mode` tinyint(1) NOT NULL DEFAULT '0',
`last-child` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `guid` (`guid`),
@ -244,6 +245,7 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `starred` (`starred`),
KEY `deleted` (`deleted`),
KEY `origin` (`origin`),
KEY `forum_mode` (`forum_mode`),
KEY `last-child` (`last-child`),
KEY `unseen` (`unseen`),
KEY `wall` (`wall`),

View file

@ -893,6 +893,8 @@ function item_store($arr,$force_parent = false) {
);
}
tgroup_deliver($arr['uid'],$current_post);
return $current_post;
}
@ -909,6 +911,69 @@ function get_item_contact($item,$contacts) {
}
function tgroup_deliver($uid,$item_id) {
// setup a second delivery chain for forum/community posts if appropriate
$a = get_app();
$deliver_to_tgroup = false;
$u = q("select * from user where uid = %d and `page-flags` = %d limit 1",
intval($uid),
intval(PAGE_COMMUNITY)
);
if(! count($u))
return;
$i = q("select * from item where id = %d and uid = %d limit 1",
intval($item_id),
intval($uid)
);
if(! count($i))
return;
$item = $i[0];
// prevent delivery looping - only proceed
// if the message originated elsewhere and is a top-level post
if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
return;
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
$cnt = preg_match_all('/\@\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
if(link_compare($link,$mtch[1])) {
$deliver_to_tgroup = true;
logger('tgroup_deliver: local group mention found: ' . $mtch[2]);
}
}
}
if(! $deliver_to_tgroup)
return;
// now change this copy of the post to a forum head message and deliver to all the tgroup members
q("update item set wall = 1, origin = 1, forum_mode = 1 where id = %d limit 1",
intval($item_id)
);
proc_run('php','include/notifier.php','tgroup',$item_id);
}
function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$a = get_app();
@ -1963,18 +2028,31 @@ function local_delivery($importer,$data) {
if($is_reply) {
$community = false;
if($importer['page-flags'] == PAGE_COMMUNITY) {
$sql_extra = '';
$community = true;
logger('local_delivery: community reply');
}
else
$sql_extra = " and contact.self = 1 and item.wall = 1 ";
// was the top-level post for this reply written by somebody on this site?
// Specifically, the recipient?
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
AND `item`.`uid` = %d LIMIT 1",
WHERE `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
AND `item`.`uid` = %d
$sql_extra
LIMIT 1",
dbesc($parent_uri),
dbesc($parent_uri),
intval($importer['importer_uid'])
);
if($r && count($r)) {
logger('local_delivery: received remote comment');
@ -1982,11 +2060,14 @@ function local_delivery($importer,$data) {
// remote reply to our post. Import and then notify everybody else.
$datarray = get_atom_elements($feed,$item);
if(! link_compare($datarray['author-link'],$importer['url'])) {
logger('local_delivery: received relay claiming to be from ' . $importer['url'] . ' however comment author url is ' . $datarray['author-link'] );
// TODO: make this next part work against both delivery threads of a community post
// if((! link_compare($datarray['author-link'],$importer['url'])) && (! $community)) {
// logger('local_delivery: received relay claiming to be from ' . $importer['url'] . ' however comment author url is ' . $datarray['author-link'] );
// they won't know what to do so don't report an error. Just quietly die.
return 0;
}
// return 0;
// }
$datarray['type'] = 'remote-comment';
$datarray['wall'] = 1;
@ -2031,6 +2112,16 @@ function local_delivery($importer,$data) {
}
}
// if($community) {
// $newtag = '@[url=' . $a->get_baseurl() . '/profile/' . $importer['nickname'] . ']' . $importer['username'] . '[/url]';
// if(! stristr($datarray['tag'],$newtag)) {
// if(strlen($datarray['tag']))
// $datarray['tag'] .= ',';
// $datarray['tag'] .= $newtag;
// }
// }
$posted_id = item_store($datarray);
$parent = 0;

View file

@ -22,7 +22,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
}
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
@curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
if(intval($timeout)) {
@ -105,7 +105,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
if(intval($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);

View file

@ -218,6 +218,11 @@ function notifier_run($argv, $argc){
$relay_to_owner = true;
}
if(($cmd === 'uplink') && (intval($parent['forum_mode'])) && (! $top_level)) {
$relay_to_owner = true;
}
// until the 'origin' flag has been in use for several months
// we will just use it as a fallback test
// later we will be able to use it as the primary test of whether or not to relay.
@ -259,6 +264,13 @@ function notifier_run($argv, $argc){
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));
// if our parent is a forum, uplink to the origonal author causing
// a delivery fork
if(intval($parent['forum_mode']) && (! $top_level) && ($cmd !== 'uplink')) {
proc_run('php','include/notifier','uplink',$item_id);
}
$conversants = array();
foreach($items as $item) {

View file

@ -75,8 +75,6 @@ $a->timezone = (($default_timezone) ? $default_timezone : 'UTC');
date_default_timezone_set($a->timezone);
$a->init_pagehead();
session_start();
/**
@ -95,6 +93,12 @@ if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
load_translation_table($lang);
}
/*
* Create the page head after setting the language
*
*/
$a->init_pagehead();
/**
*

View file

@ -80,7 +80,7 @@ ACPopup.prototype._search = function(){
that.cont.show();
$(data.items).each(function(){
html = "<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo, this.name, this.nick)
that.add(html, this.nick + '+' + this.id + ' - ' + this.link);
that.add(html, this.nick.replace(' ','') + '+' + this.id + ' - ' + this.link);
});
} else {
that.cont.hide();

View file

@ -865,12 +865,12 @@ function item_post(&$a) {
$addr = trim($recip);
if(! strlen($addr))
continue;
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username'])
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />';
$disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
$disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
$subject = '[Friendika]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']);
$subject = '[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']);
$headers = 'From: ' . $a->user['username'] . ' <' . $a->user['email'] . '>' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";

View file

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1104 );
define( 'UPDATE_VERSION' , 1105 );
/**
*
@ -895,4 +895,11 @@ function update_1103() {
}
function update_1104() {
q("ALTER TABLE `item` ADD `forum_mode` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `origin` , ADD INDEX ( `forum_mode` ) ");
}