From c96f1dbbe22edf5a71170a7a39dd7b6fcea938f5 Mon Sep 17 00:00:00 2001
From: zotlabs <mike@macgirvin.com>
Date: Wed, 22 Nov 2017 20:24:43 -0800
Subject: mod_file_upload: provide a handler for chunked uploads for when we
 eventually support this on the client side

---
 Zotlabs/Module/File_upload.php | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php
index 5c4b9a502..e99118417 100644
--- a/Zotlabs/Module/File_upload.php
+++ b/Zotlabs/Module/File_upload.php
@@ -47,6 +47,46 @@ class File_upload extends \Zotlabs\Web\Controller {
 			}
 		}
 		else {
+
+			$matches = [];
+			$partial = false;
+
+			$x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches);
+			if($x) {
+				// logger('Content-Range: ' . print_r($matches,true));
+				$partial = true;
+			}
+
+			if($partial) {
+				$x = save_chunk($channel,$matches[1],$matches[2],$matches[3]);
+				if($x['partial']) {
+					header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0));
+					json_return_and_die($result);
+				}
+				else {
+					header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0));
+
+					$_FILES['userfile'] = [
+						'name'     => $x['name'],
+						'type'     => $x['type'],
+						'tmp_name' => $x['tmp_name'],
+						'error'    => $x['error'],
+						'size'     => $x['size']
+					];
+				}
+			}
+			else {	
+				if(! array_key_exists('userfile',$_FILES)) {
+					$_FILES['userfile'] = [
+						'name'     => $_FILES['files']['name'],
+						'type'     => $_FILES['files']['type'],
+						'tmp_name' => $_FILES['files']['tmp_name'],
+						'error'    => $_FILES['files']['error'],
+						'size'     => $_FILES['files']['size']
+					];
+				}
+			}
+
 			$r = attach_store($channel, get_observer_hash(), '', $_REQUEST);
 			if($r['success']) {
 				$sync = attach_export_data($channel,$r['data']['hash']);
-- 
cgit v1.2.3


From a99ebd42ec47ea531496f8ca5c07bf2868e21467 Mon Sep 17 00:00:00 2001
From: zotlabs <mike@macgirvin.com>
Date: Thu, 23 Nov 2017 15:21:50 -0800
Subject: change to bbcode calling parameters: important: will require pulling
 addons; also some extra checking of server headers in upload functions

---
 Zotlabs/Module/File_upload.php | 16 ++++++++++------
 Zotlabs/Module/Wall_attach.php | 10 ++++++----
 2 files changed, 16 insertions(+), 10 deletions(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php
index e99118417..296dab708 100644
--- a/Zotlabs/Module/File_upload.php
+++ b/Zotlabs/Module/File_upload.php
@@ -30,8 +30,8 @@ class File_upload extends \Zotlabs\Web\Controller {
 
 		$_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']);
 		$_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']);
-		$_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']);
-		$_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']);
+		$_REQUEST['deny_cid']  = perms2str($_REQUEST['contact_deny']);
+		$_REQUEST['deny_gid']  = perms2str($_REQUEST['group_deny']);
 
 		if($_REQUEST['filename']) {
 			$r = attach_mkdir($channel, get_observer_hash(), $_REQUEST);
@@ -51,10 +51,14 @@ class File_upload extends \Zotlabs\Web\Controller {
 			$matches = [];
 			$partial = false;
 
-			$x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches);
-			if($x) {
-				// logger('Content-Range: ' . print_r($matches,true));
-				$partial = true;
+
+
+			if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) {
+				$pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches);
+				if($pm) {
+					// logger('Content-Range: ' . print_r($matches,true));
+					$partial = true;
+				}
 			}
 
 			if($partial) {
diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php
index e001ad929..2250e6e44 100644
--- a/Zotlabs/Module/Wall_attach.php
+++ b/Zotlabs/Module/Wall_attach.php
@@ -41,10 +41,12 @@ class Wall_attach extends \Zotlabs\Web\Controller {
 		$matches = [];
 		$partial = false;
 
-		$x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches);
-		if($x) {
-			// logger('Content-Range: ' . print_r($matches,true));
-			$partial = true;
+		if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) {
+			$pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches);
+			if($pm) {
+				// logger('Content-Range: ' . print_r($matches,true));
+				$partial = true;
+			}
 		}
 
 		if($partial) {
-- 
cgit v1.2.3


From 3bb0efd2cb393decf71fc717ef7e431a9f65d374 Mon Sep 17 00:00:00 2001
From: zotlabs <mike@macgirvin.com>
Date: Thu, 23 Nov 2017 20:35:34 -0800
Subject: remove deprecated $a argument from advanced_profile()

---
 Zotlabs/Module/Profile.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php
index 43106e3af..4235f0b97 100644
--- a/Zotlabs/Module/Profile.php
+++ b/Zotlabs/Module/Profile.php
@@ -109,7 +109,7 @@ class Profile extends \Zotlabs\Web\Controller {
 			'title' => 'oembed'
 		]);
 
-		$o .= advanced_profile($a);
+		$o .= advanced_profile();
 		call_hooks('profile_advanced',$o);
 		return $o;
 	
-- 
cgit v1.2.3


From 874cff1a873c306f4174b4910b02de5795a037ca Mon Sep 17 00:00:00 2001
From: zotlabs <mike@macgirvin.com>
Date: Fri, 24 Nov 2017 00:12:19 -0800
Subject: sync packet not generated when deleting a file using the web browser
 interface

---
 Zotlabs/Module/Filestorage.php | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php
index 55713027a..5c8557e5a 100644
--- a/Zotlabs/Module/Filestorage.php
+++ b/Zotlabs/Module/Filestorage.php
@@ -103,6 +103,11 @@ class Filestorage extends \Zotlabs\Web\Controller {
 
 			attach_delete($owner, $f['hash']);
 
+			$sync = attach_export_data($channel, $f['hash'], true);
+			if($sync) {
+				build_sync_packet($channel['channel_id'], array('file' => array($sync)));
+			}
+
 			goaway(dirname($url));
 		}
 
-- 
cgit v1.2.3


From 87eaa6d8e5a5fece531a8ce191f8e89e90f673c2 Mon Sep 17 00:00:00 2001
From: Mario Vavti <mario@mariovavti.com>
Date: Fri, 24 Nov 2017 15:01:34 +0100
Subject: some more work on mod hq

---
 Zotlabs/Lib/ThreadStream.php |  4 ++++
 Zotlabs/Module/Hq.php        | 19 ++++++++++---------
 Zotlabs/Module/Ping.php      |  2 +-
 3 files changed, 15 insertions(+), 10 deletions(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php
index 9eebb929c..bdd2e9657 100644
--- a/Zotlabs/Lib/ThreadStream.php
+++ b/Zotlabs/Lib/ThreadStream.php
@@ -54,6 +54,10 @@ class ThreadStream {
 				$this->profile_owner = local_channel();
 				$this->writable = true;
 				break;
+			case 'hq':
+				$this->profile_owner = local_channel();
+				$this->writable = true;
+				break;
 			case 'channel':
 				$this->profile_owner = \App::$profile['profile_uid'];
 				$this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments');
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 78087c0f9..2795b9086 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -61,6 +61,7 @@ class Hq extends \Zotlabs\Web\Controller {
 			$item_hash = 'b64.' . base64url_encode($r[0]['mid']);
 		}
 
+
 		if(strpos($item_hash,'b64.') === 0)
 			$decoded = @base64url_decode(substr($item_hash,4));
 		if($decoded)
@@ -91,7 +92,7 @@ class Hq extends \Zotlabs\Web\Controller {
 				'bang'                => '',
 				'visitor'             => true,
 				'profile_uid'         => local_channel(),
-				'return_path'         => 'channel/' . $channel['channel_address'],
+				'return_path'         => 'hq',
 				'expanded'            => true,
 				'editor_autocomplete' => true,
 				'bbco_autocomplete'   => 'bbcode',
@@ -133,6 +134,8 @@ class Hq extends \Zotlabs\Web\Controller {
 	
 		if(! $update && ! $load) {
 
+			nav_set_selected('HQ');
+
 			$static  = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1);
 
 			// if the target item is not a post (eg a like) we want to address its thread parent
@@ -143,14 +146,14 @@ class Hq extends \Zotlabs\Web\Controller {
 			if($decoded)
 				$mid = 'b64.' . base64url_encode($mid);
 
-			$o .= '<div id="live-display"></div>' . "\r\n";
+			$o .= '<div id="live-hq"></div>' . "\r\n";
 			$o .= "<script> var profile_uid = " . local_channel()
 				. "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . "; </script>\r\n";
 	
 			\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
 				'$baseurl' => z_root(),
-				'$pgtype'  => 'display',
-				'$uid'     => '0',
+				'$pgtype'  => 'hq',
+				'$uid'     => local_channel(),
 				'$gid'     => '0',
 				'$cid'     => '0',
 				'$cmin'    => '0',
@@ -181,6 +184,7 @@ class Hq extends \Zotlabs\Web\Controller {
 		}
 
 		if($load) {
+
 			$r = null;
 
 			$r = q("SELECT item.id as item_id from item
@@ -198,6 +202,7 @@ class Hq extends \Zotlabs\Web\Controller {
 		}
 	
 		elseif($update) {
+
 			$r = null;
 
 			$r = q("SELECT item.parent AS item_id from item
@@ -238,7 +243,7 @@ class Hq extends \Zotlabs\Web\Controller {
 			$items = [];
 		}
 	
-		$o .= conversation($items, 'display', $update, 'client');
+		$o .= conversation($items, 'hq', $update, 'client');
 
 		if($updateable) {
 			$x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ",
@@ -249,10 +254,6 @@ class Hq extends \Zotlabs\Web\Controller {
 
 		$o .= '<div id="content-complete"></div>';
 
-		if(($update && $load) && (! $items))  {
-			notice( t('Something went wrong.') . EOL );
-		}
-
 		return $o;
 
 	}
diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php
index 406e554d1..84f9d2a21 100644
--- a/Zotlabs/Module/Ping.php
+++ b/Zotlabs/Module/Ping.php
@@ -496,7 +496,7 @@ class Ping extends \Zotlabs\Web\Controller {
 			$r = q("SELECT id, item_wall FROM item
 				WHERE item_unseen = 1 and uid = %d
 				$item_normal
-				AND author_xchan != '%s' $sql_extra ",
+				AND author_xchan != '%s'",
 				intval(local_channel()),
 				dbesc($ob_hash)
 			);
-- 
cgit v1.2.3


From 64c81ed17474cfa3dfe0e84475a49089c0af0106 Mon Sep 17 00:00:00 2001
From: Mario Vavti <mario@mariovavti.com>
Date: Fri, 24 Nov 2017 15:12:40 +0100
Subject: missing files

---
 Zotlabs/Module/Update_hq.php   | 31 +++++++++++++++++++++++++++++++
 Zotlabs/Widget/Hq_controls.php | 26 ++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 Zotlabs/Module/Update_hq.php
 create mode 100644 Zotlabs/Widget/Hq_controls.php

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/Update_hq.php b/Zotlabs/Module/Update_hq.php
new file mode 100644
index 000000000..bb1495c64
--- /dev/null
+++ b/Zotlabs/Module/Update_hq.php
@@ -0,0 +1,31 @@
+<?php
+namespace Zotlabs\Module;
+
+// See update_profile.php for documentation
+
+require_once('include/group.php');
+
+
+class Update_hq extends \Zotlabs\Web\Controller {
+
+	function get() {
+	
+		$profile_uid = intval($_GET['p']);
+
+		$load = (((argc() > 1) && (argv(1) == 'load')) ? 1 : 0);
+		header("Content-type: text/html");
+		echo "<!DOCTYPE html><html><body>\r\n";
+		echo (($_GET['msie'] == 1) ? '<div>' : '<section>');
+	
+		$mod = new Hq();
+		$text = $mod->get($profile_uid, $load);
+
+		echo str_replace("\t",'       ',$text);
+		echo (($_GET['msie'] == 1) ? '</div>' : '</section>');
+		echo "</body></html>\r\n";
+
+		killme();
+	
+	}
+	
+}
diff --git a/Zotlabs/Widget/Hq_controls.php b/Zotlabs/Widget/Hq_controls.php
new file mode 100644
index 000000000..0caa54a1a
--- /dev/null
+++ b/Zotlabs/Widget/Hq_controls.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Hq_controls {
+
+	function widget($arr) {
+
+		if (! local_channel())
+			return;
+
+		return replace_macros(get_markup_template('hq_controls.tpl'),
+			[
+				'$title' => t('HQ Control Panel'),
+				'$menu' => [
+					'create' => [
+						'label' => t('Create a new post'),
+						'id' => 'jot-toggle',
+						'href' => '#',
+						'class' => ''
+					]
+				]
+			]
+		);
+	}
+}
-- 
cgit v1.2.3


From b03545f89939ef1c13ca7f5a950d52fcb7f2313f Mon Sep 17 00:00:00 2001
From: Mario Vavti <mario@mariovavti.com>
Date: Fri, 24 Nov 2017 22:48:15 +0100
Subject: mod hq: minor query change

---
 Zotlabs/Module/Hq.php | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 2795b9086..08f4ddda5 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -43,10 +43,9 @@ class Hq extends \Zotlabs\Web\Controller {
 		$item_normal_update = item_normal_update();
 
 		if(! $item_hash) {
-
 			$r = q("SELECT mid FROM item
 				WHERE uid = %d 
-				AND item_thread_top = 1
+				AND mid = parent_mid
 				ORDER BY created DESC
 				limit 1",
 				intval(local_channel())
@@ -64,13 +63,13 @@ class Hq extends \Zotlabs\Web\Controller {
 
 		if(strpos($item_hash,'b64.') === 0)
 			$decoded = @base64url_decode(substr($item_hash,4));
+
 		if($decoded)
 			$item_hash = $decoded;
 	
 		$updateable = false;
 
 		if(! $update) {
-	
 			$channel = \App::get_channel();
 
 			$channel_acl = [
@@ -139,7 +138,6 @@ class Hq extends \Zotlabs\Web\Controller {
 			$static  = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1);
 
 			// if the target item is not a post (eg a like) we want to address its thread parent
-
 			$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']);
 
 			// if we got a decoded hash we must encode it again before handing to javascript 
@@ -180,11 +178,9 @@ class Hq extends \Zotlabs\Web\Controller {
 				'$net'     => '',
 				'$mid'     => $mid
 			]);
-
 		}
 
 		if($load) {
-
 			$r = null;
 
 			$r = q("SELECT item.id as item_id from item
@@ -198,11 +194,8 @@ class Hq extends \Zotlabs\Web\Controller {
 			if($r) {
 				$updateable = true;
 			}
-
 		}
-	
 		elseif($update) {
-
 			$r = null;
 
 			$r = q("SELECT item.parent AS item_id from item
@@ -220,7 +213,6 @@ class Hq extends \Zotlabs\Web\Controller {
 
 			$_SESSION['loadtime'] = datetime_convert();
 		}
-	
 		else {
 			$r = [];
 		}
-- 
cgit v1.2.3


From fda5231a719025c0e2d7cc3954ebbab5b0d53586 Mon Sep 17 00:00:00 2001
From: zotlabs <mike@macgirvin.com>
Date: Fri, 24 Nov 2017 14:55:39 -0800
Subject: default profile assign

---
 Zotlabs/Module/Settings/Channel.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php
index 63370a141..db0f79060 100644
--- a/Zotlabs/Module/Settings/Channel.php
+++ b/Zotlabs/Module/Settings/Channel.php
@@ -2,6 +2,8 @@
 
 namespace Zotlabs\Module\Settings;
 
+require_once('include/selectors.php');
+
 
 class Channel {
 
@@ -148,7 +150,8 @@ class Channel {
 		$defpermcat       = ((x($_POST,'defpermcat')) ? notags(trim($_POST['defpermcat'])) : 'default');
 	
 		$cal_first_day   = (((x($_POST,'first_day')) && (intval($_POST['first_day']) == 1)) ? 1: 0);
-		$mailhost       = ((array_key_exists('mailhost',$_POST)) ? notags(trim($_POST['mailhost'])) : '');
+		$mailhost        = ((array_key_exists('mailhost',$_POST)) ? notags(trim($_POST['mailhost'])) : '');
+		$profile_assign  = ((x($_POST,'profile_assign')) ? notags(trim($_POST['profile_assign'])) : '');
 
 	
 		$pageflags = $channel['channel_pageflags'];
@@ -242,6 +245,7 @@ class Channel {
 		set_pconfig(local_channel(),'system','cal_first_day',$cal_first_day);
 		set_pconfig(local_channel(),'system','default_permcat',$defpermcat);
 		set_pconfig(local_channel(),'system','email_notify_host',$mailhost);
+		set_pconfig(local_channel(),'system','profile_assign',$profile_assign);
 	
 		$r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d",
 			dbesc($username),
@@ -515,6 +519,9 @@ class Channel {
 			'$permissions' => t('Default Privacy Group'),
 			'$permdesc' => t("\x28click to open/close\x29"),
 			'$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))),
+			'$profseltxt' => t('Profile to assign new connections'),
+			'$profselect' => ((feature_enabled(local_channel(),'multi_profiles')) ? contact_profile_assign(get_pconfig(local_channel(),'system','profile_assign','')) : ''),
+
 			'$allow_cid' => acl2json($perm_defaults['allow_cid']),
 			'$allow_gid' => acl2json($perm_defaults['allow_gid']),
 			'$deny_cid' => acl2json($perm_defaults['deny_cid']),
-- 
cgit v1.2.3


From 4b2bd871b765e0287f329ad398a15f20cb6a6425 Mon Sep 17 00:00:00 2001
From: Mario <mario@mariovavti.com>
Date: Sat, 25 Nov 2017 10:44:47 +0100
Subject: implement pubstream items in mod hq

---
 Zotlabs/Module/Hq.php | 47 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 11 deletions(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 08f4ddda5..c5b3ced3e 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -125,11 +125,12 @@ class Hq 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($static && $simple_update)
 			$simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
+
+		$sys = get_sys_channel();
+		$sql_extra = item_permissions_sql($sys['channel_id']);
 	
 		if(! $update && ! $load) {
 
@@ -183,34 +184,58 @@ class Hq extends \Zotlabs\Web\Controller {
 		if($load) {
 			$r = null;
 
-			$r = q("SELECT item.id as item_id from item
+			$r = q("SELECT item.id AS item_id FROM item
 				WHERE uid = %d
-				and mid = '%s'
+				AND mid = '%s'
 				$item_normal
-				limit 1",
+				LIMIT 1",
 				intval(local_channel()),
 				dbesc($target_item['parent_mid'])
 			);
+
 			if($r) {
 				$updateable = true;
 			}
+
+			if(!$r) {
+				$r = q("SELECT item.id AS item_id FROM item
+					LEFT JOIN abook ON item.author_xchan = abook.abook_xchan
+					WHERE mid = '%s' AND item.uid = %d $item_normal
+					AND (abook.abook_blocked = 0 or abook.abook_flags is null)
+					$sql_extra LIMIT 1",
+					dbesc($target_item['parent_mid']),
+					intval($sys['channel_id'])
+				);
+			}
 		}
 		elseif($update) {
 			$r = null;
 
-			$r = q("SELECT item.parent AS item_id from item
+			$r = q("SELECT item.parent AS item_id FROM item
 				WHERE uid = %d
-				and parent_mid = '%s'
+				AND parent_mid = '%s'
 				$item_normal_update
 				$simple_update
-				limit 1",
+				LIMIT 1",
 				intval(local_channel()),
 				dbesc($target_item['parent_mid'])
 			);
+
 			if($r) {
 				$updateable = true;
 			}
 
+			if(!$r) {
+				$r = q("SELECT item.parent AS item_id FROM item
+					LEFT JOIN abook ON item.author_xchan = abook.abook_xchan
+					WHERE mid = '%s' AND item.uid = %d $item_normal_update $simple_update
+					AND (abook.abook_blocked = 0 or abook.abook_flags is null)
+					$sql_extra LIMIT 1",
+					dbesc($target_item['parent_mid']),
+					intval($sys['channel_id'])
+				);
+			}
+
 			$_SESSION['loadtime'] = datetime_convert();
 		}
 		else {
@@ -222,11 +247,11 @@ class Hq extends \Zotlabs\Web\Controller {
 			if($parents_str) {
 				$items = q("SELECT item.*, item.id AS item_id 
 					FROM item
-					WHERE parent in ( %s ) $item_normal ",
+					WHERE parent IN ( %s ) $item_normal ",
 					dbesc($parents_str)
 				);
 	
-				xchan_query($items);
+				xchan_query($items,true,local_channel());
 				$items = fetch_post_tags($items,true);
 				$items = conv_sort($items,'created');
 			}
@@ -238,7 +263,7 @@ class Hq extends \Zotlabs\Web\Controller {
 		$o .= conversation($items, 'hq', $update, 'client');
 
 		if($updateable) {
-			$x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ",
+			$x = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d AND parent = %d ",
 				intval(local_channel()),
 				intval($r[0]['item_id'])
 			);
-- 
cgit v1.2.3


From fe37b037575a3de5c60c2ccd3d4e1f6bc24fce37 Mon Sep 17 00:00:00 2001
From: zotlabs <mike@macgirvin.com>
Date: Sat, 25 Nov 2017 03:01:25 -0800
Subject: blah is not author or owner

---
 Zotlabs/Daemon/Notifier.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index d0175549b..3f07d4ce0 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -309,7 +309,7 @@ class Notifier {
 			if($s)
 				$channel = $s[0];
 
-			if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) {
+			if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan'] && ( ! intval($channel['channel_system']))) {
 				logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}", LOGGER_NORMAL, LOG_WARNING);
 				return;
 			}
-- 
cgit v1.2.3


From 014b629928b19dec4bfa2f12f961fd4048d71d19 Mon Sep 17 00:00:00 2001
From: Mario <mario@mariovavti.com>
Date: Sat, 25 Nov 2017 14:33:57 +0100
Subject: fix regression in cdav calendar widget

---
 Zotlabs/Widget/Cdav.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'Zotlabs')

diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php
index 60a860f93..589f915c5 100644
--- a/Zotlabs/Widget/Cdav.php
+++ b/Zotlabs/Widget/Cdav.php
@@ -63,9 +63,10 @@ class Cdav {
 
 				$sharees = [];
 				$share_displayname = [];
+
 				foreach($invites as $invite) {
 					if(strpos($invite->href, 'mailto:') !== false) {
-						$sharee = channelx_by_hash(substr($invite->href, 7));
+						$sharee = channelx_by_nick(substr($invite->principal, 11));
 						$sharees[] = [
 							'name' => $sharee['channel_name'],
 							'access' => (($invite->access == 3) ? ' (RW)' : ' (R)'),
@@ -173,4 +174,4 @@ class Cdav {
 		}
 
 	}
-}
\ No newline at end of file
+}
-- 
cgit v1.2.3