From 2dff10564c66ceb9f199d4edc936a542c28f5104 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 23 Apr 2018 21:12:31 +0200 Subject: possible fix for issue #1101 --- Zotlabs/Module/Ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 87f9ee78a..206b8c3d1 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -143,7 +143,7 @@ class Ping extends \Zotlabs\Web\Controller { $sql_extra = ''; if(! ($vnotify & VNOTIFY_LIKE)) - $sql_extra = ' AND verb NOT IN ("' . dbesc(ACTIVITY_LIKE) . '", "' . dbesc(ACTIVITY_DISLIKE) . '") '; + $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; $discover_tab_on = can_view_public_stream(); -- cgit v1.2.3 From 97308ad2fbb31ec90644e6145ec6e17bc9663c22 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 23 Apr 2018 16:05:55 -0700 Subject: provide a short term compatibility mapping between social_party and social_federation --- Zotlabs/Module/Settings/Channel.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 3e928ec58..65b9b197e 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -21,6 +21,10 @@ class Channel { $role = ((x($_POST,'permissions_role')) ? notags(trim($_POST['permissions_role'])) : ''); $oldrole = get_pconfig(local_channel(),'system','permissions_role'); + // This mapping can be removed after 3.4 release + if($oldrole === 'social_party') { + $oldrole = 'social_federation'; + } if(($role != $oldrole) || ($role === 'custom')) { @@ -471,6 +475,10 @@ class Channel { $permissions_role = get_pconfig(local_channel(),'system','permissions_role'); if(! $permissions_role) $permissions_role = 'custom'; + // compatibility mapping - can be removed after 3.4 release + if($permissions_role === 'social_party') + $permissions_role = 'social_federation'; + $permissions_set = (($permissions_role != 'custom') ? true : false); -- cgit v1.2.3 From a6c42e875633e8e67bbf93425182cce4de3eb653 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 23 Apr 2018 21:55:16 -0700 Subject: added variable to store the raw json string as received, since this is signed and we may need to forward the signed data. --- Zotlabs/Lib/ActivityStreams.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 2e9bb0703..3a99e7b49 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -9,6 +9,7 @@ namespace Zotlabs\Lib; */ class ActivityStreams { + public $raw = null; public $data; public $valid = false; public $id = ''; @@ -33,6 +34,7 @@ class ActivityStreams { */ function __construct($string) { + $this->raw = $string; $this->data = json_decode($string, true); if($this->data) { $this->valid = true; -- cgit v1.2.3 From 2ea87b65ca4aeab08e68a4e5cd1fd940ae470146 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Apr 2018 15:41:35 +0200 Subject: fix php warnings --- Zotlabs/Module/Photos.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index fa22c3f26..a143c4d4c 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1148,10 +1148,10 @@ class Photos extends \Zotlabs\Web\Controller { builtin_activity_puller($item, $conv_responses); } - $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : ''); $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : ''); - if (count($like_list) > MAX_LIKERS) { + + if(is_array($like_list) && (count($like_list) > MAX_LIKERS)) { $like_list_part = array_slice($like_list, 0, MAX_LIKERS); array_push($like_list_part, '' . t('View all') . ''); } else { @@ -1163,7 +1163,7 @@ class Photos extends \Zotlabs\Web\Controller { $dislike_count = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid']] : ''); $dislike_list = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid'] . '-l'] : ''); $dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun'); - if (count($dislike_list) > MAX_LIKERS) { + if (is_array($dislike_list) && (count($dislike_list) > MAX_LIKERS)) { $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS); array_push($dislike_list_part, '' . t('View all') . ''); } else { -- cgit v1.2.3 From e11e99b2d1e2d94417e9f9934b759c88a70177ac Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Apr 2018 17:09:51 +0200 Subject: fix regression with forum widget unseen count --- Zotlabs/Widget/Forums.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index f65a639ff..7415c0f0a 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -66,8 +66,8 @@ class Forums { for($x = 0; $x < count($r1); $x ++) { $r = q("select sum(item_unseen) as unseen from item where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", - dbesc($r1[$x]['xchan_hash']), - intval(local_channel()) + intval(local_channel()), + dbesc($r1[$x]['xchan_hash']) ); if($r) $r1[$x]['unseen'] = $r[0]['unseen']; -- cgit v1.2.3 From 8face5a66c82e7086c379ca4b07f178a85a781b3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 24 Apr 2018 15:32:24 -0700 Subject: make tag autocomplete less scary looking in the editor. If this works out we can simplify and get rid of a huge amount of spaghetti tag logic. --- Zotlabs/Module/Acl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 4c5883e88..35594ae9f 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -354,7 +354,7 @@ class Acl extends \Zotlabs\Web\Controller { "name" => $g['name'] . (($type === 'f') ? '' : '+'), "id" => urlencode($g['id']) . (($type === 'f') ? '' : '+'), "xid" => $g['hash'], - "link" => $g['nick'], + "link" => (($g['nick']) ? $g['nick'] : $g['url']), "nick" => substr($g['nick'],0,strpos($g['nick'],'@')), "self" => (intval($g['abook_self']) ? 'abook-self' : ''), "taggable" => 'taggable', @@ -368,7 +368,7 @@ class Acl extends \Zotlabs\Web\Controller { "name" => $g['name'], "id" => urlencode($g['id']), "xid" => $g['hash'], - "link" => $g['nick'], + "link" => (($g['nick']) ? $g['nick'] : $g['url']), "nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']), "self" => (intval($g['abook_self']) ? 'abook-self' : ''), "taggable" => '', -- cgit v1.2.3 From 5a9e9284c260c8bb880987c0942a9fe040442a2b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 25 Apr 2018 14:10:11 -0700 Subject: generating random numbers too large for 32-bit systems --- Zotlabs/Lib/Enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 05ea67ea5..cfb0bd344 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -747,8 +747,8 @@ class Enotify { // generate a mime boundary $mimeBoundary = rand(0, 9) . "-" - .rand(10000000000, 9999999999) . "-" - .rand(10000000000, 9999999999) . "=:" + .rand(100000000, 999999999) . "-" + .rand(100000000, 999999999) . "=:" .rand(10000, 99999); // generate a multipart/alternative message header -- cgit v1.2.3 From f923d21df341546e054eb0f9628891365c4c2d62 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 25 Apr 2018 18:41:19 -0700 Subject: some tagging work --- Zotlabs/Module/Acl.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 35594ae9f..b1f75263d 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -268,15 +268,15 @@ class Acl extends \Zotlabs\Web\Controller { }); } } - if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_channel(),'system','taganyone'))) { - 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 $sql_extra2 order by $order_extra2 xchan_name asc" - ); - if($r2) - $r = array_merge($r,$r2); - } + 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 $sql_extra2 order by $order_extra2 xchan_name asc" + ); + if($r2) { + $r = array_merge($r,$r2); + $r = unique_multidim_array($r,'hash'); + } } } elseif($type == 'm') { -- cgit v1.2.3 From 5f8b093d791e88041602c0b41a13112ad8e45688 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 25 Apr 2018 18:51:30 -0700 Subject: fine tuning --- Zotlabs/Module/Acl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index b1f75263d..92e7d176d 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -271,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 $sql_extra2 order by $order_extra2 xchan_name asc" + WHERE xchan_deleted = 0 and not xchan_network in ('rss','anon','unknown') $sql_extra2 order by $order_extra2 xchan_name asc" ); if($r2) { $r = array_merge($r,$r2); -- cgit v1.2.3 From fe724acc3b78af5ed86b4bf0ff58bdd9b56356e2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 25 Apr 2018 22:53:20 -0700 Subject: mod_network: privacy group query returning results when group is empty. Notification that the group is empty was also displayed twice. --- Zotlabs/Module/Network.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 8d017207b..e97ebf1d0 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -218,15 +218,13 @@ class Network extends \Zotlabs\Web\Controller { $contact_str = ''; $contacts = group_get_members($group); if($contacts) { - foreach($contacts as $c) { - if($contact_str) - $contact_str .= ','; - $contact_str .= "'" . $c['xchan'] . "'"; - } + $contact_str = ids_to_querystr($contacts,'xchan',true); } else { - $contact_str = ' 0 '; - info( t('Privacy group is empty')); + $contact_str = " '0' "; + if(! $update) { + info( t('Privacy group is empty')); + } } $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 ) "; @@ -480,7 +478,6 @@ class Network extends \Zotlabs\Web\Controller { $ordering = "commented"; if($load) { - // Fetch a page full of parent items for this page $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) -- cgit v1.2.3 From f32ba0656430929ba5af3d1ef730d7ada98c0ea7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 26 Apr 2018 02:42:48 -0700 Subject: work through a few more autocomplete minor nits --- Zotlabs/Module/Acl.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 92e7d176d..2678aeb7a 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -337,22 +337,21 @@ class Acl extends \Zotlabs\Web\Controller { if($r) { foreach($r as $g) { - if(($g['network'] === 'rss') && ($type != 'a')) + if(in_array($g['network'],['rss','anon','unknown']) && ($type != 'a')) continue; $g['hash'] = urlencode($g['hash']); if(! $g['nick']) { - $t = explode(' ',strtolower($g['name'])); - $g['nick'] = $t[0] . '@'; + $g['nick'] = $g['url']; } - if(in_array($g['hash'],$permitted) && in_array($type, [ 'c', 'f' ]) && (! $noforums)) { + if(in_array($g['hash'],$permitted) && $type === 'f' && (! $noforums)) { $contacts[] = array( "type" => "c", "photo" => "images/twopeople.png", - "name" => $g['name'] . (($type === 'f') ? '' : '+'), - "id" => urlencode($g['id']) . (($type === 'f') ? '' : '+'), + "name" => $g['name'], + "id" => urlencode($g['id']), "xid" => $g['hash'], "link" => (($g['nick']) ? $g['nick'] : $g['url']), "nick" => substr($g['nick'],0,strpos($g['nick'],'@')), @@ -369,7 +368,7 @@ class Acl extends \Zotlabs\Web\Controller { "id" => urlencode($g['id']), "xid" => $g['hash'], "link" => (($g['nick']) ? $g['nick'] : $g['url']), - "nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']), + "nick" => ((strpos($g['nick'],'@')) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']), "self" => (intval($g['abook_self']) ? 'abook-self' : ''), "taggable" => '', "label" => '', -- cgit v1.2.3 From 38e99c83544ca89edabe6f0786c5faac39f07e95 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 26 Apr 2018 17:25:58 -0700 Subject: set the 'force' flag on attach_mkdir when initiated from a DAV operation. This will report success if it already exists rather than throwing an exception. --- Zotlabs/Storage/Directory.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index a2ae0fee8..d063eed40 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -389,8 +389,12 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo ); if ($r) { + + // When initiated from DAV, set the 'force' flag on attach_mkdir(). This will cause the operation to report success even if the + // folder already exists. + require_once('include/attach.php'); - $result = attach_mkdir($r[0], $this->auth->observer, array('filename' => $name, 'folder' => $this->folder_hash)); + $result = attach_mkdir($r[0], $this->auth->observer, array('filename' => $name, 'folder' => $this->folder_hash, 'force' => true)); if($result['success']) { $sync = attach_export_data($r[0],$result['data']['hash']); -- cgit v1.2.3 From 09ef1b1bb68a4517b090f05f947b5af1acb89bd5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 27 Apr 2018 02:34:52 -0700 Subject: sql error --- Zotlabs/Storage/Directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index d063eed40..7068ee15a 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -169,7 +169,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $x = attach_syspaths($this->auth->owner_id,$this->folder_hash); - $y = q("update attach set display_path = '%s where hash = '%s' and uid = %d", + $y = q("update attach set display_path = '%s' where hash = '%s' and uid = %d", dbesc($x['path']), dbesc($this->folder_hash), intval($this->auth->owner_id) -- cgit v1.2.3 From aa15867c9538e416aaa46de0fef8f2a92b69bf05 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 29 Apr 2018 17:50:35 -0700 Subject: Update issues on postgres --- Zotlabs/Update/_1208.php | 2 +- Zotlabs/Update/_1209.php | 2 +- Zotlabs/Update/_1211.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1208.php b/Zotlabs/Update/_1208.php index 4cbcf4322..840252694 100644 --- a/Zotlabs/Update/_1208.php +++ b/Zotlabs/Update/_1208.php @@ -8,7 +8,7 @@ class _1208 { if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { $r1 = q("ALTER TABLE poll ADD poll_author text NOT NULL"); - $r2 = q("create index \"poll_author_idx\" on poll \"poll_author\""); + $r2 = q("create index \"poll_author_idx\" on poll (\"poll_author\") "); $r = ($r1 && $r2); } diff --git a/Zotlabs/Update/_1209.php b/Zotlabs/Update/_1209.php index 5ec449395..dc95c3166 100644 --- a/Zotlabs/Update/_1209.php +++ b/Zotlabs/Update/_1209.php @@ -8,7 +8,7 @@ class _1209 { if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { $r1 = q("ALTER TABLE poll_elm ADD pelm_order numeric(6) NOT NULL DEFAULT '0' "); - $r2 = q("create index \"pelm_order_idx\" on poll_elm \"pelm_order\""); + $r2 = q("create index \"pelm_order_idx\" on poll_elm (\"pelm_order\")"); $r = ($r1 && $r2); } diff --git a/Zotlabs/Update/_1211.php b/Zotlabs/Update/_1211.php index 739a5670d..7068ecbd3 100644 --- a/Zotlabs/Update/_1211.php +++ b/Zotlabs/Update/_1211.php @@ -8,7 +8,7 @@ class _1211 { if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { $r1 = q("ALTER TABLE channel ADD channel_active timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r2 = q("create index \"channel_active\" on channel_active \"channel_active\""); + $r2 = q("create index \"channel_active\" on channel_active (\"channel_active\")"); $r = ($r1 && $r2); } -- cgit v1.2.3 From 7d3dfc3ed8d530cdf7e268b4e2fc4e815b4c5f79 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 30 Apr 2018 09:13:26 +0200 Subject: missing class --- Zotlabs/Widget/Tasklist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Tasklist.php b/Zotlabs/Widget/Tasklist.php index 3961eecce..56342bd17 100644 --- a/Zotlabs/Widget/Tasklist.php +++ b/Zotlabs/Widget/Tasklist.php @@ -21,7 +21,7 @@ class Tasklist { '; $o .= '
' . '

' . t('Tasks') . '

