aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/to_do_code.bb2
-rw-r--r--include/api.php16
-rw-r--r--include/attach.php36
-rw-r--r--include/auth.php3
-rw-r--r--include/bb2diaspora.php76
-rwxr-xr-xinclude/diaspora.php6
-rw-r--r--include/hubloc.php8
-rwxr-xr-xinclude/items.php19
-rw-r--r--include/poller.php14
-rw-r--r--include/security.php6
-rw-r--r--include/text.php31
-rw-r--r--mod/channel.php5
-rw-r--r--mod/home.php3
-rw-r--r--mod/item.php27
-rwxr-xr-xmod/like.php12
-rw-r--r--mod/network.php21
-rw-r--r--mod/ping.php6
-rw-r--r--mod/sharedwithme.php22
-rw-r--r--mod/zotfeed.php5
-rw-r--r--version.inc2
-rw-r--r--view/css/mod_sharedwithme.css1
-rw-r--r--view/tpl/sharedwithme.tpl2
22 files changed, 231 insertions, 92 deletions
diff --git a/doc/to_do_code.bb b/doc/to_do_code.bb
index e0e3d7f96..4b7b98ee1 100644
--- a/doc/to_do_code.bb
+++ b/doc/to_do_code.bb
@@ -8,7 +8,6 @@ We need much more than this, but here are areas where developers can help. Pleas
[li]Infinite scroll improvements (i.e. embedded page links) see http://scrollsample.appspot.com/items
[li]Finish the anti-spam bayesian engine[/li]
[li]implement an email permission denied bounce message from the sys channel[/li]
-[li]finish Wordpress connector - import wordpress comments back to redmatrix[/li]
[li]provide a way for xchans with a certain network type to upgrade (unknown to rss, rss to statusnet, friendica-over-diaspora to friendica, for instance) based on new knowledge and/or redmatrix ability[/li]
[li]If DAV folders exist, add an option to the Settings page to set a default folder for attachment uploads.[/li]
[li]Integrate the "open site" list with the register page[/li]
@@ -25,6 +24,7 @@ We need much more than this, but here are areas where developers can help. Pleas
[li]service classes - account overview page showing resources consumed by channel. With special consideration this page can also be accessed at a meta level by the site admin to drill down on problematic accounts/channels.[/li]
[li]Events module - fix permissions on events, and provide JS translation support for the calendar overview; integrate with calDAV[/li]
[li]Uploads - integrate #^[url=https://github.com/blueimp/jQuery-File-Upload]https://github.com/blueimp/jQuery-File-Upload[/url][/li]
+[li]We could probably improve even more on the infamous sys_channel query by carrying a column in the channel DB for the timestamp of the last post; so we don't have to randomly select channels from which to find public content and quite possibly randomly select a bunch that are inactive. This would also be a huge win for the statistics queries which could look at the same exact field and not have to count hundreds of thousands of things.[/li]
[li]Import/export - include events, things, etc.[/li]
[li]Import channel from Diaspora/Friendica[/li]
[li]MediaGoblin photo "crosspost" connector[/li]
diff --git a/include/api.php b/include/api.php
index 8c0e32ecc..3ac8ddbda 100644
--- a/include/api.php
+++ b/include/api.php
@@ -622,10 +622,14 @@ require_once('include/items.php');
function api_red_xchan(&$a,$type) {
+ logger('api_xchan');
+
if(api_user() === false)
return false;
+ logger('api_xchan');
require_once('include/hubloc.php');
- if($_SERVER['request_method'] === 'POST') {
+
+ if($_SERVER['REQUEST_METHOD'] === 'POST') {
$r = xchan_store($_REQUEST);
}
$r = xchan_fetch($_REQUEST);
@@ -727,6 +731,16 @@ require_once('include/items.php');
else
$_REQUEST['parent_mid'] = $parent;
+ if($_REQUEST['namespace'] && $parent) {
+ $x = q("select iid from item_id where service = '%s' and sid = '%s' limit 1",
+ dbesc($_REQUEST['namespace']),
+ dbesc($parent)
+ );
+ if($x) {
+ $_REQUEST['parent'] = $x[0]['iid'];
+ }
+ }
+
if(requestdata('lat') && requestdata('long'))
$_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
diff --git a/include/attach.php b/include/attach.php
index 1daa42aef..2ca302949 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -976,6 +976,18 @@ function pipe_streams($in, $out) {
return $size;
}
+/**
+ * @brief Activity for files
+ *
+ * @param $channel_id
+ * @param $object
+ * @param $allow_cid
+ * @param $allow_gid
+ * @param $deny_cid
+ * @param $deny_gid
+ * @param $verb
+ * @param $no_activity
+ */
function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $no_activity) {
require_once('include/items.php');
@@ -1030,7 +1042,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$jsonobject = json_encode($object);
//check if item for this object exists
- $y = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1",
+ $y = q("SELECT mid FROM item WHERE verb = '%s' AND obj_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1",
dbesc(ACTIVITY_POST),
dbesc($objtype),
dbesc($object['hash']),
@@ -1143,6 +1155,13 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
}
+/**
+ * @brief Create file activity object
+ *
+ * @param $channel_id
+ * @param $hash
+ * @param $cloudpath
+ */
function get_file_activity_object($channel_id, $hash, $cloudpath) {
$x = q("SELECT creator, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
@@ -1184,6 +1203,15 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) {
}
+/**
+ * @brief Returns array of channels which have recursive permission for a file
+ *
+ * @param $arr_allow_cid
+ * @param $arr_allow_gid
+ * @param $arr_deny_cid
+ * @param $arr_deny_gid
+ * @param $folder_hash
+ */
function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash) {
$ret = array();
@@ -1295,6 +1323,12 @@ function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny
return $ret;
}
+
+/**
+ * @brief Returns members of a group
+ *
+ * @param $group_id
+ */
function in_group($group_id) {
$group_members = array();
diff --git a/include/auth.php b/include/auth.php
index 6c9c33861..643894e32 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -29,7 +29,8 @@ function nuke_session() {
unset($_SESSION['mobile_theme']);
unset($_SESSION['show_mobile']);
unset($_SESSION['page_flags']);
- unset($_SESSION['submanage']);
+ unset($_SESSION['delegate']);
+ unset($_SESSION['delegate_channel']);
unset($_SESSION['my_url']);
unset($_SESSION['my_address']);
unset($_SESSION['addr']);
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index fa3aa3aa2..118e78639 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -1,4 +1,8 @@
-<?php /** @file */
+<?php
+/**
+ * @file include/bb2diaspora.php
+ * @brief Some functions for BB conversions for Diaspora protocol.
+ */
require_once("include/oembed.php");
require_once("include/event.php");
@@ -107,14 +111,19 @@ function diaspora_mention_callback($matches) {
}
-
-// we don't want to support a bbcode specific markdown interpreter
-// and the markdown library we have is pretty good, but provides HTML output.
-// So we'll use that to convert to HTML, then convert the HTML back to bbcode,
-// and then clean up a few Diaspora specific constructs.
-
-function diaspora2bb($s,$use_zrl = false) {
-
+/**
+ * @brief
+ *
+ * We don't want to support a bbcode specific markdown interpreter
+ * and the markdown library we have is pretty good, but provides HTML output.
+ * So we'll use that to convert to HTML, then convert the HTML back to bbcode,
+ * and then clean up a few Diaspora specific constructs.
+ *
+ * @param string $s
+ * @param boolean $use_zrl default false
+ * @return string
+ */
+function diaspora2bb($s, $use_zrl = false) {
$s = str_replace("&#xD;","\r",$s);
$s = str_replace("&#xD;\n&gt;","",$s);
@@ -150,7 +159,6 @@ function diaspora2bb($s,$use_zrl = false) {
}
else {
$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s);
-
}
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
@@ -217,18 +225,33 @@ function diaspora_ol($s) {
//////////////////////
// Non-Markdownify versions of "diaspora_ol" and "diaspora_ul"
//////////////////////
+/**
+ * @brief
+ *
+ * Replace "[\\*]" followed by any number (including zero) of
+ * spaces by "* " to match Diaspora's list format.
+ *
+ * @param string $s
+ * @return string
+ */
function diaspora_ul($s) {
- // Replace "[\\*]" followed by any number (including zero) of
- // spaces by "* " to match Diaspora's list format
return preg_replace("/\[\\\\\*\]( *)/", "* ", $s[1]);
}
+/**
+ * @brief
+ *
+ * A hack: Diaspora will create a properly-numbered ordered list even
+ * if you use '1.' for each element of the list, like:
+ * \code
+ * 1. First element
+ * 1. Second element
+ * 1. Third element
+ * \endcode
+ * @param string $s
+ * @return string
+ */
function diaspora_ol($s) {
- // A hack: Diaspora will create a properly-numbered ordered list even
- // if you use '1.' for each element of the list, like:
- // 1. First element
- // 1. Second element
- // 1. Third element
return preg_replace("/\[\\\\\*\]( *)/", "1. ", $s[1]);
}
@@ -240,8 +263,8 @@ function bb2dmention_callback($match) {
if($r)
return '@{' . $match[3] . ' ; ' . $r[0]['xchan_addr'] . '}';
- return '@' . $match[3];
+ return '@' . $match[3];
}
@@ -272,14 +295,15 @@ function bb2diaspora_itemwallwall(&$item) {
}
// $item['author'] might cause a surprise further down the line if it wasn't expected to be here.
-
- if(! $author_exists)
- $unset($item['author']);
+ if(! $author_exists)
+ unset($item['author']);
}
-function bb2diaspora_itembody($item,$force_update = false) {
+function bb2diaspora_itembody($item, $force_update = false) {
+
+ $matches = array();
if(($item['diaspora_meta']) && (! $force_update)) {
$diaspora_meta = json_decode($item['diaspora_meta'],true);
@@ -344,8 +368,8 @@ function bb2diaspora_itembody($item,$force_update = false) {
$body = "## " . $title . "\n\n" . $body;
if($item['attach']) {
- $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism',$item['attach'],$matches,PREG_SET_ORDER);
- if(cnt) {
+ $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism', $item['attach'], $matches, PREG_SET_ORDER);
+ if($cnt) {
$body .= "\n" . t('Attachments:') . "\n";
foreach($matches as $mtch) {
$body .= '[' . $mtch[3] . '](' . $mtch[1] . ')' . "\n";
@@ -356,7 +380,6 @@ function bb2diaspora_itembody($item,$force_update = false) {
// logger('bb2diaspora_itembody : ' . $body, LOGGER_DATA);
return html_entity_decode($body);
-
}
function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
@@ -365,7 +388,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
// The bbcode parser now handles youtube-links (and the other stuff) correctly.
// Additionally the html code is now fixed so that lists are now working.
- /**
+ /*
* Transform #tags, strip off the [url] and replace spaces with underscore
*/
$Text = preg_replace_callback('/#\[([zu])rl\=(\w+.*?)\](\w+.*?)\[\/[(zu)]rl\]/i', create_function('$match',
@@ -451,5 +474,6 @@ function format_event_diaspora($ev) {
. "\n";
$o .= "\n";
+
return $o;
}
diff --git a/include/diaspora.php b/include/diaspora.php
index 1e0e48a86..405fa1e40 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -843,7 +843,7 @@ function diaspora_post($importer,$xml,$msg) {
// Look for tags and linkify them
- $results = linkify_tags(get_app(), $body, $importer['channel_id']);
+ $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
$datarray['term'] = array();
@@ -1062,7 +1062,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray = array();
// Look for tags and linkify them
- $results = linkify_tags(get_app(), $body, $importer['channel_id']);
+ $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
$datarray['term'] = array();
@@ -1397,7 +1397,7 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray = array();
// Look for tags and linkify them
- $results = linkify_tags(get_app(), $body, $importer['channel_id']);
+ $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
$datarray['term'] = array();
diff --git a/include/hubloc.php b/include/hubloc.php
index 98c1a21f3..a4efe1c75 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -184,6 +184,8 @@ function hubloc_mark_as_down($posturl) {
function xchan_store($arr) {
+ logger('xchan_store: ' . print_r($arr,true));
+
if(! $arr['hash'])
$arr['hash'] = $arr['guid'];
if(! $arr['hash'])
@@ -202,7 +204,7 @@ function xchan_store($arr) {
if(! $arr['url'])
$arr['url'] = z_root();
if(! $arr['photo'])
- $arr['photo'] = get_default_profile_photo();
+ $arr['photo'] = z_root() . '/' . get_default_profile_photo();
$r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_flags, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d,'%s') ",
dbesc($arr['hash']),
@@ -256,12 +258,12 @@ function xchan_fetch($arr) {
if(! $key)
return false;
- $r = q("select * from xchan where $key = '$v'");
+ $r = q("select * from xchan where $key = '$v' limit 1");
if(! $r)
return false;
$ret = array();
- foreach($r as $k => $v) {
+ foreach($r[0] as $k => $v) {
if($k === 'xchan_addr')
$ret['address'] = $v;
else
diff --git a/include/items.php b/include/items.php
index 8e293d761..32e5dcbe5 100755
--- a/include/items.php
+++ b/include/items.php
@@ -4366,12 +4366,11 @@ function zot_feed($uid,$observer_xchan,$arr) {
$sql_extra = item_permissions_sql($uid);
}
+ $limit = " LIMIT 100 ";
+
if($mindate != NULL_DATE) {
$sql_extra .= " and ( created > '$mindate' or edited > '$mindate' ) ";
- $limit = "";
}
- else
- $limit = " limit 0, 50 ";
if($message_id) {
$sql_extra .= " and mid = '" . dbesc($message_id) . "' ";
@@ -4382,20 +4381,20 @@ function zot_feed($uid,$observer_xchan,$arr) {
if(is_sys_channel($uid)) {
require_once('include/security.php');
- $r = q("SELECT distinct parent, created from item
+ $r = q("SELECT parent from item
WHERE uid != %d
- and uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0
- AND (item_flags & %d)>0
- and item_private = 0 $sql_extra ORDER BY created ASC $limit",
+ AND item_private = 0 AND item_restrict = 0 AND uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ")
+ AND (item_flags & %d) > 0
+ $sql_extra GROUP BY parent ORDER BY created ASC $limit",
intval($uid),
intval(ITEM_WALL)
);
}
else {
- $r = q("SELECT distinct parent, created from item
+ $r = q("SELECT parent from item
WHERE uid = %d AND item_restrict = 0
- AND (item_flags & %d)>0
- $sql_extra ORDER BY created ASC $limit",
+ AND (item_flags & %d) > 0
+ $sql_extra GROUP BY parent ORDER BY created ASC $limit",
intval($uid),
intval(ITEM_WALL)
);
diff --git a/include/poller.php b/include/poller.php
index 43cc3f3c0..4786188af 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -41,6 +41,12 @@ function poller_run($argv, $argc){
// run queue delivery process in the background
proc_run('php',"include/queue.php");
+
+
+ // maintenance for mod sharedwithme - check for updated items and remove them
+
+ require_once('include/sharedwithme.php');
+ apply_updates();
// expire any expired mail
@@ -82,11 +88,13 @@ function poller_run($argv, $argc){
}
// publish any applicable items that were set to be published in the future
- // (time travel posts)
+ // (time travel posts). Restrict to items that have come of age in the last
+ // couple of days to limit the query to something reasonable.
- $r = q("select id from item where ( item_restrict & %d ) > 0 and created <= %s ",
+ $r = q("select id from item where ( item_restrict & %d ) > 0 and created <= %s and created > '%s' ",
intval(ITEM_DELAYED_PUBLISH),
- db_utcnow()
+ db_utcnow(),
+ dbesc(datetime_convert('UTC','UTC','now - 2 days'))
);
if($r) {
foreach($r as $rr) {
diff --git a/include/security.php b/include/security.php
index e9b41dcf9..c3b0e9763 100644
--- a/include/security.php
+++ b/include/security.php
@@ -396,13 +396,15 @@ function init_groups_visitor($contact_id) {
// will likely be too expensive.
// Returns a string list of comma separated channel_ids suitable for direct inclusion in a SQL query
-function stream_perms_api_uids($perms = NULL ) {
+function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) {
$perms = is_null($perms) ? (PERMS_SITE|PERMS_NETWORK|PERMS_PUBLIC) : $perms;
$ret = array();
+ $limit_sql = (($limit) ? " LIMIT " . intval($limit) . " " : '');
+ $random_sql = (($rand) ? " ORDER BY " . db_getfunc('RAND') . " " : '');
if(local_channel())
$ret[] = local_channel();
- $r = q("select channel_id from channel where channel_r_stream > 0 and (channel_r_stream & %d)>0 and not (channel_pageflags & %d)>0",
+ $r = q("select channel_id from channel where channel_r_stream > 0 and ( channel_r_stream & %d )>0 and ( channel_pageflags & %d ) = 0 $random_sql $limit_sql ",
intval($perms),
intval(PAGE_ADULT|PAGE_CENSORED|PAGE_SYSTEM|PAGE_REMOVED)
);
diff --git a/include/text.php b/include/text.php
index 86da3ee42..0aba45d14 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1855,9 +1855,13 @@ function check_webbie($arr) {
function ids_to_querystr($arr,$idx = 'id') {
$t = array();
- foreach($arr as $x)
- $t[] = $x[$idx];
-
+ if($arr) {
+ foreach($arr as $x) {
+ if(! in_array($x[$idx],$t)) {
+ $t[] = $x[$idx];
+ }
+ }
+ }
return(implode(',', $t));
}
@@ -2101,7 +2105,7 @@ function extra_query_args() {
*
* @return boolean true if replaced, false if not replaced
*/
-function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
+function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $diaspora = false) {
$replaced = false;
$r = null;
@@ -2169,7 +2173,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
if(strpos($tag,'@') === 0) {
// The @! tag will alter permissions
- $exclusive = ((strpos($tag,'!') === 1) ? true : false);
+ $exclusive = ((strpos($tag,'!') === 1 && (! $diaspora)) ? true : false);
//is it already replaced?
if(strpos($tag,'[zrl='))
@@ -2198,10 +2202,19 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
// Here we're looking for an address book entry as provided by the auto-completer
// of the form something+nnn where nnn is an abook_id or the first chars of xchan_hash
- if(strrpos($newname,'+')) {
+
+ // If there's a +nnn in the string make sure there isn't a space preceding it
+
+ $t1 = strpos($newname,' ');
+ $t2 = strrpos($newname,'+');
+
+ if($t1 && $t2 && $t1 < $t2)
+ $t2 = 0;
+
+ if(($t2) && (! $diaspora)) {
//get the id
- $tagcid = substr($newname,strrpos($newname,'+') + 1);
+ $tagcid = substr($newname,$t2 + 1);
if(strrpos($tagcid,' '))
$tagcid = substr($tagcid,0,strrpos($tagcid,' '));
@@ -2346,7 +2359,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $newname, 'url' => $url, 'contact' => $r[0]);
}
-function linkify_tags($a, &$body, $uid) {
+function linkify_tags($a, &$body, $uid, $diaspora = false) {
$str_tags = '';
$tagged = array();
$results = array();
@@ -2370,7 +2383,7 @@ function linkify_tags($a, &$body, $uid) {
if($fullnametagged)
continue;
- $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : $a->profile_uid , $tag);
+ $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : $a->profile_uid , $tag, $diaspora);
$results[] = array('success' => $success, 'access_tag' => $access_tag);
if($success['replaced']) $tagged[] = $tag;
}
diff --git a/mod/channel.php b/mod/channel.php
index 3fc4a9269..022def2a8 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -158,13 +158,11 @@ function channel_content(&$a, $update = 0, $load = false) {
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
-
if($update && $_SESSION['loadtime'])
- $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ";
+ $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
if($load)
$simple_update = '';
-
if(($update) && (! $load)) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0
@@ -185,6 +183,7 @@ function channel_content(&$a, $update = 0, $load = false) {
intval(ITEM_WALL),
intval(ABOOK_FLAG_BLOCKED)
);
+ $_SESSION['loadtime'] = datetime_convert();
}
}
diff --git a/mod/home.php b/mod/home.php
index c449a0561..f4358da5c 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -185,7 +185,7 @@ function home_content(&$a, $update = 0, $load = false) {
$simple_update = (($update) ? " and item.item_unseen = 1 " : '');
if($update && $_SESSION['loadtime'])
- $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ";
+ $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
if($load)
$simple_update = '';
@@ -221,6 +221,7 @@ function home_content(&$a, $update = 0, $load = false) {
$sql_extra3 $sql_extra $sql_nets",
intval(ABOOK_FLAG_BLOCKED)
);
+ $_SESSION['loadtime'] = datetime_convert();
}
// Then fetch all the children of the parents that are on this page
$parents_str = '';
diff --git a/mod/item.php b/mod/item.php
index dad883f50..6644be291 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -35,6 +35,23 @@ function item_post(&$a) {
$channel = null;
$observer = null;
+
+ /**
+ * Is this a reply to something?
+ */
+
+ $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
+ $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : '');
+
+ $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false);
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($remote_xchan)
+ );
+ if($r)
+ $remote_observer = $r[0];
+ else
+ $remote_xchan = $remote_observer = false;
+
$profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
require_once('include/identity.php');
$sys = get_sys_channel();
@@ -116,13 +133,6 @@ function item_post(&$a) {
$item_flags = $item_restrict = 0;
- /**
- * Is this a reply to something?
- */
-
- $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
- $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : '');
-
$route = '';
$parent_item = null;
$parent_contact = null;
@@ -275,6 +285,9 @@ function item_post(&$a) {
$walltowall = false;
$walltowall_comment = false;
+ if($remote_xchan)
+ $observer = $remote_observer;
+
if($observer) {
logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG);
diff --git a/mod/like.php b/mod/like.php
index dc4531fbb..d3b6f3ecf 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -303,7 +303,7 @@ function like_content(&$a) {
$multi_undo = 1;
}
- $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
+ $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ",
dbesc($observer['xchan_hash']),
intval($item_id),
@@ -316,6 +316,16 @@ function like_content(&$a) {
require_once('include/items.php');
foreach($r as $rr) {
drop_item($rr['id'],false,DROPITEM_PHASE1);
+ // set the changed timestamp on the parent so we'll see the update without a page reload
+ $z = q("update item set changed = '%s' where id = %d and uid = %d",
+ dbesc(datetime_convert()),
+ intval($rr['parent']),
+ intval($rr['uid'])
+ );
+ // Prior activity was a duplicate of the one we're submitting, just undo it;
+ // don't fall through and create another
+ if(activity_match($rr['verb'],$activity))
+ $multi_undo = false;
}
if($interactive)
diff --git a/mod/network.php b/mod/network.php
index f71a7569a..8db3bfd58 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -396,7 +396,7 @@ function network_content(&$a, $update = 0, $load = false) {
// which are both ITEM_UNSEEN and have "changed" since that time. Cross fingers...
if($update && $_SESSION['loadtime'])
- $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ";
+ $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
if($load)
$simple_update = '';
@@ -444,16 +444,15 @@ function network_content(&$a, $update = 0, $load = false) {
}
else {
- if(! $firehose) {
- // update
- $r = q("SELECT item.parent AS item_id FROM item
- left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE true $uids AND item.item_restrict = 0 $simple_update
- and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
- $sql_extra3 $sql_extra $sql_nets ",
- intval(ABOOK_FLAG_BLOCKED)
- );
- }
+ // this is an update
+ $r = q("SELECT item.parent AS item_id FROM item
+ left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
+ WHERE true $uids AND item.item_restrict = 0 $simple_update
+ and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
+ $sql_extra3 $sql_extra $sql_nets ",
+ intval(ABOOK_FLAG_BLOCKED)
+ );
+ $_SESSION['loadtime'] = datetime_convert();
}
// Then fetch all the children of the parents that are on this page
diff --git a/mod/ping.php b/mod/ping.php
index 001c5594d..b676726fe 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -274,7 +274,7 @@ function ping_init(&$a) {
$r = q("SELECT * FROM item
WHERE item_restrict = 0 and item_unseen = 1 and uid = %d
- and author_xchan != '%s' ORDER BY created DESC",
+ and author_xchan != '%s' ORDER BY created DESC limit 300",
intval(local_channel()),
dbesc($ob_hash)
);
@@ -295,7 +295,7 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
- $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC",
+ $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC LIMIT 50",
intval(local_channel()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -327,7 +327,7 @@ function ping_init(&$a) {
$r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash
WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
- ORDER BY `start` DESC ",
+ ORDER BY `start` DESC LIMIT 1000",
intval(local_channel()),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php
index b77c9dad1..bee072ea7 100644
--- a/mod/sharedwithme.php
+++ b/mod/sharedwithme.php
@@ -42,7 +42,7 @@ function sharedwithme_content(&$a) {
}
//list files
- $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'",
+ $r = q("SELECT id, uid, object, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'",
dbesc(ACTIVITY_POST),
dbesc(ACTIVITY_OBJ_FILE),
intval(local_channel()),
@@ -50,8 +50,10 @@ function sharedwithme_content(&$a) {
);
$items =array();
+ $ids = '';
if($r) {
+
foreach($r as $rr) {
$object = json_decode($rr['object'],true);
@@ -63,10 +65,27 @@ function sharedwithme_content(&$a) {
$item['objfilename'] = $object['filename'];
$item['objfilesize'] = userReadableSize($object['filesize']);
$item['objedited'] = $object['edited'];
+ $item['unseen'] = $rr['item_unseen'];
$items[] = $item;
+ if($item['unseen'] > 0) {
+ $ids .= " '" . $rr['id'] . "',";
+ }
+
}
+
+ }
+
+ if($ids) {
+
+ //remove trailing ,
+ $ids = rtrim($ids, ",");
+
+ q("UPDATE item SET item_unseen = 0 WHERE id IN ( $ids ) AND uid = %d",
+ intval(local_channel())
+ );
+
}
$o = profile_tabs($a, $is_owner, $channel['channel_address']);
@@ -74,6 +93,7 @@ function sharedwithme_content(&$a) {
$o .= replace_macros(get_markup_template('sharedwithme.tpl'), array(
'$header' => t('Files: shared with me'),
'$name' => t('Name'),
+ '$label_new' => t('NEW'),
'$size' => t('Size'),
'$lastmod' => t('Last Modified'),
'$dropall' => t('Remove all files'),
diff --git a/mod/zotfeed.php b/mod/zotfeed.php
index 7bf91d4db..78a667330 100644
--- a/mod/zotfeed.php
+++ b/mod/zotfeed.php
@@ -9,7 +9,7 @@ function zotfeed_init(&$a) {
$mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : '');
if(! $mindate)
- $mindate = datetime_convert('UTC','UTC', 'now - 1 month');
+ $mindate = datetime_convert('UTC','UTC', 'now - 4 days');
if(get_config('system','block_public') && (! get_account_id()) && (! remote_channel())) {
$result['message'] = 'Public access denied';
@@ -21,7 +21,7 @@ function zotfeed_init(&$a) {
$channel_address = ((argc() > 1) ? argv(1) : '');
if($channel_address) {
- $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d)>0 limit 1",
+ $r = q("select channel_id, channel_name from channel where channel_address = '%s' and not (channel_pageflags & %d) > 0 limit 1",
dbesc(argv(1)),
intval(PAGE_REMOVED)
);
@@ -30,6 +30,7 @@ function zotfeed_init(&$a) {
$x = get_sys_channel();
if($x)
$r = array($x);
+ $mindate = datetime_convert('UTC','UTC', 'now - 2 days');
}
if(! $r) {
$result['message'] = 'Channel not found.';
diff --git a/version.inc b/version.inc
index 35d00274e..320610d0f 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2015-03-21.978
+2015-03-24.981
diff --git a/view/css/mod_sharedwithme.css b/view/css/mod_sharedwithme.css
index 79fe0d7a9..8bf626deb 100644
--- a/view/css/mod_sharedwithme.css
+++ b/view/css/mod_sharedwithme.css
@@ -21,4 +21,3 @@
.cloud-index-tool {
padding: 7px 10px;
}
-
diff --git a/view/tpl/sharedwithme.tpl b/view/tpl/sharedwithme.tpl
index 1aeb9d4d7..4502df276 100644
--- a/view/tpl/sharedwithme.tpl
+++ b/view/tpl/sharedwithme.tpl
@@ -14,7 +14,7 @@
{{foreach $items as $item}}
<tr id="cloud-index-{{$item.id}}">
<td><i class="{{$item.objfiletypeclass}}" title="{{$item.objfiletype}}"></i></td>
- <td><a href="{{$item.objurl}}">{{$item.objfilename}}</a></td>
+ <td><a href="{{$item.objurl}}">{{$item.objfilename}}</a>{{if $item.unseen}}&nbsp;<span class="label label-success">{{$label_new}}</span>{{/if}}</td>
<td class="cloud-index-tool"><a href="/sharedwithme/{{$item.id}}/drop" title="{{$drop}}" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a></td>
<td class="hidden-xs">{{$item.objfilesize}}</td>
<td class="hidden-xs">{{$item.objedited}}</td>