aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Master.php5
-rw-r--r--Zotlabs/Module/Acl.php7
-rw-r--r--Zotlabs/Module/Linkinfo.php4
-rw-r--r--Zotlabs/Module/Network.php59
-rw-r--r--Zotlabs/Module/Ping.php23
-rw-r--r--Zotlabs/Widget/Activity_filter.php59
-rw-r--r--Zotlabs/Widget/Activity_order.php4
7 files changed, 95 insertions, 66 deletions
diff --git a/Zotlabs/Daemon/Master.php b/Zotlabs/Daemon/Master.php
index 3a71ee578..0656ca05b 100644
--- a/Zotlabs/Daemon/Master.php
+++ b/Zotlabs/Daemon/Master.php
@@ -60,7 +60,8 @@ class Master {
$k = explode('_',$worker['k']);
q("delete from config where cat='queueworkers' and k='%s'",
'workerstarted_'.$k[1]);
- q("update config set k='workitem' where cat='queuework' and k='%s'",
+ q("update config set k='%s' where cat='queuework' and k='%s'",
+ dbesc(uniqid('workitem:',true)),
'workitem_'.$k[1]);
unset($workers[$idx]);
}
@@ -69,7 +70,7 @@ class Master {
return false;
}
}
- return uniqid();
+ return uniqid('',true);
}
diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php
index ea131e08c..738e8fbe2 100644
--- a/Zotlabs/Module/Acl.php
+++ b/Zotlabs/Module/Acl.php
@@ -83,7 +83,8 @@ class Acl extends \Zotlabs\Web\Controller {
if($search) {
$sql_extra = " AND pgrp.gname LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ";
$sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc(punify($search)) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") ";
-
+ $sql_extra2_xchan = "AND ( xchan_name LIKE " . protect_sprintf( "'" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'" . dbesc(punify($search)) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") ";
+
// This horrible mess is needed because position also returns 0 if nothing is found.
// Would be MUCH easier if it instead returned a very large value
// Otherwise we could just
@@ -226,7 +227,7 @@ class Acl extends \Zotlabs\Web\Controller {
else { // Visitors
$r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
FROM xchan left join xlink on xlink_link = xchan_hash
- WHERE xlink_xchan = '%s' AND xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
+ WHERE xlink_xchan = '%s' AND xchan_deleted = 0 $sql_extra2_xchan order by $order_extra2 xchan_name asc" ,
dbesc(get_observer_hash())
);
@@ -270,7 +271,7 @@ class Acl extends \Zotlabs\Web\Controller {
if((count($r) < 100) && $type == 'c') {
$r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
FROM xchan
- WHERE xchan_deleted = 0 and not xchan_network in ('rss','anon','unknown') $sql_extra2 order by $order_extra2 xchan_name asc"
+ WHERE xchan_deleted = 0 and not xchan_network in ('rss','anon','unknown') $sql_extra2_xchan order by $order_extra2 xchan_name asc"
);
if($r2) {
$r = array_merge($r,$r2);
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index f0d62b5e0..a0ad17e68 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -228,8 +228,8 @@ class Linkinfo extends \Zotlabs\Web\Controller {
$header = $result['header'];
$body = $result['body'];
-
- $body = mb_convert_encoding($body, 'UTF-8', 'UTF-8');
+
+ $body = mb_convert_encoding($body, 'UTF-8', (preg_match('/meta.+content=["|\']text\/html;\s+charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'UTF-8'));
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
$doc = new \DOMDocument();
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 792f92418..294e11c52 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -128,11 +128,12 @@ class Network extends \Zotlabs\Web\Controller {
$xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : '');
$net = ((x($_GET,'net')) ? $_GET['net'] : '');
$pf = ((x($_GET,'pf')) ? $_GET['pf'] : '');
+ $unseen = ((x($_GET,'unseen')) ? $_GET['unseen'] : '');
$deftag = '';
- if(x($_GET,'search') || $file || (!$pf && $cid) || $hashtags || $verb || $category)
+ if(x($_GET,'search') || $file || (!$pf && $cid) || $hashtags || $verb || $category || $conv || $unseen)
$nouveau = true;
if($cid) {
@@ -220,6 +221,7 @@ class Network extends \Zotlabs\Web\Controller {
$sql_extra = '';
if($group) {
+
$contact_str = '';
$contacts = group_get_members($group);
if($contacts) {
@@ -232,7 +234,6 @@ class Network extends \Zotlabs\Web\Controller {
}
}
$item_thread_top = '';
-
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) ";
$x = group_rec_byhash(local_channel(), $group_hash);
@@ -252,15 +253,35 @@ class Network extends \Zotlabs\Web\Controller {
if($load || $update) {
if(!$pf && $nouveau) {
+ // This is for nouveau view cid queries (not a public forum)
$sql_extra = " AND author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ";
}
+ elseif($pf && $unseen && $nouveau) {
+
+ // This is for nouveau view public forum cid queries (if a forum notification is clicked)
+ $p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'",
+ intval(local_channel()),
+ intval(TERM_FORUM),
+ dbesc($cid_r[0]['xchan_name'])
+ );
+
+ $p_str = ids_to_querystr($p, 'parent');
+ if($p_str)
+ $p_sql = " OR item.parent IN ( $p_str ) ";
+
+ $sql_extra = " AND ( owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' OR owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' $p_sql ) AND item_unseen = 1 ";
+ }
else {
+ // This is for threaded view cid queries (e.g. if a forum is selected from the forum filter)
$ttype = (($pf) ? TERM_FORUM : TERM_MENTION);
$p1 = q("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal ");
$p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype = $ttype AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'");
$p_str = ids_to_querystr(array_merge($p1,$p2),'parent');
+ if(! $p_str)
+ killme();
+
$sql_extra = " AND item.parent IN ( $p_str ) ";
}
}
@@ -345,7 +366,8 @@ class Network extends \Zotlabs\Web\Controller {
'$verb' => $verb,
'$net' => $net,
'$dbegin' => $datequery2,
- '$pf' => (($pf) ? $pf : '0'),
+ '$pf' => (($pf) ? $pf : '0'),
+ '$unseen' => $unseen
));
}
@@ -386,15 +408,7 @@ class Network extends \Zotlabs\Web\Controller {
if($conv) {
$item_thread_top = '';
-
- if($nouveau) {
- $sql_extra .= " AND author_xchan = '" . dbesc($channel['channel_hash']) . "' ";
- }
- else {
- $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan = '%s' or item_mentionsme = 1 )) ",
- dbesc(protect_sprintf($channel['channel_hash']))
- );
- }
+ $sql_extra .= " AND ( author_xchan = '" . dbesc($channel['channel_hash']) . "' OR item_mentionsme = 1 ) ";
}
if($update && ! $load) {
@@ -441,9 +455,11 @@ class Network extends \Zotlabs\Web\Controller {
$page_mode = 'list';
else
$page_mode = 'client';
-
- $simple_update = (($update) ? " and item_unseen = 1 " : '');
+ $parents_str = '';
+ $update_unseen = '';
+
+ $simple_update = (($update) ? " and item_unseen = 1 " : '');
// This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day
// or three and look at your matrix page - after opening up your browser. The first page loads just as it
@@ -459,15 +475,15 @@ class Network extends \Zotlabs\Web\Controller {
if($update && $_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($load)
+ $simple_update = '';
if($static && $simple_update)
$simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
if($nouveau && $load) {
// "New Item View" - show all items unthreaded in reverse created date order
-
$items = q("SELECT item.*, item.id AS item_id, created FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
$net_query
@@ -478,7 +494,12 @@ class Network extends \Zotlabs\Web\Controller {
$net_query2
ORDER BY item.created DESC $pager_sql "
);
-
+
+ $parents_str = ids_to_querystr($items,'item_id');
+ if($parents_str) {
+ $update_unseen = " AND id IN ( " . dbesc($parents_str) . " )";
+ }
+
require_once('include/items.php');
xchan_query($items);
@@ -521,8 +542,6 @@ class Network extends \Zotlabs\Web\Controller {
}
// Then fetch all the children of the parents that are on this page
- $parents_str = '';
- $update_unseen = '';
if($r) {
diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php
index 14627f56e..75e8843d6 100644
--- a/Zotlabs/Module/Ping.php
+++ b/Zotlabs/Module/Ping.php
@@ -634,23 +634,30 @@ class Ping extends \Zotlabs\Web\Controller {
if($vnotify & VNOTIFY_FORUMS) {
$forums = get_forum_channels(local_channel());
- if(! $forums) {
- $result['forums'] = 0;
- }
- else {
-
- $perms_sql = item_permissions_sql(local_channel()) . item_normal();
+ if($forums) {
+ $perms_sql = item_permissions_sql(local_channel());
+ $item_normal = item_normal();
$fcount = count($forums);
$forums['total'] = 0;
for($x = 0; $x < $fcount; $x ++) {
+ $p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'",
+ intval(local_channel()),
+ intval(TERM_FORUM),
+ dbesc($forums[$x]['xchan_hash'])
+ );
+
+ $p_str = ids_to_querystr($p, 'parent');
+ $p_sql = (($p_str) ? "OR parent IN ( $p_str )" : '');
+
$r = q("select sum(item_unseen) as unseen from item
- where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ",
+ where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $perms_sql $item_normal",
intval(local_channel()),
+ dbesc($forums[$x]['xchan_hash']),
dbesc($forums[$x]['xchan_hash'])
);
if($r[0]['unseen']) {
- $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&cid=' . $forums[$x]['abook_id']);
+ $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']);
$forums[$x]['name'] = $forums[$x]['xchan_name'];
$forums[$x]['url'] = $forums[$x]['xchan_url'];
$forums[$x]['photo'] = $forums[$x]['xchan_photo_s'];
diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php
index 4ea0086dd..32ab10c77 100644
--- a/Zotlabs/Widget/Activity_filter.php
+++ b/Zotlabs/Widget/Activity_filter.php
@@ -16,35 +16,6 @@ class Activity_filter {
$tabs = [];
- if(feature_enabled(local_channel(),'personal_tab')) {
- if(x($_GET,'conv')) {
- $conv_active = (($_GET['conv'] == 1) ? 'active' : '');
- $filter_active = 'personal';
- }
-
- $tabs[] = [
- 'label' => t('Personal Posts'),
- 'icon' => 'user-circle',
- 'url' => z_root() . '/' . $cmd . '/?f=&conv=1',
- 'sel' => $conv_active,
- 'title' => t('Show posts that mention or involve me')
- ];
- }
-
- if(feature_enabled(local_channel(),'star_posts')) {
- if(x($_GET,'star')) {
- $starred_active = (($_GET['star'] == 1) ? 'active' : '');
- $filter_active = 'star';
- }
-
- $tabs[] = [
- 'label' => t('Starred Posts'),
- 'icon' => 'star',
- 'url'=>z_root() . '/' . $cmd . '/?f=&star=1',
- 'sel'=>$starred_active,
- 'title' => t('Show posts that I have starred')
- ];
- }
if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) {
$groups = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
@@ -110,6 +81,36 @@ class Activity_filter {
}
}
+ if(feature_enabled(local_channel(),'star_posts')) {
+ if(x($_GET,'star')) {
+ $starred_active = (($_GET['star'] == 1) ? 'active' : '');
+ $filter_active = 'star';
+ }
+
+ $tabs[] = [
+ 'label' => t('Starred Posts'),
+ 'icon' => 'star',
+ 'url'=>z_root() . '/' . $cmd . '/?f=&star=1',
+ 'sel'=>$starred_active,
+ 'title' => t('Show posts that I have starred')
+ ];
+ }
+
+ if(feature_enabled(local_channel(),'personal_tab')) {
+ if(x($_GET,'conv')) {
+ $conv_active = (($_GET['conv'] == 1) ? 'active' : '');
+ $filter_active = 'personal';
+ }
+
+ $tabs[] = [
+ 'label' => t('Personal Posts'),
+ 'icon' => 'user-circle',
+ 'url' => z_root() . '/' . $cmd . '/?f=&conv=1',
+ 'sel' => $conv_active,
+ 'title' => t('Show posts that mention or involve me')
+ ];
+ }
+
if(feature_enabled(local_channel(),'filing')) {
$terms = q("select distinct term from term where uid = %d and ttype = %d order by term asc",
intval(local_channel()),
diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php
index 1cba1ce8c..d3fe2a30f 100644
--- a/Zotlabs/Widget/Activity_order.php
+++ b/Zotlabs/Widget/Activity_order.php
@@ -54,8 +54,8 @@ class Activity_order {
}
}
- // override order for search, filer and cid results
- if(x($_GET,'search') || x($_GET,'file') || (! x($_GET,'pf') && x($_GET,'cid')) || x($_GET,'verb') || x($_GET,'tag') || x($_GET,'cat')) {
+ // override order for some filter results
+ if(x($_GET,'search') || x($_GET,'file') || (! x($_GET,'pf') && x($_GET,'cid')) || x($_GET,'verb') || x($_GET,'tag') || x($_GET,'cat') || x($_GET,'conv') || x($_GET,'unseen')) {
$unthreaded_active = 'active';
$commentord_active = $postord_active = 'disabled';
}