aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-11-21 13:52:15 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2011-11-21 13:52:15 +0100
commitcb05e677a96e1312263c0a1c63ee10cea62268b1 (patch)
tree9234db8ab0c946ed65123181acba0df71524a8eb
parenta86fd26bd86945fe75b7220e149b8986f88feb01 (diff)
parentaaedac8f574278fba89cd11d3d8f1adaeb6b030e (diff)
downloadvolse-hubzilla-cb05e677a96e1312263c0a1c63ee10cea62268b1.tar.gz
volse-hubzilla-cb05e677a96e1312263c0a1c63ee10cea62268b1.tar.bz2
volse-hubzilla-cb05e677a96e1312263c0a1c63ee10cea62268b1.zip
Merge remote-tracking branch 'friendica/master'
-rw-r--r--boot.php4
-rw-r--r--database.sql2
-rw-r--r--include/items.php103
-rw-r--r--include/network.php4
-rw-r--r--include/notifier.php12
-rw-r--r--index.php8
-rw-r--r--js/fk.autocomplete.js2
-rw-r--r--mod/item.php4
-rw-r--r--update.php9
9 files changed, 132 insertions, 16 deletions
diff --git a/boot.php b/boot.php
index 7d9337b2e..773422637 100644
--- a/boot.php
+++ b/boot.php
@@ -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' );
diff --git a/database.sql b/database.sql
index 924cc49b2..98067d8d6 100644
--- a/database.sql
+++ b/database.sql
@@ -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`),
diff --git a/include/items.php b/include/items.php
index a008e4ac8..fd36dcadb 100644
--- a/include/items.php
+++ b/include/items.php
@@ -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;
diff --git a/include/network.php b/include/network.php
index e89eb94da..78ed24074 100644
--- a/include/network.php
+++ b/include/network.php
@@ -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);
diff --git a/include/notifier.php b/include/notifier.php
index a4fe9b71e..c81ca2d15 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -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) {
diff --git a/index.php b/index.php
index 78ceb6d77..e43d7332d 100644
--- a/index.php
+++ b/index.php
@@ -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();
/**
*
diff --git a/js/fk.autocomplete.js b/js/fk.autocomplete.js
index 545fd1645..85b51baeb 100644
--- a/js/fk.autocomplete.js
+++ b/js/fk.autocomplete.js
@@ -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();
diff --git a/mod/item.php b/mod/item.php
index ee3bdca99..145c42cec 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -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";
diff --git a/update.php b/update.php
index 14d68ea12..96fdec691 100644
--- a/update.php
+++ b/update.php
@@ -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` ) ");
+
+}
+
+
+