'; - $o .= '
'; + $o .= '
'; $o .= ''; return $o; -- cgit v1.2.3 From feb5d3af89cc8709f2774e0dc867f7c849cc80f7 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 30 Apr 2018 11:51:14 +0200 Subject: fix another pgsql update error --- Zotlabs/Update/_1211.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1211.php b/Zotlabs/Update/_1211.php index 7068ecbd3..26e25536d 100644 --- a/Zotlabs/Update/_1211.php +++ b/Zotlabs/Update/_1211.php @@ -8,7 +8,7 @@ class _1211 { if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { $r1 = q("ALTER TABLE channel ADD channel_active timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r2 = q("create index \"channel_active\" on channel_active (\"channel_active\")"); + $r2 = q("create index \"channel_active_idx\" on channel (\"channel_active\")"); $r = ($r1 && $r2); } -- cgit v1.2.3 From 32423a7706c45d0d7187444f50eac33ca4fdfaa0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 30 Apr 2018 22:30:59 -0700 Subject: parent folder permissions weren't being checked back to the cloud root directory in all cases --- Zotlabs/Module/Photo.php | 70 +++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 49 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 8a110f925..b3171fe75 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -127,69 +127,45 @@ class Photo extends \Zotlabs\Web\Controller { } } - $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", + $r = q("SELECT uid, photo_usage FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) ); if($r) { - - $allowed = (($r[0]['uid']) ? perm_is_allowed($r[0]['uid'],$observer_xchan,'view_storage') : true); - - $sql_extra = permissions_sql($r[0]['uid']); - if(! $sql_extra) - $sql_extra = ' and true '; - - // Only check permissions on normal photos. Those photos we don't check includes - // profile photos, xchan photos (which are also profile photos), 'thing' photos, - // and cover photos - - $sql_extra = " and (( photo_usage = 0 $sql_extra ) or photo_usage != 0 )"; + $allowed = (-1); + if(intval($r[0]['photo_usage'])) { + $allowed = 1; + if(intval($r[0]['photo_usage']) === PHOTO_COVER) + if($resolution < PHOTO_RES_COVER_1200) + $allowed = (-1); + if(intval($r[0]['photo_usage']) === PHOTO_PROFILE) + if(! in_array($resolution,[4,5,6])) + $allowed = (-1); + } + if($allowed === (-1)) + $allowed = attach_can_view($r[0]['uid'],$observer_xchan,$photo); + $channel = channelx_by_n($r[0]['uid']); // Now we'll see if we can access the photo - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1", + $e = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1", dbesc($photo), intval($resolution) ); - // viewing cover photos is allowed unless a plugin chooses to block it. - - if($r && intval($r[0]['photo_usage']) === PHOTO_COVER && $resolution >= PHOTO_RES_COVER_1200) - $allowed = 1; - - $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ]; - call_hooks('get_photo',$d); + $exists = (($e) ? true : false); - $resolution = $d['imgscale']; - $photo = $d['resource_id']; - $r = $d['photo']; - $allowed = $d['allowed']; - - if($r && $allowed) { - $data = dbunescbin($r[0]['content']); - $mimetype = $r[0]['mimetype']; - if(intval($r[0]['os_storage'])) { + if($exists && $allowed) { + $data = dbunescbin($e[0]['content']); + $mimetype = $e[0]['mimetype']; + if(intval($e[0]['os_storage'])) { $streaming = $data; } } else { - - // Does the picture exist? It may be a remote person with no credentials, - // but who should otherwise be able to view it. Show a default image to let - // them know permissions was denied. It may be possible to view the image - // through an authenticated profile visit. - // There won't be many completely unauthorised people seeing this because - // they won't have the photo link, so there's a reasonable chance that the person - // might be able to obtain permission to view it. - - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", - dbesc($photo), - intval($resolution) - ); - - if($r) { + if(! $allowed) { logger('mod_photo: forbidden. ' . \App::$query_string); $observer = \App::get_observer(); logger('mod_photo: observer = ' . (($observer) ? $observer['xchan_addr'] : '(not authenticated)')); @@ -201,9 +177,6 @@ class Photo extends \Zotlabs\Web\Controller { } } - - - if(! isset($data)) { if(isset($resolution)) { switch($resolution) { @@ -295,7 +268,6 @@ class Photo extends \Zotlabs\Web\Controller { } killme(); - // NOTREACHED } } -- cgit v1.2.3 From 08bcd29eeee1166d62791b04c7de4a6c1a4e7456 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 May 2018 16:15:59 -0700 Subject: hubzilla issue #1149, don't duplicate addressbook entries on repeated channel imports --- Zotlabs/Module/Import.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 81c405f00..58f0c60d5 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -363,11 +363,27 @@ class Import extends \Zotlabs\Web\Controller { continue; } - abook_store_lowlevel($abook); + $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($abook['abook_xchan']), + intval($channel['channel_id']) + ); + if($r) { + foreach($abook as $k => $v) { + $r = q("UPDATE abook SET " . TQUOT . "%s" . TQUOT . " = '%s' WHERE abook_xchan = '%s' AND abook_channel = %d", + dbesc($k), + dbesc($v), + dbesc($abook['abook_xchan']), + intval($channel['channel_id']) + ); + } + } + else { + abook_store_lowlevel($abook); - $friends ++; - if(intval($abook['abook_feed'])) - $feeds ++; + $friends ++; + if(intval($abook['abook_feed'])) + $feeds ++; + } translate_abook_perms_inbound($channel,$abook_copy); -- cgit v1.2.3 From db930b794dc228f24549d7ef8052be8110990e1f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 May 2018 16:54:54 -0700 Subject: provide warnings about profile photo and cover photo permissions --- Zotlabs/Module/Cover_photo.php | 1 + Zotlabs/Module/Profile_photo.php | 1 + 2 files changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index d76c1b408..76e80156c 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -355,6 +355,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $o .= replace_macros($tpl,array( '$user' => \App::$channel['channel_address'], + '$info' => t('Your cover photo may be visible to anybody on the internet'), '$existing' => get_cover_photo(local_channel(),'array',PHOTO_RES_COVER_850), '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 2ce8686b9..751c4338f 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -451,6 +451,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { $o .= replace_macros($tpl,array( '$user' => \App::$channel['channel_address'], + '$info' => ((count($profiles) > 1) ? t('Your default profile photo is visible to anybody on the internet. Profile photos for alternate profiles will inherit the permissions of the profile') : t('Your profile photo is visible to anybody on the internet and may be distributed to other websites.')), '$importfile' => (($importing) ? \App::$data['importfile'] : ''), '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), -- cgit v1.2.3 From cd200ee7064159e4bc253fefe04ddf6ba25d4dde Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 May 2018 19:38:32 -0700 Subject: The channel import page seems to have missed the big theme cleanup of the last couple of years. --- Zotlabs/Module/Import.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 58f0c60d5..c36e4723a 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -532,16 +532,19 @@ class Import extends \Zotlabs\Web\Controller { '$desc' => t('Use this form to import an existing channel from a different server/hub. You may retrieve the channel identity from the old server/hub via the network or provide an export file.'), '$label_filename' => t('File to Upload'), '$choice' => t('Or provide the old server/hub details'), - '$label_old_address' => t('Your old identity address (xyz@example.com)'), - '$label_old_email' => t('Your old login email address'), - '$label_old_pass' => t('Your old login password'), + + '$old_address' => [ 'old_address', t('Your old identity address (xyz@example.com)'), '', ''], + '$email' => [ 'email', t('Your old login email address'), '', '' ], + '$password' => [ 'password', t('Your old login password'), '', '' ], + '$import_posts' => [ 'import_posts', t('Import a few months of posts if possible (limited by available memory'), false, '', [ t('No'), t('Yes') ]], + '$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'), - '$label_import_primary' => t('Make this hub my primary location'), - '$label_import_moving' => t('Move this channel (disable all previous locations)'), - '$label_import_posts' => t('Import a few months of posts if possible (limited by available memory'), + + '$make_primary' => [ 'make_primary', t('Make this hub my primary location'), false, '', [ t('No'), t('Yes') ] ], + '$moving' => [ 'moving', t('Move this channel (disable all previous locations)'), false, '', [ t('No'), t('Yes') ] ], + '$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'), - '$email' => '', - '$pass' => '', + '$form_security_token' => get_form_security_token('channel_import'), '$submit' => t('Submit') )); -- cgit v1.2.3 From 7a55ead97db94284146612364b8ce1c59de8771f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 May 2018 20:29:07 -0700 Subject: new feature (post 3.4): allow a different username to be used when importing. --- Zotlabs/Module/Import.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index c36e4723a..d031bf16b 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -6,6 +6,7 @@ require_once('include/zot.php'); require_once('include/channel.php'); require_once('include/import.php'); require_once('include/perm_upgrade.php'); +require_once('library/urlify/URLify.php'); /** @@ -38,6 +39,7 @@ class Import extends \Zotlabs\Web\Controller { $filename = basename($_FILES['filename']['name']); $filesize = intval($_FILES['filename']['size']); $filetype = $_FILES['filename']['type']; + $newname = trim(strtolower($_REQUEST['newname'])); // import channel from file if($src) { @@ -146,7 +148,20 @@ class Import extends \Zotlabs\Web\Controller { } } - $channel = import_channel($data['channel'], $account_id, $seize); + if($newname) { + $x = false; + + if(get_config('system','unicode_usernames')) { + $x = punify(mb_strtolower($newname)); + } + + if((! $x) || strlen($x) > 64) { + $x = strtolower(\URLify::transliterate($newname)); + } + $newname = $x; + } + + $channel = import_channel($data['channel'], $account_id, $seize, $newname); } else { $moving = false; @@ -542,6 +557,7 @@ class Import extends \Zotlabs\Web\Controller { '$make_primary' => [ 'make_primary', t('Make this hub my primary location'), false, '', [ t('No'), t('Yes') ] ], '$moving' => [ 'moving', t('Move this channel (disable all previous locations)'), false, '', [ t('No'), t('Yes') ] ], + '$newname' => [ 'newname', t('Use this channel nickname instead of the one provided'), '', t('Leave blank to keep your existing channel nickname. You will be randomly assigned a similar nickname if either name is already allocated on this site.')], '$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'), -- cgit v1.2.3 From 406ea67bbc9b67ca4bd80d80eb012bc68afc5262 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 May 2018 17:39:12 -0700 Subject: Provide admin delete ability if the viewer is admin but has no existing delete authority. For 3.5+ as a new string is involved. --- Zotlabs/Lib/ThreadItem.php | 4 ++++ Zotlabs/Module/Item.php | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 61a012f9d..b7fc8e65d 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -141,6 +141,10 @@ class ThreadItem { 'delete' => t('Delete'), ); } + elseif(is_site_admin()) { + $drop = [ 'dropping' => true, 'delete' => t('Admin Delete') ]; + } + // FIXME if($observer_is_pageowner) { $multidrop = array( diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index bba1dc02d..87f83e877 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1084,7 +1084,7 @@ class Item extends \Zotlabs\Web\Controller { if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) { require_once('include/items.php'); - $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_type from item where id = %d limit 1", + $i = q("select id, uid, item_origin, author_xchan, owner_xchan, source_xchan, item_type from item where id = %d limit 1", intval(argv(2)) ); @@ -1094,14 +1094,21 @@ class Item extends \Zotlabs\Web\Controller { if(local_channel() && local_channel() == $i[0]['uid']) $local_delete = true; - $sys = get_sys_channel(); - if(is_site_admin() && $sys['channel_id'] == $i[0]['uid']) - $can_delete = true; - + // The site admin can delete any post/item on the site. + // If the item originated on this site+channel the deletion will propagate downstream. + // Otherwise just the local copy is removed. + + if(is_site_admin()) { + $local_delete = true; + if(intval($i[0]['item_origin'])) + $can_delete = true; + } + $ob_hash = get_observer_hash(); - if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) + if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) { $can_delete = true; - + } + if(! ($can_delete || $local_delete)) { notice( t('Permission denied.') . EOL); return; -- cgit v1.2.3 From 9713436f497a031e4369130dda40b415ff285fd8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 May 2018 18:23:42 -0700 Subject: backend work to allow admin to delete photos. Still requires frontend work to give admin access to either the photos and/or the delete link. --- Zotlabs/Module/Item.php | 15 ++++++++++----- Zotlabs/Module/Photos.php | 41 +++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 23 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 87f83e877..fd99c4a64 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1084,6 +1084,8 @@ class Item extends \Zotlabs\Web\Controller { if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) { require_once('include/items.php'); + + $i = q("select id, uid, item_origin, author_xchan, owner_xchan, source_xchan, item_type from item where id = %d limit 1", intval(argv(2)) ); @@ -1091,9 +1093,16 @@ class Item extends \Zotlabs\Web\Controller { if($i) { $can_delete = false; $local_delete = false; - if(local_channel() && local_channel() == $i[0]['uid']) + + if(local_channel() && local_channel() == $i[0]['uid']) { $local_delete = true; + } + $ob_hash = get_observer_hash(); + if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) { + $can_delete = true; + } + // The site admin can delete any post/item on the site. // If the item originated on this site+channel the deletion will propagate downstream. // Otherwise just the local copy is removed. @@ -1104,10 +1113,6 @@ class Item extends \Zotlabs\Web\Controller { $can_delete = true; } - $ob_hash = get_observer_hash(); - if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) { - $can_delete = true; - } if(! ($can_delete || $local_delete)) { notice( t('Permission denied.') . EOL); diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index a143c4d4c..e21f3025c 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -102,14 +102,7 @@ class Photos extends \Zotlabs\Web\Controller { if($_REQUEST['dropalbum'] == t('Delete Album')) { - - // This is dangerous because we combined file storage and photos into one interface - // This function will remove all photos from any directory with the same name since - // we have not passed the path value. - - // The correct solution would be to use a full pathname from your storage root for 'album' - // We also need to prevent/block removing the storage root folder. - + $folder_hash = ''; $r = q("select * from attach where is_dir = 1 and uid = %d and hash = '%s'", @@ -124,7 +117,8 @@ class Photos extends \Zotlabs\Web\Controller { $res = array(); - + $admin_delete = false; + // get the list of photos we are about to delete if(remote_channel() && (! local_channel())) { @@ -133,6 +127,10 @@ class Photos extends \Zotlabs\Web\Controller { elseif(local_channel()) { $str = photos_album_get_db_idstr(local_channel(),$album); } + elseif(is_site_admin()) { + $str = photos_album_get_db_idstr_admin($page_owner_uid,$album); + $admin_delete = true; + } else { $str = null; } @@ -145,7 +143,7 @@ class Photos extends \Zotlabs\Web\Controller { ); if($r) { foreach($r as $i) { - attach_delete($page_owner_uid, $i['resource_id'], 1 ); + attach_delete($page_owner_uid, $i['resource_id'], true ); } } @@ -158,12 +156,14 @@ class Photos extends \Zotlabs\Web\Controller { // @FIXME do the same for the linked attach if($folder_hash) { - attach_delete($page_owner_uid,$folder_hash, 1); - - $sync = attach_export_data(\App::$data['channel'],$folder_hash, true); + attach_delete($page_owner_uid, $folder_hash, true ); + + if(! $admin_delete) { + $sync = attach_export_data(\App::$data['channel'],$folder_hash, true); - if($sync) - build_sync_packet($page_owner_uid,array('file' => array($sync))); + if($sync) + build_sync_packet($page_owner_uid,array('file' => array($sync))); + } } } @@ -181,17 +181,22 @@ class Photos extends \Zotlabs\Web\Controller { $r = q("SELECT id, resource_id FROM photo WHERE ( xchan = '%s' or uid = %d ) AND resource_id = '%s' LIMIT 1", dbesc($ob_hash), intval(local_channel()), - dbesc(\App::$argv[2]) + dbesc(argv(2)) ); if($r) { - attach_delete($page_owner_uid, $r[0]['resource_id'], 1 ); + attach_delete($page_owner_uid, $r[0]['resource_id'], true ); $sync = attach_export_data(\App::$data['channel'],$r[0]['resource_id'], true); if($sync) build_sync_packet($page_owner_uid,array('file' => array($sync))); } - + elseif(is_site_admin()) { + // If the admin deletes a photo, don't sync + attach_delete($page_owner_uid, argv(2), true); + } + + goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']); } -- cgit v1.2.3 From e9f49d9d9c02ef6b2f5259f9a323a8a2a2d75af5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 May 2018 20:08:59 -0700 Subject: admin delete of files --- Zotlabs/Module/Filestorage.php | 39 +++++++++++++++++++++++++++++++-------- Zotlabs/Storage/Browser.php | 4 +++- 2 files changed, 34 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index 5c8557e5a..cd9ab601d 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -66,7 +66,7 @@ class Filestorage extends \Zotlabs\Web\Controller { $perms = get_all_perms($owner, $ob_hash); - if(! $perms['view_storage']) { + if(! ($perms['view_storage'] || is_site_admin())){ notice( t('Permission denied.') . EOL); return; } @@ -75,15 +75,29 @@ class Filestorage extends \Zotlabs\Web\Controller { // need to return for anyone other than the owner, despite the perms check for now. $is_owner = (((local_channel()) && ($owner == local_channel())) ? true : false); - if(! $is_owner) { + if(! ($is_owner || is_site_admin())){ info( t('Permission Denied.') . EOL ); return; } if(argc() > 3 && argv(3) === 'delete') { + + if(argc() > 4 && argv(4) === 'json') + $json_return = true; + + + $admin_delete = false; + if(! $perms['write_storage']) { - notice( t('Permission denied.') . EOL); - return; + if(is_site_admin()) { + $admin_delete = true; + } + else { + notice( t('Permission denied.') . EOL); + if($json_return) + json_return_and_die([ 'success' => false ]); + return; + } } $file = intval(argv(2)); @@ -92,22 +106,31 @@ class Filestorage extends \Zotlabs\Web\Controller { intval($owner) ); if(! $r) { + if($json_return) + json_return_and_die([ 'success' => false ]); + notice( t('File not found.') . EOL); goaway(z_root() . '/cloud/' . $which); } $f = $r[0]; - $channel = \App::get_channel(); + + $channel = channelx_by_n($owner); $url = get_cloud_url($channel['channel_id'], $channel['channel_address'], $f['hash']); 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))); + if(! $admin_delete) { + $sync = attach_export_data($channel, $f['hash'], true); + if($sync) { + build_sync_packet($channel['channel_id'], array('file' => array($sync))); + } } + if(json_return) + json_return_and_die([ 'success' => true ]); + goaway(dirname($url)); } diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 508c39d22..f4f906ad1 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -241,7 +241,7 @@ class Browser extends DAV\Browser\Plugin { // put the array for this file together $ft['attachId'] = $this->findAttachIdByHash($attachHash); - $ft['fileStorageUrl'] = substr($fullPath, 0, strpos($fullPath, "cloud/")) . "filestorage/" . $this->auth->getCurrentUser(); + $ft['fileStorageUrl'] = substr($fullPath, 0, strpos($fullPath, "cloud/")) . "filestorage/" . $this->auth->owner_nick; $ft['icon'] = $icon; $ft['photo_icon'] = $photo_icon; $ft['attachIcon'] = (($size) ? $attachIcon : ''); @@ -276,6 +276,8 @@ class Browser extends DAV\Browser\Plugin { '$create' => t('Create'), '$upload' => t('Add Files'), '$is_owner' => $is_owner, + '$is_admin' => is_site_admin(), + '$admin_delete' => t('Admin Delete'), '$parentpath' => $parentpath, '$cpath' => bin2hex(\App::$query_string), '$tiles' => intval($_SESSION['cloud_tiles']), -- cgit v1.2.3 From 6bf5eea64670996fafb80f92a4b8ec6a44f22bb0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 May 2018 22:05:55 -0700 Subject: make the cloud logging a bit less verbose until we actually need it. --- Zotlabs/Module/Oep.php | 2 +- Zotlabs/Storage/File.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php index ec40bf9db..0f20a5f9a 100644 --- a/Zotlabs/Module/Oep.php +++ b/Zotlabs/Module/Oep.php @@ -72,7 +72,7 @@ class Oep extends \Zotlabs\Web\Controller { $url = $args['url']; $maxwidth = intval($args['maxwidth']); $maxheight = intval($args['maxheight']); - logger('processing display'); + if(preg_match('#//(.*?)/display/(.*?)(&|\?|$)#',$url,$matches)) { $res = $matches[2]; } diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 53d5d3476..4610aceb7 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -49,7 +49,7 @@ class File extends DAV\Node implements DAV\IFile { $this->data = $data; $this->auth = $auth; - logger(print_r($this->data, true), LOGGER_DATA); + // logger(print_r($this->data, true), LOGGER_DATA); } /** -- cgit v1.2.3 From 459ec78a5e3cb09ee908fd7810bbb0b80b2e4713 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 May 2018 22:59:21 -0700 Subject: provide easy access to the autoperms setting for forum and repository channels. This may be needed in the future to protect an existing forum from assault by spammers with changing identities. The forum can quickly be turned into membership by approval and either left that way permanently or hopefully reversed at a later date. Previously this would require switching to expert mode or setting a pconfig manually. --- Zotlabs/Module/Settings/Channel.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 65b9b197e..beb62a3a3 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -146,6 +146,7 @@ class Channel { $unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0); $cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0); $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0); + $autoperms = ((x($_POST,'autoperms')) ? intval($_POST['autoperms']) : 0); $post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0); $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0); @@ -252,6 +253,7 @@ class Channel { 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); + set_pconfig(local_channel(),'system','autoperms',$autoperms); $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), @@ -479,13 +481,21 @@ class Channel { if($permissions_role === 'social_party') $permissions_role = 'social_federation'; - + if(in_array($permissions_role,['forum','repository'])) + $autoperms = replace_macros(get_markup_template('field_checkbox.tpl'), [ + '$field' => [ 'autoperms',t('Automatic membership approval'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('If enabled, connection requests will be approved without your interaction'), $yes_no ]]); + else + $autoperms = ''; + $permissions_set = (($permissions_role != 'custom') ? true : false); $perm_roles = \Zotlabs\Access\PermissionRoles::roles(); if((get_account_techlevel() < 4) && $permissions_role !== 'custom') unset($perm_roles[t('Other')]); + + + $vnotify = get_pconfig(local_channel(),'system','vnotify'); $always_show_in_notices = get_pconfig(local_channel(),'system','always_show_in_notices'); if($vnotify === false) @@ -497,6 +507,7 @@ class Channel { $disable_discover_tab = intval(get_config('system','disable_discover_tab',1)) == 1; $site_firehose = intval(get_config('system','site_firehose',0)) == 1; + $o .= replace_macros($stpl,array( '$ptitle' => t('Channel Settings'), @@ -553,7 +564,7 @@ class Channel { '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']) ,t("Useful to reduce spamming")), - + '$autoperms' => $autoperms, '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), -- cgit v1.2.3 From b52e9731e39125f5911fe6795ef34eb1f183d4b3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 3 May 2018 20:14:58 -0700 Subject: tagging changes: + (old style forum mentions), and underscore space replacement are no longer supported. --- Zotlabs/Module/Item.php | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index fd99c4a64..640b4fa5c 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -528,16 +528,6 @@ class Item extends \Zotlabs\Web\Controller { // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - // If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set. - - if((! $parent) && (get_pconfig($profile_uid,'system','tagifonlyrecip')) && (substr_count($str_contact_allow,'<') == 1) && ($str_group_allow == '') && ($str_contact_deny == '') && ($str_group_deny == '')) { - $x = q("select abook_id, abconfig.v from abook left join abconfig on abook_xchan = abconfig.xchan and abook_channel = abconfig.chan and cat= 'their_perms' and abconfig.k = 'tag_deliver' and abconfig.v = 1 and abook_xchan = '%s' and abook_channel = %d limit 1", - dbesc(str_replace(array('<','>'),array('',''),$str_contact_allow)), - intval($profile_uid) - ); - if($x) - $body .= "\n\n@group+" . $x[0]['abook_id'] . "\n"; - } $body = cleanup_bbcode($body); -- cgit v1.2.3 From 97cb1089377681aa0f7b1c14aa86e00be4ce6ca6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 4 May 2018 22:03:51 +0200 Subject: missing permission description --- Zotlabs/Module/Wiki.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 7dc8eb1bc..322a3933c 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -95,7 +95,7 @@ class Wiki extends \Zotlabs\Web\Controller { $owner['channel_deny_gid']) ? 'lock' : 'unlock' ), - 'acl' => populate_acl($owner_acl), + 'acl' => populate_acl($owner_acl, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_wiki')), 'allow_cid' => acl2json($owner_acl['allow_cid']), 'allow_gid' => acl2json($owner_acl['allow_gid']), 'deny_cid' => acl2json($owner_acl['deny_cid']), -- cgit v1.2.3 From c6e65ec6dab38ee67afe1d07f5c003413cfdf67e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 5 May 2018 00:39:53 -0700 Subject: support '@' paths --- Zotlabs/Module/Wfinger.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 81d4beaed..88cb3e879 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -109,7 +109,8 @@ class Wfinger extends \Zotlabs\Web\Controller { $aliases = array( z_root() . (($pchan) ? '/pchan/' : '/channel/') . $r[0]['channel_address'], - z_root() . '/~' . $r[0]['channel_address'] + z_root() . '/~' . $r[0]['channel_address'], + z_root() . '/@' . $r[0]['channel_address'] ); if($h) { -- cgit v1.2.3 From 83c18f4d4a5f4f767e2d9073a8962c0dc9fc6fb8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 6 May 2018 16:12:06 -0700 Subject: Back in the day there were good reasons for showing a permission denied photo instead of a null img. It distinguished a 403 from a 404 in an unmistakable way. What we've discovered is that nothing that is gained from this knowledge and it mostly just annoys and confuses people who can't really do anything about it except to express their annoyance/confusion. So just do a 403/404 instead. --- Zotlabs/Module/Photo.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index b3171fe75..9cafc8d07 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -144,9 +144,11 @@ class Photo extends \Zotlabs\Web\Controller { if(! in_array($resolution,[4,5,6])) $allowed = (-1); } - if($allowed === (-1)) + + if($allowed === (-1)) { $allowed = attach_can_view($r[0]['uid'],$observer_xchan,$photo); - + } + $channel = channelx_by_n($r[0]['uid']); // Now we'll see if we can access the photo @@ -166,13 +168,12 @@ class Photo extends \Zotlabs\Web\Controller { } else { if(! $allowed) { - logger('mod_photo: forbidden. ' . \App::$query_string); - $observer = \App::get_observer(); - logger('mod_photo: observer = ' . (($observer) ? $observer['xchan_addr'] : '(not authenticated)')); - $data = file_get_contents('images/nosign.png'); - $mimetype = 'image/png'; - $prvcachecontrol = true; + http_status_exit(403,'forbidden'); + } + if(! $exists) { + http_status_exit(404,'not found'); } + } } } -- cgit v1.2.3 From e646684493f5c3d49e972308aa8a5722877f26ce Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 6 May 2018 19:57:37 -0700 Subject: pdf embeds --- Zotlabs/Module/Linkinfo.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index 3392e4114..3f58f3e01 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -82,6 +82,10 @@ class Linkinfo extends \Zotlabs\Web\Controller { echo $br . '[audio]' . $url . '[/audio]' . $br; killme(); } + if(strtolower($type) === 'application/pdf' || strtolower($type) === 'application/x-pdf') { + echo $br . '[embed]' . $url . '[/embed]' . $br; + killme(); + } } } -- cgit v1.2.3 From aab16123b5188e69b31893263f7074f9e9c7f210 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 17:31:53 -0700 Subject: Simplify first channel creation even further by using a site-configurable default permissions role and removing one more conceptual roadblock for first time registrants. This default role only applies to the first channel an account creates and can be changed from the settings page once they've started to explore. This functionality was always present but optional and not well exposed. Now it is part of the standard workflow and exposed in the admin settings. --- Zotlabs/Module/Admin/Site.php | 10 ++++++++++ Zotlabs/Module/New_channel.php | 25 ++++++++++++++++++------- Zotlabs/Module/Register.php | 4 ++-- 3 files changed, 30 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 656770ad9..5c35e4a9d 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -77,6 +77,8 @@ class Site { $thumbnail_security = ((x($_POST,'thumbnail_security')) ? intval($_POST['thumbnail_security']) : 0); $force_queue = ((intval($_POST['force_queue']) > 0) ? intval($_POST['force_queue']) : 3000); + $permissions_role = escape_tags(trim($_POST['permissions_role'])); + $techlevel = null; if(array_key_exists('techlevel', $_POST)) $techlevel = intval($_POST['techlevel']); @@ -102,6 +104,7 @@ class Site { set_config('system', 'from_email_name' , $from_email_name); set_config('system', 'imagick_convert_path' , $imagick_path); set_config('system', 'thumbnail_security' , $thumbnail_security); + set_config('system', 'default_permissions_role', $permissions_role); set_config('system', 'techlevel_lock', $techlevel_lock); @@ -286,6 +289,12 @@ class Site { '5' => t('Wizard - I probably know more than you do') ]; + $perm_roles = \Zotlabs\Access\PermissionRoles::roles(); + $default_role = get_config('system','default_permissions_role','social'); + + $role = array('permissions_role' , t('Default permission role for new accounts'), $default_role, t('This role will be used for the first channel created after registration.'),$perm_roles); + + $homelogin = get_config('system','login_on_homepage'); $enable_context_help = get_config('system','enable_context_help'); @@ -321,6 +330,7 @@ class Site { '$minimum_age' => array('minimum_age', t("Minimum age"), (x(get_config('system','minimum_age'))?get_config('system','minimum_age'):13), t("Minimum age (in years) for who may register on this site.")), '$access_policy' => array('access_policy', t("Which best describes the types of account offered by this hub?"), get_config('system','access_policy'), "This is displayed on the public server site list.", $access_choices), '$register_text' => array('register_text', t("Register text"), htmlspecialchars(get_config('system','register_text'), ENT_QUOTES, 'UTF-8'), t("Will be displayed prominently on the registration page.")), + '$role' => $role, '$frontpage' => array('frontpage', t("Site homepage to show visitors (default: login box)"), get_config('system','frontpage'), t("example: 'public' to show public stream, 'page/sys/home' to show a system webpage called 'home' or 'include:home.html' to include a file.")), '$mirror_frontpage' => array('mirror_frontpage', t("Preserve site homepage URL"), get_config('system','mirror_frontpage'), t('Present the site homepage in a frame at the original location instead of redirecting')), '$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')), diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index d9becbc22..df7da2fe8 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -124,7 +124,7 @@ class New_channel extends \Zotlabs\Web\Controller { intval($aid) ); if($r && (! intval($r[0]['total']))) { - $default_role = get_config('system','default_permissions_role'); + $default_role = get_config('system','default_permissions_role','social'); } $limit = account_service_class_fetch(get_account_id(),'total_identities'); @@ -136,21 +136,32 @@ class New_channel extends \Zotlabs\Web\Controller { $channel_usage_message = ''; } } - + + $name_help = (($default_role) + ? t('Your real name is recommended.') + : t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"') + ); + + $nick_help = t('This will be used to create a unique network address (like an email address).'); + + if(! get_config('system','unicode_usernames')) { + $nick_help .= ' ' . t('Allowed characters are a-z 0-9, - and _'); + } + $privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "" ); $perm_roles = \Zotlabs\Access\PermissionRoles::roles(); if((get_account_techlevel() < 4) && $privacy_role !== 'custom') unset($perm_roles[t('Other')]); - $name = array('name', t('Name or caption'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"'), "*"); + $name = array('name', t('Channel name'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), $name_help, "*"); $nickhub = '@' . \App::get_hostname(); - $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), sprintf( t('Your nickname will be used to create an easy to remember channel address e.g. nickname%s'), $nickhub), "*"); - $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); + $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), $nick_help, "*"); + $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel permission role compatible with your usage needs and privacy requirements.') . '
' . '' . t('Read more about channel permission roles') . '',$perm_roles); $o = replace_macros(get_markup_template('new_channel.tpl'), array( - '$title' => t('Create Channel'), - '$desc' => t('A channel is a unique network identity. It can represent a person (social network profile), a forum (group), a business or celebrity page, a newsfeed, and many other things. Channels can make connections with other channels to share information with each other.') . ' ' . t('The type of channel you create affects the basic privacy settings, the permissions that are granted to connections/friends, and also the channel\'s visibility across the network.'), + '$title' => t('Create a Channel'), + '$desc' => t('A channel is a unique network identity. It can represent a person (social network profile), a forum (group), a business or celebrity page, a newsfeed, and many other things.') , '$label_import' => t('or import an existing channel from another location.'), '$name' => $name, '$role' => $role, diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 5356669e9..6bdffd034 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -251,10 +251,10 @@ class Register extends \Zotlabs\Web\Controller { $password = array('password', t('Choose a password'), ''); $password2 = array('password2', t('Please re-enter your password'), ''); $invite_code = array('invite_code', t('Please enter your invitation code'), ((x($_REQUEST,'invite_code')) ? strip_tags(trim($_REQUEST['invite_code'])) : "")); - $name = array('name', t('Name or caption'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"')); + $name = array('name', t('Your Name'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Real names are preferred.')); $nickhub = '@' . str_replace(array('http://','https://','/'), '', get_config('system','baseurl')); $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), sprintf( t('Your nickname will be used to create an easy to remember channel address e.g. nickname%s'), $nickhub)); - $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); + $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel permission role for your usage needs and privacy requirements.') . ' ' . t('Read more about channel permission roles') . '',$perm_roles); $tos = array('tos', $label_tos, '', '', array(t('no'),t('yes'))); -- cgit v1.2.3 From eb85d381fdb447d23e568dfecbde24a860879952 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 18:46:42 -0700 Subject: Add supported protocols to siteinfo (not siteinfo.json) --- Zotlabs/Module/Siteinfo.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php index 92ee78cc6..25276815d 100644 --- a/Zotlabs/Module/Siteinfo.php +++ b/Zotlabs/Module/Siteinfo.php @@ -12,6 +12,9 @@ class Siteinfo extends \Zotlabs\Web\Controller { } function get() { + + $federated = []; + call_hooks('federated_transports',$federated); $siteinfo = replace_macros(get_markup_template('siteinfo.tpl'), [ @@ -27,6 +30,9 @@ class Siteinfo extends \Zotlabs\Web\Controller { '$prj_name' => t('This site is powered by $Projectname'), '$prj_transport' => t('Federated and decentralised networking and identity services provided by Zot'), '$transport_link' => 'https://zotlabs.com', + + '$additional_text' => t('Additional federated transport protocols:'), + '$additional_fed' => implode(',',$federated), '$prj_version' => ((get_config('system','hidden_version_siteinfo')) ? '' : sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version())), '$prj_linktxt' => t('Project homepage'), '$prj_srctxt' => t('Developer homepage'), -- cgit v1.2.3 From 0c43a9bb5dae1ab6c1646c690f0e9b765e88832e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 19:33:58 -0700 Subject: yet another postgres/"group by" issue --- Zotlabs/Module/Search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 43464ad8b..3a552bb22 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -175,7 +175,7 @@ class Search extends \Zotlabs\Web\Controller { OR ( item.uid = %d )) OR item.owner_xchan = '%s' ) $item_normal $sql_extra - group by mid order by created desc $pager_sql ", + group by mid, created order by created desc $pager_sql ", intval(local_channel()), dbesc($sys['xchan_hash']) ); @@ -188,7 +188,7 @@ class Search extends \Zotlabs\Web\Controller { $pub_sql ) OR owner_xchan = '%s') $item_normal $sql_extra - group by mid order by created desc $pager_sql", + group by mid, created order by created desc $pager_sql", dbesc($sys['xchan_hash']) ); } -- cgit v1.2.3 From 611e22d67641b0c82486c60d0daa59cc8e0d6b9a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 22:07:44 -0700 Subject: turn down logging from DAV basicauth until needed --- Zotlabs/Storage/BasicAuth.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index d8af03703..a5c01fbb7 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -253,11 +253,11 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { * @return void */ public function log() { - logger('channel_name ' . $this->channel_name, LOGGER_DATA); - logger('channel_id ' . $this->channel_id, LOGGER_DATA); - logger('channel_hash ' . $this->channel_hash, LOGGER_DATA); - logger('observer ' . $this->observer, LOGGER_DATA); - logger('owner_id ' . $this->owner_id, LOGGER_DATA); - logger('owner_nick ' . $this->owner_nick, LOGGER_DATA); +// logger('channel_name ' . $this->channel_name, LOGGER_DATA); +// logger('channel_id ' . $this->channel_id, LOGGER_DATA); +// logger('channel_hash ' . $this->channel_hash, LOGGER_DATA); +// logger('observer ' . $this->observer, LOGGER_DATA); +// logger('owner_id ' . $this->owner_id, LOGGER_DATA); +// logger('owner_nick ' . $this->owner_nick, LOGGER_DATA); } } -- cgit v1.2.3 From 3c8de7b59d010f8273370c720aafde80067f77d7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 23:57:17 -0700 Subject: use imagemagick first stage thumbnail for cover photos, if configured --- Zotlabs/Module/Cover_photo.php | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 76e80156c..d0780c4de 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -84,10 +84,39 @@ class Cover_photo extends \Zotlabs\Web\Controller { ); if($r) { - - $base_image = $r[0]; - $base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($base_image['content'])) : dbunescbin($base_image['content'])); - + + $max_thumb = intval(get_config('system','max_thumbnail',1600)); + $iscaled = false; + if(intval($r[0]['height']) > $max_thumb || intval($r[0]['width']) > $max_thumb) { + $imagick_path = get_config('system','imagick_convert_path'); + if($imagick_path && @file_exists($imagick_path) && intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); + $tmp_name = $fname . '-001'; + $newsize = photo_calculate_scale(array_merge(getimagesize($fname),['max' => $max_thumb])); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $fname) . ' -thumbnail ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); + // logger('imagick thumbnail command: ' . $cmd); + for($x = 0; $x < 4; $x ++) { + exec($cmd); + if(file_exists($tmp_name)) { + break; + } + } + if(file_exists($tmp_name)) { + $base_image = $r[0]; + $gis = getimagesize($tmp_name); + $base_image['width'] = $gis[0]; + $base_image['height'] = $gis[1]; + $base_image['content'] = @file_get_contents($tmp_name); + $iscaled = true; + @unlink($tmp_name); + } + } + } + if(! $iscaled) { + $base_image = $r[0]; + $base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($base_image['content'])) : dbunescbin($base_image['content'])); + } + $im = photo_factory($base_image['content'], $base_image['mimetype']); if($im->is_valid()) { -- cgit v1.2.3 From fbd26e8d9d5482961d5b0d0f2f10a38b2ea8009c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 May 2018 16:50:16 -0700 Subject: changes made during testing imagick scaling for cover photo thumbnail --- Zotlabs/Module/Cover_photo.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index d0780c4de..9adfa2209 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -90,6 +90,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { if(intval($r[0]['height']) > $max_thumb || intval($r[0]['width']) > $max_thumb) { $imagick_path = get_config('system','imagick_convert_path'); if($imagick_path && @file_exists($imagick_path) && intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); $tmp_name = $fname . '-001'; $newsize = photo_calculate_scale(array_merge(getimagesize($fname),['max' => $max_thumb])); @@ -104,6 +105,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { if(file_exists($tmp_name)) { $base_image = $r[0]; $gis = getimagesize($tmp_name); +logger('gis: ' . print_r($gis,true)); $base_image['width'] = $gis[0]; $base_image['height'] = $gis[1]; $base_image['content'] = @file_get_contents($tmp_name); @@ -148,10 +150,10 @@ class Cover_photo extends \Zotlabs\Web\Controller { intval(local_channel()) ); - $orig_srcx = ( $r[0]['width'] / $scaled_width ) * $srcX; - $orig_srcy = ( $r[0]['height'] / $scaled_height ) * $srcY; - $orig_srcw = ( $srcW / $scaled_width ) * $r[0]['width']; - $orig_srch = ( $srcH / $scaled_height ) * $r[0]['height']; + $orig_srcx = ( $base_image['width'] / $scaled_width ) * $srcX; + $orig_srcy = ( $base_image['height'] / $scaled_height ) * $srcY; + $orig_srcw = ( $srcW / $scaled_width ) * $base_image['width']; + $orig_srch = ( $srcH / $scaled_height ) * $base_image['height']; $im->cropImageRect(1200,435,$orig_srcx, $orig_srcy, $orig_srcw, $orig_srch); -- cgit v1.2.3 From 0545baaf56efa6353b728b46e25e64f1a058bb5f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 May 2018 20:12:49 -0700 Subject: initial backend support for channel page item search --- Zotlabs/Module/Channel.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 953f87f11..2ed40047b 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -178,6 +178,21 @@ class Channel extends \Zotlabs\Web\Controller { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + + $search = EMPTY_STR; + if(x($_GET,'search')) { + $search = escape_tags($_GET['search']); + if(strpos($search,'#') === 0) { + $sql_extra2 .= term_query('item',substr($search,1),TERM_HASHTAG,TERM_COMMUNITYTAG); + } + else { + $sql_extra2 .= sprintf(" AND item.body like '%s' ", + dbesc(protect_sprintf('%' . $search . '%')) + ); + } + } + + head_add_link([ 'rel' => 'alternate', 'type' => 'application/json+oembed', @@ -233,6 +248,7 @@ class Channel extends \Zotlabs\Web\Controller { $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); } + $itemspage = get_pconfig(local_channel(),'system','itemspage'); \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); @@ -251,7 +267,7 @@ class Channel extends \Zotlabs\Web\Controller { else { $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) - WHERE true and item.uid = %d AND item.item_thread_top = 1 $item_normal + WHERE true and item.uid = %d $item_normal AND (abook.abook_blocked = 0 or abook.abook_flags is null) AND item.item_wall = 1 $sql_extra $sql_extra2 @@ -323,7 +339,7 @@ class Channel extends \Zotlabs\Web\Controller { '$fh' => '0', '$static' => $static, '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), - '$search' => '', + '$search' => $search, '$xchan' => '', '$order' => '', '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), -- cgit v1.2.3 From cab22f228ac3dd78af3e2d695f9cbdc8f32a8f56 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 May 2018 23:01:24 -0700 Subject: hide dotfiles by default in /cloud - the web interface (they are still accessible but hidden). Change this behaviour with pconfig system.show_dot_files --- Zotlabs/Storage/Directory.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 7068ee15a..b30d45b0e 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -719,6 +719,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo ); foreach ($r as $rr) { + if((strpos($rr['filename'],'.') === 0) && (! get_pconfig($channel_id,'system','show_dot_files'))) + continue; // @FIXME I don't think we use revisions currently in attach structures. // In case we see any in the wild provide a unique filename. This -- cgit v1.2.3 From 2bd7d30a5b3b1b12c2caeb6ecbc8fe9af23f3e1c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 9 May 2018 01:54:18 -0700 Subject: show/hide dot files only in mod_cloud. For DAV let the OS decide --- Zotlabs/Storage/Directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index b30d45b0e..f46e2e666 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -719,7 +719,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo ); foreach ($r as $rr) { - if((strpos($rr['filename'],'.') === 0) && (! get_pconfig($channel_id,'system','show_dot_files'))) + if(\App::$module === 'cloud' && (strpos($rr['filename'],'.') === 0) && (! get_pconfig($channel_id,'system','show_dot_files')) ) continue; // @FIXME I don't think we use revisions currently in attach structures. -- cgit v1.2.3 From d41556a1ea45fe3ef86f6d9d129c8b0d98ee3f2f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 9 May 2018 18:20:28 -0700 Subject: minor regression on date queries from channel page --- Zotlabs/Module/Channel.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 2ed40047b..9ce57d6eb 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -248,6 +248,9 @@ class Channel extends \Zotlabs\Web\Controller { $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); } + if($datequery || $datequery2) { + $sql_extra2 .= " and item.item_thread_top != 0 "; + } $itemspage = get_pconfig(local_channel(),'system','itemspage'); \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); -- cgit v1.2.3 From 67bb167cf83f384a9bfd52a0b1fc65098d4b13d7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 9 May 2018 21:22:25 -0700 Subject: Change hovertip on paperclip button to read 'Attach/Upload file' because a lot of people gravitate to 'insert photo from album' instead, looking for a way to upload into the post. --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index b7fc8e65d..c7a2c9373 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -760,7 +760,7 @@ class ThreadItem { '$edquote' => t('Quote'), '$edcode' => t('Code'), '$edimg' => t('Image'), - '$edatt' => t('Attach File'), + '$edatt' => t('Attach/Upload file'), '$edurl' => t('Insert Link'), '$edvideo' => t('Video'), '$preview' => t('Preview'), // ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), -- cgit v1.2.3 From 721496f9220fa59059f90d16d3b3fb19337b2f16 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 10 May 2018 17:11:03 -0700 Subject: hubzilla issue #1169 --- Zotlabs/Lib/MessageFilter.php | 79 +++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Admin/Site.php | 10 +++++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Lib/MessageFilter.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php new file mode 100644 index 000000000..df59aa57e --- /dev/null +++ b/Zotlabs/Lib/MessageFilter.php @@ -0,0 +1,79 @@ + 0) ? intval($_POST['force_queue']) : 3000); + $pub_incl = escape_tags(trim($_POST['pub_incl'])); + $pub_excl = escape_tags(trim($_POST['pub_excl'])); $permissions_role = escape_tags(trim($_POST['permissions_role'])); @@ -105,6 +107,8 @@ class Site { set_config('system', 'imagick_convert_path' , $imagick_path); set_config('system', 'thumbnail_security' , $thumbnail_security); set_config('system', 'default_permissions_role', $permissions_role); + set_config('system', 'pubstream_incl',$pub_incl); + set_config('system', 'pubstream_excl',$pub_excl); set_config('system', 'techlevel_lock', $techlevel_lock); @@ -340,6 +344,10 @@ class Site { '$disable_discover_tab' => array('disable_discover_tab', t('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')), '$site_firehose' => array('site_firehose', t('Site only Public Streams'), get_config('system','site_firehose'), t('Allow access to public content originating only from this site if Imported Public Streams are disabled.')), '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the Public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing. Warning: this content is unmoderated.')), + '$incl' => array('pub_incl',t('Only import Public stream posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), + '$excl' => array('pub_excl',t('Do not import Public stream posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), + + '$login_on_homepage' => array('login_on_homepage', t("Login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")), '$enable_context_help' => array('enable_context_help', t("Enable context help"),((intval($enable_context_help) === 1 || $enable_context_help === false) ? 1 : 0) , t("Display contextual help for the current page when the help button is pressed.")), @@ -363,7 +371,7 @@ class Site { '$active_expire_days' => array('active_expire_days', t('Do not expire any posts which have comments less than this many days ago'), intval(get_config('system','active_expire_days',7)), ''), '$sellpage' => array('site_sellpage', t('Public servers: Optional landing (marketing) webpage for new registrants'), get_config('system','sellpage',''), sprintf( t('Create this page first. Default is %s/register'),z_root())), - '$first_page' => array('first_page', t('Page to display after creating a new channel'), get_config('system','workflow_channel_next','profiles'), t('Recommend: profiles, go, or settings')), + '$first_page' => array('first_page', t('Page to display after creating a new channel'), get_config('system','workflow_channel_next','profiles'), t('Default: profiles')), '$location' => array('site_location', t('Optional: site location'), get_config('system','site_location',''), t('Region or country')), -- cgit v1.2.3 From ef6e067a45efa43eb30b4639676ed179636d2a1d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 10 May 2018 18:42:58 -0700 Subject: add top level posts containing the cid's url to the cid search in mod_network. We could alternatively search for mention tags here for a bit more precision but the sql could get pretty hairy with all the joins going on. --- Zotlabs/Module/Network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index e97ebf1d0..2d6307eb1 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -251,7 +251,7 @@ class Network extends \Zotlabs\Web\Controller { ); if($r) { $item_thread_top = ''; - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) "; + $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or (body like '" . protect_sprintf('%' . $r[0]['xchan_url'] . '%') . "' and item_thread_top = 1 )) $item_normal ) "; $title = replace_macros(get_markup_template("section_title.tpl"),array( '$title' => '' . urlencode($r[0]['xchan_name']) . ' ' . $r[0]['xchan_name'] . '' )); -- cgit v1.2.3 From 5dae0ef4f9be92d76260739348e7adf85c2fff19 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 10 May 2018 20:54:48 -0700 Subject: add cancel button to editor, fix issue with autosave of categories --- Zotlabs/Module/Article_edit.php | 1 + Zotlabs/Module/Card_edit.php | 1 + Zotlabs/Module/Editblock.php | 1 + Zotlabs/Module/Editlayout.php | 1 + Zotlabs/Module/Editpost.php | 1 + Zotlabs/Module/Editwebpage.php | 1 + Zotlabs/Module/Rpost.php | 1 + 7 files changed, 7 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Article_edit.php b/Zotlabs/Module/Article_edit.php index 758c1db2e..89abccc40 100644 --- a/Zotlabs/Module/Article_edit.php +++ b/Zotlabs/Module/Article_edit.php @@ -128,6 +128,7 @@ class Article_edit extends \Zotlabs\Web\Controller { '$title' => t('Edit Article'), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$id' => $itm[0]['id'], + '$cancel' => t('Cancel'), '$editor' => $editor )); diff --git a/Zotlabs/Module/Card_edit.php b/Zotlabs/Module/Card_edit.php index 7cc563fd2..694bdc4ea 100644 --- a/Zotlabs/Module/Card_edit.php +++ b/Zotlabs/Module/Card_edit.php @@ -128,6 +128,7 @@ class Card_edit extends \Zotlabs\Web\Controller { '$title' => t('Edit Card'), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$id' => $itm[0]['id'], + '$cancel' => t('Cancel'), '$editor' => $editor )); diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index 8a7e87a09..563ad9ca2 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -138,6 +138,7 @@ class Editblock extends \Zotlabs\Web\Controller { '$title' => t('Edit Block'), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$id' => $itm[0]['id'], + '$cancel' => t('Cancel'), '$editor' => $editor )); diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php index 3d6a79507..67e0bcd32 100644 --- a/Zotlabs/Module/Editlayout.php +++ b/Zotlabs/Module/Editlayout.php @@ -137,6 +137,7 @@ class Editlayout extends \Zotlabs\Web\Controller { '$title' => t('Edit Layout'), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$id' => $itm[0]['id'], + '$cancel' => t('Cancel'), '$editor' => $editor )); diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 57a4cb97f..45d8e7644 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -106,6 +106,7 @@ class Editpost extends \Zotlabs\Web\Controller { $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit post'), + '$cancel' => t('Cancel'), '$editor' => $editor )); diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index da536a729..b67421cd5 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -166,6 +166,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { '$title' => t('Edit Webpage'), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$editor' => $editor, + '$cancel' => t('Cancel'), '$id' => $itm[0]['id'] )); diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index f0c4a06b9..86ee296ec 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -142,6 +142,7 @@ class Rpost extends \Zotlabs\Web\Controller { $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit post'), + '$cancel' => '', '$editor' => $editor )); -- cgit v1.2.3 From efb0ac599613129ff514d3a5a7c3b90ff2522654 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 12 May 2018 13:28:04 +0200 Subject: fix php warning --- Zotlabs/Lib/MessageFilter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php index df59aa57e..eb0fc3d2c 100644 --- a/Zotlabs/Lib/MessageFilter.php +++ b/Zotlabs/Lib/MessageFilter.php @@ -23,7 +23,7 @@ class MessageFilter { $lang = detect_language($text); } - $tags = ((count($item['term'])) ? $item['term'] : false); + $tags = ((is_array($item['term']) && count($item['term'])) ? $item['term'] : false); // exclude always has priority @@ -76,4 +76,4 @@ class MessageFilter { } -} \ No newline at end of file +} -- cgit v1.2.3 From 7991db14be2078aacc4f731214c36e3fa3c6c507 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 12 May 2018 16:41:09 -0700 Subject: hubzilla issue #1045 - display pubsites link in info area if invite only --- Zotlabs/Module/Register.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 6bdffd034..4ab1ccd81 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -201,6 +201,15 @@ class Register extends \Zotlabs\Web\Controller { $registration_is = t('Registration on this hub is by approval only.'); $other_sites = t('Register at another affiliated hub.'); } + + + $invitations = false; + + if(intval(get_config('system','invitation_only'))) { + $invitations = true; + $registration_is = t('Registration on this hub is by invitation only.'); + $other_sites = t('Register at another affiliated hub.'); + } $max_dailies = intval(get_config('system','max_daily_registrations')); if($max_dailies) { @@ -270,8 +279,7 @@ class Register extends \Zotlabs\Web\Controller { '$reg_is' => $registration_is, '$registertext' => bbcode(get_config('system','register_text')), '$other_sites' => $other_sites, - '$invitations' => get_config('system','invitation_only'), - '$invite_desc' => t('Membership on this site is by invitation only.'), + '$invitations' => $invitations, '$invite_code' => $invite_code, '$auto_create' => $auto_create, '$name' => $name, -- cgit v1.2.3 From 4f69bcfc38290db87c97645e311fda7a48e1468e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 13 May 2018 14:29:09 +0200 Subject: streamline appearence of guest tokens individual perms with those in connedit --- Zotlabs/Module/Settings/Tokens.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Tokens.php b/Zotlabs/Module/Settings/Tokens.php index bf22ec7aa..619c8b5ba 100644 --- a/Zotlabs/Module/Settings/Tokens.php +++ b/Zotlabs/Module/Settings/Tokens.php @@ -161,8 +161,8 @@ class Tokens { '$me' => t('My Settings'), '$perms' => $perms, '$inherited' => t('inherited'), - '$notself' => 0, - '$self' => 1, + '$notself' => 1, + '$self' => 0, '$permlbl' => t('Individual Permissions'), '$permnote' => t('Some permissions may be inherited from your channel\'s privacy settings, which have higher priority than individual settings. You can not change those settings here.'), '$submit' => t('Submit') @@ -170,4 +170,4 @@ class Tokens { return $o; } -} \ No newline at end of file +} -- cgit v1.2.3 From d9759ba63c8fd70c4da66669389bd19bae3333ff Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 14 May 2018 17:20:25 -0700 Subject: more refactor tags/mentions --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 640b4fa5c..ef1eb3700 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -533,7 +533,7 @@ class Item extends \Zotlabs\Web\Controller { // Look for tags and linkify them $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid); - +logger('linkify: ' . print_r($results,true)); if($results) { // Set permissions based on tag replacements -- cgit v1.2.3 From c8fc3ad7cd47a1545da030109ba743105417c047 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 14 May 2018 19:19:25 -0700 Subject: refactor the 'where does the register link point?' logic --- Zotlabs/Module/Home.php | 4 ++-- Zotlabs/Module/Login.php | 2 +- Zotlabs/Module/Register.php | 6 +++--- Zotlabs/Module/Regmod.php | 3 +-- 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Home.php b/Zotlabs/Module/Home.php index 79449c3b2..4b3e596a9 100644 --- a/Zotlabs/Module/Home.php +++ b/Zotlabs/Module/Home.php @@ -89,11 +89,11 @@ class Home extends \Zotlabs\Web\Controller { $sitename = get_config('system','sitename'); if($sitename) - $o .= '

' . sprintf( t("Welcome to %s") ,$sitename) . '

'; + $o .= '

' . sprintf( t('Welcome to %s') ,$sitename) . '

'; $loginbox = get_config('system','login_on_homepage'); if(intval($loginbox) || $loginbox === false) - $o .= login((\App::$config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); + $o .= login(true); return $o; diff --git a/Zotlabs/Module/Login.php b/Zotlabs/Module/Login.php index ae35b922f..6430939b4 100644 --- a/Zotlabs/Module/Login.php +++ b/Zotlabs/Module/Login.php @@ -10,7 +10,7 @@ class Login extends \Zotlabs\Web\Controller { if(remote_channel() && $_SESSION['atoken']) goaway(z_root()); - return login((\App::$config['system']['register_policy'] == REGISTER_CLOSED) ? false : true); + return login(true); } } diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 4ab1ccd81..3dded19c7 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -187,8 +187,8 @@ class Register extends \Zotlabs\Web\Controller { $registration_is = ''; $other_sites = ''; - if(get_config('system','register_policy') == REGISTER_CLOSED) { - if(get_config('system','directory_mode') == DIRECTORY_MODE_STANDALONE) { + if(intval(get_config('system','register_policy')) === REGISTER_CLOSED) { + if(intval(get_config('system','directory_mode')) === DIRECTORY_MODE_STANDALONE) { notice( t('Registration on this hub is disabled.') . EOL); return; } @@ -197,7 +197,7 @@ class Register extends \Zotlabs\Web\Controller { return $mod->get(); } - if(get_config('system','register_policy') == REGISTER_APPROVE) { + if(intval(get_config('system','register_policy')) == REGISTER_APPROVE) { $registration_is = t('Registration on this hub is by approval only.'); $other_sites = t('Register at another affiliated hub.'); } diff --git a/Zotlabs/Module/Regmod.php b/Zotlabs/Module/Regmod.php index 70635d707..6fe89ca90 100644 --- a/Zotlabs/Module/Regmod.php +++ b/Zotlabs/Module/Regmod.php @@ -13,8 +13,7 @@ class Regmod extends \Zotlabs\Web\Controller { if(! local_channel()) { info( t('Please login.') . EOL); - $o .= '

' . login((\App::$config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); - return $o; + return login(); } if(! is_site_admin()) { -- cgit v1.2.3 From 959667c009ece0d67945ad09774c2bd091ba1450 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 14 May 2018 20:23:00 -0700 Subject: If somebody used hooks to create a new permission role, there was no mechanism to insert the new role into the dropdown list of roles at selection time. --- Zotlabs/Access/PermissionRoles.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php index 9855a05c4..c8b4953a5 100644 --- a/Zotlabs/Access/PermissionRoles.php +++ b/Zotlabs/Access/PermissionRoles.php @@ -308,6 +308,8 @@ class PermissionRoles { ] ]; + call_hooks('list_permission_roles',$roles); + return $roles; } -- cgit v1.2.3 From 062dea8e13ddafb1ff466d4a1c4a262d1e525e55 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 14 May 2018 22:10:21 -0700 Subject: code whitespace and formatting --- Zotlabs/Module/Removeme.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php index ca2080e83..111230937 100644 --- a/Zotlabs/Module/Removeme.php +++ b/Zotlabs/Module/Removeme.php @@ -56,12 +56,12 @@ class Removeme extends \Zotlabs\Web\Controller { $tpl = get_markup_template('removeme.tpl'); $o .= replace_macros($tpl, array( '$basedir' => z_root(), - '$hash' => $hash, - '$title' => t('Remove This Channel'), - '$desc' => array(t('WARNING: '), t('This channel will be completely removed from the network. '), t('This action is permanent and can not be undone!')), - '$passwd' => t('Please enter your password for verification:'), - '$global' => array('global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network'), array(t('No'),t('Yes'))), - '$submit' => t('Remove Channel') + '$hash' => $hash, + '$title' => t('Remove This Channel'), + '$desc' => [ t('WARNING: '), t('This channel will be completely removed from the network. '), t('This action is permanent and can not be undone!') ], + '$passwd' => t('Please enter your password for verification:'), + '$global' => [ 'global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network'), [ t('No'),t('Yes') ] ], + '$submit' => t('Remove Channel') )); return $o; -- cgit v1.2.3 From de63e40a704761c2efd1e04e1313a37c43fef20e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 15 May 2018 10:20:20 +0200 Subject: we must now provide the full path to the profile image for the cavatar plugin to work --- Zotlabs/Module/Chatsvc.php | 8 ++++---- Zotlabs/Module/Photo.php | 12 ++++++------ Zotlabs/Module/Ping.php | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Chatsvc.php b/Zotlabs/Module/Chatsvc.php index b4657e84d..d6708d95c 100644 --- a/Zotlabs/Module/Chatsvc.php +++ b/Zotlabs/Module/Chatsvc.php @@ -119,10 +119,10 @@ class Chatsvc extends \Zotlabs\Web\Controller { $rv['xchan_network'] = 'unknown'; $rv['xchan_url'] = z_root(); $rv['xchan_hidden'] = 1; - $rv['xchan_photo_mimetype'] = 'image/jpeg'; - $rv['xchan_photo_l'] = get_default_profile_photo(300); - $rv['xchan_photo_m'] = get_default_profile_photo(80); - $rv['xchan_photo_s'] = get_default_profile_photo(48); + $rv['xchan_photo_mimetype'] = 'image/png'; + $rv['xchan_photo_l'] = z_root() . '/' . get_default_profile_photo(300); + $rv['xchan_photo_m'] = z_root() . '/' . get_default_profile_photo(80); + $rv['xchan_photo_s'] = z_root() . '/' . get_default_profile_photo(48); } diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 9cafc8d07..ccc59ed09 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -31,7 +31,7 @@ class Photo extends \Zotlabs\Web\Controller { $observer_xchan = get_observer_hash(); - $default = get_default_profile_photo(); + $default = z_root() . '/' . get_default_profile_photo(); if(isset($type)) { @@ -45,11 +45,11 @@ class Photo extends \Zotlabs\Web\Controller { case 'm': $resolution = 5; - $default = get_default_profile_photo(80); + $default = z_root() . '/' . get_default_profile_photo(80); break; case 's': $resolution = 6; - $default = get_default_profile_photo(48); + $default = z_root() . '/' . get_default_profile_photo(48); break; case 'l': default: @@ -183,15 +183,15 @@ class Photo extends \Zotlabs\Web\Controller { switch($resolution) { case 4: - $data = file_get_contents(get_default_profile_photo()); + $data = file_get_contents(z_root() . '/' . get_default_profile_photo()); $mimetype = 'image/png'; break; case 5: - $data = file_get_contents(get_default_profile_photo(80)); + $data = file_get_contents(z_root() . '/' . get_default_profile_photo(80)); $mimetype = 'image/png'; break; case 6: - $data = file_get_contents(get_default_profile_photo(48)); + $data = file_get_contents(z_root() . '/' . get_default_profile_photo(48)); $mimetype = 'image/png'; break; default: diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 206b8c3d1..bb80adc41 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -401,7 +401,7 @@ class Ping extends \Zotlabs\Web\Controller { 'notify_link' => z_root() . '/admin/accounts', 'name' => $rr['account_email'], 'url' => '', - 'photo' => get_default_profile_photo(48), + 'photo' => z_root() . '/' . get_default_profile_photo(48), 'when' => relative_date($rr['account_created']), 'hclass' => ('notify-unseen'), 'message' => t('requires approval') -- cgit v1.2.3 From aac5fd96cc9ea03a329234f6b2bd8b12a0f4ae5f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 15 May 2018 16:51:04 -0700 Subject: provide function to fetch photo contents from url --- Zotlabs/Module/Linkinfo.php | 6 +++--- Zotlabs/Module/Photo.php | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index 3f58f3e01..f0d62b5e0 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -55,10 +55,10 @@ class Linkinfo extends \Zotlabs\Web\Controller { $h = explode("\n",$result['header']); foreach ($h as $l) { list($k,$v) = array_map("trim", explode(":", trim($l), 2)); - $hdrs[$k] = $v; + $hdrs[strtolower($k)] = $v; } - if (array_key_exists('Content-Type', $hdrs)) - $type = $hdrs['Content-Type']; + if (array_key_exists('content-type', $hdrs)) + $type = $hdrs['content-type']; if($type) { $zrl = is_matrix_url($url); if(stripos($type,'image/') !== false) { diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index ccc59ed09..29ad06e80 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -83,7 +83,7 @@ class Photo extends \Zotlabs\Web\Controller { $data = file_get_contents($data); } if(! $data) { - $data = file_get_contents($default); + $data = fetch_image_from_url($default,$mimetype); } if(! $mimetype) { $mimetype = 'image/png'; @@ -183,16 +183,13 @@ class Photo extends \Zotlabs\Web\Controller { switch($resolution) { case 4: - $data = file_get_contents(z_root() . '/' . get_default_profile_photo()); - $mimetype = 'image/png'; + $data = fetch_image_from_url(z_root() . '/' . get_default_profile_photo(),$mimetype); break; case 5: - $data = file_get_contents(z_root() . '/' . get_default_profile_photo(80)); - $mimetype = 'image/png'; + $data = fetch_image_from_url(z_root() . '/' . get_default_profile_photo(80),$mimetype); break; case 6: - $data = file_get_contents(z_root() . '/' . get_default_profile_photo(48)); - $mimetype = 'image/png'; + $data = fetch_image_from_url(z_root() . '/' . get_default_profile_photo(48),$mimetype); break; default: killme(); -- cgit v1.2.3 From 179eeb10a6e1b661dc7788d74d60a7c11dfca6bf Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Tue, 15 May 2018 19:57:40 -0400 Subject: Rename Permission Groups to Permission Categories and clarify feature settings text. --- Zotlabs/Widget/Settings_menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index 9574becc3..f35d6f147 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -105,7 +105,7 @@ class Settings_menu { if(feature_enabled(local_channel(),'permcats')) { $tabs[] = array( - 'label' => t('Permission Groups'), + 'label' => t('Permission Categories'), 'url' => z_root() . '/settings/permcats', 'selected' => ((argv(1) === 'permcats') ? 'active' : ''), ); -- cgit v1.2.3 From 12c571a1878348c77362a345853eb9575943ef38 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 16 May 2018 10:47:18 +0200 Subject: missing include --- Zotlabs/Module/Photo.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 29ad06e80..f348866d9 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -4,6 +4,7 @@ namespace Zotlabs\Module; require_once('include/security.php'); require_once('include/attach.php'); require_once('include/photo/photo_driver.php'); +require_once('include/photos.php'); class Photo extends \Zotlabs\Web\Controller { -- cgit v1.2.3 From 7f7e049397fcd7526ca75dd91bd881369219f019 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 18 May 2018 21:30:07 +0200 Subject: an attempt to fix the new_channel validation situation --- Zotlabs/Module/New_channel.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index df7da2fe8..c946961bc 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -137,16 +137,19 @@ class New_channel extends \Zotlabs\Web\Controller { } } - $name_help = (($default_role) + $name_help = ''; + $name_help .= (($default_role) ? t('Your real name is recommended.') : t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"') - ); - - $nick_help = t('This will be used to create a unique network address (like an email address).'); + ); + $name_help .= ''; + $nick_help = ''; + $nick_help .= t('This will be used to create a unique network address (like an email address).'); if(! get_config('system','unicode_usernames')) { $nick_help .= ' ' . t('Allowed characters are a-z 0-9, - and _'); } + $nick_help .= ''; $privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "" ); -- cgit v1.2.3 From dae89ce91c65679003d10da113a45f3ff37a8d39 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 18 May 2018 16:57:45 -0700 Subject: wrong default param for pubstream_incl (this checkin also picked up a few minor and hopefully non-significant changes) --- Zotlabs/Module/Admin/Site.php | 4 ++-- Zotlabs/Module/Photo.php | 5 +++-- Zotlabs/Module/Removeme.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index ff4f56ac8..292de4c3a 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -344,8 +344,8 @@ class Site { '$disable_discover_tab' => array('disable_discover_tab', t('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')), '$site_firehose' => array('site_firehose', t('Site only Public Streams'), get_config('system','site_firehose'), t('Allow access to public content originating only from this site if Imported Public Streams are disabled.')), '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the Public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing. Warning: this content is unmoderated.')), - '$incl' => array('pub_incl',t('Only import Public stream posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), - '$excl' => array('pub_excl',t('Do not import Public stream posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), + '$incl' => array('pub_incl',t('Only import Public stream posts with this text'), get_config('system','pubstream_incl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), + '$excl' => array('pub_excl',t('Do not import Public stream posts with this text'), get_config('system','pubstream_excl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), '$login_on_homepage' => array('login_on_homepage', t("Login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")), diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index f348866d9..8efc00707 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -14,7 +14,8 @@ class Photo extends \Zotlabs\Web\Controller { $prvcachecontrol = false; $streaming = null; $channel = null; - + $person = 0; + switch(argc()) { case 4: $person = argv(3); @@ -31,7 +32,7 @@ class Photo extends \Zotlabs\Web\Controller { } $observer_xchan = get_observer_hash(); - + $default = z_root() . '/' . get_default_profile_photo(); if(isset($type)) { diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php index 111230937..451e280c3 100644 --- a/Zotlabs/Module/Removeme.php +++ b/Zotlabs/Module/Removeme.php @@ -38,7 +38,7 @@ class Removeme extends \Zotlabs\Web\Controller { } $global_remove = intval($_POST['global']); - + channel_remove(local_channel(),1 - $global_remove,true); } -- cgit v1.2.3 From 8b4af7cf0ba59fe0a50ca7caf843569578ac3044 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 19 May 2018 00:54:47 -0700 Subject: hubzilla issue #1086, pending count on admin summary page --- Zotlabs/Module/Admin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 30f3dfa48..934312efe 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -100,8 +100,12 @@ class Admin extends \Zotlabs\Web\Controller { } // pending registrations - $r = q("SELECT COUNT(id) AS rtotal FROM register WHERE uid != '0'"); - $pending = $r[0]['rtotal']; + + $pdg = q("SELECT account.*, register.hash from account left join register on account_id = register.uid where (account_flags & %d ) > 0 ", + intval(ACCOUNT_PENDING) + ); + + $pending = (($pdg) ? count($pdg) : 0); // available channels, primary and clones $channels = array(); -- cgit v1.2.3 From 7e99931733c75ded40c5c6bdd12a42213ccb7a2e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 May 2018 09:23:44 +0200 Subject: implement jot reset button --- Zotlabs/Module/Network.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 2d6307eb1..82c88e565 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -185,7 +185,8 @@ class Network extends \Zotlabs\Web\Controller { 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true, - 'jotnets' => true + 'jotnets' => true, + 'reset' => t('Reset form') ); if($deftag) $x['pretext'] = $deftag; -- cgit v1.2.3 From 4eb40528a9d615b9498c64b4a308596ba632119a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 May 2018 14:07:30 +0200 Subject: local_channel() is not string --- Zotlabs/Module/Settings/Oauth2.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Oauth2.php b/Zotlabs/Module/Settings/Oauth2.php index 88bbea3b8..66eb95f81 100644 --- a/Zotlabs/Module/Settings/Oauth2.php +++ b/Zotlabs/Module/Settings/Oauth2.php @@ -132,10 +132,10 @@ class Oauth2 { } - $r = q("SELECT oauth_clients.*, oauth_access_tokens.access_token as oauth_token, (oauth_clients.user_id = '%s') AS my + $r = q("SELECT oauth_clients.*, oauth_access_tokens.access_token as oauth_token, (oauth_clients.user_id = %d) AS my FROM oauth_clients LEFT JOIN oauth_access_tokens ON oauth_clients.client_id=oauth_access_tokens.client_id - WHERE oauth_clients.user_id IN ('%s',0)", + WHERE oauth_clients.user_id IN (%d,0)", dbesc(local_channel()), dbesc(local_channel()) ); @@ -157,4 +157,4 @@ class Oauth2 { } -} \ No newline at end of file +} -- cgit v1.2.3 From 9e1af2492ff30f65e678ca1b885350069583ade0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 May 2018 14:15:46 +0200 Subject: more local_channel() is not string --- Zotlabs/Module/Settings/Oauth2.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Oauth2.php b/Zotlabs/Module/Settings/Oauth2.php index 66eb95f81..8db5c14aa 100644 --- a/Zotlabs/Module/Settings/Oauth2.php +++ b/Zotlabs/Module/Settings/Oauth2.php @@ -43,24 +43,24 @@ class Oauth2 { redirect_uri = '%s', grant_types = '%s', scope = '%s', - user_id = '%s' + user_id = %d WHERE client_id='%s'", dbesc($name), dbesc($secret), dbesc($redirect), dbesc($grant), dbesc($scope), - dbesc(local_channel()), + intval(local_channel()), dbesc($name)); } else { $r = q("INSERT INTO oauth_clients (client_id, client_secret, redirect_uri, grant_types, scope, user_id) - VALUES ('%s','%s','%s','%s','%s','%s')", + VALUES ('%s','%s','%s','%s','%s',%d)", dbesc($name), dbesc($secret), dbesc($redirect), dbesc($grant), dbesc($scope), - dbesc(local_channel()) + intval(local_channel()) ); $r = q("INSERT INTO xperm (xp_client, xp_channel, xp_perm) VALUES ('%s', %d, '%s') ", dbesc($name), @@ -93,9 +93,9 @@ class Oauth2 { } if((argc() > 3) && (argv(2) === 'edit')) { - $r = q("SELECT * FROM oauth_clients WHERE client_id='%s' AND user_id= '%s'", + $r = q("SELECT * FROM oauth_clients WHERE client_id='%s' AND user_id= %d", dbesc(argv(3)), - dbesc(local_channel()) + intval(local_channel()) ); if (! $r){ @@ -123,9 +123,9 @@ class Oauth2 { if((argc() > 3) && (argv(2) === 'delete')) { check_form_security_token_redirectOnErr('/settings/oauth2', 'settings_oauth2', 't'); - $r = q("DELETE FROM oauth_clients WHERE client_id = '%s' AND user_id = '%s'", + $r = q("DELETE FROM oauth_clients WHERE client_id = '%s' AND user_id = %d", dbesc(argv(3)), - dbesc(local_channel()) + intval(local_channel()) ); goaway(z_root()."/settings/oauth2/"); return; @@ -136,8 +136,8 @@ class Oauth2 { FROM oauth_clients LEFT JOIN oauth_access_tokens ON oauth_clients.client_id=oauth_access_tokens.client_id WHERE oauth_clients.user_id IN (%d,0)", - dbesc(local_channel()), - dbesc(local_channel()) + intval(local_channel()), + intval(local_channel()) ); $tpl = get_markup_template("settings_oauth2.tpl"); -- cgit v1.2.3 From 55e1026c986f1c2c7e2a0376579b01111a93ab5d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 May 2018 20:48:52 +0200 Subject: improve abconfig queries --- Zotlabs/Update/_1213.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Zotlabs/Update/_1213.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1213.php b/Zotlabs/Update/_1213.php new file mode 100644 index 000000000..d396829a6 --- /dev/null +++ b/Zotlabs/Update/_1213.php @@ -0,0 +1,28 @@ + Date: Sun, 20 May 2018 22:42:47 +0200 Subject: update oauth related tables to use bigint/int(10) for user_id column. this is to be more consistent with the rest of the tables and fixes issue #1180 --- Zotlabs/Module/Settings/Oauth2.php | 3 +- Zotlabs/Update/_1214.php | 57 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Update/_1214.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Oauth2.php b/Zotlabs/Module/Settings/Oauth2.php index 8db5c14aa..985095115 100644 --- a/Zotlabs/Module/Settings/Oauth2.php +++ b/Zotlabs/Module/Settings/Oauth2.php @@ -14,7 +14,8 @@ class Oauth2 { $key = $_POST['remove']; q("DELETE FROM tokens WHERE id='%s' AND uid=%d", dbesc($key), - local_channel()); + intval(local_channel()) + ); goaway(z_root()."/settings/oauth2/"); return; } diff --git a/Zotlabs/Update/_1214.php b/Zotlabs/Update/_1214.php new file mode 100644 index 000000000..06e5d96ed --- /dev/null +++ b/Zotlabs/Update/_1214.php @@ -0,0 +1,57 @@ + Date: Mon, 21 May 2018 09:13:14 +0200 Subject: bring jot reset to some more places --- Zotlabs/Module/Channel.php | 3 ++- Zotlabs/Module/Display.php | 3 ++- Zotlabs/Module/Hq.php | 3 ++- Zotlabs/Module/Pubstream.php | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 9ce57d6eb..327ca53db 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -152,7 +152,8 @@ class Channel extends \Zotlabs\Web\Controller { 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true, - 'jotnets' => true + 'jotnets' => true, + 'reset' => t('Reset form') ); $o .= status_editor($a,$x); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 06c9479b2..83f05a625 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -78,7 +78,8 @@ class Display extends \Zotlabs\Web\Controller { 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true, - 'jotnets' => true + 'jotnets' => true, + 'reset' => t('Reset form') ); $o = '
'; diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index baeba82e8..33c9cca4d 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -131,7 +131,8 @@ class Hq extends \Zotlabs\Web\Controller { 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true, - 'jotnets' => true + 'jotnets' => true, + 'reset' => t('Reset form') ]; $o = replace_macros(get_markup_template("hq.tpl"), diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 571118201..f0ce4749b 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -77,7 +77,8 @@ class Pubstream extends \Zotlabs\Web\Controller { 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true, - 'jotnets' => true + 'jotnets' => true, + 'reset' => t('Reset form') ); $o = '
'; -- cgit v1.2.3 From a8274bbfb3c5ac315f3dcf470f45262c03d48e06 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 21 May 2018 09:25:57 +0200 Subject: missing permission description --- Zotlabs/Module/Display.php | 3 +-- Zotlabs/Module/Hq.php | 3 +-- Zotlabs/Module/Pubstream.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 83f05a625..a127ab196 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -67,8 +67,7 @@ class Display extends \Zotlabs\Web\Controller { 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - - 'acl' => populate_acl($channel_acl), + 'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'permissions' => $channel_acl, 'bang' => '', 'visitor' => true, diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 33c9cca4d..fee4246c0 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -120,8 +120,7 @@ class Hq extends \Zotlabs\Web\Controller { 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - - 'acl' => populate_acl($channel_acl), + 'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'permissions' => $channel_acl, 'bang' => '', 'visitor' => true, diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index f0ce4749b..f0e87f468 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -66,8 +66,7 @@ class Pubstream extends \Zotlabs\Web\Controller { 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - - 'acl' => populate_acl($channel_acl), + 'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'permissions' => $channel_acl, 'bang' => '', 'visitor' => true, -- cgit v1.2.3 From 9bf26cee6de1015aab3eec87e335c3b90827cd33 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 21 May 2018 16:19:17 -0700 Subject: add hook 'get_system_apps' --- Zotlabs/Lib/Apps.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 24cb4a626..2dded1aaa 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -45,6 +45,8 @@ class Apps { } } + call_hooks('get_system_apps',$ret); + return $ret; } -- cgit v1.2.3 From 2b3f931c859b0e5b3a561c445b29035b00b4dc20 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 21 May 2018 19:25:03 -0700 Subject: oauth2 discovery per draft-ietf-oauth-discovery-10 --- Zotlabs/Module/Oauthinfo.php | 23 +++++++++++++++++++++++ Zotlabs/Module/Well_known.php | 10 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Module/Oauthinfo.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Oauthinfo.php b/Zotlabs/Module/Oauthinfo.php new file mode 100644 index 000000000..6eea2e02b --- /dev/null +++ b/Zotlabs/Module/Oauthinfo.php @@ -0,0 +1,23 @@ + z_root(), + 'authorization_endpoint' => z_root() . '/authorize', + 'token_endpoint' => z_root() . '/token', + 'response_types_supported' => [ 'code', 'code token' ] + ]; + + + json_return_and_die($ret); + } + + +} \ No newline at end of file diff --git a/Zotlabs/Module/Well_known.php b/Zotlabs/Module/Well_known.php index 177de2323..442994b54 100644 --- a/Zotlabs/Module/Well_known.php +++ b/Zotlabs/Module/Well_known.php @@ -50,7 +50,15 @@ class Well_known extends \Zotlabs\Web\Controller { $module = new \Zotlabs\Module\Hostxrd(); $module->init(); break; - + + case 'oauth-authorization-server': + \App::$argc -= 1; + array_shift(\App::$argv); + \App::$argv[0] = 'oauthinfo'; + $module = new \Zotlabs\Module\Oauthinfo(); + $module->init(); + break; + case 'dnt-policy.txt': echo file_get_contents('doc/dnt-policy.txt'); killme(); -- cgit v1.2.3 From a403611ac9d3c1f50a9c93e982dda693a26624f7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 21 May 2018 19:34:03 -0700 Subject: update response types --- Zotlabs/Module/Oauthinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Oauthinfo.php b/Zotlabs/Module/Oauthinfo.php index 6eea2e02b..2d10913c4 100644 --- a/Zotlabs/Module/Oauthinfo.php +++ b/Zotlabs/Module/Oauthinfo.php @@ -12,7 +12,7 @@ class Oauthinfo extends \Zotlabs\Web\Controller { 'issuer' => z_root(), 'authorization_endpoint' => z_root() . '/authorize', 'token_endpoint' => z_root() . '/token', - 'response_types_supported' => [ 'code', 'code token' ] + 'response_types_supported' => [ 'code', 'token', 'id_token', 'code id_token', 'token id_token' ] ]; -- cgit v1.2.3 From 1061027071fac2eedd85d795445fb0b72aa942d6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 21 May 2018 20:17:17 -0700 Subject: new_channel - make text strings translatable and use the name as a base for the nick if you try to create without entering a nick --- Zotlabs/Module/New_channel.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index c946961bc..97a46a43e 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -41,7 +41,7 @@ class New_channel extends \Zotlabs\Web\Controller { $test[] = legal_webbie($x); // fullname plus random number $test[] = legal_webbie($x) . mt_rand(1000,9999); - + json_return_and_die(check_webbie($test)); } @@ -49,7 +49,10 @@ class New_channel extends \Zotlabs\Web\Controller { require_once('library/urlify/URLify.php'); $result = array('error' => false, 'message' => ''); $n = trim($_REQUEST['nick']); - + if(! $n) { + $n = trim($_REQUEST['name']); + } + $x = false; if(get_config('system','unicode_usernames')) { @@ -58,9 +61,20 @@ class New_channel extends \Zotlabs\Web\Controller { if((! $x) || strlen($x) > 64) $x = strtolower(\URLify::transliterate($n)); - + + $test = array(); + // first name + if(strpos($x,' ')) + $test[] = legal_webbie(substr($x,0,strpos($x,' '))); + if($test[0]) { + // first name plus first initial of last + $test[] = ((strpos($x,' ')) ? $test[0] . legal_webbie(trim(substr($x,strpos($x,' '),2))) : ''); + // first name plus random number + $test[] = $test[0] . mt_rand(1000,9999); + } + $n = legal_webbie($x); if(strlen($n)) { $test[] = $n; -- cgit v1.2.3 From 9cf8931136c703c66d0bf83e4c6b8fb7f4d2cf0b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 23 May 2018 22:11:13 +0200 Subject: paint the locks on private activitypub items red. their privacy model is "slightly" different from ours --- Zotlabs/Lib/ThreadItem.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index c7a2c9373..0fed78158 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -102,6 +102,9 @@ class ThreadItem { if($item['author']['xchan_network'] === 'rss') $shareable = true; + $privacy_warning = false; + if($item['owner']['xchan_network'] === 'activitypub') + $privacy_warning = true; $mode = $conv->get_mode(); @@ -370,6 +373,7 @@ class ThreadItem { 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : ''), 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), 'lock' => $lock, + 'privacy_warning' => $privacy_warning, 'verified' => $verified, 'unverified' => $unverified, 'forged' => $forged, -- cgit v1.2.3 From 33700e9cf47e2b5f0b4597772d9cea81e811bae3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 25 May 2018 15:29:59 +0200 Subject: differentiate between direct messages and followers-only messages --- Zotlabs/Lib/ThreadItem.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 0fed78158..a3c7f99b9 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -103,8 +103,12 @@ class ThreadItem { $shareable = true; $privacy_warning = false; - if($item['owner']['xchan_network'] === 'activitypub') - $privacy_warning = true; + if(($item['item_private'] == 1) && ($item['owner']['xchan_network'] === 'activitypub')) { + $recips = get_iconfig($item['parent'], 'activitypub', 'recips'); + + if(! in_array($observer['xchan_url'], $recips['to'])) + $privacy_warning = true; + } $mode = $conv->get_mode(); -- cgit v1.2.3 From eb04dbc5ce2321ca5da4274005bd3e4352cf83fa Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 26 May 2018 21:15:22 +0200 Subject: DB update to fix wrong hubloc_url for activitypub hublocs --- Zotlabs/Update/_1215.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Zotlabs/Update/_1215.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1215.php b/Zotlabs/Update/_1215.php new file mode 100644 index 000000000..3acaab587 --- /dev/null +++ b/Zotlabs/Update/_1215.php @@ -0,0 +1,26 @@ +0"); + + // this will fix peertube hubloc_url + $r2 = q("UPDATE hubloc SET hubloc_url = LEFT(hubloc_url, POSITION('/account' IN hubloc_url)-1) WHERE POSITION('/account' IN hubloc_url)>0"); + + if($r1 && $r2) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + else { + q("ROLLBACK"); + return UPDATE_FAILED; + } + } + +} -- cgit v1.2.3 From 4f3be92a0d8b9b8555647d3086e13dd3530c6463 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Sun, 27 May 2018 17:57:35 +0200 Subject: include photos.php required for photo_calculate_scale() --- Zotlabs/Module/Cover_photo.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 9adfa2209..88fd4485d 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -9,6 +9,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); require_once('include/channel.php'); +require_once('include/photos.php'); -- cgit v1.2.3 From ddebbcc0a08aae9cd33bb3105ce1f2c8863b544c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 27 May 2018 17:46:25 -0700 Subject: hubzilla issue #1200 --- Zotlabs/Module/Network.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 82c88e565..942b48109 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -131,7 +131,7 @@ class Network extends \Zotlabs\Web\Controller { if(x($_GET,'search') || x($_GET,'file')) $nouveau = true; if($cid) { - $r = q("SELECT abook_xchan FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + $r = q("SELECT abook_xchan, xchan_addr, xchan_url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($cid), intval(local_channel()) ); @@ -144,7 +144,7 @@ class Network extends \Zotlabs\Web\Controller { // NOTREACHED } if($_GET['pf'] === '1') - $deftag = '!' . t('forum') . '+' . intval($cid); + $deftag = '!{' . (($r[0]['xchan_addr']) ? $r[0]['xchan_addr'] : $r[0]['xchan_url']) . '}'; else $def_acl = [ 'allow_cid' => '<' . $r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } -- cgit v1.2.3 From 139c39c2ce270ca1e95d86b517ebe0ad4182ecfa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 28 May 2018 22:23:40 -0700 Subject: we probably don't need to delivery local items more than once --- Zotlabs/Daemon/Deliver.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index 394a7bf3e..b809cba91 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -75,6 +75,8 @@ class Deliver { q("delete from dreport where dreport_queue = '%s'", dbesc($argv[$x]) ); + + continue; } } -- cgit v1.2.3 From ed3d3b6f27452969164f35fee3cf7955733b503e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 29 May 2018 17:35:44 -0700 Subject: provide possibility of using different orderings (post, commented) on channel page --- Zotlabs/Module/Channel.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 327ca53db..9108f6841 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -82,6 +82,7 @@ class Channel extends \Zotlabs\Web\Controller { $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); + $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'post'); $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); $groups = array(); @@ -244,6 +245,7 @@ class Channel extends \Zotlabs\Web\Controller { if($datequery) { $sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); + $order = 'post'; } if($datequery2) { $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); @@ -253,6 +255,12 @@ class Channel extends \Zotlabs\Web\Controller { $sql_extra2 .= " and item.item_thread_top != 0 "; } + if($order === 'post') + $ordering = "created"; + else + $ordering = "commented"; + + $itemspage = get_pconfig(local_channel(),'system','itemspage'); \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); @@ -275,7 +283,7 @@ class Channel extends \Zotlabs\Web\Controller { AND (abook.abook_blocked = 0 or abook.abook_flags is null) AND item.item_wall = 1 $sql_extra $sql_extra2 - ORDER BY created DESC, id $pager_sql ", + ORDER BY $ordering DESC, id $pager_sql ", intval(\App::$profile['profile_uid']) ); } @@ -284,7 +292,6 @@ class Channel extends \Zotlabs\Web\Controller { $r = array(); } } - if($r) { $parents_str = ids_to_querystr($r,'item_id'); @@ -300,7 +307,7 @@ class Channel extends \Zotlabs\Web\Controller { xchan_query($items); $items = fetch_post_tags($items, true); - $items = conv_sort($items,'created'); + $items = conv_sort($items,$ordering); if($load && $mid && (! count($items))) { // This will happen if we don't have sufficient permissions @@ -345,7 +352,7 @@ class Channel extends \Zotlabs\Web\Controller { '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), '$search' => $search, '$xchan' => '', - '$order' => '', + '$order' => $order, '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), '$file' => '', '$cats' => (($category) ? urlencode($category) : ''), -- cgit v1.2.3 From 9fcb3bf2e8fab84f9144eecceaf984b2026e6d08 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 14:02:58 +0200 Subject: first cut on restructuring the previously called network tabs --- Zotlabs/Module/Network.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 942b48109..060179217 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -57,13 +57,26 @@ class Network extends \Zotlabs\Web\Controller { $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); - $nouveau = ((x($_GET,'new')) ? intval($_GET['new']) : 0); $static = ((x($_GET,'static')) ? intval($_GET['static']) : 0); $gid = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0); $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); - + + + $order = get_pconfig(local_channel(), 'mod_network', 'order', 0); + switch($order) { + case 0: + $order = 'comment'; + break; + case 1: + $order = 'post'; + break; + case 2: + $nouveau = true; + break; + } + $search = (($_GET['search']) ? $_GET['search'] : ''); if($search) { $_GET['netsearch'] = escape_tags($search); @@ -84,7 +97,7 @@ class Network extends \Zotlabs\Web\Controller { } if($datequery) - $_GET['order'] = 'post'; + $order = 'post'; // filter by collection (e.g. group) @@ -150,7 +163,7 @@ class Network extends \Zotlabs\Web\Controller { } if(! $update) { - $tabs = network_tabs(); + $tabs = ''; //network_tabs(); $o .= $tabs; // search terms header -- cgit v1.2.3 From 8d6441704bdc8d0628149dbb32321b6921f097ba Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 14:06:18 +0200 Subject: add widget files and templates --- Zotlabs/Widget/Activity_filter.php | 66 ++++++++++++++++++++++ Zotlabs/Widget/Activity_order.php | 111 +++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 Zotlabs/Widget/Activity_filter.php create mode 100644 Zotlabs/Widget/Activity_order.php (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php new file mode 100644 index 000000000..a60144239 --- /dev/null +++ b/Zotlabs/Widget/Activity_filter.php @@ -0,0 +1,66 @@ + t('Personal Posts'), + 'icon' => 'user-circle', + 'url' => z_root() . '/' . $cmd . '?f=' . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '') . '&conv=1', + 'sel' => $conv_active, + 'title' => t('Posts that mention or involve you'), + ); + } + + if(feature_enabled(local_channel(),'star_posts')) { + $tabs[] = array( + 'label' => t('Starred Posts'), + 'icon' => 'star', + 'url'=>z_root() . '/' . $cmd . '/?f=' . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '') . '&star=1', + 'sel'=>$starred_active, + 'title' => t('Favourite Posts'), + ); + } + + + $arr = ['tabs' => $tabs]; + + call_hooks('network_tabs', $arr); + + $tpl = get_markup_template('common_pills.tpl'); + + if($arr['tabs']) { + return replace_macros($tpl, [ + '$title' => t('Additional Filters'), + '$tabs' => $arr['tabs'], + ]); + } + else { + return ''; + } + } + +} diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php new file mode 100644 index 000000000..ba288965f --- /dev/null +++ b/Zotlabs/Widget/Activity_order.php @@ -0,0 +1,111 @@ + t('Commented Date'), + 'url'=>z_root() . '/' . $cmd . '?f=&order=comment' . $filter, + 'sel'=> $commentord_active, + 'title' => t('Sort by Comment Date'), + ]; + $tabs[] = [ + 'label' => t('Posted Date'), + 'url'=>z_root() . '/' . $cmd . '?f=&order=post' . $filter, + 'sel'=> $postord_active, + 'title' => t('Sort by Post Date'), + ]; + $tabs[] = array( + 'label' => t('Date Unthreaded'), + 'url' => z_root() . '/' . $cmd . '?f=&order=unthreaded' . $filter, + 'sel' => $unthreaded_active, + 'title' => t('Activity Stream - by date'), + ); + + $arr = ['tabs' => $tabs]; + + call_hooks('network_tabs', $arr); + + $tpl = get_markup_template('common_pills.tpl'); + + if($arr['tabs']) { + return replace_macros($tpl, [ + '$title' => t('Order Activity by'), + '$tabs' => $arr['tabs'], + ]); + } + else { + return ''; + } + } + +} -- cgit v1.2.3 From 293e405f5b9761ade0c621c3696b93439b2440bf Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 14:09:24 +0200 Subject: just query for data we actually need --- Zotlabs/Daemon/Poller.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Poller.php b/Zotlabs/Daemon/Poller.php index e4bc9c143..49151437c 100644 --- a/Zotlabs/Daemon/Poller.php +++ b/Zotlabs/Daemon/Poller.php @@ -71,14 +71,18 @@ class Poller { $randfunc = db_getfunc('RAND'); - $contacts = q("SELECT * FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash + $contacts = q("SELECT abook.abook_updated, abook.abook_connected, abook.abook_feed, + abook.abook_channel, abook.abook_id, abook.abook_archived, abook.abook_pending, + abook.abook_ignored, abook.abook_blocked, + xchan.xchan_network, + account.account_lastlog, account.account_flags + FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash LEFT JOIN account on abook_account = account_id where abook_self = 0 $sql_extra AND (( account_flags = %d ) OR ( account_flags = %d )) $abandon_sql ORDER BY $randfunc", intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED) // FIXME - ); if($contacts) { -- cgit v1.2.3 From 881406f82b455cbd78eb64570a0a41937814a444 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 14:54:39 +0200 Subject: remove redundant reference for order --- Zotlabs/Module/Network.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 060179217..5e7492fd4 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -120,16 +120,11 @@ class Network extends \Zotlabs\Web\Controller { $def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>'); } - $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0); $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99); - - // if no tabs are selected, defaults to comments - $cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0); $star = ((x($_GET,'star')) ? intval($_GET['star']) : 0); - $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment'); $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0); $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0); $spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0); -- cgit v1.2.3 From 6349a7417f41cd697ba2dea82653911a1abaaf94 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 22:40:22 +0200 Subject: make navbar search use the module search function in /network and /channel --- Zotlabs/Module/Channel.php | 29 ++++++++++++++++------------- Zotlabs/Module/Network.php | 4 ++++ Zotlabs/Widget/Activity_order.php | 7 +++++++ 3 files changed, 27 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 9108f6841..dac177c9e 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -84,6 +84,7 @@ class Channel extends \Zotlabs\Web\Controller { $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'post'); $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); + $search = ((x($_GET,'search')) ? $_GET['search'] : EMPTY_STR); $groups = array(); @@ -119,9 +120,12 @@ class Channel extends \Zotlabs\Web\Controller { $static = channel_manual_conv_update(\App::$profile['profile_uid']); - //$o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']); - - // $o .= common_friends_visitor_widget(\App::$profile['profile_uid']); + // search terms header + if($search) { + $o .= replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') + )); + } if($channel && $is_owner) { $channel_acl = array( @@ -180,15 +184,13 @@ class Channel extends \Zotlabs\Web\Controller { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); - - $search = EMPTY_STR; - if(x($_GET,'search')) { - $search = escape_tags($_GET['search']); + if($search) { + $search = escape_tags($search); if(strpos($search,'#') === 0) { - $sql_extra2 .= term_query('item',substr($search,1),TERM_HASHTAG,TERM_COMMUNITYTAG); + $sql_extra .= term_query('item',substr($search,1),TERM_HASHTAG,TERM_COMMUNITYTAG); } else { - $sql_extra2 .= sprintf(" AND item.body like '%s' ", + $sql_extra .= sprintf(" AND item.body like '%s' ", dbesc(protect_sprintf('%' . $search . '%')) ); } @@ -255,7 +257,7 @@ class Channel extends \Zotlabs\Web\Controller { $sql_extra2 .= " and item.item_thread_top != 0 "; } - if($order === 'post') + if($order === 'post') $ordering = "created"; else $ordering = "commented"; @@ -282,7 +284,7 @@ class Channel extends \Zotlabs\Web\Controller { WHERE true and item.uid = %d $item_normal AND (abook.abook_blocked = 0 or abook.abook_flags is null) AND item.item_wall = 1 - $sql_extra $sql_extra2 + $sql_extra $sql_extra2 ORDER BY $ordering DESC, id $pager_sql ", intval(\App::$profile['profile_uid']) ); @@ -398,12 +400,13 @@ class Channel extends \Zotlabs\Web\Controller { } } + $mode = (($search) ? 'search' : 'channel'); if($checkjs->disabled()) { - $o .= conversation($items,'channel',$update,'traditional'); + $o .= conversation($items,$mode,$update,'traditional'); } else { - $o .= conversation($items,'channel',$update,$page_mode); + $o .= conversation($items,$mode,$update,$page_mode); } if((! $update) || ($checkjs->disabled())) { diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 5e7492fd4..acd12158c 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -138,6 +138,7 @@ class Network extends \Zotlabs\Web\Controller { if(x($_GET,'search') || x($_GET,'file')) $nouveau = true; + if($cid) { $r = q("SELECT abook_xchan, xchan_addr, xchan_url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($cid), @@ -567,6 +568,9 @@ class Network extends \Zotlabs\Web\Controller { } $mode = (($nouveau) ? 'network-new' : 'network'); + + if($search) + $mode = 'search'; $o .= conversation($items,$mode,$update,$page_mode); diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php index ba288965f..edeef2c20 100644 --- a/Zotlabs/Widget/Activity_order.php +++ b/Zotlabs/Widget/Activity_order.php @@ -53,6 +53,12 @@ class Activity_order { } } + // override order for search results and filer results + if(x($_GET,'search') || x($_GET,'file')) { + $unthreaded_active = 'active'; + $commentord_active = $postord_active = ''; + } + $cmd = \App::$cmd; $filter = ''; @@ -69,6 +75,7 @@ class Activity_order { if(x($_GET,'conv')) $filter .= '&conv=' . $_GET['conv']; + // tabs $tabs = []; -- cgit v1.2.3 From 5505f5fa02f35a9c0b64badb1ff3ff2b791d2a41 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 22:55:28 +0200 Subject: restrict the network/channel navbar search to content and hashtags --- Zotlabs/Module/Channel.php | 3 +++ Zotlabs/Module/Network.php | 3 +++ 2 files changed, 6 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index dac177c9e..21a6bd122 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -18,6 +18,9 @@ class Channel extends \Zotlabs\Web\Controller { function init() { + if(strpos($_GET['search'], ['@', '!', '?']) == 0) + goaway('search' . '?f=&search=' . $_GET['search']); + $which = null; if(argc() > 1) $which = argv(1); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index acd12158c..64f9e668c 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -15,6 +15,9 @@ class Network extends \Zotlabs\Web\Controller { notice( t('Permission denied.') . EOL); return; } + + if(strpos($_GET['search'], ['@', '!', '?']) == 0) + goaway('search' . '?f=&search=' . $_GET['search']); if(count($_GET) < 2) { $network_options = get_pconfig(local_channel(),'system','network_page_default'); -- cgit v1.2.3 From 6bfc5aa96c44d3a16962242d0ef02ccfa879ab7b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 23:15:43 +0200 Subject: strpos does not work with arrays :( --- Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Network.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 21a6bd122..c2e464470 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -18,7 +18,7 @@ class Channel extends \Zotlabs\Web\Controller { function init() { - if(strpos($_GET['search'], ['@', '!', '?']) == 0) + if(strpos($_GET['search'], '@') === 0 || strpos($_GET['search'], '!') === 0 || strpos($_GET['search'], '?') === 0) goaway('search' . '?f=&search=' . $_GET['search']); $which = null; diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 64f9e668c..0d4deb736 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -16,7 +16,7 @@ class Network extends \Zotlabs\Web\Controller { return; } - if(strpos($_GET['search'], ['@', '!', '?']) == 0) + if(strpos($_GET['search'], '@') === 0 || strpos($_GET['search'], '!') === 0 || strpos($_GET['search'], '?') === 0) goaway('search' . '?f=&search=' . $_GET['search']); if(count($_GET) < 2) { -- cgit v1.2.3 From fc31ecdab0abdd5ca83723c2c1da2f711016c274 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 30 May 2018 17:30:17 -0700 Subject: autocomplete private mail addresses based on substring in either the name or webbie (prevously required an '@' to trigger a webbie search) --- Zotlabs/Module/Acl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 2678aeb7a..7b52e88b5 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -94,8 +94,7 @@ class Acl extends \Zotlabs\Web\Controller { . " then POSITION('" . protect_sprintf(dbesc($search)) . "' IN xchan_name) else position('" . protect_sprintf(dbesc(punify($search))) . "' IN xchan_addr) end, "; - $col = ((strpos($search,'@') !== false) ? 'xchan_addr' : 'xchan_name' ); - $sql_extra3 = "AND $col like " . protect_sprintf( "'%" . dbesc(($col === 'xchan_addr') ? punify($search) : $search) . "%'" ) . " "; + $sql_extra3 = "AND ( xchan_addr like " . protect_sprintf( "'%" . dbesc(punify($search)) . "%'" ) . " OR xchan_name like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ) "; } else { -- cgit v1.2.3 From cbaaa1c57ffed0b0a11a7d4cf9a492c26e577194 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 31 May 2018 13:05:32 +0200 Subject: merge groups and filed posts into activity filters --- Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Network.php | 4 +- Zotlabs/Widget/Activity_filter.php | 80 ++++++++++++++++++++++++++++---------- Zotlabs/Widget/Activity_order.php | 5 ++- 4 files changed, 67 insertions(+), 24 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index c2e464470..6969b6226 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -18,7 +18,7 @@ class Channel extends \Zotlabs\Web\Controller { function init() { - if(strpos($_GET['search'], '@') === 0 || strpos($_GET['search'], '!') === 0 || strpos($_GET['search'], '?') === 0) + if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?'])) goaway('search' . '?f=&search=' . $_GET['search']); $which = null; diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 0d4deb736..8a381d678 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -16,7 +16,7 @@ class Network extends \Zotlabs\Web\Controller { return; } - if(strpos($_GET['search'], '@') === 0 || strpos($_GET['search'], '!') === 0 || strpos($_GET['search'], '?') === 0) + if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?'])) goaway('search' . '?f=&search=' . $_GET['search']); if(count($_GET) < 2) { @@ -389,7 +389,7 @@ class Network extends \Zotlabs\Web\Controller { if($conv) { $item_thread_top = ''; - $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", + $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'])) ); } diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index a60144239..e56d13fc1 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -9,42 +9,82 @@ class Activity_filter { if(! local_channel()) return ''; - $starred_active = ''; - $conv_active = ''; - - if(x($_GET,'star')) { - $starred_active = 'active'; - } - - if(x($_GET,'conv')) { - $conv_active = 'active'; - } - $cmd = \App::$cmd; - // tabs $tabs = []; if(feature_enabled(local_channel(),'personal_tab')) { - $tabs[] = array( + if(x($_GET,'conv')) { + $conv_active = (($_GET['conv'] == 1) ? 'active' : ''); + } + + $tabs[] = [ 'label' => t('Personal Posts'), 'icon' => 'user-circle', - 'url' => z_root() . '/' . $cmd . '?f=' . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '') . '&conv=1', + 'url' => z_root() . '/' . $cmd . '/?f=&conv=1', 'sel' => $conv_active, - 'title' => t('Posts that mention or involve you'), - ); + 'title' => t('Show posts that mention or involve me'), + ]; } if(feature_enabled(local_channel(),'star_posts')) { - $tabs[] = array( + if(x($_GET,'star')) { + $starred_active = (($_GET['star'] == 1) ? 'active' : ''); + } + + $tabs[] = [ 'label' => t('Starred Posts'), 'icon' => 'star', - 'url'=>z_root() . '/' . $cmd . '/?f=' . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '') . '&star=1', + 'url'=>z_root() . '/' . $cmd . '/?f=&star=1', 'sel'=>$starred_active, - 'title' => t('Favourite Posts'), + 'title' => t('Show posts that i have starred'), + ]; + } + + if(feature_enabled(local_channel(),'groups')) { + $groups = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + intval(local_channel()) ); + + if($groups) { + foreach($groups as $g) { + if(x($_GET,'gid')) { + $group_active = (($_GET['gid'] == $g['id']) ? 'active' : ''); + } + + $tabs[] = [ + 'label' => $g['gname'], + 'icon' => 'users', + 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], + 'sel' => $group_active, + 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']), + ]; + } + } } + 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()), + intval(TERM_FILE) + ); + + if($terms) { + foreach($terms as $t) { + if(x($_GET,'file')) { + $file_active = (($_GET['file'] == $t['term']) ? 'active' : ''); + } + + $tabs[] = [ + 'label' => $t['term'], + 'icon' => 'folder', + 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], + 'sel' => $file_active, + 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + ]; + } + } + } $arr = ['tabs' => $tabs]; @@ -54,7 +94,7 @@ class Activity_filter { if($arr['tabs']) { return replace_macros($tpl, [ - '$title' => t('Additional Filters'), + '$title' => t('Activity Filters'), '$tabs' => $arr['tabs'], ]); } diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php index edeef2c20..c973e3809 100644 --- a/Zotlabs/Widget/Activity_order.php +++ b/Zotlabs/Widget/Activity_order.php @@ -56,7 +56,7 @@ class Activity_order { // override order for search results and filer results if(x($_GET,'search') || x($_GET,'file')) { $unthreaded_active = 'active'; - $commentord_active = $postord_active = ''; + $commentord_active = $postord_active = 'disabled'; } $cmd = \App::$cmd; @@ -75,6 +75,9 @@ class Activity_order { if(x($_GET,'conv')) $filter .= '&conv=' . $_GET['conv']; + if(x($_GET,'file')) + $filter .= '&file=' . $_GET['file']; + // tabs $tabs = []; -- cgit v1.2.3 From 7e8c7f86f0d103dbffa0ee4fc7538d89a0925a15 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 31 May 2018 13:13:46 +0200 Subject: change some strings --- Zotlabs/Widget/Activity_order.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php index c973e3809..10ec142d9 100644 --- a/Zotlabs/Widget/Activity_order.php +++ b/Zotlabs/Widget/Activity_order.php @@ -86,19 +86,19 @@ class Activity_order { 'label' => t('Commented Date'), 'url'=>z_root() . '/' . $cmd . '?f=&order=comment' . $filter, 'sel'=> $commentord_active, - 'title' => t('Sort by Comment Date'), + 'title' => t('Order by last commented date'), ]; $tabs[] = [ 'label' => t('Posted Date'), 'url'=>z_root() . '/' . $cmd . '?f=&order=post' . $filter, 'sel'=> $postord_active, - 'title' => t('Sort by Post Date'), + 'title' => t('Order by last posted date'), ]; $tabs[] = array( 'label' => t('Date Unthreaded'), 'url' => z_root() . '/' . $cmd . '?f=&order=unthreaded' . $filter, 'sel' => $unthreaded_active, - 'title' => t('Activity Stream - by date'), + 'title' => t('Order unthreaded by date'), ); $arr = ['tabs' => $tabs]; @@ -109,7 +109,7 @@ class Activity_order { if($arr['tabs']) { return replace_macros($tpl, [ - '$title' => t('Order Activity by'), + '$title' => t('Activity Order'), '$tabs' => $arr['tabs'], ]); } -- cgit v1.2.3 From d03c27d18c10d287cbfd3133b3301934d0457636 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 31 May 2018 14:02:34 +0200 Subject: implement reset button for filters --- Zotlabs/Widget/Activity_filter.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index e56d13fc1..a85ab8dc1 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -10,12 +10,14 @@ class Activity_filter { return ''; $cmd = \App::$cmd; + $filter_active = false; $tabs = []; if(feature_enabled(local_channel(),'personal_tab')) { if(x($_GET,'conv')) { $conv_active = (($_GET['conv'] == 1) ? 'active' : ''); + $filter_active = true; } $tabs[] = [ @@ -30,6 +32,7 @@ class Activity_filter { if(feature_enabled(local_channel(),'star_posts')) { if(x($_GET,'star')) { $starred_active = (($_GET['star'] == 1) ? 'active' : ''); + $filter_active = true; } $tabs[] = [ @@ -50,6 +53,7 @@ class Activity_filter { foreach($groups as $g) { if(x($_GET,'gid')) { $group_active = (($_GET['gid'] == $g['id']) ? 'active' : ''); + $filter_active = true; } $tabs[] = [ @@ -73,6 +77,7 @@ class Activity_filter { foreach($terms as $t) { if(x($_GET,'file')) { $file_active = (($_GET['file'] == $t['term']) ? 'active' : ''); + $filter_active = true; } $tabs[] = [ @@ -86,6 +91,21 @@ class Activity_filter { } } + if(x($_GET,'search')) { + $filter_active = true; + } + + if($filter_active) { + $reset = [ + 'label' => t('Remove Filter'), + 'icon' => 'remove', + 'url'=> z_root() . '/' . $cmd, + 'sel'=> 'active bg-danger', + 'title' => t('Remove active filter'), + ]; + array_unshift($tabs, $reset); + } + $arr = ['tabs' => $tabs]; call_hooks('network_tabs', $arr); -- cgit v1.2.3 From 7c05500392aea9d992919e1791c1557dd2f49424 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 31 May 2018 16:17:24 -0700 Subject: don't show forums in forum widget if archived flag is set --- Zotlabs/Widget/Forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index 7415c0f0a..d3e2f2534 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -51,7 +51,7 @@ class Forums { - $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 $sql_extra order by xchan_name $limit ", + $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra order by xchan_name $limit ", intval(local_channel()) ); -- cgit v1.2.3 From dd962027cce033b6bcdef7a2fef7b946a9f67a20 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 31 May 2018 21:14:12 -0700 Subject: proper pronoun --- Zotlabs/Widget/Activity_filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index e56d13fc1..40f294fa5 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -80,7 +80,7 @@ class Activity_filter { 'icon' => 'folder', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], 'sel' => $file_active, - 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + 'title' => sprintf(t('Show posts that I have filed to %s'), $t['term']), ]; } } -- cgit v1.2.3 From 6bf0f4225c0fc7ecc1762ed5cfe2c4861cd1bd4e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Jun 2018 12:11:07 +0200 Subject: move file and groups filter to submenu --- Zotlabs/Widget/Activity_filter.php | 65 ++++++++++++++++++++++++++------------ Zotlabs/Widget/Activity_order.php | 16 ++++++---- 2 files changed, 54 insertions(+), 27 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index a85ab8dc1..18207b37b 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -17,7 +17,7 @@ class Activity_filter { if(feature_enabled(local_channel(),'personal_tab')) { if(x($_GET,'conv')) { $conv_active = (($_GET['conv'] == 1) ? 'active' : ''); - $filter_active = true; + $filter_active = 'personal'; } $tabs[] = [ @@ -32,7 +32,7 @@ class Activity_filter { if(feature_enabled(local_channel(),'star_posts')) { if(x($_GET,'star')) { $starred_active = (($_GET['star'] == 1) ? 'active' : ''); - $filter_active = true; + $filter_active = 'star'; } $tabs[] = [ @@ -53,17 +53,26 @@ class Activity_filter { foreach($groups as $g) { if(x($_GET,'gid')) { $group_active = (($_GET['gid'] == $g['id']) ? 'active' : ''); - $filter_active = true; + $filter_active = 'group'; } - - $tabs[] = [ + $gsub[] = [ 'label' => $g['gname'], - 'icon' => 'users', + 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], 'sel' => $group_active, 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']), ]; } + $tabs[] = [ + 'id' => 'privacy_groups', + 'label' => t('Privacy Groups'), + 'icon' => 'users', + 'url' => '#', + 'sel' => (($filter_active == 'group') ? true : false), + 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + 'sub' => $gsub + + ]; } } @@ -77,50 +86,64 @@ class Activity_filter { foreach($terms as $t) { if(x($_GET,'file')) { $file_active = (($_GET['file'] == $t['term']) ? 'active' : ''); - $filter_active = true; + $filter_active = 'file'; } - - $tabs[] = [ + $tsub[] = [ 'label' => $t['term'], - 'icon' => 'folder', + 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], 'sel' => $file_active, - 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + 'title' => '', ]; } + + $tabs[] = [ + 'label' => t('Saved Folders'), + 'icon' => 'folder', + 'url' => '#', + 'sel' => (($filter_active == 'file') ? true : false), + 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + 'sub' => $tsub + + ]; } } if(x($_GET,'search')) { - $filter_active = true; + $filter_active = 'search'; } + $reset = []; if($filter_active) { $reset = [ - 'label' => t('Remove Filter'), + 'label' => '', 'icon' => 'remove', 'url'=> z_root() . '/' . $cmd, - 'sel'=> 'active bg-danger', + 'sel'=> '', 'title' => t('Remove active filter'), ]; - array_unshift($tabs, $reset); } $arr = ['tabs' => $tabs]; call_hooks('network_tabs', $arr); - $tpl = get_markup_template('common_pills.tpl'); + $o = ''; if($arr['tabs']) { - return replace_macros($tpl, [ + $content = replace_macros(get_markup_template('common_pills.tpl'), [ + '$pills' => $arr['tabs'], + ]); + + $o .= replace_macros(get_markup_template('activity_filter_widget.tpl'), [ '$title' => t('Activity Filters'), - '$tabs' => $arr['tabs'], + '$reset' => $reset, + '$content' => $content, ]); } - else { - return ''; - } + + return $o; + } } diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php index 10ec142d9..93bfc5a26 100644 --- a/Zotlabs/Widget/Activity_order.php +++ b/Zotlabs/Widget/Activity_order.php @@ -105,17 +105,21 @@ class Activity_order { call_hooks('network_tabs', $arr); - $tpl = get_markup_template('common_pills.tpl'); + $o = ''; if($arr['tabs']) { - return replace_macros($tpl, [ + $content = replace_macros(get_markup_template('common_pills.tpl'), [ + '$pills' => $arr['tabs'], + ]); + + $o = replace_macros(get_markup_template('common_widget.tpl'), [ '$title' => t('Activity Order'), - '$tabs' => $arr['tabs'], + '$content' => $content, ]); } - else { - return ''; - } + + return $o; + } } -- cgit v1.2.3 From ec6d4f8ac34e584f07606a65a911e8b2bc8554f8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Jun 2018 13:30:02 +0200 Subject: add hover effect to dropdown caret --- Zotlabs/Widget/Activity_order.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php index 93bfc5a26..534d6caee 100644 --- a/Zotlabs/Widget/Activity_order.php +++ b/Zotlabs/Widget/Activity_order.php @@ -84,18 +84,21 @@ class Activity_order { $tabs[] = [ 'label' => t('Commented Date'), + 'icon' => '', 'url'=>z_root() . '/' . $cmd . '?f=&order=comment' . $filter, 'sel'=> $commentord_active, 'title' => t('Order by last commented date'), ]; $tabs[] = [ 'label' => t('Posted Date'), + 'icon' => '', 'url'=>z_root() . '/' . $cmd . '?f=&order=post' . $filter, 'sel'=> $postord_active, 'title' => t('Order by last posted date'), ]; $tabs[] = array( 'label' => t('Date Unthreaded'), + 'icon' => '', 'url' => z_root() . '/' . $cmd . '?f=&order=unthreaded' . $filter, 'sel' => $unthreaded_active, 'title' => t('Order unthreaded by date'), -- cgit v1.2.3 From 56f0244360462d96e2737ca4407feb7909c170d8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Jun 2018 20:59:28 +0200 Subject: fixes for css fix --- Zotlabs/Widget/Activity_filter.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 18207b37b..38e45ea29 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -111,6 +111,13 @@ class Activity_filter { if(x($_GET,'search')) { $filter_active = 'search'; + $tabs[] = [ + 'label' => t('Search'), + 'icon' => 'search', + 'url' => z_root() . '/' . $cmd . '/?f=&search=' . $_GET['search'], + 'sel' => 'active disabled', + 'title' => t('Panel search'), + ]; } $reset = []; -- cgit v1.2.3 From 22a9e4c9a9e4a48f644deed0432dc05a7e5b189c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Jun 2018 21:52:54 +0200 Subject: add manage privacy groups entry to the panel channel menu dropdown for now --- Zotlabs/Widget/Forums.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index 7415c0f0a..f3141031d 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -27,6 +27,8 @@ class Forums { $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", intval(local_channel()) ); +//print_r($x1);killme(); + if($x1) { $xc = ids_to_querystr($x1,'xchan',true); -- cgit v1.2.3 From 53efd4e470f10e123209ed63b90213b20a87e011 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Jun 2018 23:22:52 +0200 Subject: unread forum notifications - wip/unfinished --- Zotlabs/Module/Ping.php | 61 ++++++++++++++++++++++++++++++++++++++++ Zotlabs/Widget/Forums.php | 2 -- Zotlabs/Widget/Notifications.php | 15 ++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index bb80adc41..a43d9863e 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -39,6 +39,7 @@ class Ping extends \Zotlabs\Web\Controller { $result['info'] = array(); $result['pubs'] = 0; $result['files'] = 0; + $result['forums'] = 0; if(! $_SESSION['static_loadtime']) $_SESSION['static_loadtime'] = datetime_convert(); @@ -622,6 +623,66 @@ class Ping extends \Zotlabs\Web\Controller { if(! ($vnotify & VNOTIFY_BIRTHDAY)) $result['birthdays'] = 0; + + +#### unseen forum + + $perms_sql = item_permissions_sql(local_channel()) . item_normal(); + + $xf = false; + + $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", + intval(local_channel()) + ); + if($x1) { + $xc = ids_to_querystr($x1,'xchan',true); + + $x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = '1' and xchan in (" . $xc . ") ", + intval(local_channel()) + ); + + if($x2) { + $xf = ids_to_querystr($x2,'xchan',true); + + // private forums + $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", + intval(local_channel()) + ); + if($x3) { + $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); + } + } + } + + $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); + + $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 $sql_extra order by xchan_name", + intval(local_channel()) + ); + + if(! $r1) { + $result['forums'] = 0; + } + else { + $fcount = count($r1); + $r1['total'] = 0; + for($x = 0; $x < $fcount; $x ++) { + $r = q("select sum(item_unseen) as unseen from item + where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", + intval(local_channel()), + dbesc($r1[$x]['xchan_hash']) + ); + if($r[0]['unseen']) { + $r1[$x]['unseen'] = $r[0]['unseen']; + $r1['total'] = $r1['total'] + $r[0]['unseen']; + } + else { + unset($r1[$x]); + } + } + $result['forums'] = $r1['total']; + } + $x = json_encode($result); $t8 = dba_timer(); diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index f3141031d..7415c0f0a 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -27,8 +27,6 @@ class Forums { $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", intval(local_channel()) ); -//print_r($x1);killme(); - if($x1) { $xc = ids_to_querystr($x1,'xchan',true); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index fc78a2a39..1be467ba6 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -111,6 +111,21 @@ class Notifications { 'label' => t('Mark all notices seen') ] ]; + + $notifications[] = [ + 'type' => 'forums', + 'icon' => 'comments-o', + 'severity' => 'secondary', + 'label' => t('Forums'), + 'title' => t('Forums'), + 'viewall' => [ + //'url' => 'notifications/system', + //'label' => t('View all notices') + ], + 'markall' => [ + //'label' => t('Mark all notices seen') + ] + ]; } if(local_channel() && is_site_admin()) { -- cgit v1.2.3 From db0a3a753420e8722776094334759dd4ff61fc77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 2 Jun 2018 15:39:38 +0200 Subject: some more work on forum notifications --- Zotlabs/Module/Ping.php | 13 +++++++++++++ Zotlabs/Widget/Notifications.php | 8 ++------ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a43d9863e..941b7b286 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -673,14 +673,27 @@ class Ping extends \Zotlabs\Web\Controller { dbesc($r1[$x]['xchan_hash']) ); if($r[0]['unseen']) { + $r1[$x]['notify_link'] = z_root() . '/network/?f=&cid=' . $r1[$x]['abook_id']; + $r1[$x]['name'] = $r1[$x]['xchan_name']; + $r1[$x]['url'] = $r1[$x]['xchan_url']; + $r1[$x]['photo'] = $r1[$x]['xchan_photo_s']; $r1[$x]['unseen'] = $r[0]['unseen']; $r1['total'] = $r1['total'] + $r[0]['unseen']; + + unset($r1[$x]['abook_id']); + unset($r1[$x]['xchan_hash']); + unset($r1[$x]['xchan_name']); + unset($r1[$x]['xchan_url']); + unset($r1[$x]['xchan_photo_s']); } else { unset($r1[$x]); } } $result['forums'] = $r1['total']; + unset($r1['total']); + + $result['forums_sub'] = $r1; } $x = json_encode($result); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 1be467ba6..a4cf4e706 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -118,12 +118,8 @@ class Notifications { 'severity' => 'secondary', 'label' => t('Forums'), 'title' => t('Forums'), - 'viewall' => [ - //'url' => 'notifications/system', - //'label' => t('View all notices') - ], - 'markall' => [ - //'label' => t('Mark all notices seen') + 'filter' => [ + 'name_label' => t('Filter by name') ] ]; } -- cgit v1.2.3 From 8189408190333b4f6ac45f98623be0d1db8b9462 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 2 Jun 2018 22:11:11 +0200 Subject: finalize filters and forum notifications --- Zotlabs/Module/Ping.php | 109 ++++++++++++++---------------------- Zotlabs/Module/Settings/Channel.php | 3 + Zotlabs/Widget/Activity_filter.php | 48 +++++++++++++--- 3 files changed, 86 insertions(+), 74 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 941b7b286..3f2015d6d 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -35,11 +35,12 @@ class Ping extends \Zotlabs\Web\Controller { $result['birthdays_today'] = 0; $result['all_events'] = 0; $result['all_events_today'] = 0; - $result['notice'] = array(); - $result['info'] = array(); + $result['notice'] = []; + $result['info'] = []; $result['pubs'] = 0; $result['files'] = 0; $result['forums'] = 0; + $result['forums_sub'] = []; if(! $_SESSION['static_loadtime']) $_SESSION['static_loadtime'] = datetime_convert(); @@ -625,75 +626,51 @@ class Ping extends \Zotlabs\Web\Controller { -#### unseen forum + if($vnotify & VNOTIFY_FORUMS) { + $forums = get_forum_channels(local_channel()); - $perms_sql = item_permissions_sql(local_channel()) . item_normal(); - - $xf = false; - - $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", - intval(local_channel()) - ); - if($x1) { - $xc = ids_to_querystr($x1,'xchan',true); - - $x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = '1' and xchan in (" . $xc . ") ", - intval(local_channel()) - ); - - if($x2) { - $xf = ids_to_querystr($x2,'xchan',true); - - // private forums - $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", - intval(local_channel()) - ); - if($x3) { - $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); - } + if(! $forums) { + $result['forums'] = 0; } - } - - $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); - - $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 $sql_extra order by xchan_name", - intval(local_channel()) - ); + else { + $fcount = count($forums); + $forums['total'] = 0; + for($x = 0; $x < $fcount; $x ++) { + $r = q("select sum(item_unseen) as unseen from item + where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", + intval(local_channel()), + 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=&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']; + $forums[$x]['unseen'] = $r[0]['unseen']; + $forums[$x]['private_forum'] = (($forums[$x]['private_forum']) ? 'lock' : ''); + $forums[$x]['message'] = (($forums[$x]['private_forum']) ? t('Private forum') : t('Public forum')); + + $forums['total'] = $forums['total'] + $r[0]['unseen']; + + unset($forums[$x]['abook_id']); + unset($forums[$x]['xchan_hash']); + unset($forums[$x]['xchan_name']); + unset($forums[$x]['xchan_url']); + unset($forums[$x]['xchan_photo_s']); + + //if($forums[$x]['private_forum']) + // unset($forums[$x]['private_forum']); - if(! $r1) { - $result['forums'] = 0; - } - else { - $fcount = count($r1); - $r1['total'] = 0; - for($x = 0; $x < $fcount; $x ++) { - $r = q("select sum(item_unseen) as unseen from item - where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", - intval(local_channel()), - dbesc($r1[$x]['xchan_hash']) - ); - if($r[0]['unseen']) { - $r1[$x]['notify_link'] = z_root() . '/network/?f=&cid=' . $r1[$x]['abook_id']; - $r1[$x]['name'] = $r1[$x]['xchan_name']; - $r1[$x]['url'] = $r1[$x]['xchan_url']; - $r1[$x]['photo'] = $r1[$x]['xchan_photo_s']; - $r1[$x]['unseen'] = $r[0]['unseen']; - $r1['total'] = $r1['total'] + $r[0]['unseen']; - - unset($r1[$x]['abook_id']); - unset($r1[$x]['xchan_hash']); - unset($r1[$x]['xchan_name']); - unset($r1[$x]['xchan_url']); - unset($r1[$x]['xchan_photo_s']); - } - else { - unset($r1[$x]); + } + else { + unset($forums[$x]); + } } - } - $result['forums'] = $r1['total']; - unset($r1['total']); + $result['forums'] = $forums['total']; + unset($forums['total']); - $result['forums_sub'] = $r1; + $result['forums_sub'] = $forums; + } } $x = json_encode($result); diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index beb62a3a3..3a6e03588 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -215,6 +215,8 @@ class Channel { $vnotify += intval($_POST['vnotify13']); if(x($_POST,'vnotify14')) $vnotify += intval($_POST['vnotify14']); + if(x($_POST,'vnotify15')) + $vnotify += intval($_POST['vnotify15']); $always_show_in_notices = x($_POST,'always_show_in_notices') ? 1 : 0; @@ -599,6 +601,7 @@ class Channel { '$vnotify12' => array('vnotify12', t('Unseen shared files'), ($vnotify & VNOTIFY_FILES), VNOTIFY_FILES, '', $yes_no), '$vnotify13' => (($disable_discover_tab && !$site_firehose) ? array() : array('vnotify13', t('Unseen public activity'), ($vnotify & VNOTIFY_PUBS), VNOTIFY_PUBS, '', $yes_no)), '$vnotify14' => array('vnotify14', t('Unseen likes and dislikes'), ($vnotify & VNOTIFY_LIKE), VNOTIFY_LIKE, '', $yes_no), + '$vnotify15' => array('vnotify15', t('Unseen forum posts'), ($vnotify & VNOTIFY_FORUMS), VNOTIFY_FORUMS, '', $yes_no), '$mailhost' => [ 'mailhost', t('Email notification hub (hostname)'), get_pconfig(local_channel(),'system','email_notify_host',\App::get_hostname()), sprintf( t('If your channel is mirrored to multiple hubs, set this to your preferred location. This will prevent duplicate email notifications. Example: %s'),\App::get_hostname()) ], '$always_show_in_notices' => array('always_show_in_notices', t('Show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 38e45ea29..6a1ad6f0a 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -25,7 +25,7 @@ class Activity_filter { 'icon' => 'user-circle', 'url' => z_root() . '/' . $cmd . '/?f=&conv=1', 'sel' => $conv_active, - 'title' => t('Show posts that mention or involve me'), + 'title' => t('Show posts that mention or involve me') ]; } @@ -40,7 +40,7 @@ class Activity_filter { 'icon' => 'star', 'url'=>z_root() . '/' . $cmd . '/?f=&star=1', 'sel'=>$starred_active, - 'title' => t('Show posts that i have starred'), + 'title' => t('Show posts that i have starred') ]; } @@ -60,7 +60,7 @@ class Activity_filter { 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], 'sel' => $group_active, - 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']), + 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']) ]; } $tabs[] = [ @@ -93,7 +93,7 @@ class Activity_filter { 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], 'sel' => $file_active, - 'title' => '', + 'title' => '' ]; } @@ -109,6 +109,38 @@ class Activity_filter { } } + if(feature_enabled(local_channel(),'forums_tab')) { + $forums = get_forum_channels(local_channel()); + + if($forums) { + foreach($forums as $f) { + if(x($_GET,'cid')) { + $forum_active = (($_GET['cid'] == $f['abook_id']) ? 'active' : ''); + $filter_active = 'forums'; + } + $fsub[] = [ + 'label' => $f['xchan_name'], + 'img' => $f['xchan_photo_s'], + 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&cid=' . $f['abook_id']), + 'sel' => $forum_active, + 'title' => t('Private forum'), + 'lock' => (($f['private_forum']) ? 'lock' : '') + ]; + } + + $tabs[] = [ + 'label' => t('Forums'), + 'icon' => 'comments-o', + 'url' => '#', + 'sel' => (($filter_active == 'forums') ? true : false), + 'title' => t('Show this forums posts'), + 'sub' => $fsub + + ]; + } + } + + if(x($_GET,'search')) { $filter_active = 'search'; $tabs[] = [ @@ -116,7 +148,7 @@ class Activity_filter { 'icon' => 'search', 'url' => z_root() . '/' . $cmd . '/?f=&search=' . $_GET['search'], 'sel' => 'active disabled', - 'title' => t('Panel search'), + 'title' => t('Panel search') ]; } @@ -127,7 +159,7 @@ class Activity_filter { 'icon' => 'remove', 'url'=> z_root() . '/' . $cmd, 'sel'=> '', - 'title' => t('Remove active filter'), + 'title' => t('Remove active filter') ]; } @@ -139,13 +171,13 @@ class Activity_filter { if($arr['tabs']) { $content = replace_macros(get_markup_template('common_pills.tpl'), [ - '$pills' => $arr['tabs'], + '$pills' => $arr['tabs'] ]); $o .= replace_macros(get_markup_template('activity_filter_widget.tpl'), [ '$title' => t('Activity Filters'), '$reset' => $reset, - '$content' => $content, + '$content' => $content ]); } -- cgit v1.2.3 From 2438af1cb5d8c4d439dae315bffb8eaeb5c153a5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Jun 2018 00:16:46 +0200 Subject: the pf argument is required here for some functionality in /network --- Zotlabs/Widget/Activity_filter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index f9993759c..07389f2bc 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -40,7 +40,7 @@ class Activity_filter { 'icon' => 'star', 'url'=>z_root() . '/' . $cmd . '/?f=&star=1', 'sel'=>$starred_active, - 'title' => t('Show posts that i have starred') + 'title' => t('Show posts that I have starred') ]; } @@ -69,7 +69,7 @@ class Activity_filter { 'icon' => 'users', 'url' => '#', 'sel' => (($filter_active == 'group') ? true : false), - 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + 'title' => sprintf(t('Show posts that I have filed to %s'), $t['term']), 'sub' => $gsub ]; @@ -121,7 +121,7 @@ class Activity_filter { $fsub[] = [ 'label' => $f['xchan_name'], 'img' => $f['xchan_photo_s'], - 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&cid=' . $f['abook_id']), + 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), 'sel' => $forum_active, 'title' => t('Private forum'), 'lock' => (($f['private_forum']) ? 'lock' : '') -- cgit v1.2.3 From a42ff1e6d40496cc93481312b47548200e8af380 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Jun 2018 13:27:06 +0200 Subject: missing $perm_sql --- Zotlabs/Module/Ping.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 3f2015d6d..d95df34a0 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -633,8 +633,11 @@ class Ping extends \Zotlabs\Web\Controller { $result['forums'] = 0; } else { + + $perms_sql = item_permissions_sql(local_channel()) . item_normal(); $fcount = count($forums); $forums['total'] = 0; + for($x = 0; $x < $fcount; $x ++) { $r = q("select sum(item_unseen) as unseen from item where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", @@ -642,7 +645,7 @@ class Ping extends \Zotlabs\Web\Controller { 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=&cid=' . $forums[$x]['abook_id']); + $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&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']; -- cgit v1.2.3 From 3d3e7bafd5821a200d2e2cc54463d6f16f5c5f15 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Jun 2018 17:31:50 +0200 Subject: distinct is needed or it can heavily impact pagination in certain situations (5 per page instead of 20). Add ordering to the select clause to mitigate errors in postgres and add item_thread_top = 1 for slightly better performance. --- Zotlabs/Module/Channel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 6969b6226..80e81580a 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -282,13 +282,13 @@ class Channel extends \Zotlabs\Web\Controller { } } else { - $r = q("SELECT item.parent AS item_id FROM item + $r = q("SELECT DISTINCT item.parent AS item_id, $ordering FROM item left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) WHERE true and item.uid = %d $item_normal AND (abook.abook_blocked = 0 or abook.abook_flags is null) - AND item.item_wall = 1 + AND item.item_wall = 1 AND item.item_thread_top = 1 $sql_extra $sql_extra2 - ORDER BY $ordering DESC, id $pager_sql ", + ORDER BY $ordering DESC $pager_sql ", intval(\App::$profile['profile_uid']) ); } -- cgit v1.2.3 From 8b76b5a0a6f6784f9d97332cc93b395504f6f527 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Jun 2018 23:03:30 +0200 Subject: improve network cid query --- Zotlabs/Module/Network.php | 46 ++++++++++++++++++-------------------- Zotlabs/Widget/Activity_filter.php | 4 ++-- 2 files changed, 24 insertions(+), 26 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 8a381d678..013e9b763 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -143,11 +143,12 @@ class Network extends \Zotlabs\Web\Controller { $nouveau = true; if($cid) { - $r = q("SELECT abook_xchan, xchan_addr, xchan_url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + $cid_r = q("SELECT abook.abook_xchan, xchan.xchan_addr, xchan.xchan_name, xchan.xchan_url, xchan.xchan_photo_s, xchan.xchan_pubforum from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", intval($cid), intval(local_channel()) ); - if(! $r) { + + if(! $cid_r) { if($update) { killme(); } @@ -156,9 +157,9 @@ class Network extends \Zotlabs\Web\Controller { // NOTREACHED } if($_GET['pf'] === '1') - $deftag = '!{' . (($r[0]['xchan_addr']) ? $r[0]['xchan_addr'] : $r[0]['xchan_url']) . '}'; + $deftag = '!{' . (($cid_r[0]['xchan_addr']) ? $cid_r[0]['xchan_addr'] : $cid_r[0]['xchan_url']) . '}'; else - $def_acl = [ 'allow_cid' => '<' . $r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; + $def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } if(! $update) { @@ -240,6 +241,7 @@ 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); @@ -255,27 +257,23 @@ class Network extends \Zotlabs\Web\Controller { $o .= $status_editor; } - - elseif($cid) { - - $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", - intval($cid), - intval(local_channel()) - ); - if($r) { - $item_thread_top = ''; - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or (body like '" . protect_sprintf('%' . $r[0]['xchan_url'] . '%') . "' and item_thread_top = 1 )) $item_normal ) "; - $title = replace_macros(get_markup_template("section_title.tpl"),array( - '$title' => '' . urlencode($r[0]['xchan_name']) . ' ' . $r[0]['xchan_name'] . '' - )); - $o = $tabs; - $o .= $title; - $o .= $status_editor; - } - else { - notice( t('Invalid connection.') . EOL); - goaway(z_root() . '/network'); + elseif($cid_r) { + $item_thread_top = ''; + + if($load || $update) { + $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 ORDER BY created DESC"); + $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); + $p_str = ids_to_querystr(array_merge($p1,$p2),'parent'); + $sql_extra = " AND item.parent IN ( $p_str ) "; } + + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => '' . urlencode($cid_r[0]['xchan_name']) . ' ' . $cid_r[0]['xchan_name'] . '' + )); + + $o = $tabs; + $o .= $title; + $o .= $status_editor; } elseif($xchan) { $r = q("select * from xchan where xchan_hash = '%s'", diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 07389f2bc..672225ef1 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -114,8 +114,8 @@ class Activity_filter { if($forums) { foreach($forums as $f) { - if(x($_GET,'cid')) { - $forum_active = (($_GET['cid'] == $f['abook_id']) ? 'active' : ''); + if(x($_GET,'pf') && x($_GET,'cid')) { + $forum_active = ((x($_GET,'pf') && $_GET['cid'] == $f['abook_id']) ? 'active' : ''); $filter_active = 'forums'; } $fsub[] = [ -- cgit v1.2.3 From dd9f7ef6e926cb53f68216f58769552a6355993c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Jun 2018 23:14:01 -0700 Subject: fix submenunavigation on activity filters --- Zotlabs/Widget/Activity_filter.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 672225ef1..36e24342d 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -89,6 +89,7 @@ class Activity_filter { $filter_active = 'file'; } $tsub[] = [ + 'id' => 'saved_folders', 'label' => $t['term'], 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], @@ -119,6 +120,7 @@ class Activity_filter { $filter_active = 'forums'; } $fsub[] = [ + 'id' => 'forums', 'label' => $f['xchan_name'], 'img' => $f['xchan_photo_s'], 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), -- cgit v1.2.3 From 57231a88076289c5dbeff70c9b92dbbe2bcefd8d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Jun 2018 23:16:40 -0700 Subject: wrong level --- Zotlabs/Widget/Activity_filter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 36e24342d..18d81d8e3 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -89,7 +89,6 @@ class Activity_filter { $filter_active = 'file'; } $tsub[] = [ - 'id' => 'saved_folders', 'label' => $t['term'], 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], @@ -99,6 +98,7 @@ class Activity_filter { } $tabs[] = [ + 'id' => 'saved_folders', 'label' => t('Saved Folders'), 'icon' => 'folder', 'url' => '#', @@ -120,7 +120,6 @@ class Activity_filter { $filter_active = 'forums'; } $fsub[] = [ - 'id' => 'forums', 'label' => $f['xchan_name'], 'img' => $f['xchan_photo_s'], 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), @@ -131,6 +130,7 @@ class Activity_filter { } $tabs[] = [ + 'id' => 'forums', 'label' => t('Forums'), 'icon' => 'comments-o', 'url' => '#', -- cgit v1.2.3 From 5a9e6c8a695f0adac35baf2d63f58fb27424140f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Jun 2018 23:38:03 -0700 Subject: sort out some mismatched hovertips on the activity filter --- Zotlabs/Widget/Activity_filter.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 18d81d8e3..32da20bf6 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -69,7 +69,7 @@ class Activity_filter { 'icon' => 'users', 'url' => '#', 'sel' => (($filter_active == 'group') ? true : false), - 'title' => sprintf(t('Show posts that I have filed to %s'), $t['term']), + 'title' => t('Show my privacy groups'), 'sub' => $gsub ]; @@ -93,7 +93,7 @@ class Activity_filter { 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], 'sel' => $file_active, - 'title' => '' + 'title' => sprintf(t('Show posts that I have filed to %s'), $t['term']), ]; } @@ -103,7 +103,7 @@ class Activity_filter { 'icon' => 'folder', 'url' => '#', 'sel' => (($filter_active == 'file') ? true : false), - 'title' => sprintf(t('Show posts that I have filed to %s'), $t['term']), + 'title' => t('Show filed post categories'), 'sub' => $tsub ]; @@ -124,7 +124,7 @@ class Activity_filter { 'img' => $f['xchan_photo_s'], 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), 'sel' => $forum_active, - 'title' => t('Private forum'), + 'title' => t('Show posts to this forum'), 'lock' => (($f['private_forum']) ? 'lock' : '') ]; } @@ -135,7 +135,7 @@ class Activity_filter { 'icon' => 'comments-o', 'url' => '#', 'sel' => (($filter_active == 'forums') ? true : false), - 'title' => t('Show this forums posts'), + 'title' => t('Show forums'), 'sub' => $fsub ]; -- cgit v1.2.3 From 6019a34da2184519bc535fa771b30695d9580b92 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Jun 2018 15:54:18 +0200 Subject: be specific about the term type and do not sort the results --- Zotlabs/Module/Network.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 013e9b763..1ab94eff4 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -261,8 +261,11 @@ class Network extends \Zotlabs\Web\Controller { $item_thread_top = ''; if($load || $update) { - $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 ORDER BY created DESC"); - $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); + $ttype = (($cid_r[0]['xchan_pubforum']) ? 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'); $sql_extra = " AND item.parent IN ( $p_str ) "; } -- cgit v1.2.3 From 7188e719eff137c3a0b47824de97245832441a20 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 5 Jun 2018 11:56:30 +0200 Subject: rely on the pf argument to determine if we deal with a forum or not. xchan_pubforum is not set for all public forums in the forum filters for some reason. --- Zotlabs/Module/Network.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 1ab94eff4..6a24b9453 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -136,6 +136,7 @@ class Network extends \Zotlabs\Web\Controller { $file = ((x($_GET,'file')) ? $_GET['file'] : ''); $xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : ''); $net = ((x($_GET,'net')) ? $_GET['net'] : ''); + $pf = ((x($_GET,'pf')) ? $_GET['pf'] : ''); $deftag = ''; @@ -156,7 +157,7 @@ class Network extends \Zotlabs\Web\Controller { goaway(z_root() . '/network'); // NOTREACHED } - if($_GET['pf'] === '1') + if($pf) $deftag = '!{' . (($cid_r[0]['xchan_addr']) ? $cid_r[0]['xchan_addr'] : $cid_r[0]['xchan_url']) . '}'; else $def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; @@ -261,7 +262,7 @@ class Network extends \Zotlabs\Web\Controller { $item_thread_top = ''; if($load || $update) { - $ttype = (($cid_r[0]['xchan_pubforum']) ? TERM_FORUM : TERM_MENTION); + $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']) . "'"); @@ -350,7 +351,8 @@ class Network extends \Zotlabs\Web\Controller { '$mid' => '', '$verb' => $verb, '$net' => $net, - '$dbegin' => $datequery2 + '$dbegin' => $datequery2, + '$pf' => (($pf) ? $pf : '0'), )); } -- cgit v1.2.3 From d6f98ab88ec147b317bc9266395320e9cc64329a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 5 Jun 2018 21:12:42 -0700 Subject: some work to make menus editable by visitors with webpage write permissions; this needed to revise the link structure so that the page specified an owner channel in the url. Otherwise we could only operate on menus owned by local_channel(). Have done some basic regression testing but have not yet fully tested guest editing functionality. --- Zotlabs/Module/Menu.php | 117 ++++++++++++++++++++++++++++++++++++----------- Zotlabs/Module/Mitem.php | 99 ++++++++++++++++++++++----------------- 2 files changed, 149 insertions(+), 67 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Menu.php b/Zotlabs/Module/Menu.php index 1dec65c1f..1687a4414 100644 --- a/Zotlabs/Module/Menu.php +++ b/Zotlabs/Module/Menu.php @@ -7,18 +7,36 @@ require_once('include/channel.php'); class Menu extends \Zotlabs\Web\Controller { + function init() { - if (array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { + + if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) { $sys = get_sys_channel(); - if ($sys && intval($sys['channel_id'])) { + if($sys && intval($sys['channel_id'])) { \App::$is_sys = true; } } + + if(argc() > 1) + $which = argv(1); + else + return; + + profile_load($which); + } + - function post() { + function post() { - $uid = local_channel(); + if(! \App::$profile) { + return; + } + + $which = argv(1); + + + $uid = \App::$profile['channel_id']; if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { $sys = get_sys_channel(); @@ -43,7 +61,7 @@ class Menu extends \Zotlabs\Web\Controller { if($r) { menu_sync_packet($uid,get_observer_hash(),$menu_id); //info( t('Menu updated.') . EOL); - goaway(z_root() . '/mitem/' . $menu_id . ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/mitem/' . $which . '/' . $menu_id . ((\App::$is_sys) ? '?f=&sys=1' : '')); } else notice( t('Unable to update menu.'). EOL); @@ -54,7 +72,7 @@ class Menu extends \Zotlabs\Web\Controller { menu_sync_packet($uid,get_observer_hash(),$r); //info( t('Menu created.') . EOL); - goaway(z_root() . '/mitem/' . $r . ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/mitem/' . $which . '/' . $r . ((\App::$is_sys) ? '?f=&sys=1' : '')); } else notice( t('Unable to create menu.'). EOL); @@ -67,27 +85,71 @@ class Menu extends \Zotlabs\Web\Controller { function get() { + + + if(! \App::$profile) { + notice( t('Requested profile is not available.') . EOL ); + \App::$error = 404; + return; + } + + $which = argv(1); + + $_SESSION['return_url'] = \App::$query_string; + $uid = local_channel(); - - if (\App::$is_sys && is_site_admin()) { + $owner = 0; + $channel = null; + $observer = \App::get_observer(); + + $channel = \App::get_channel(); + + if(\App::$is_sys && is_site_admin()) { $sys = get_sys_channel(); - $uid = intval($sys['channel_id']); + if($sys && intval($sys['channel_id'])) { + $uid = $owner = intval($sys['channel_id']); + $channel = $sys; + $observer = $sys; + } } - - if(! $uid) { + + if(! $owner) { + // Figure out who the page owner is. + $r = channelx_by_nick($which); + if($r) { + $owner = intval($r['channel_id']); + } + } + + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + + $perms = get_all_perms($owner,$ob_hash); + + if(! $perms['write_pages']) { notice( t('Permission denied.') . EOL); - return ''; + return; } + + // Get the observer, check their permissions + + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + + $perms = get_all_perms($owner,$ob_hash); + + if(! $perms['write_pages']) { + notice( t('Permission denied.') . EOL); + return; + } + + if(argc() == 2) { - if(argc() == 1) { - - $channel = (($sys) ? $sys : \App::get_channel()); + $channel = (($sys) ? $sys : channelx_by_n($owner)); // list menus - $x = menu_list($uid); + $x = menu_list($owner); if($x) { for($y = 0; $y < count($x); $y ++) { - $m = menu_fetch($x[$y]['menu_name'],$uid,get_observer_hash()); + $m = menu_fetch($x[$y]['menu_name'],$owner,get_observer_hash()); if($m) $x[$y]['element'] = '[element]' . base64url_encode(json_encode(menu_element($channel,$m))) . '[/element]'; $x[$y]['bookmark'] = (($x[$y]['menu_flags'] & MENU_BOOKMARK) ? true : false); @@ -100,6 +162,7 @@ class Menu extends \Zotlabs\Web\Controller { '$menu_bookmark' => array('menu_bookmark', t('Allow Bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), '$submit' => t('Submit and proceed'), '$sys' => \App::$is_sys, + '$nick' => $which, '$display' => 'none' )); @@ -119,6 +182,7 @@ class Menu extends \Zotlabs\Web\Controller { '$hintdrop' => t('Delete this menu'), '$hintcontent' => t('Edit menu contents'), '$hintedit' => t('Edit this menu'), + '$nick' => $which, '$sys' => \App::$is_sys )); @@ -126,19 +190,19 @@ class Menu extends \Zotlabs\Web\Controller { } - if(argc() > 1) { - if(intval(argv(1))) { + if(argc() > 2) { + if(intval(argv(2))) { - if(argc() == 3 && argv(2) == 'drop') { - menu_sync_packet($uid,get_observer_hash(),intval(argv(1)),true); - $r = menu_delete_id(intval(argv(1)),$uid); + if(argc() == 4 && argv(3) == 'drop') { + menu_sync_packet($owner,get_observer_hash(),intval(argv(1)),true); + $r = menu_delete_id(intval(argv(2)),$owner); if(!$r) notice( t('Menu could not be deleted.'). EOL); - goaway(z_root() . '/menu' . ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/menu/' . $which . ((\App::$is_sys) ? '?f=&sys=1' : '')); } - $m = menu_fetch_id(intval(argv(1)),$uid); + $m = menu_fetch_id(intval(argv(2)),$owner); if(! $m) { notice( t('Menu not found.') . EOL); @@ -148,14 +212,15 @@ class Menu extends \Zotlabs\Web\Controller { $o = replace_macros(get_markup_template('menuedit.tpl'), array( '$header' => t('Edit Menu'), '$sys' => \App::$is_sys, - '$menu_id' => intval(argv(1)), - '$menu_edit_link' => 'mitem/' . intval(argv(1)) . ((\App::$is_sys) ? '?f=&sys=1' : ''), + '$menu_id' => intval(argv(2)), + '$menu_edit_link' => 'mitem/' . $which . '/' . intval(argv(1)) . ((\App::$is_sys) ? '?f=&sys=1' : ''), '$hintedit' => t('Add or remove entries to this menu'), '$editcontents' => t('Edit menu contents'), '$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'), '$menu_desc' => array('menu_desc', t('Menu title'), $m['menu_desc'], t('Menu title as seen by others'), ''), '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), (($m['menu_flags'] & MENU_BOOKMARK) ? 1 : 0), t('Menu may be used to store saved bookmarks'), array(t('No'), t('Yes'))), '$menu_system' => (($m['menu_flags'] & MENU_SYSTEM) ? 1 : 0), + '$nick' => $which, '$submit' => t('Submit and proceed') )); diff --git a/Zotlabs/Module/Mitem.php b/Zotlabs/Module/Mitem.php index 28f51b81b..ac7470e13 100644 --- a/Zotlabs/Module/Mitem.php +++ b/Zotlabs/Module/Mitem.php @@ -8,22 +8,25 @@ require_once('include/acl_selectors.php'); class Mitem extends \Zotlabs\Web\Controller { function init() { - - $uid = local_channel(); - - if(array_key_exists('sys',$_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { + + if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) { $sys = get_sys_channel(); - $uid = intval($sys['channel_id']); - \App::$is_sys = true; + if($sys && intval($sys['channel_id'])) { + \App::$is_sys = true; + } } - - if(! $uid) + + if(argc() > 1) + $which = argv(1); + else return; + + profile_load($which); - if(argc() < 2) + if(argc() < 3) return; - $m = menu_fetch_id(intval(argv(1)),$uid); + $m = menu_fetch_id(intval(argv(2)),\App::$profile['channel_id']); if(! $m) { notice( t('Menu not found.') . EOL); return ''; @@ -32,19 +35,27 @@ class Mitem extends \Zotlabs\Web\Controller { } - function post() { + function post() { - $uid = local_channel(); + if(! \App::$profile) { + return; + } + + $which = argv(1); + + + $uid = \App::$profile['channel_id']; - if(\App::$is_sys && is_site_admin()) { + if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { $sys = get_sys_channel(); $uid = intval($sys['channel_id']); + \App::$is_sys = true; } - if(! $uid) { + if(! $uid) return; - } - + + if(! \App::$data['menu']) return; @@ -63,14 +74,14 @@ class Mitem extends \Zotlabs\Web\Controller { $_REQUEST['mitem_flags'] |= MENU_ITEM_NEWWIN; - $mitem_id = ((argc() > 2) ? intval(argv(2)) : 0); + $mitem_id = ((argc() > 3) ? intval(argv(3)) : 0); if($mitem_id) { $_REQUEST['mitem_id'] = $mitem_id; $r = menu_edit_item($_REQUEST['menu_id'],$uid,$_REQUEST); if($r) { menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); //info( t('Menu element updated.') . EOL); - goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/mitem/' . $which . '/' . $_REQUEST['menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); } else notice( t('Unable to update menu element.') . EOL); @@ -82,10 +93,10 @@ class Mitem extends \Zotlabs\Web\Controller { menu_sync_packet($uid,get_observer_hash(),$_REQUEST['menu_id']); //info( t('Menu element added.') . EOL); if($_REQUEST['submit']) { - goaway(z_root() . '/menu' . ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/menu/' . $which . ((\App::$is_sys) ? '?f=&sys=1' : '')); } if($_REQUEST['submit-more']) { - goaway(z_root() . '/mitem/' . $_REQUEST['menu_id'] . '?f=&display=block' . ((\App::$is_sys) ? '&sys=1' : '') ); + goaway(z_root() . '/mitem/' . $which . '/' . $_REQUEST['menu_id'] . '?f=&display=block' . ((\App::$is_sys) ? '&sys=1' : '') ); } } else @@ -96,12 +107,15 @@ class Mitem extends \Zotlabs\Web\Controller { } - function get() { + function get() { $uid = local_channel(); - $channel = \App::get_channel(); + $owner = \App::$profile['channel_id']; + $channel = channelx_by_n($owner); $observer = \App::get_observer(); - + + $which = argv(1); + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); if(\App::$is_sys && is_site_admin()) { @@ -116,15 +130,15 @@ class Mitem extends \Zotlabs\Web\Controller { return ''; } - if(argc() < 2 || (! \App::$data['menu'])) { + if(argc() < 3 || (! \App::$data['menu'])) { notice( t('Not found.') . EOL); return ''; } - $m = menu_fetch(\App::$data['menu']['menu_name'],$uid,$ob_hash); + $m = menu_fetch(\App::$data['menu']['menu_name'],$owner,$ob_hash); \App::$data['menu_item'] = $m; - $menu_list = menu_list($uid); + $menu_list = menu_list($owner); foreach($menu_list as $menus) { if($menus['menu_name'] != $m['menu']['menu_name']) @@ -135,10 +149,10 @@ class Mitem extends \Zotlabs\Web\Controller { $lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'); - if(argc() == 2) { + if(argc() == 3) { $r = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d order by mitem_order asc, mitem_desc asc", intval(\App::$data['menu']['menu_id']), - intval($uid) + intval($owner) ); if($_GET['display']) { @@ -167,6 +181,7 @@ class Mitem extends \Zotlabs\Web\Controller { '$display' => $display, '$lockstate' => $lockstate, '$menu_names' => $menu_names, + '$nick' => $which, '$sys' => \App::$is_sys )); @@ -187,40 +202,41 @@ class Mitem extends \Zotlabs\Web\Controller { '$hintnew' => t('Add menu element'), '$hintdrop' => t('Delete this menu item'), '$hintedit' => t('Edit this menu item'), + '$nick' => $which, )); return $o; } - if(argc() > 2) { - - if(intval(argv(2))) { + if(argc() > 3) { + + if(intval(argv(3))) { $m = q("select * from menu_item where mitem_id = %d and mitem_channel_id = %d limit 1", - intval(argv(2)), - intval($uid) + intval(argv(3)), + intval($owner) ); if(! $m) { notice( t('Menu item not found.') . EOL); - goaway(z_root() . '/menu'. ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/menu/'. $which . ((\App::$is_sys) ? '?f=&sys=1' : '')); } $mitem = $m[0]; $lockstate = (($mitem['allow_cid'] || $mitem['allow_gid'] || $mitem['deny_cid'] || $mitem['deny_gid']) ? 'lock' : 'unlock'); - if(argc() == 4 && argv(3) == 'drop') { - menu_sync_packet($uid,get_observer_hash(),$mitem['mitem_menu_id']); - $r = menu_del_item($mitem['mitem_menu_id'], $uid, intval(argv(2))); - menu_sync_packet($uid,get_observer_hash(),$mitem['mitem_menu_id']); + if(argc() == 5 && argv(4) == 'drop') { + menu_sync_packet($owner,get_observer_hash(),$mitem['mitem_menu_id']); + $r = menu_del_item($mitem['mitem_menu_id'], $owner, intval(argv(3))); + menu_sync_packet($owner,get_observer_hash(),$mitem['mitem_menu_id']); if($r) info( t('Menu item deleted.') . EOL); else notice( t('Menu item could not be deleted.'). EOL); - goaway(z_root() . '/mitem/' . $mitem['mitem_menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); + goaway(z_root() . '/mitem/' . $which . '/' . $mitem['mitem_menu_id'] . ((\App::$is_sys) ? '?f=&sys=1' : '')); } // edit menu item @@ -234,7 +250,7 @@ class Mitem extends \Zotlabs\Web\Controller { '$allow_gid' => acl2json($mitem['allow_gid']), '$deny_cid' => acl2json($mitem['deny_cid']), '$deny_gid' => acl2json($mitem['deny_gid']), - '$mitem_id' => intval(argv(2)), + '$mitem_id' => intval(argv(3)), '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), '$mitem_link' => array('mitem_link', t('Link or Submenu Target'), $mitem['mitem_link'], 'Enter URL of the link or select a menu name to create a submenu', '*', 'list="menu-names"'), '$usezid' => array('usezid', t('Use magic-auth if available'), (($mitem['mitem_flags'] & MENU_ITEM_ZID) ? 1 : 0), '', array(t('No'), t('Yes'))), @@ -242,7 +258,8 @@ class Mitem extends \Zotlabs\Web\Controller { '$mitem_order' => array('mitem_order', t('Order in list'),$mitem['mitem_order'],t('Higher numbers will sink to bottom of listing')), '$submit' => t('Submit'), '$lockstate' => $lockstate, - '$menu_names' => $menu_names + '$menu_names' => $menu_names, + '$nick' => $which )); return $o; -- cgit v1.2.3 From 5d1d6299cde7b0d699851da00a32878cdc49593e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 6 Jun 2018 18:02:25 +0200 Subject: add the pf argument to the forum notification links --- Zotlabs/Module/Ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index d95df34a0..baefe62ec 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -645,7 +645,7 @@ class Ping extends \Zotlabs\Web\Controller { 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=&cid=' . $forums[$x]['abook_id']); + $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]['name'] = $forums[$x]['xchan_name']; $forums[$x]['url'] = $forums[$x]['xchan_url']; $forums[$x]['photo'] = $forums[$x]['xchan_photo_s']; -- cgit v1.2.3 From 2c7597066c03bc60e83b934415df6fd7551016d1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 6 Jun 2018 17:12:20 -0700 Subject: update a number of links in the code --- Zotlabs/Lib/System.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index c3e11eb6a..7bf1343bb 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -54,7 +54,7 @@ class System { static public function get_project_srclink() { if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_srclink']) return \App::$config['system']['project_srclink']; - return 'https://github.com/redmatrix/hubzilla'; + return 'https://framagit.org/hubzilla/core.git'; } static public function get_server_role() { -- cgit v1.2.3 From d3bc50e18d77d0f21b2b34560338c2ded4ae59eb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Jun 2018 21:58:09 +0200 Subject: do not query for parents if $conv and $nouveau are set --- Zotlabs/Module/Network.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 6a24b9453..9837d35a3 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -392,9 +392,15 @@ class Network extends \Zotlabs\Web\Controller { if($conv) { $item_thread_top = ''; - $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'])) - ); + + 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'])) + ); + } } if($update && ! $load) { @@ -489,9 +495,9 @@ class Network extends \Zotlabs\Web\Controller { // Normal conversation view if($order === 'post') - $ordering = "created"; + $ordering = "created"; else - $ordering = "commented"; + $ordering = "commented"; if($load) { // Fetch a page full of parent items for this page -- cgit v1.2.3 From b3928f3d2a7c4c77df5ceba6fc29cbfcbe067dff Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Jun 2018 22:45:07 +0200 Subject: escape query string --- Zotlabs/Module/Connections.php | 2 +- Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Photos.php | 4 ++-- Zotlabs/Module/Viewconnections.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index 3bbdbf326..cecada769 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -326,7 +326,7 @@ class Connections extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $o .= replace_macros(get_markup_template('connections.tpl'),array( '$header' => t('Connections') . (($head) ? ': ' . $head : ''), '$tabs' => $tabs, diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index f2673fa1a..8a7c6baf6 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -395,7 +395,7 @@ class Directory extends \Zotlabs\Web\Controller { $dirtitle = (($globaldir) ? t('Global Directory') : t('Local Directory')); - $o .= ""; + $o .= ""; $o .= replace_macros($tpl, array( '$search' => $search, '$desc' => t('Find'), diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index e21f3025c..489bffc4a 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -838,7 +838,7 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template('photo_album.tpl'); $o .= replace_macros($tpl, array( '$photos' => $photos, @@ -1377,7 +1377,7 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template('photos_recent.tpl'); $o .= replace_macros($tpl, array( '$title' => t('Recent Photos'), diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 8366e1325..0a5e86907 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -107,7 +107,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array( '$title' => t('View Connections'), -- cgit v1.2.3 From dfa48ba17c0263355901cfba67d5058475168bfb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Jun 2018 23:24:36 +0200 Subject: fixes for search_item.tpl --- Zotlabs/Lib/ThreadItem.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index a3c7f99b9..ed78ae00b 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -243,16 +243,9 @@ class ThreadItem { // FIXME check this permission if(($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) { -// FIXME we don't need all this stuff, some can be done in the template - $star = array( - 'do' => t("Add Star"), - 'undo' => t("Remove Star"), 'toggle' => t("Toggle Star Status"), - 'classdo' => ((intval($item['item_starred'])) ? "hidden" : ""), - 'classundo' => ((intval($item['item_starred'])) ? "" : "hidden"), 'isstarred' => ((intval($item['item_starred'])) ? true : false), - 'starred' => t('starred'), ); } -- cgit v1.2.3 From 4feff1cf897918892e6555b431f0d069031a8597 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Fri, 8 Jun 2018 05:37:23 -0400 Subject: Update github.com git repo URLs with framagit.org URLs --- Zotlabs/Storage/Browser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index f4f906ad1..153016da6 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -12,7 +12,7 @@ use Sabre\DAV; * * @extends \\Sabre\\DAV\\Browser\\Plugin * - * @link http://github.com/redmatrix/hubzilla + * @link http://framagit.org/hubzilla/core/ * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) */ class Browser extends DAV\Browser\Plugin { -- cgit v1.2.3 From 468af29e3e4fb5c59f44afe8e870e21b66153992 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 8 Jun 2018 23:03:05 +0200 Subject: new feature filter network by name --- Zotlabs/Widget/Activity_filter.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 32da20bf6..78e439fdd 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -154,6 +154,20 @@ class Activity_filter { ]; } + $name = []; + if(feature_enabled(local_channel(),'name_tab')) { + if(x($_GET,'cid') && ! x($_GET,'pf')) { + $filter_active = 'name'; + } + $name = [ + 'label' => x($_GET,'name') ? $_GET['name'] : t('Filter by name'), + 'icon' => 'filter', + 'url'=> z_root() . '/' . $cmd . '/', + 'sel'=> $filter_active == 'name' ? 'is-valid' : '', + 'title' => '' + ]; + } + $reset = []; if($filter_active) { $reset = [ @@ -179,7 +193,8 @@ class Activity_filter { $o .= replace_macros(get_markup_template('activity_filter_widget.tpl'), [ '$title' => t('Activity Filters'), '$reset' => $reset, - '$content' => $content + '$content' => $content, + '$name' => $name ]); } -- cgit v1.2.3 From 1fbc1314695feff17ec9d6ecaa009f5e554ad109 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 8 Jun 2018 23:19:30 +0200 Subject: if unthreaded and cid and not pf, query author only --- Zotlabs/Module/Network.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 9837d35a3..132770608 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -262,13 +262,18 @@ class Network extends \Zotlabs\Web\Controller { $item_thread_top = ''; if($load || $update) { - $ttype = (($pf) ? TERM_FORUM : TERM_MENTION); + if(!$pf && $nouveau) { + $sql_extra = " AND author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' "; + } + else { + $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']) . "'"); + $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'); - $sql_extra = " AND item.parent IN ( $p_str ) "; + $p_str = ids_to_querystr(array_merge($p1,$p2),'parent'); + $sql_extra = " AND item.parent IN ( $p_str ) "; + } } $title = replace_macros(get_markup_template("section_title.tpl"),array( -- cgit v1.2.3 From c4778e5e2494d262c18dd73815fb495964355fce Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 9 Jun 2018 10:58:01 +0200 Subject: restrict cid filter to unthreaded order (makes much more sense that way imho and the query is a lot faster) and slighty change order of the filters --- Zotlabs/Module/Network.php | 2 +- Zotlabs/Widget/Activity_filter.php | 65 +++++++++++++++++++------------------- Zotlabs/Widget/Activity_order.php | 4 +-- 3 files changed, 35 insertions(+), 36 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 132770608..2e9bcd2ce 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -140,7 +140,7 @@ class Network extends \Zotlabs\Web\Controller { $deftag = ''; - if(x($_GET,'search') || x($_GET,'file')) + if(x($_GET,'search') || $file || (!$pf && $cid)) $nouveau = true; if($cid) { diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 78e439fdd..fadf39144 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -76,6 +76,38 @@ class Activity_filter { } } + if(feature_enabled(local_channel(),'forums_tab')) { + $forums = get_forum_channels(local_channel()); + + if($forums) { + foreach($forums as $f) { + if(x($_GET,'pf') && x($_GET,'cid')) { + $forum_active = ((x($_GET,'pf') && $_GET['cid'] == $f['abook_id']) ? 'active' : ''); + $filter_active = 'forums'; + } + $fsub[] = [ + 'label' => $f['xchan_name'], + 'img' => $f['xchan_photo_s'], + 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), + 'sel' => $forum_active, + 'title' => t('Show posts to this forum'), + 'lock' => (($f['private_forum']) ? 'lock' : '') + ]; + } + + $tabs[] = [ + 'id' => 'forums', + 'label' => t('Forums'), + 'icon' => 'comments-o', + 'url' => '#', + 'sel' => (($filter_active == 'forums') ? true : false), + 'title' => t('Show forums'), + 'sub' => $fsub + + ]; + } + } + 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()), @@ -110,39 +142,6 @@ class Activity_filter { } } - if(feature_enabled(local_channel(),'forums_tab')) { - $forums = get_forum_channels(local_channel()); - - if($forums) { - foreach($forums as $f) { - if(x($_GET,'pf') && x($_GET,'cid')) { - $forum_active = ((x($_GET,'pf') && $_GET['cid'] == $f['abook_id']) ? 'active' : ''); - $filter_active = 'forums'; - } - $fsub[] = [ - 'label' => $f['xchan_name'], - 'img' => $f['xchan_photo_s'], - 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), - 'sel' => $forum_active, - 'title' => t('Show posts to this forum'), - 'lock' => (($f['private_forum']) ? 'lock' : '') - ]; - } - - $tabs[] = [ - 'id' => 'forums', - 'label' => t('Forums'), - 'icon' => 'comments-o', - 'url' => '#', - 'sel' => (($filter_active == 'forums') ? true : false), - 'title' => t('Show forums'), - 'sub' => $fsub - - ]; - } - } - - if(x($_GET,'search')) { $filter_active = 'search'; $tabs[] = [ diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php index 534d6caee..0e660afc3 100644 --- a/Zotlabs/Widget/Activity_order.php +++ b/Zotlabs/Widget/Activity_order.php @@ -53,8 +53,8 @@ class Activity_order { } } - // override order for search results and filer results - if(x($_GET,'search') || x($_GET,'file')) { + // override order for search, filer and cid results + if(x($_GET,'search') || x($_GET,'file') || (! x($_GET,'pf') && x($_GET,'cid'))) { $unthreaded_active = 'active'; $commentord_active = $postord_active = 'disabled'; } -- cgit v1.2.3 From 9e29c136788fc14b9264843e11541bb6a2176e19 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 9 Jun 2018 16:38:15 +0200 Subject: fix issue #1219 --- Zotlabs/Module/Viewsrc.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php index 54ab89e81..5900e385a 100644 --- a/Zotlabs/Module/Viewsrc.php +++ b/Zotlabs/Module/Viewsrc.php @@ -28,7 +28,7 @@ class Viewsrc extends \Zotlabs\Web\Controller { $item_normal = item_normal(); if(local_channel() && $item_id) { - $r = q("select id, item_flags, mimetype, item_obscured, body from item where uid in (%d , %d) and id = %d $item_normal limit 1", + $r = q("select id, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id) @@ -52,8 +52,11 @@ class Viewsrc extends \Zotlabs\Web\Controller { } if(is_ajax()) { - print '
' . t('Source of Item') . ' ' . $r[0]['id'] . '
'; - echo $o; + echo '
'; + echo '
id: ' . $r[0]['id'] . ' | plink | llink
'; + echo '
'; + echo '
' . $o . '
'; + echo '
'; killme(); } -- cgit v1.2.3 From d0f7b1d9b79a5a96314d5c6caa011f7050cec2f9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 10 Jun 2018 17:04:34 +0200 Subject: fix issue #1221 --- Zotlabs/Lib/Share.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php index e9e4d23c4..d3ecbf7fa 100644 --- a/Zotlabs/Lib/Share.php +++ b/Zotlabs/Lib/Share.php @@ -107,7 +107,7 @@ class Share { } public function bbcode() { - $bb = NULL_STR; + $bb = EMPTY_STR; if(! $this->item) return $bb; @@ -140,4 +140,4 @@ class Share { } -} \ No newline at end of file +} -- cgit v1.2.3 From 254a6be277e8536ae101faa429805fcbd6382d61 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Jun 2018 16:25:50 -0700 Subject: null db fields in mod_invite --- Zotlabs/Module/Invite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php index 0bcd1c1fa..4722a7ee5 100644 --- a/Zotlabs/Module/Invite.php +++ b/Zotlabs/Module/Invite.php @@ -113,7 +113,7 @@ class Invite extends \Zotlabs\Web\Controller { $invite_code = autoname(8) . rand(1000,9999); $nmessage = str_replace('$invite_code',$invite_code,$message); - $r = q("INSERT INTO register (hash,created) VALUES ('%s', '%s') ", + $r = q("INSERT INTO register (hash,created,uid,password,lang) VALUES ('%s', '%s','','','') ", dbesc($invite_code), dbesc(datetime_convert()) ); -- cgit v1.2.3 From 65cbc7c2bba523a2663a89fae29b5cef162fd0a1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Jun 2018 16:37:16 -0700 Subject: uid is integer --- Zotlabs/Module/Invite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php index 4722a7ee5..359f99b3e 100644 --- a/Zotlabs/Module/Invite.php +++ b/Zotlabs/Module/Invite.php @@ -113,7 +113,7 @@ class Invite extends \Zotlabs\Web\Controller { $invite_code = autoname(8) . rand(1000,9999); $nmessage = str_replace('$invite_code',$invite_code,$message); - $r = q("INSERT INTO register (hash,created,uid,password,lang) VALUES ('%s', '%s','','','') ", + $r = q("INSERT INTO register (hash,created,uid,password,lang) VALUES ('%s', '%s',0,'','') ", dbesc($invite_code), dbesc(datetime_convert()) ); -- cgit v1.2.3 From b5e4a5f51c478d646248c5a9eb22907cda32dd3e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Jun 2018 20:27:10 -0700 Subject: SECURITY: provide option to disable the cloud 'root' directory and make the cloud module require a target channel nickname. This is a low impact change as there is currently no disclosure of private information. The presence of a file browser for all the channels on the site could be (and is reported to be) a concern to some people and there is no reason why it shouldn't be optional. --- Zotlabs/Module/Admin/Security.php | 5 +++++ Zotlabs/Module/Cloud.php | 9 +++++++++ 2 files changed, 14 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php index 49e1ccf42..249fda469 100644 --- a/Zotlabs/Module/Admin/Security.php +++ b/Zotlabs/Module/Admin/Security.php @@ -16,6 +16,10 @@ class Security { $block_public = ((x($_POST,'block_public')) ? True : False); set_config('system','block_public',$block_public); + + $cloud_noroot = ((x($_POST,'cloud_noroot')) ? 1 : 0); + set_config('system','cloud_disable_siteroot',1 - $cloud_noroot); + $ws = $this->trim_array_elems(explode("\n",$_POST['whitelisted_sites'])); set_config('system','whitelisted_sites',$ws); @@ -87,6 +91,7 @@ class Security { '$page' => t('Security'), '$form_security_token' => get_form_security_token('admin_security'), '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")), + '$cloud_noroot' => [ 'cloud_noroot', t('Provide a cloud root directory'), 1 - intval(get_config('system','cloud_disable_siteroot')), t('The cloud root directory lists all channel names which provide public files') ], '$transport_security' => array('transport_security', t('Set "Transport Security" HTTP header'),intval(get_config('system','transport_security_header')),''), '$content_security' => array('content_security', t('Set "Content Security Policy" HTTP header'),intval(get_config('system','content_security_policy')),''), '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")), diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 34397d275..1b330ecba 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -35,11 +35,20 @@ class Cloud extends \Zotlabs\Web\Controller { if (argc() > 1) $which = argv(1); + + if (argc() < 2 && intval(get_config('system','cloud_disable_siteroot'))) { + notice( t('Permission denied.') . EOL); + construct_page(); + killme(); + } + $profile = 0; if ($which) profile_load( $which, $profile); + + $auth = new \Zotlabs\Storage\BasicAuth(); $ob_hash = get_observer_hash(); -- cgit v1.2.3 From 8da0f9d3569e7c19e5581c4d402931a07dcab317 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Jun 2018 21:06:56 -0700 Subject: optionally report total available space when uploading --- Zotlabs/Module/Admin/Security.php | 5 ++++- Zotlabs/Storage/Browser.php | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php index 249fda469..80c1d85b7 100644 --- a/Zotlabs/Module/Admin/Security.php +++ b/Zotlabs/Module/Admin/Security.php @@ -20,7 +20,9 @@ class Security { $cloud_noroot = ((x($_POST,'cloud_noroot')) ? 1 : 0); set_config('system','cloud_disable_siteroot',1 - $cloud_noroot); - + $cloud_disksize = ((x($_POST,'cloud_disksize')) ? 1 : 0); + set_config('system','cloud_report_disksize',$cloud_disksize); + $ws = $this->trim_array_elems(explode("\n",$_POST['whitelisted_sites'])); set_config('system','whitelisted_sites',$ws); @@ -92,6 +94,7 @@ class Security { '$form_security_token' => get_form_security_token('admin_security'), '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently authenticated.")), '$cloud_noroot' => [ 'cloud_noroot', t('Provide a cloud root directory'), 1 - intval(get_config('system','cloud_disable_siteroot')), t('The cloud root directory lists all channel names which provide public files') ], + '$cloud_disksize' => [ 'cloud_disksize', t('Show total disk space available to cloud uploads'), intval(get_config('system','cloud_report_disksize')), '' ], '$transport_security' => array('transport_security', t('Set "Transport Security" HTTP header'),intval(get_config('system','transport_security_header')),''), '$content_security' => array('content_security', t('Set "Content Security Policy" HTTP header'),intval(get_config('system','content_security_policy')),''), '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")), diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 153016da6..67d934783 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -347,6 +347,10 @@ class Browser extends DAV\Browser\Plugin { // Storage and quota for the account (all channels of the owner of this directory)! $limit = engr_units_to_bytes(service_class_fetch($owner, 'attach_upload_limit')); + if((! $limit) && get_config('system','cloud_report_disksize')) { + $limit = engr_units_to_bytes(disk_free_space('store')); + } + $r = q("SELECT SUM(filesize) AS total FROM attach WHERE aid = %d", intval($this->auth->channel_account_id) ); -- cgit v1.2.3 From 7a144b90fb9174eb50e5d53d2f62d6d8d2671353 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 14 Jun 2018 20:40:25 -0700 Subject: re-implement/refactor getQuotaInfo() on DAV storage --- Zotlabs/Module/Home.php | 2 +- Zotlabs/Storage/Browser.php | 6 ++-- Zotlabs/Storage/Directory.php | 77 ++++++++++++++++++++++++------------------- 3 files changed, 49 insertions(+), 36 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Home.php b/Zotlabs/Module/Home.php index 4b3e596a9..647a6412a 100644 --- a/Zotlabs/Module/Home.php +++ b/Zotlabs/Module/Home.php @@ -9,7 +9,7 @@ require_once('include/conversation.php'); class Home extends \Zotlabs\Web\Controller { function init() { - + $ret = array(); call_hooks('home_init',$ret); diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 67d934783..c2d70b854 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -333,6 +333,7 @@ class Browser extends DAV\Browser\Plugin { $aclselect = null; $lockstate = ''; + $limit = 0; if($this->auth->owner_id) { $channel = channelx_by_n($this->auth->owner_id); @@ -343,10 +344,11 @@ class Browser extends DAV\Browser\Plugin { $aclselect = ((local_channel() == $this->auth->owner_id) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : ''); } + + // Storage and quota for the account (all channels of the owner of this directory)! + $limit = engr_units_to_bytes(service_class_fetch($this->auth->owner_id, 'attach_upload_limit')); } - // Storage and quota for the account (all channels of the owner of this directory)! - $limit = engr_units_to_bytes(service_class_fetch($owner, 'attach_upload_limit')); if((! $limit) && get_config('system','cloud_report_disksize')) { $limit = engr_units_to_bytes(disk_free_space('store')); } diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index f46e2e666..73548fda0 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -571,39 +571,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo return datetime_convert('UTC', 'UTC', $r[0]['edited'], 'U'); } - /** - * @brief Return quota usage. - * - * @fixme Should guests relly see the used/free values from filesystem of the - * complete store directory? - * - * @return array with used and free values in bytes. - */ - public function getQuotaInfo() { - // values from the filesystem of the complete store/ directory - $limit = disk_total_space('store'); - $free = disk_free_space('store'); - - if ($this->auth->owner_id) { - $c = q("select * from channel where channel_id = %d and channel_removed = 0 limit 1", - intval($this->auth->owner_id) - ); - - $ulimit = engr_units_to_bytes(service_class_fetch($c[0]['channel_id'], 'attach_upload_limit')); - $limit = (($ulimit) ? $ulimit : $limit); - - $x = q("select sum(filesize) as total from attach where aid = %d", - intval($c[0]['channel_account_id']) - ); - $free = (($x) ? $limit - $x[0]['total'] : 0); - } - - return array( - $limit - $free, - $free - ); - } - /** * @brief Array with all Directory and File DAV\\Node items for the given path. @@ -895,4 +862,48 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo return false; } + public function getQuotaInfo() { + + /** + * Returns the quota information + * + * This method MUST return an array with 2 values, the first being the total used space, + * the second the available space (in bytes) + */ + + $used = 0; + $limit = 0; + $free = 0; + + if ($this->auth->owner_id) { + $channel = channelx_by_n($this->auth->owner_id); + if($channel) { + $r = q("SELECT SUM(filesize) AS total FROM attach WHERE aid = %d", + intval($channel['channel_account_id']) + ); + $used = (($r) ? (float) $r[0]['total'] : 0); + $limit = (float) service_class_fetch($this->auth->owner_id, 'attach_upload_limit'); + if($limit) { + // Don't let the result go negative + $free = (($limit > $used) ? $limit - $used : 0); + } + } + } + + if(! $limit) { + $free = disk_free_space('store'); + $used = disk_total_space('store') - $free; + } + + // prevent integer overflow on 32-bit systems + + if($used > (float) PHP_INT_MAX) + $used = PHP_INT_MAX; + if($free > (float) PHP_INT_MAX) + $free = PHP_INT_MAX; + + return [ (int) $used, (int) $free ]; + + } + } -- cgit v1.2.3 From 2f3c3db02062fa867cb9b39ffcf11f646a9b80bb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 15 Jun 2018 02:02:03 -0700 Subject: hubzilla core issue #1227 - affinity slider unable to reach 0,99 when slider saved default changes --- Zotlabs/Module/Network.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 2e9bcd2ce..a01425188 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -123,8 +123,8 @@ class Network extends \Zotlabs\Web\Controller { $def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>'); } - $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0); - $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99); + $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1)); + $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1)); $cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0); $star = ((x($_GET,'star')) ? intval($_GET['star']) : 0); @@ -140,6 +140,7 @@ class Network extends \Zotlabs\Web\Controller { $deftag = ''; + if(x($_GET,'search') || $file || (!$pf && $cid)) $nouveau = true; @@ -420,8 +421,9 @@ class Network extends \Zotlabs\Web\Controller { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); } - - if(($cmin != 0) || ($cmax != 99)) { + // cmin and cmax are both -1 when the affinity tool is disabled + + if(($cmin != (-1)) || ($cmax != (-1))) { // Not everybody who shows up in the network stream will be in your address book. // By default those that aren't are assumed to have closeness = 99; but this isn't -- cgit v1.2.3 From 7e736c5359732647f5203bf2bb7fcd50c448fad9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 15 Jun 2018 15:21:19 -0700 Subject: apply changes to slider defaults across all modules that use buildQuery for updates --- Zotlabs/Module/Channel.php | 4 ++-- Zotlabs/Module/Display.php | 4 ++-- Zotlabs/Module/Network.php | 4 ++-- Zotlabs/Module/Pubstream.php | 4 ++-- Zotlabs/Module/Search.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 80e81580a..b5e6b3aee 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -344,8 +344,8 @@ class Channel extends \Zotlabs\Web\Controller { '$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'), '$gid' => '0', '$cid' => '0', - '$cmin' => '0', - '$cmax' => '0', + '$cmin' => '(-1)', + '$cmax' => '(-1)', '$star' => '0', '$liked' => '0', '$conv' => '0', diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index a127ab196..fe0408c6f 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -213,8 +213,8 @@ class Display extends \Zotlabs\Web\Controller { '$uid' => '0', '$gid' => '0', '$cid' => '0', - '$cmin' => '0', - '$cmax' => '99', + '$cmin' => '(-1)', + '$cmax' => '(-1)', '$star' => '0', '$liked' => '0', '$conv' => '0', diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index a01425188..172157aab 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -335,8 +335,8 @@ class Network extends \Zotlabs\Web\Controller { '$uid' => ((local_channel()) ? local_channel() : '0'), '$gid' => (($gid) ? $gid : '0'), '$cid' => (($cid) ? $cid : '0'), - '$cmin' => (($cmin) ? $cmin : '0'), - '$cmax' => (($cmax) ? $cmax : '0'), + '$cmin' => (($cmin) ? $cmin : '(-1)'), + '$cmax' => (($cmax) ? $cmax : '(-1)'), '$star' => (($star) ? $star : '0'), '$liked' => (($liked) ? $liked : '0'), '$conv' => (($conv) ? $conv : '0'), diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index f0e87f468..7b80a3978 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -118,8 +118,8 @@ class Pubstream extends \Zotlabs\Web\Controller { '$uid' => ((local_channel()) ? local_channel() : '0'), '$gid' => '0', '$cid' => '0', - '$cmin' => '0', - '$cmax' => '99', + '$cmin' => '(-1)', + '$cmax' => '(-1)', '$star' => '0', '$liked' => '0', '$conv' => '0', diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 3a552bb22..e520c671d 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -121,8 +121,8 @@ class Search extends \Zotlabs\Web\Controller { '$uid' => ((\App::$profile['profile_uid']) ? \App::$profile['profile_uid'] : '0'), '$gid' => '0', '$cid' => '0', - '$cmin' => '0', - '$cmax' => '0', + '$cmin' => '(-1)', + '$cmax' => '(-1)', '$star' => '0', '$liked' => '0', '$conv' => '0', -- cgit v1.2.3 From 9c5df51141d68e50d3c1f5d3097160408debce48 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 17 Jun 2018 16:58:12 +0200 Subject: some work on mod group --- Zotlabs/Module/Group.php | 107 +++++++++++++++++++++++++++-------------- Zotlabs/Widget/Collections.php | 3 ++ 2 files changed, 73 insertions(+), 37 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php index 93a089d02..acebe995d 100644 --- a/Zotlabs/Module/Group.php +++ b/Zotlabs/Module/Group.php @@ -7,6 +7,17 @@ require_once('include/group.php'); class Group extends \Zotlabs\Web\Controller { + function init() { + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + return; + } + + \App::$profile_uid = local_channel(); + + nav_set_selected('Privacy Groups'); + } + function post() { if(! local_channel()) { @@ -22,12 +33,10 @@ class Group extends \Zotlabs\Web\Controller { $r = group_add(local_channel(),$name,$public); if($r) { info( t('Privacy group created.') . EOL ); - $r = group_byname(local_channel(),$name); - if($r) - goaway(z_root() . '/group/' . $r); } - else - notice( t('Could not create privacy group.') . EOL ); + else { + notice( t('Could not create privacy group.') . EOL ); + } goaway(z_root() . '/group'); } @@ -74,30 +83,59 @@ class Group extends \Zotlabs\Web\Controller { notice( t('Permission denied') . EOL); return; } - + // Switch to text mode interface if we have more than 'n' contacts or group members - $switchtotext = get_pconfig(local_channel(),'system','groupedit_image_limit'); if($switchtotext === false) $switchtotext = get_config('system','groupedit_image_limit'); if($switchtotext === false) $switchtotext = 400; - - $tpl = get_markup_template('group_edit.tpl'); - $context = array('$submit' => t('Submit')); - - if((argc() == 2) && (argv(1) === 'new')) { - - return replace_macros($tpl, $context + array( - '$title' => t('Create a group of channels.'), - '$gname' => array('groupname',t('Privacy group name: '), '', ''), - '$gid' => 'new', - '$public' => array('public',t('Members are visible to other channels'), false, ''), + + + if((argc() == 1) || ((argc() == 2) && (argv(1) === 'new'))) { + + $new = (((argc() == 2) && (argv(1) === 'new')) ? true : false); + + $groups = q("SELECT id, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + intval(local_channel()) + ); + + $i = 0; + foreach($groups as $group) { + $entries[$i]['name'] = $group['gname']; + $entries[$i]['id'] = $group['id']; + $entries[$i]['count'] = count(group_get_members($group['id'])); + $i++; + } + + $tpl = get_markup_template('privacy_groups.tpl'); + $o = replace_macros($tpl, [ + '$title' => t('Privacy Groups'), + '$add_new_label' => t('Add Group'), + '$new' => $new, + + // new group form + '$gname' => array('groupname',t('Privacy group name')), + '$public' => array('public',t('Members are visible to other channels'), false), '$form_security_token' => get_form_security_token("group_edit"), - )); - - + '$submit' => t('Submit'), + + // groups list + '$title' => t('Privacy Groups'), + '$name_label' => t('Name'), + '$count_label' => t('Members'), + '$entries' => $entries + ]); + + return $o; + } + + + + + $context = array('$submit' => t('Submit')); + $tpl = get_markup_template('group_edit.tpl'); if((argc() == 3) && (argv(1) === 'drop')) { check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); @@ -172,22 +210,17 @@ class Group extends \Zotlabs\Web\Controller { $preselected[] = $member['xchan_hash']; } } - - $drop_tpl = get_markup_template('group_drop.tpl'); - $drop_txt = replace_macros($drop_tpl, array( - '$id' => $group['id'], - '$delete' => t('Delete'), - '$form_security_token' => get_form_security_token("group_drop"), - )); - - + $context = $context + array( - '$title' => t('Privacy group editor'), + '$title' => sprintf(t('Privacy Group: %s'), $group['gname']), + '$details_label' => t('Edit'), '$gname' => array('groupname',t('Privacy group name: '),$group['gname'], ''), '$gid' => $group['id'], '$drop' => $drop_txt, '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''), - '$form_security_token' => get_form_security_token('group_edit'), + '$form_security_token_edit' => get_form_security_token('group_edit'), + '$delete' => t('Delete Group'), + '$form_security_token_drop' => get_form_security_token("group_drop"), ); } @@ -196,14 +229,14 @@ class Group extends \Zotlabs\Web\Controller { return; $groupeditor = array( - 'label_members' => t('Members'), + 'label_members' => t('Group members'), 'members' => array(), - 'label_contacts' => t('All Connected Channels'), + 'label_contacts' => t('Not in this group'), 'contacts' => array(), ); $sec_token = addslashes(get_form_security_token('group_member_change')); - $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); + $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : 'card'); foreach($members as $member) { if($member['xchan_url']) { $member['archived'] = (intval($member['abook_archived']) ? true : false); @@ -219,7 +252,7 @@ class Group extends \Zotlabs\Web\Controller { ); if(count($r)) { - $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); + $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : 'card'); foreach($r as $member) { if(! in_array($member['xchan_hash'],$preselected)) { $member['archived'] = (intval($member['abook_archived']) ? true : false); @@ -230,7 +263,7 @@ class Group extends \Zotlabs\Web\Controller { } $context['$groupeditor'] = $groupeditor; - $context['$desc'] = t('Click on a channel to add or remove.'); + $context['$desc'] = t('Click a channel to toggle membership'); if($change) { $tpl = get_markup_template('groupeditor.tpl'); diff --git a/Zotlabs/Widget/Collections.php b/Zotlabs/Widget/Collections.php index d2b29679a..bc9c812c6 100644 --- a/Zotlabs/Widget/Collections.php +++ b/Zotlabs/Widget/Collections.php @@ -8,6 +8,9 @@ class Collections { function widget($args) { + if(argc() < 2) + return; + $mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation'); switch($mode) { case 'conversation': -- cgit v1.2.3 From e4ed0f8acd5a994d7098e89e4408698d3b7a6129 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 17 Jun 2018 17:30:09 -0700 Subject: owa: htmlentity encoding encountered in authentication workflow (possibly introduced during Apache mod_rewrite with QSA flag) --- Zotlabs/Module/Magic.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 4b3a223ba..25c318f30 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -19,7 +19,11 @@ class Magic extends \Zotlabs\Web\Controller { $rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0); $owa = ((x($_REQUEST,'owa')) ? intval($_REQUEST['owa']) : 0); $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); - + + // Apache(?) appears to perform an htmlentities() operation on this variable + + $dest = html_entity_decode($dest); + $parsed = parse_url($dest); if(! $parsed) { if($test) { @@ -139,6 +143,9 @@ class Magic extends \Zotlabs\Web\Controller { if($owa) { + $dest = strip_zids($dest); + $dest = strip_query_param($dest,'f'); + $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['X-Open-Web-Auth'] = random_string(); -- cgit v1.2.3 From 48a25b1b858b5d43eb64e1e45e0c8ad850957e4e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 18 Jun 2018 20:44:59 -0700 Subject: channel sources: add 'resend' option to discard original author - similar to the Friendica remote_self setting --- Zotlabs/Module/Sources.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sources.php b/Zotlabs/Module/Sources.php index a180d9b6e..91e2efa60 100644 --- a/Zotlabs/Module/Sources.php +++ b/Zotlabs/Module/Sources.php @@ -12,12 +12,13 @@ class Sources extends \Zotlabs\Web\Controller { return ''; $source = intval($_REQUEST['source']); - $xchan = $_REQUEST['xchan']; + $xchan = escape_tags($_REQUEST['xchan']); $abook = intval($_REQUEST['abook']); - $words = $_REQUEST['words']; + $words = escape_tags($_REQUEST['words']); + $resend = intval($_REQUEST['resend']); $frequency = $_REQUEST['frequency']; - $name = $_REQUEST['name']; - $tags = $_REQUEST['tags']; + $name = escape_tags($_REQUEST['name']); + $tags = escape_tags($_REQUEST['tags']); $channel = \App::get_channel(); @@ -38,6 +39,8 @@ class Sources extends \Zotlabs\Web\Controller { return; } + set_abconfig(local_channel(),$xchan, 'system','rself',$resend); + if(! $source) { $r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt, src_tag ) values ( %d, '%s', '%s', '%s', '%s' ) ", @@ -69,7 +72,7 @@ class Sources extends \Zotlabs\Web\Controller { } - function get() { + function get() { if(! local_channel()) { notice( t('Permission denied.') . EOL); return ''; @@ -110,7 +113,7 @@ class Sources extends \Zotlabs\Web\Controller { '$words' => array( 'words', t('Only import content with these words (one per line)'),'',t('Leave blank to import all public content')), '$name' => array( 'name', t('Channel Name'), '', ''), '$tags' => array('tags', t('Add the following categories to posts imported from this source (comma separated)'),'',t('Optional')), - + '$resend' => [ 'resend', t('Resend posts with this channel as author'), 0, t('Copyrights may apply'), [ t('No'), t('Yes') ]], '$submit' => t('Submit') )); return $o; @@ -145,6 +148,8 @@ class Sources extends \Zotlabs\Web\Controller { '$xchan' => $r[0]['src_xchan'], '$abook' => $x[0]['abook_id'], '$tags' => array('tags', t('Add the following categories to posts imported from this source (comma separated)'),$r[0]['src_tag'],t('Optional')), + '$resend' => [ 'resend', t('Resend posts with this channel as author'), get_abconfig(local_channel(), $r[0]['xchan_hash'],'system','rself'), t('Copyrights may apply'), [ t('No'), t('Yes') ]], + '$name' => array( 'name', t('Channel Name'), $r[0]['xchan_name'], ''), '$submit' => t('Submit') )); -- cgit v1.2.3 From 3716f4e80928f160965dde6fa475e9fa3155b25a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 18 Jun 2018 22:57:38 -0700 Subject: hiding a channel from the directory also hides them from the cloud rootdir --- Zotlabs/Storage/Directory.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 73548fda0..642af6300 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -722,14 +722,13 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo function ChannelList(&$auth) { $ret = array(); - $r = q("SELECT channel_id, channel_address FROM channel WHERE channel_removed = 0 - AND channel_system = 0 AND (channel_pageflags & %d) = 0", + $r = q("SELECT channel_id, channel_address, profile.publish FROM channel left join profile on profile.uid = channel.channel_id WHERE channel_removed = 0 AND channel_system = 0 AND (channel_pageflags & %d) = 0", intval(PAGE_HIDDEN) ); if ($r) { foreach ($r as $rr) { - if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage')) { + if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage') && $rr['publish']) { logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA); // @todo can't we drop '/cloud'? It gets stripped off anyway in RedDirectory $ret[] = new Directory('/cloud/' . $rr['channel_address'], $auth); -- cgit v1.2.3 From 712759ea4b587f9d5b9dfac7216b7f14f32e7792 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Jun 2018 13:42:21 -0700 Subject: disable log noise until it is needed --- Zotlabs/Module/Acl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 7b52e88b5..0c2ad7522 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -24,7 +24,7 @@ class Acl extends \Zotlabs\Web\Controller { function init() { - logger('mod_acl: ' . print_r($_REQUEST,true),LOGGER_DATA); + // logger('mod_acl: ' . print_r($_GET,true),LOGGER_DATA); $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 500); -- cgit v1.2.3 From 524551a05c9ea7436afc713e2564aacd9276541e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Jun 2018 23:20:02 -0700 Subject: do not include system channels in directory results --- Zotlabs/Module/Dirsearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index 08f1f7a13..81942860f 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -257,7 +257,7 @@ class Dirsearch extends \Zotlabs\Web\Controller { else { $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash - where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 + where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql $order $qlimit " ); -- cgit v1.2.3 From 156010050c874eb51f8d2b2334d36909f99e732c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 26 Jun 2018 17:19:32 -0700 Subject: imagick converter: -thumbnail doesn't preserve exif, -resize does --- Zotlabs/Module/Cover_photo.php | 2 +- Zotlabs/Thumbs/Pdf.php | 2 +- Zotlabs/Thumbs/Video.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 88fd4485d..b911ac991 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -95,7 +95,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $fname = dbunescbin($r[0]['content']); $tmp_name = $fname . '-001'; $newsize = photo_calculate_scale(array_merge(getimagesize($fname),['max' => $max_thumb])); - $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $fname) . ' -thumbnail ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $fname) . ' -resize ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); // logger('imagick thumbnail command: ' . $cmd); for($x = 0; $x < 4; $x ++) { exec($cmd); diff --git a/Zotlabs/Thumbs/Pdf.php b/Zotlabs/Thumbs/Pdf.php index 98bcf11b5..11714ad53 100644 --- a/Zotlabs/Thumbs/Pdf.php +++ b/Zotlabs/Thumbs/Pdf.php @@ -27,7 +27,7 @@ class Pdf { $imagick_path = get_config('system','imagick_convert_path'); if($imagick_path && @file_exists($imagick_path)) { - $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -thumbnail ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -resize ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile); // logger('imagick thumbnail command: ' . $cmd); for($x = 0; $x < 4; $x ++) { exec($cmd); diff --git a/Zotlabs/Thumbs/Video.php b/Zotlabs/Thumbs/Video.php index ff4d10a36..15d3ace12 100644 --- a/Zotlabs/Thumbs/Video.php +++ b/Zotlabs/Thumbs/Video.php @@ -46,7 +46,7 @@ class Video { $imagick_path = get_config('system','imagick_convert_path'); if($imagick_path && @file_exists($imagick_path)) { - $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -thumbnail ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -resize ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile); // logger('imagick thumbnail command: ' . $cmd); /** @scrutinizer ignore-unhandled */ -- cgit v1.2.3 From cae0a26ac087448a12b3bb913bc53f6c9b6603d4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 28 Jun 2018 13:38:15 -0700 Subject: String change to reflect the current forum tagging method --- Zotlabs/Access/Permissions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index bca40a9c1..20dc22a72 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -67,7 +67,7 @@ class Permissions { 'post_comments' => t('Can comment on or like my posts'), 'post_mail' => t('Can send me private mail messages'), 'post_like' => t('Can like/dislike profiles and profile things'), - 'tag_deliver' => t('Can forward to all my channel connections via @+ mentions in posts'), + 'tag_deliver' => t('Can forward to all my channel connections via ! mentions in posts'), 'chat' => t('Can chat with me'), 'republish' => t('Can source my public posts in derived channels'), 'delegate' => t('Can administer my channel') -- cgit v1.2.3 From fa6e5e4d754fec3acee019ed1edaa68357f0c2d0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 28 Jun 2018 16:43:22 -0700 Subject: plugins -> addons --- Zotlabs/Module/Admin.php | 2 +- Zotlabs/Module/Admin/Addons.php | 479 +++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Admin/Plugins.php | 479 --------------------------------------- Zotlabs/Widget/Admin.php | 6 +- 4 files changed, 483 insertions(+), 483 deletions(-) create mode 100644 Zotlabs/Module/Admin/Addons.php delete mode 100644 Zotlabs/Module/Admin/Plugins.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 934312efe..2df8dc25d 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -144,7 +144,7 @@ class Admin extends \Zotlabs\Web\Controller { '$accounts' => array( t('Registered accounts'), $accounts), '$pending' => array( t('Pending registrations'), $pending), '$channels' => array( t('Registered channels'), $channels), - '$plugins' => array( t('Active plugins'), $plugins ), + '$plugins' => array( t('Active addons'), $plugins ), '$version' => array( t('Version'), STD_VERSION), '$vmaster' => array( t('Repository version (master)'), $vmaster), '$vdev' => array( t('Repository version (dev)'), $vdev), diff --git a/Zotlabs/Module/Admin/Addons.php b/Zotlabs/Module/Admin/Addons.php new file mode 100644 index 000000000..b35922aef --- /dev/null +++ b/Zotlabs/Module/Admin/Addons.php @@ -0,0 +1,479 @@ + 2 && is_file("addon/" . argv(2) . "/" . argv(2) . ".php")) { + @include_once("addon/" . argv(2) . "/" . argv(2) . ".php"); + if(function_exists(argv(2).'_plugin_admin_post')) { + $func = argv(2) . '_plugin_admin_post'; + $func($a); + } + + goaway(z_root() . '/admin/addons/' . argv(2) ); + } + elseif(argc() > 2) { + switch(argv(2)) { + case 'updaterepo': + if (array_key_exists('repoName', $_REQUEST)) { + $repoName = $_REQUEST['repoName']; + } + else { + json_return_and_die(array('message' => 'No repo name provided.', 'success' => false)); + } + $extendDir = 'store/[data]/git/sys/extend'; + $addonDir = $extendDir . '/addon'; + if (!file_exists($extendDir)) { + if (!mkdir($extendDir, 0770, true)) { + logger('Error creating extend folder: ' . $extendDir); + json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); + } + else { + if (!symlink(realpath('extend/addon'), $addonDir)) { + logger('Error creating symlink to addon folder: ' . $addonDir); + json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); + } + } + } + $repoDir = 'store/[data]/git/sys/extend/addon/' . $repoName; + if (!is_dir($repoDir)) { + logger('Repo directory does not exist: ' . $repoDir); + json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false)); + } + if (!is_writable($repoDir)) { + logger('Repo directory not writable to web server: ' . $repoDir); + json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false)); + } + $git = new GitRepo('sys', null, false, $repoName, $repoDir); + try { + if ($git->pull()) { + $files = array_diff(scandir($repoDir), array('.', '..')); + foreach ($files as $file) { + if (is_dir($repoDir . '/' . $file) && $file !== '.git') { + $source = '../extend/addon/' . $repoName . '/' . $file; + $target = realpath('addon/') . '/' . $file; + unlink($target); + if (!symlink($source, $target)) { + logger('Error linking addons to /addon'); + json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false)); + } + } + } + json_return_and_die(array('message' => 'Repo updated.', 'success' => true)); + } else { + json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false)); + } + } catch (\PHPGit\Exception\GitException $e) { + json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false)); + } + case 'removerepo': + if (array_key_exists('repoName', $_REQUEST)) { + $repoName = $_REQUEST['repoName']; + } else { + json_return_and_die(array('message' => 'No repo name provided.', 'success' => false)); + } + $extendDir = 'store/[data]/git/sys/extend'; + $addonDir = $extendDir . '/addon'; + if (!file_exists($extendDir)) { + if (!mkdir($extendDir, 0770, true)) { + logger('Error creating extend folder: ' . $extendDir); + json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); + } else { + if (!symlink(realpath('extend/addon'), $addonDir)) { + logger('Error creating symlink to addon folder: ' . $addonDir); + json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); + } + } + } + $repoDir = 'store/[data]/git/sys/extend/addon/' . $repoName; + if (!is_dir($repoDir)) { + logger('Repo directory does not exist: ' . $repoDir); + json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false)); + } + if (!is_writable($repoDir)) { + logger('Repo directory not writable to web server: ' . $repoDir); + json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false)); + } + /// @TODO remove directory and unlink /addon/files + if (rrmdir($repoDir)) { + json_return_and_die(array('message' => 'Repo deleted.', 'success' => true)); + } else { + json_return_and_die(array('message' => 'Error deleting addon repo.', 'success' => false)); + } + case 'installrepo': + if (array_key_exists('repoURL', $_REQUEST)) { + require_once('library/PHPGit.autoload.php'); // Load PHPGit dependencies + $repoURL = $_REQUEST['repoURL']; + $extendDir = 'store/[data]/git/sys/extend'; + $addonDir = $extendDir . '/addon'; + if (!file_exists($extendDir)) { + if (!mkdir($extendDir, 0770, true)) { + logger('Error creating extend folder: ' . $extendDir); + json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); + } else { + if (!symlink(realpath('extend/addon'), $addonDir)) { + logger('Error creating symlink to addon folder: ' . $addonDir); + json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); + } + } + } + if (!is_writable($extendDir)) { + logger('Directory not writable to web server: ' . $extendDir); + json_return_and_die(array('message' => 'Directory not writable to web server.', 'success' => false)); + } + $repoName = null; + if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') { + $repoName = $_REQUEST['repoName']; + } else { + $repoName = GitRepo::getRepoNameFromURL($repoURL); + } + if (!$repoName) { + logger('Invalid git repo'); + json_return_and_die(array('message' => 'Invalid git repo', 'success' => false)); + } + $repoDir = $addonDir . '/' . $repoName; + $tempRepoBaseDir = 'store/[data]/git/sys/temp/'; + $tempAddonDir = $tempRepoBaseDir . $repoName; + + if (!is_writable($addonDir) || !is_writable($tempAddonDir)) { + logger('Temp repo directory or /extend/addon not writable to web server: ' . $tempAddonDir); + json_return_and_die(array('message' => 'Temp repo directory not writable to web server.', 'success' => false)); + } + rename($tempAddonDir, $repoDir); + + if (!is_writable(realpath('addon/'))) { + logger('/addon directory not writable to web server: ' . $tempAddonDir); + json_return_and_die(array('message' => '/addon directory not writable to web server.', 'success' => false)); + } + $files = array_diff(scandir($repoDir), array('.', '..')); + foreach ($files as $file) { + if (is_dir($repoDir . '/' . $file) && $file !== '.git') { + $source = '../extend/addon/' . $repoName . '/' . $file; + $target = realpath('addon/') . '/' . $file; + unlink($target); + if (!symlink($source, $target)) { + logger('Error linking addons to /addon'); + json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false)); + } + } + } + $git = new GitRepo('sys', $repoURL, false, $repoName, $repoDir); + $repo = $git->probeRepo(); + json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true)); + } + case 'addrepo': + if (array_key_exists('repoURL', $_REQUEST)) { + require_once('library/PHPGit.autoload.php'); // Load PHPGit dependencies + $repoURL = $_REQUEST['repoURL']; + $extendDir = 'store/[data]/git/sys/extend'; + $addonDir = $extendDir . '/addon'; + $tempAddonDir = realpath('store/[data]') . '/git/sys/temp'; + if (!file_exists($extendDir)) { + if (!mkdir($extendDir, 0770, true)) { + logger('Error creating extend folder: ' . $extendDir); + json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); + } else { + if (!symlink(realpath('extend/addon'), $addonDir)) { + logger('Error creating symlink to addon folder: ' . $addonDir); + json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); + } + } + } + if (!is_dir($tempAddonDir)) { + if (!mkdir($tempAddonDir, 0770, true)) { + logger('Error creating temp plugin repo folder: ' . $tempAddonDir); + json_return_and_die(array('message' => 'Error creating temp plugin repo folder: ' . $tempAddonDir, 'success' => false)); + } + } + $repoName = null; + if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') { + $repoName = $_REQUEST['repoName']; + } else { + $repoName = GitRepo::getRepoNameFromURL($repoURL); + } + if (!$repoName) { + logger('Invalid git repo'); + json_return_and_die(array('message' => 'Invalid git repo: ' . $repoName, 'success' => false)); + } + $repoDir = $tempAddonDir . '/' . $repoName; + if (!is_writable($tempAddonDir)) { + logger('Temporary directory for new addon repo is not writable to web server: ' . $tempAddonDir); + json_return_and_die(array('message' => 'Temporary directory for new addon repo is not writable to web server.', 'success' => false)); + } + // clone the repo if new automatically + $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir); + + $remotes = $git->git->remote(); + $fetchURL = $remotes['origin']['fetch']; + if ($fetchURL !== $git->url) { + if (rrmdir($repoDir)) { + $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir); + } else { + json_return_and_die(array('message' => 'Error deleting existing addon repo.', 'success' => false)); + } + } + $repo = $git->probeRepo(); + $repo['readme'] = $repo['manifest'] = null; + foreach ($git->git->tree('master') as $object) { + if ($object['type'] == 'blob' && (strtolower($object['file']) === 'readme.md' || strtolower($object['file']) === 'readme')) { + $repo['readme'] = MarkdownExtra::defaultTransform($git->git->cat->blob($object['hash'])); + } else if ($object['type'] == 'blob' && strtolower($object['file']) === 'manifest.json') { + $repo['manifest'] = $git->git->cat->blob($object['hash']); + } + } + json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true)); + } else { + json_return_and_die(array('message' => 'No repo URL provided', 'success' => false)); + } + break; + default: + break; + } + } + } + + /** + * @brief Addons admin page. + * + * @return string with parsed HTML + */ + function get() { + + /* + * Single plugin + */ + + if (\App::$argc == 3){ + $plugin = \App::$argv[2]; + if (!is_file("addon/$plugin/$plugin.php")){ + notice( t("Item not found.") ); + return ''; + } + + $enabled = in_array($plugin,\App::$plugins); + $info = get_plugin_info($plugin); + $x = check_plugin_versions($info); + + // disable plugins which are installed but incompatible versions + + if($enabled && ! $x) { + $enabled = false; + $idz = array_search($plugin, \App::$plugins); + if ($idz !== false) { + unset(\App::$plugins[$idz]); + uninstall_plugin($plugin); + set_config("system","addon", implode(", ",\App::$plugins)); + } + } + $info['disabled'] = 1-intval($x); + + if (x($_GET,"a") && $_GET['a']=="t"){ + check_form_security_token_redirectOnErr('/admin/addons', 'admin_addons', 't'); + $pinstalled = false; + // Toggle plugin status + $idx = array_search($plugin, \App::$plugins); + if ($idx !== false){ + unset(\App::$plugins[$idx]); + uninstall_plugin($plugin); + $pinstalled = false; + info( sprintf( t("Plugin %s disabled."), $plugin ) ); + } else { + \App::$plugins[] = $plugin; + install_plugin($plugin); + $pinstalled = true; + info( sprintf( t("Plugin %s enabled."), $plugin ) ); + } + set_config("system","addon", implode(", ",\App::$plugins)); + + if($pinstalled) { + @require_once("addon/$plugin/$plugin.php"); + if(function_exists($plugin.'_plugin_admin')) + goaway(z_root() . '/admin/addons/' . $plugin); + } + goaway(z_root() . '/admin/addons' ); + } + + // display plugin details + + if (in_array($plugin, \App::$plugins)){ + $status = 'on'; + $action = t('Disable'); + } else { + $status = 'off'; + $action = t('Enable'); + } + + $readme = null; + if (is_file("addon/$plugin/README.md")){ + $readme = file_get_contents("addon/$plugin/README.md"); + $readme = MarkdownExtra::defaultTransform($readme); + } else if (is_file("addon/$plugin/README")){ + $readme = "
". file_get_contents("addon/$plugin/README") ."
"; + } + + $admin_form = ''; + + $r = q("select * from addon where plugin_admin = 1 and aname = '%s' limit 1", + dbesc($plugin) + ); + + if($r) { + @require_once("addon/$plugin/$plugin.php"); + if(function_exists($plugin.'_plugin_admin')) { + $func = $plugin.'_plugin_admin'; + $func($a, $admin_form); + } + } + + + $t = get_markup_template('admin_plugins_details.tpl'); + return replace_macros($t, array( + '$title' => t('Administration'), + '$page' => t('Addons'), + '$toggle' => t('Toggle'), + '$settings' => t('Settings'), + '$baseurl' => z_root(), + + '$plugin' => $plugin, + '$status' => $status, + '$action' => $action, + '$info' => $info, + '$str_author' => t('Author: '), + '$str_maintainer' => t('Maintainer: '), + '$str_minversion' => t('Minimum project version: '), + '$str_maxversion' => t('Maximum project version: '), + '$str_minphpversion' => t('Minimum PHP version: '), + '$str_serverroles' => t('Compatible Server Roles: '), + '$str_requires' => t('Requires: '), + '$disabled' => t('Disabled - version incompatibility'), + + '$admin_form' => $admin_form, + '$function' => 'addons', + '$screenshot' => '', + '$readme' => $readme, + + '$form_security_token' => get_form_security_token('admin_addons'), + )); + } + + + /* + * List plugins + */ + $plugins = array(); + $files = glob('addon/*/'); + if($files) { + foreach($files as $file) { + if (is_dir($file)){ + list($tmp, $id) = array_map('trim', explode('/', $file)); + $info = get_plugin_info($id); + $enabled = in_array($id,\App::$plugins); + $x = check_plugin_versions($info); + + // disable plugins which are installed but incompatible versions + + if($enabled && ! $x) { + $enabled = false; + $idz = array_search($id, \App::$plugins); + if ($idz !== false) { + unset(\App::$plugins[$idz]); + uninstall_plugin($id); + set_config("system","addon", implode(", ",\App::$plugins)); + } + } + $info['disabled'] = 1-intval($x); + + $plugins[] = array( $id, (($enabled)?"on":"off") , $info); + } + } + } + + usort($plugins,'self::plugin_sort'); + + $allowManageRepos = false; + if(is_writable('extend/addon') && is_writable('store/[data]')) { + $allowManageRepos = true; + } + + $admin_plugins_add_repo_form= replace_macros( + get_markup_template('admin_plugins_addrepo.tpl'), array( + '$post' => 'admin/addons/addrepo', + '$desc' => t('Enter the public git repository URL of the addon repo.'), + '$repoURL' => array('repoURL', t('Addon repo git URL'), '', ''), + '$repoName' => array('repoName', t('Custom repo name'), '', '', t('(optional)')), + '$submit' => t('Download Addon Repo') + ) + ); + $newRepoModalID = random_string(3); + $newRepoModal = replace_macros( + get_markup_template('generic_modal.tpl'), array( + '$id' => $newRepoModalID, + '$title' => t('Install new repo'), + '$ok' => t('Install'), + '$cancel' => t('Cancel') + ) + ); + + $reponames = $this->listAddonRepos(); + $addonrepos = []; + foreach($reponames as $repo) { + $addonrepos[] = array('name' => $repo, 'description' => ''); + /// @TODO Parse repo info to provide more information about repos + } + + $t = get_markup_template('admin_plugins.tpl'); + return replace_macros($t, array( + '$title' => t('Administration'), + '$page' => t('Addons'), + '$submit' => t('Submit'), + '$baseurl' => z_root(), + '$function' => 'addons', + '$plugins' => $plugins, + '$disabled' => t('Disabled - version incompatibility'), + '$form_security_token' => get_form_security_token('admin_addons'), + '$allowManageRepos' => $allowManageRepos, + '$managerepos' => t('Manage Repos'), + '$installedtitle' => t('Installed Addon Repositories'), + '$addnewrepotitle' => t('Install a New Addon Repository'), + '$expandform' => false, + '$form' => $admin_plugins_add_repo_form, + '$newRepoModal' => $newRepoModal, + '$newRepoModalID' => $newRepoModalID, + '$addonrepos' => $addonrepos, + '$repoUpdateButton' => t('Update'), + '$repoBranchButton' => t('Switch branch'), + '$repoRemoveButton' => t('Remove') + )); + } + + function listAddonRepos() { + $addonrepos = []; + $addonDir = 'extend/addon/'; + if(is_dir($addonDir)) { + if ($handle = opendir($addonDir)) { + while (false !== ($entry = readdir($handle))) { + if ($entry != "." && $entry != "..") { + $addonrepos[] = $entry; + } + } + closedir($handle); + } + } + return $addonrepos; + } + + static public function plugin_sort($a,$b) { + return(strcmp(strtolower($a[2]['name']),strtolower($b[2]['name']))); + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Admin/Plugins.php b/Zotlabs/Module/Admin/Plugins.php deleted file mode 100644 index feb29e9d6..000000000 --- a/Zotlabs/Module/Admin/Plugins.php +++ /dev/null @@ -1,479 +0,0 @@ - 2 && is_file("addon/" . argv(2) . "/" . argv(2) . ".php")) { - @include_once("addon/" . argv(2) . "/" . argv(2) . ".php"); - if(function_exists(argv(2).'_plugin_admin_post')) { - $func = argv(2) . '_plugin_admin_post'; - $func($a); - } - - goaway(z_root() . '/admin/plugins/' . argv(2) ); - } - elseif(argc() > 2) { - switch(argv(2)) { - case 'updaterepo': - if (array_key_exists('repoName', $_REQUEST)) { - $repoName = $_REQUEST['repoName']; - } - else { - json_return_and_die(array('message' => 'No repo name provided.', 'success' => false)); - } - $extendDir = 'store/[data]/git/sys/extend'; - $addonDir = $extendDir . '/addon'; - if (!file_exists($extendDir)) { - if (!mkdir($extendDir, 0770, true)) { - logger('Error creating extend folder: ' . $extendDir); - json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); - } - else { - if (!symlink(realpath('extend/addon'), $addonDir)) { - logger('Error creating symlink to addon folder: ' . $addonDir); - json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); - } - } - } - $repoDir = 'store/[data]/git/sys/extend/addon/' . $repoName; - if (!is_dir($repoDir)) { - logger('Repo directory does not exist: ' . $repoDir); - json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false)); - } - if (!is_writable($repoDir)) { - logger('Repo directory not writable to web server: ' . $repoDir); - json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false)); - } - $git = new GitRepo('sys', null, false, $repoName, $repoDir); - try { - if ($git->pull()) { - $files = array_diff(scandir($repoDir), array('.', '..')); - foreach ($files as $file) { - if (is_dir($repoDir . '/' . $file) && $file !== '.git') { - $source = '../extend/addon/' . $repoName . '/' . $file; - $target = realpath('addon/') . '/' . $file; - unlink($target); - if (!symlink($source, $target)) { - logger('Error linking addons to /addon'); - json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false)); - } - } - } - json_return_and_die(array('message' => 'Repo updated.', 'success' => true)); - } else { - json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false)); - } - } catch (\PHPGit\Exception\GitException $e) { - json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false)); - } - case 'removerepo': - if (array_key_exists('repoName', $_REQUEST)) { - $repoName = $_REQUEST['repoName']; - } else { - json_return_and_die(array('message' => 'No repo name provided.', 'success' => false)); - } - $extendDir = 'store/[data]/git/sys/extend'; - $addonDir = $extendDir . '/addon'; - if (!file_exists($extendDir)) { - if (!mkdir($extendDir, 0770, true)) { - logger('Error creating extend folder: ' . $extendDir); - json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); - } else { - if (!symlink(realpath('extend/addon'), $addonDir)) { - logger('Error creating symlink to addon folder: ' . $addonDir); - json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); - } - } - } - $repoDir = 'store/[data]/git/sys/extend/addon/' . $repoName; - if (!is_dir($repoDir)) { - logger('Repo directory does not exist: ' . $repoDir); - json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false)); - } - if (!is_writable($repoDir)) { - logger('Repo directory not writable to web server: ' . $repoDir); - json_return_and_die(array('message' => 'Repo directory not writable to web server.', 'success' => false)); - } - /// @TODO remove directory and unlink /addon/files - if (rrmdir($repoDir)) { - json_return_and_die(array('message' => 'Repo deleted.', 'success' => true)); - } else { - json_return_and_die(array('message' => 'Error deleting addon repo.', 'success' => false)); - } - case 'installrepo': - if (array_key_exists('repoURL', $_REQUEST)) { - require_once('library/PHPGit.autoload.php'); // Load PHPGit dependencies - $repoURL = $_REQUEST['repoURL']; - $extendDir = 'store/[data]/git/sys/extend'; - $addonDir = $extendDir . '/addon'; - if (!file_exists($extendDir)) { - if (!mkdir($extendDir, 0770, true)) { - logger('Error creating extend folder: ' . $extendDir); - json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); - } else { - if (!symlink(realpath('extend/addon'), $addonDir)) { - logger('Error creating symlink to addon folder: ' . $addonDir); - json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); - } - } - } - if (!is_writable($extendDir)) { - logger('Directory not writable to web server: ' . $extendDir); - json_return_and_die(array('message' => 'Directory not writable to web server.', 'success' => false)); - } - $repoName = null; - if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') { - $repoName = $_REQUEST['repoName']; - } else { - $repoName = GitRepo::getRepoNameFromURL($repoURL); - } - if (!$repoName) { - logger('Invalid git repo'); - json_return_and_die(array('message' => 'Invalid git repo', 'success' => false)); - } - $repoDir = $addonDir . '/' . $repoName; - $tempRepoBaseDir = 'store/[data]/git/sys/temp/'; - $tempAddonDir = $tempRepoBaseDir . $repoName; - - if (!is_writable($addonDir) || !is_writable($tempAddonDir)) { - logger('Temp repo directory or /extend/addon not writable to web server: ' . $tempAddonDir); - json_return_and_die(array('message' => 'Temp repo directory not writable to web server.', 'success' => false)); - } - rename($tempAddonDir, $repoDir); - - if (!is_writable(realpath('addon/'))) { - logger('/addon directory not writable to web server: ' . $tempAddonDir); - json_return_and_die(array('message' => '/addon directory not writable to web server.', 'success' => false)); - } - $files = array_diff(scandir($repoDir), array('.', '..')); - foreach ($files as $file) { - if (is_dir($repoDir . '/' . $file) && $file !== '.git') { - $source = '../extend/addon/' . $repoName . '/' . $file; - $target = realpath('addon/') . '/' . $file; - unlink($target); - if (!symlink($source, $target)) { - logger('Error linking addons to /addon'); - json_return_and_die(array('message' => 'Error linking addons to /addon', 'success' => false)); - } - } - } - $git = new GitRepo('sys', $repoURL, false, $repoName, $repoDir); - $repo = $git->probeRepo(); - json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true)); - } - case 'addrepo': - if (array_key_exists('repoURL', $_REQUEST)) { - require_once('library/PHPGit.autoload.php'); // Load PHPGit dependencies - $repoURL = $_REQUEST['repoURL']; - $extendDir = 'store/[data]/git/sys/extend'; - $addonDir = $extendDir . '/addon'; - $tempAddonDir = realpath('store/[data]') . '/git/sys/temp'; - if (!file_exists($extendDir)) { - if (!mkdir($extendDir, 0770, true)) { - logger('Error creating extend folder: ' . $extendDir); - json_return_and_die(array('message' => 'Error creating extend folder: ' . $extendDir, 'success' => false)); - } else { - if (!symlink(realpath('extend/addon'), $addonDir)) { - logger('Error creating symlink to addon folder: ' . $addonDir); - json_return_and_die(array('message' => 'Error creating symlink to addon folder: ' . $addonDir, 'success' => false)); - } - } - } - if (!is_dir($tempAddonDir)) { - if (!mkdir($tempAddonDir, 0770, true)) { - logger('Error creating temp plugin repo folder: ' . $tempAddonDir); - json_return_and_die(array('message' => 'Error creating temp plugin repo folder: ' . $tempAddonDir, 'success' => false)); - } - } - $repoName = null; - if (array_key_exists('repoName', $_REQUEST) && $_REQUEST['repoName'] !== '') { - $repoName = $_REQUEST['repoName']; - } else { - $repoName = GitRepo::getRepoNameFromURL($repoURL); - } - if (!$repoName) { - logger('Invalid git repo'); - json_return_and_die(array('message' => 'Invalid git repo: ' . $repoName, 'success' => false)); - } - $repoDir = $tempAddonDir . '/' . $repoName; - if (!is_writable($tempAddonDir)) { - logger('Temporary directory for new addon repo is not writable to web server: ' . $tempAddonDir); - json_return_and_die(array('message' => 'Temporary directory for new addon repo is not writable to web server.', 'success' => false)); - } - // clone the repo if new automatically - $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir); - - $remotes = $git->git->remote(); - $fetchURL = $remotes['origin']['fetch']; - if ($fetchURL !== $git->url) { - if (rrmdir($repoDir)) { - $git = new GitRepo('sys', $repoURL, true, $repoName, $repoDir); - } else { - json_return_and_die(array('message' => 'Error deleting existing addon repo.', 'success' => false)); - } - } - $repo = $git->probeRepo(); - $repo['readme'] = $repo['manifest'] = null; - foreach ($git->git->tree('master') as $object) { - if ($object['type'] == 'blob' && (strtolower($object['file']) === 'readme.md' || strtolower($object['file']) === 'readme')) { - $repo['readme'] = MarkdownExtra::defaultTransform($git->git->cat->blob($object['hash'])); - } else if ($object['type'] == 'blob' && strtolower($object['file']) === 'manifest.json') { - $repo['manifest'] = $git->git->cat->blob($object['hash']); - } - } - json_return_and_die(array('repo' => $repo, 'message' => '', 'success' => true)); - } else { - json_return_and_die(array('message' => 'No repo URL provided', 'success' => false)); - } - break; - default: - break; - } - } - } - - /** - * @brief Plugins admin page. - * - * @return string with parsed HTML - */ - function get() { - - /* - * Single plugin - */ - - if (\App::$argc == 3){ - $plugin = \App::$argv[2]; - if (!is_file("addon/$plugin/$plugin.php")){ - notice( t("Item not found.") ); - return ''; - } - - $enabled = in_array($plugin,\App::$plugins); - $info = get_plugin_info($plugin); - $x = check_plugin_versions($info); - - // disable plugins which are installed but incompatible versions - - if($enabled && ! $x) { - $enabled = false; - $idz = array_search($plugin, \App::$plugins); - if ($idz !== false) { - unset(\App::$plugins[$idz]); - uninstall_plugin($plugin); - set_config("system","addon", implode(", ",\App::$plugins)); - } - } - $info['disabled'] = 1-intval($x); - - if (x($_GET,"a") && $_GET['a']=="t"){ - check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't'); - $pinstalled = false; - // Toggle plugin status - $idx = array_search($plugin, \App::$plugins); - if ($idx !== false){ - unset(\App::$plugins[$idx]); - uninstall_plugin($plugin); - $pinstalled = false; - info( sprintf( t("Plugin %s disabled."), $plugin ) ); - } else { - \App::$plugins[] = $plugin; - install_plugin($plugin); - $pinstalled = true; - info( sprintf( t("Plugin %s enabled."), $plugin ) ); - } - set_config("system","addon", implode(", ",\App::$plugins)); - - if($pinstalled) { - @require_once("addon/$plugin/$plugin.php"); - if(function_exists($plugin.'_plugin_admin')) - goaway(z_root() . '/admin/plugins/' . $plugin); - } - goaway(z_root() . '/admin/plugins' ); - } - - // display plugin details - - if (in_array($plugin, \App::$plugins)){ - $status = 'on'; - $action = t('Disable'); - } else { - $status = 'off'; - $action = t('Enable'); - } - - $readme = null; - if (is_file("addon/$plugin/README.md")){ - $readme = file_get_contents("addon/$plugin/README.md"); - $readme = MarkdownExtra::defaultTransform($readme); - } else if (is_file("addon/$plugin/README")){ - $readme = "
". file_get_contents("addon/$plugin/README") ."
"; - } - - $admin_form = ''; - - $r = q("select * from addon where plugin_admin = 1 and aname = '%s' limit 1", - dbesc($plugin) - ); - - if($r) { - @require_once("addon/$plugin/$plugin.php"); - if(function_exists($plugin.'_plugin_admin')) { - $func = $plugin.'_plugin_admin'; - $func($a, $admin_form); - } - } - - - $t = get_markup_template('admin_plugins_details.tpl'); - return replace_macros($t, array( - '$title' => t('Administration'), - '$page' => t('Plugins'), - '$toggle' => t('Toggle'), - '$settings' => t('Settings'), - '$baseurl' => z_root(), - - '$plugin' => $plugin, - '$status' => $status, - '$action' => $action, - '$info' => $info, - '$str_author' => t('Author: '), - '$str_maintainer' => t('Maintainer: '), - '$str_minversion' => t('Minimum project version: '), - '$str_maxversion' => t('Maximum project version: '), - '$str_minphpversion' => t('Minimum PHP version: '), - '$str_serverroles' => t('Compatible Server Roles: '), - '$str_requires' => t('Requires: '), - '$disabled' => t('Disabled - version incompatibility'), - - '$admin_form' => $admin_form, - '$function' => 'plugins', - '$screenshot' => '', - '$readme' => $readme, - - '$form_security_token' => get_form_security_token('admin_plugins'), - )); - } - - - /* - * List plugins - */ - $plugins = array(); - $files = glob('addon/*/'); - if($files) { - foreach($files as $file) { - if (is_dir($file)){ - list($tmp, $id) = array_map('trim', explode('/', $file)); - $info = get_plugin_info($id); - $enabled = in_array($id,\App::$plugins); - $x = check_plugin_versions($info); - - // disable plugins which are installed but incompatible versions - - if($enabled && ! $x) { - $enabled = false; - $idz = array_search($id, \App::$plugins); - if ($idz !== false) { - unset(\App::$plugins[$idz]); - uninstall_plugin($id); - set_config("system","addon", implode(", ",\App::$plugins)); - } - } - $info['disabled'] = 1-intval($x); - - $plugins[] = array( $id, (($enabled)?"on":"off") , $info); - } - } - } - - usort($plugins,'self::plugin_sort'); - - $allowManageRepos = false; - if(is_writable('extend/addon') && is_writable('store/[data]')) { - $allowManageRepos = true; - } - - $admin_plugins_add_repo_form= replace_macros( - get_markup_template('admin_plugins_addrepo.tpl'), array( - '$post' => 'admin/plugins/addrepo', - '$desc' => t('Enter the public git repository URL of the plugin repo.'), - '$repoURL' => array('repoURL', t('Plugin repo git URL'), '', ''), - '$repoName' => array('repoName', t('Custom repo name'), '', '', t('(optional)')), - '$submit' => t('Download Plugin Repo') - ) - ); - $newRepoModalID = random_string(3); - $newRepoModal = replace_macros( - get_markup_template('generic_modal.tpl'), array( - '$id' => $newRepoModalID, - '$title' => t('Install new repo'), - '$ok' => t('Install'), - '$cancel' => t('Cancel') - ) - ); - - $reponames = $this->listAddonRepos(); - $addonrepos = []; - foreach($reponames as $repo) { - $addonrepos[] = array('name' => $repo, 'description' => ''); - /// @TODO Parse repo info to provide more information about repos - } - - $t = get_markup_template('admin_plugins.tpl'); - return replace_macros($t, array( - '$title' => t('Administration'), - '$page' => t('Plugins'), - '$submit' => t('Submit'), - '$baseurl' => z_root(), - '$function' => 'plugins', - '$plugins' => $plugins, - '$disabled' => t('Disabled - version incompatibility'), - '$form_security_token' => get_form_security_token('admin_plugins'), - '$allowManageRepos' => $allowManageRepos, - '$managerepos' => t('Manage Repos'), - '$installedtitle' => t('Installed Plugin Repositories'), - '$addnewrepotitle' => t('Install a New Plugin Repository'), - '$expandform' => false, - '$form' => $admin_plugins_add_repo_form, - '$newRepoModal' => $newRepoModal, - '$newRepoModalID' => $newRepoModalID, - '$addonrepos' => $addonrepos, - '$repoUpdateButton' => t('Update'), - '$repoBranchButton' => t('Switch branch'), - '$repoRemoveButton' => t('Remove') - )); - } - - function listAddonRepos() { - $addonrepos = []; - $addonDir = 'extend/addon/'; - if(is_dir($addonDir)) { - if ($handle = opendir($addonDir)) { - while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != "..") { - $addonrepos[] = $entry; - } - } - closedir($handle); - } - } - return $addonrepos; - } - - static public function plugin_sort($a,$b) { - return(strcmp(strtolower($a[2]['name']),strtolower($b[2]['name']))); - } - -} \ No newline at end of file diff --git a/Zotlabs/Widget/Admin.php b/Zotlabs/Widget/Admin.php index a761eebe3..f349377a0 100644 --- a/Zotlabs/Widget/Admin.php +++ b/Zotlabs/Widget/Admin.php @@ -24,7 +24,7 @@ class Admin { 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), 'security' => array(z_root() . '/admin/security/', t('Security'), 'security'), 'features' => array(z_root() . '/admin/features/', t('Features'), 'features'), - 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), + 'addons' => array(z_root() . '/admin/addons/', t('Addons'), 'addons'), 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), 'profs' => array(z_root() . '/admin/profs', t('Profile Fields'), 'profs'), @@ -39,7 +39,7 @@ class Admin { if($r) { foreach ($r as $h){ $plugin = $h['aname']; - $plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); + $plugins[] = array(z_root() . '/admin/addons/' . $plugin, $plugin, 'plugin'); // temp plugins with admin \App::$plugins_admin[] = $plugin; } @@ -53,7 +53,7 @@ class Admin { $o .= replace_macros(get_markup_template('admin_aside.tpl'), array( '$admin' => $aside, '$admtxt' => t('Admin'), - '$plugadmtxt' => t('Plugin Features'), + '$plugadmtxt' => t('Addon Features'), '$plugins' => $plugins, '$logtxt' => t('Logs'), '$logs' => $logs, -- cgit v1.2.3 From c28e27357a1ce700b91021344050ec531bce3889 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 28 Jun 2018 23:17:50 -0700 Subject: add the missing link to manage privacy groups --- Zotlabs/Widget/Activity_filter.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index fadf39144..2df9e518a 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -63,6 +63,14 @@ class Activity_filter { 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']) ]; } + $gsub[] = [ + 'label' => t('Manage Privacy Groups'), + 'icon' => 'gear', + 'url' => z_root() . '/group', + 'sel' => '', + 'title' => t('Create and edit privacy groups and members') + ]; + $tabs[] = [ 'id' => 'privacy_groups', 'label' => t('Privacy Groups'), -- cgit v1.2.3 From 5d7d30f7898171f0a7bd687bf4888695b2dd8af3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 30 Jun 2018 23:57:25 -0700 Subject: propagate expired posts to other networks --- Zotlabs/Daemon/Cron.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 01c43262a..d1c516f96 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -50,14 +50,19 @@ class Cron { // expire any expired items - $r = q("select id from item where expires > '2001-01-01 00:00:00' and expires < %s + $r = q("select id,item_wall from item where expires > '2001-01-01 00:00:00' and expires < %s and item_deleted = 0 ", db_utcnow() ); if($r) { require_once('include/items.php'); - foreach($r as $rr) - drop_item($rr['id'],false); + foreach($r as $rr) { + drop_item($rr['id'],false,(($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL)); + if($rr['item_wall']) { + // The notifier isn't normally invoked unless item_drop is interactive. + Zotlabs\Daemon\Master::Summon( [ 'Notifier', 'drop', $rr['id'] ] ); + } + } } -- cgit v1.2.3 From 8c26db63ddf449a033e488b5d95af83fe08bdb2e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 1 Jul 2018 19:12:45 -0700 Subject: some changes to support plume --- Zotlabs/Lib/ActivityStreams.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 3a99e7b49..37e717f58 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -36,6 +36,7 @@ class ActivityStreams { $this->raw = $string; $this->data = json_decode($string, true); + if($this->data) { $this->valid = true; } @@ -206,7 +207,7 @@ class ActivityStreams { } $x = z_fetch_url($url, true, $redirects, - ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/activity+json' ]]); + ['headers' => [ 'Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ]]); if($x['success']) return json_decode($x['body'], true); -- cgit v1.2.3 From b88a9c2627e632d0f963e0078191eb616e5a1668 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Jul 2018 10:53:07 +0200 Subject: Revert "add the missing link to manage privacy groups" This reverts commit c28e27357a1ce700b91021344050ec531bce3889. --- Zotlabs/Widget/Activity_filter.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 2df9e518a..fadf39144 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -63,14 +63,6 @@ class Activity_filter { 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']) ]; } - $gsub[] = [ - 'label' => t('Manage Privacy Groups'), - 'icon' => 'gear', - 'url' => z_root() . '/group', - 'sel' => '', - 'title' => t('Create and edit privacy groups and members') - ]; - $tabs[] = [ 'id' => 'privacy_groups', 'label' => t('Privacy Groups'), -- cgit v1.2.3 From d9ece80fda867768fb3b8de47bf4eb7c3e6108e8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Jul 2018 10:55:38 +0200 Subject: order nouveau by created instead of received since ordering by received returns unexpected results once old expired items get re-imported --- Zotlabs/Module/Network.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 172157aab..77a08585b 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -480,7 +480,7 @@ class Network extends \Zotlabs\Web\Controller { if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order - $items = q("SELECT item.*, item.id AS item_id, received FROM item + $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 WHERE true $uids $item_normal @@ -488,7 +488,7 @@ class Network extends \Zotlabs\Web\Controller { $simple_update $sql_extra $sql_options $sql_nets $net_query2 - ORDER BY item.received DESC $pager_sql " + ORDER BY item.created DESC $pager_sql " ); require_once('include/items.php'); -- cgit v1.2.3 From f6e8ce5516eeaf2e0525f69099d68a55df9501e3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 4 Jul 2018 23:20:35 -0700 Subject: appstore changes --- Zotlabs/Lib/Apps.php | 88 +++++++++++++++++++++++++++++++++++----- Zotlabs/Module/Apps.php | 6 ++- Zotlabs/Widget/Appcategories.php | 3 ++ Zotlabs/Widget/Appstore.php | 18 ++++++++ 4 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 Zotlabs/Widget/Appstore.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 2dded1aaa..81f426f4b 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -13,7 +13,12 @@ require_once('include/channel.php'); class Apps { - static public $installed_system_apps = null; + static public $available_apps = null; + static public $installed_apps = null; + + static public $base_apps = null; + + static public function get_system_apps($translate = true) { @@ -55,22 +60,52 @@ class Apps { static public function import_system_apps() { if(! local_channel()) return; + + self::$base_apps = get_config('system','base_apps',[ + 'Connections', + 'Suggest Channels', + 'Grid', + 'Settings', + 'Files', + 'Channel Home', + 'View Profile', + 'Photos', + 'Events', + 'Directory', + 'Search', + 'Help', + 'Mail', + 'Profile Photo' + ]); + $apps = self::get_system_apps(false); - self::$installed_system_apps = q("select * from app where app_system = 1 and app_channel = %d", + self::$available_apps = q("select * from app where app_channel = 0"); + + self::$installed_apps = q("select * from app where app_channel = %d", intval(local_channel()) ); if($apps) { foreach($apps as $app) { $id = self::check_install_system_app($app); + + // $id will be boolean true or false to install an app, or an integer id to update an existing app + if($id !== false) { + $app['uid'] = 0; + $app['guid'] = hash('whirlpool',$app['name']); + $app['system'] = 1; + self::app_install(0,$app); + } + + $id = self::check_install_personal_app($app); // $id will be boolean true or false to install an app, or an integer id to update an existing app if($id === false) continue; if($id !== true) { // if we already installed this app, but it changed, preserve any categories we created - $s = ''; - $r = q("select * from term where otype = %d and oid = %d", + $s = EMPTY_STR; + $r = q("select term from term where otype = %d and oid = %d", intval(TERM_OBJ_APP), intval($id) ); @@ -87,6 +122,7 @@ class Apps { $app['guid'] = hash('whirlpool',$app['name']); $app['system'] = 1; self::app_install(local_channel(),$app); + } } } @@ -97,11 +133,11 @@ class Apps { */ static public function check_install_system_app($app) { - if((! is_array(self::$installed_system_apps)) || (! count(self::$installed_system_apps))) { + if((! is_array(self::$available_apps)) || (! count(self::$available_apps))) { return true; } $notfound = true; - foreach(self::$installed_system_apps as $iapp) { + foreach(self::$available_apps as $iapp) { if($iapp['app_id'] == hash('whirlpool',$app['name'])) { $notfound = false; if(($iapp['app_version'] != $app['version']) @@ -115,6 +151,28 @@ class Apps { } + /** + * Install the system app if no system apps have been installed, or if a new system app + * is discovered, or if the version of a system app changes. + */ + + static public function check_install_personal_app($app) { + foreach(self::$installed_apps as $iapp) { + $install = false; + if($iapp['app_id'] == hash('whirlpool',$app['name'])) { + if(($iapp['app_version'] != $app['version']) + || ($app['plugin'] && (! $iapp['app_plugin']))) { + return intval($iapp['app_id']); + } + } + } + if(in_array($app['name'],self::$base_apps)) { + return true; + } + return false; + } + + static public function app_name_compare($a,$b) { return strcasecmp($a['name'],$b['name']); } @@ -235,7 +293,6 @@ class Apps { 'View Bookmarks' => t('View Bookmarks'), 'My Chatrooms' => t('My Chatrooms'), 'Connections' => t('Connections'), - 'Firefox Share' => t('Firefox Share'), 'Remote Diagnostics' => t('Remote Diagnostics'), 'Suggest Channels' => t('Suggest Channels'), 'Login' => t('Login'), @@ -290,6 +347,7 @@ class Apps { * modes: * view: normal mode for viewing an app via bbcode from a conversation or page * provides install/update button if you're logged in locally + * install: like view but does not display app-bin options if they are present * list: normal mode for viewing an app on the app page * no buttons are shown * edit: viewing the app page in editing mode provides a delete button @@ -302,7 +360,7 @@ class Apps { return; if(! $papp['photo']) - $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + $papp['photo'] = 'icon:gear'; self::translate_system_apps($papp); @@ -402,12 +460,15 @@ class Apps { )); } + if($mode === 'install') { + $papp['embed'] = true; + } return replace_macros(get_markup_template('app.tpl'),array( '$app' => $papp, '$icon' => $icon, '$hosturl' => $hosturl, '$purchase' => (($papp['page'] && (! $installed)) ? t('Purchase') : ''), - '$install' => (($hosturl && $mode == 'view') ? $install_action : ''), + '$install' => (($hosturl && in_array($mode, ['view','install'])) ? $install_action : ''), '$edit' => ((local_channel() && $installed && $mode == 'edit') ? t('Edit') : ''), '$delete' => ((local_channel() && $installed && $mode == 'edit') ? t('Delete') : ''), '$undelete' => ((local_channel() && $installed && $mode == 'edit') ? t('Undelete') : ''), @@ -738,12 +799,19 @@ class Apps { $darray = array(); $ret = array('success' => false); + $sys = get_sys_channel(); + + $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); - if((! $darray['app_url']) || (! $darray['app_channel'])) + if(! $darray['app_url']) return $ret; + if((! $arr['uid']) && (! $arr['author'])) { + $arr['author'] = $sys['channel_hash']; + } + if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) { $x = import_xchan_photo($arr['photo'],get_observer_hash(),true); $arr['photo'] = $x[1]; diff --git a/Zotlabs/Module/Apps.php b/Zotlabs/Module/Apps.php index c672ea467..10f40af71 100644 --- a/Zotlabs/Module/Apps.php +++ b/Zotlabs/Module/Apps.php @@ -15,6 +15,8 @@ class Apps extends \Zotlabs\Web\Controller { else $mode = 'list'; + $available = ((argc() == 2 && argv(1) === 'available') ? true : false); + $_SESSION['return_url'] = \App::$query_string; $apps = array(); @@ -23,7 +25,7 @@ class Apps extends \Zotlabs\Web\Controller { Zlib\Apps::import_system_apps(); $syslist = array(); $cat = ((array_key_exists('cat',$_GET) && $_GET['cat']) ? [ escape_tags($_GET['cat']) ] : ''); - $list = Zlib\Apps::app_list(local_channel(), (($mode == 'edit') ? true : false), $cat); + $list = Zlib\Apps::app_list((($available) ? 0 : local_channel()), (($mode == 'edit') ? true : false), $cat); if($list) { foreach($list as $x) { $syslist[] = Zlib\Apps::app_encode($x); @@ -39,7 +41,7 @@ class Apps extends \Zotlabs\Web\Controller { // logger('apps: ' . print_r($syslist,true)); foreach($syslist as $app) { - $apps[] = Zlib\Apps::app_render($app,$mode); + $apps[] = Zlib\Apps::app_render($app,(($available) ? 'install' : $mode)); } return replace_macros(get_markup_template('myapps.tpl'), array( diff --git a/Zotlabs/Widget/Appcategories.php b/Zotlabs/Widget/Appcategories.php index 8ff14230f..aebd144d0 100644 --- a/Zotlabs/Widget/Appcategories.php +++ b/Zotlabs/Widget/Appcategories.php @@ -17,6 +17,9 @@ class Appcategories { // Leaving this line which negates the effect of the two invalid lines prior $srchurl = z_root() . '/apps'; + if(argc() > 1 && argv(1) === 'available') + $srchurl .= '/available'; + $terms = array(); diff --git a/Zotlabs/Widget/Appstore.php b/Zotlabs/Widget/Appstore.php new file mode 100644 index 000000000..237707733 --- /dev/null +++ b/Zotlabs/Widget/Appstore.php @@ -0,0 +1,18 @@ + 1 && argv(1) === 'available') ? 1 : 0); + return replace_macros(get_markup_template('appstore.tpl'), [ + '$title' => t('App Collections'), + '$options' => [ + [ z_root() . '/apps/available', t('Available Apps'), $store ], + [ z_root() . '/apps', t('Installed apps'), 1 - $store ] + ] + ]); + } +} \ No newline at end of file -- cgit v1.2.3 From c80e009cf3750f559c18c526ebac62def7c3defb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 5 Jul 2018 21:46:34 -0700 Subject: app store fixes --- Zotlabs/Lib/Apps.php | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 81f426f4b..c2ec5c967 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -156,17 +156,20 @@ class Apps { * is discovered, or if the version of a system app changes. */ + + static public function check_install_personal_app($app) { - foreach(self::$installed_apps as $iapp) { - $install = false; + $installed = false; + foreach(self::$installed_apps as $iapp) { if($iapp['app_id'] == hash('whirlpool',$app['name'])) { + $installed = true; if(($iapp['app_version'] != $app['version']) || ($app['plugin'] && (! $iapp['app_plugin']))) { return intval($iapp['app_id']); } } } - if(in_array($app['name'],self::$base_apps)) { + if(! $installed && in_array($app['name'],self::$base_apps)) { return true; } return false; @@ -531,21 +534,13 @@ class Apps { intval(TERM_OBJ_APP), intval($x[0]['id']) ); - if($x[0]['app_system']) { - $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", - dbesc($app['guid']), - intval($uid) - ); - } - else { - $r = q("delete from app where app_id = '%s' and app_channel = %d", - dbesc($app['guid']), - intval($uid) - ); + $r = q("delete from app where app_id = '%s' and app_channel = %d", + dbesc($app['guid']), + intval($uid) + ); - // we don't sync system apps - they may be completely different on the other system - build_sync_packet($uid,array('app' => $x)); - } + // we don't sync system apps - they may be completely different on the other system + build_sync_packet($uid,array('app' => $x)); } else { self::app_undestroy($uid,$app); @@ -945,7 +940,7 @@ class Apps { // if updating an embed app, don't mess with any existing categories. - if(array_key_exists('embed',$arr) && intval($arr['embed'])) + if(array_key_exists('embed',$arr) && intval($arr['embed']) && (intval($darray['app_channel']))) return $ret; if($x) { -- cgit v1.2.3 From cc71e507cbb08a4dfec3fa273484297d048a940e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 5 Jul 2018 22:03:41 -0700 Subject: don't provide manage apps button when viewing all available --- Zotlabs/Module/Apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Apps.php b/Zotlabs/Module/Apps.php index 10f40af71..78c8d99ae 100644 --- a/Zotlabs/Module/Apps.php +++ b/Zotlabs/Module/Apps.php @@ -50,7 +50,7 @@ class Apps extends \Zotlabs\Web\Controller { '$title' => t('Apps'), '$apps' => $apps, '$authed' => ((local_channel()) ? true : false), - '$manage' => t('Manage apps'), + '$manage' => (($available) ? '' : t('Manage apps')), '$create' => (($mode == 'edit') ? t('Create new app') : '') )); -- cgit v1.2.3 From d9037728313a6efcac069dc77ae4c6bc932455e7 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Jul 2018 08:44:25 +0200 Subject: this is messing with names containing a comma and is superfluous now --- Zotlabs/Module/Notifications.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Notifications.php b/Zotlabs/Module/Notifications.php index dfa007548..1762ad5f6 100644 --- a/Zotlabs/Module/Notifications.php +++ b/Zotlabs/Module/Notifications.php @@ -41,8 +41,6 @@ class Notifications extends \Zotlabs\Web\Controller { $notifications_available = 1; foreach ($r as $rr) { $x = strip_tags(bbcode($rr['msg'])); - if(strpos($x,',')) - $x = substr($x,strpos($x,',')+1); $notif_content .= replace_macros(get_markup_template('notify.tpl'),array( '$item_link' => z_root().'/notify/view/'. $rr['id'], '$item_image' => $rr['photo'], -- cgit v1.2.3 From 931afe98b13399342d5abb4cb13cb09efc09ecad Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 18 Jul 2018 17:05:38 -0700 Subject: mangled urls on redirects (cherry picked from commit 5ce50d0a2e15ae66765a68ba2785a87ecda57f6a) --- Zotlabs/Module/Magic.php | 7 ++++--- Zotlabs/Module/Manage.php | 2 +- Zotlabs/Module/Nojs.php | 4 ++-- Zotlabs/Module/Rmagic.php | 10 +++++----- Zotlabs/Web/CheckJS.php | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 25c318f30..e034f1cdf 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -14,15 +14,16 @@ class Magic extends \Zotlabs\Web\Controller { logger('mod_magic: args: ' . print_r($_REQUEST,true),LOGGER_DATA); $addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : ''); + $bdest = ((x($_REQUEST,'bdest')) ? $_REQUEST['bdest'] : ''); $dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : ''); $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); $rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0); $owa = ((x($_REQUEST,'owa')) ? intval($_REQUEST['owa']) : 0); $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); - // Apache(?) appears to perform an htmlentities() operation on this variable - - $dest = html_entity_decode($dest); + + if($bdest) + $dest = hex2bin($bdest); $parsed = parse_url($dest); if(! $parsed) { diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index 9c5c32294..2c88a4df0 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -156,7 +156,7 @@ class Manage extends \Zotlabs\Web\Controller { if($delegates) { for($x = 0; $x < count($delegates); $x ++) { - $delegates[$x]['link'] = 'magic?f=&dest=' . urlencode($delegates[$x]['xchan_url']) + $delegates[$x]['link'] = 'magic?f=&bdest=' . bin2hex($delegates[$x]['xchan_url']) . '&delegate=' . urlencode($delegates[$x]['xchan_addr']); $delegates[$x]['channel_name'] = $delegates[$x]['xchan_name']; $delegates[$x]['delegate'] = 1; diff --git a/Zotlabs/Module/Nojs.php b/Zotlabs/Module/Nojs.php index 6fd6d8106..5f3d80ecd 100644 --- a/Zotlabs/Module/Nojs.php +++ b/Zotlabs/Module/Nojs.php @@ -7,8 +7,8 @@ class Nojs extends \Zotlabs\Web\Controller { function init() { $n = ((argc() > 1) ? intval(argv(1)) : 1); setcookie('jsdisabled', $n, 0, '/'); - $p = $_GET['redir']; - $hasq = strpos($p,'?'); + $p = hex2bin($_GET['redir']); + $hasq = strpbrk($p,'?&'); goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=' . $n); } diff --git a/Zotlabs/Module/Rmagic.php b/Zotlabs/Module/Rmagic.php index bfc03f6ec..33a6689ca 100644 --- a/Zotlabs/Module/Rmagic.php +++ b/Zotlabs/Module/Rmagic.php @@ -17,8 +17,8 @@ class Rmagic extends \Zotlabs\Web\Controller { if($r) { if($r[0]['hubloc_url'] === z_root()) goaway(z_root() . '/login'); - $dest = z_root() . '/' . str_replace(['rmagic','zid='],['','zid_='],\App::$query_string); - goaway($r[0]['hubloc_url'] . '/magic' . '?f=&owa=1&dest=' . $dest); + $dest = bin2hex(z_root() . '/' . str_replace(['rmagic','zid='],['','zid_='],\App::$query_string)); + goaway($r[0]['hubloc_url'] . '/magic' . '?f=&owa=1&bdest=' . $dest); } } } @@ -59,11 +59,11 @@ class Rmagic extends \Zotlabs\Web\Controller { if($url) { if($_SESSION['return_url']) - $dest = urlencode(z_root() . '/' . str_replace('zid=','zid_=',$_SESSION['return_url'])); + $dest = bin2hex(z_root() . '/' . str_replace('zid=','zid_=',$_SESSION['return_url'])); else - $dest = urlencode(z_root() . '/' . str_replace([ 'rmagic', 'zid=' ] ,[ '', 'zid_='],\App::$query_string)); + $dest = bin2hex(z_root() . '/' . str_replace([ 'rmagic', 'zid=' ] ,[ '', 'zid_='],\App::$query_string)); - goaway($url . '/magic' . '?f=&owa=1&dest=' . $dest); + goaway($url . '/magic' . '?f=&owa=1&bdest=' . $dest); } } } diff --git a/Zotlabs/Web/CheckJS.php b/Zotlabs/Web/CheckJS.php index 8179ceb15..c8547b6dd 100644 --- a/Zotlabs/Web/CheckJS.php +++ b/Zotlabs/Web/CheckJS.php @@ -18,7 +18,7 @@ class CheckJS { $this->jsdisabled = 0; if(! $this->jsdisabled) { - $page = urlencode(\App::$query_string); + $page = bin2hex(\App::$query_string); if($test) { $this->jsdisabled = 1; -- cgit v1.2.3 From 67848c03edf02b8a6d3c2010f08d50d823685e27 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 18 Jul 2018 17:48:23 -0700 Subject: query filter was a bit greedy (cherry picked from commit a05c8ff66bd8d09f69f6c59bc49b7627792f4109) --- Zotlabs/Module/Magic.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index e034f1cdf..be6866592 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -21,7 +21,6 @@ class Magic extends \Zotlabs\Web\Controller { $owa = ((x($_REQUEST,'owa')) ? intval($_REQUEST['owa']) : 0); $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); - if($bdest) $dest = hex2bin($bdest); -- cgit v1.2.3 From 85e21ce61731f1fac331becc0977b0f0d83e346e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 19 Jul 2018 17:19:19 -0700 Subject: checkjs fix ($page not bin-hex in all cases) (cherry picked from commit a94c9d270906136f69156c0e7c0bd2c8a2e63d1a) --- Zotlabs/Web/CheckJS.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/CheckJS.php b/Zotlabs/Web/CheckJS.php index c8547b6dd..e83ccf27b 100644 --- a/Zotlabs/Web/CheckJS.php +++ b/Zotlabs/Web/CheckJS.php @@ -17,9 +17,9 @@ class CheckJS { else $this->jsdisabled = 0; - if(! $this->jsdisabled) { - $page = bin2hex(\App::$query_string); + $page = bin2hex(\App::$query_string); + if(! $this->jsdisabled) { if($test) { $this->jsdisabled = 1; if(array_key_exists('jsdisabled',$_COOKIE)) -- cgit v1.2.3