diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 88 | ||||
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 6 | ||||
-rw-r--r-- | Zotlabs/Lib/Apps.php | 1 | ||||
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 6 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 4 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 10 | ||||
-rw-r--r-- | Zotlabs/Module/Acl.php | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Activity.php | 175 | ||||
-rw-r--r-- | Zotlabs/Module/Channel.php | 1 | ||||
-rw-r--r-- | Zotlabs/Module/Dircensor.php | 52 | ||||
-rw-r--r-- | Zotlabs/Module/Directory.php | 43 | ||||
-rw-r--r-- | Zotlabs/Module/Dirsearch.php | 54 | ||||
-rw-r--r-- | Zotlabs/Module/Display.php | 1 | ||||
-rw-r--r-- | Zotlabs/Module/Event.php | 76 | ||||
-rw-r--r-- | Zotlabs/Module/Hq.php | 1 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Like.php | 9 | ||||
-rw-r--r-- | Zotlabs/Module/Mail.php | 449 | ||||
-rw-r--r-- | Zotlabs/Module/Network.php | 6 | ||||
-rw-r--r-- | Zotlabs/Module/Pubstream.php | 10 | ||||
-rw-r--r-- | Zotlabs/Module/Search.php | 1 | ||||
-rw-r--r-- | Zotlabs/Update/_1235.php | 25 | ||||
-rw-r--r-- | Zotlabs/Widget/Activity_filter.php | 12 |
23 files changed, 504 insertions, 531 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 08a8b8d03..43315a87f 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -168,6 +168,10 @@ class Activity { if($r) { xchan_query($r,true); $r = fetch_post_tags($r,true); + if ($r[0]['verb'] === 'Create' && $r[0]['obj_type'] === ACTIVITY_OBJ_EVENT) { + $r[0]['verb'] = 'Invite'; + return self::encode_activity($r[0]); + } return self::encode_item($r[0]); } } @@ -220,7 +224,7 @@ class Activity { 'startTime' => (($ev['adjust']) ? datetime_convert($ev['timezone'],'UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')), 'content' => bbcode($ev['description'], [ 'cache' => true ]), 'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location'], [ 'cache' => true ]) ], - 'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ], + 'source' => [ 'content' => format_event_bbcode($ev,true), 'mediaType' => 'text/bbcode' ], 'actor' => $actor, ]; if(! $ev['nofinish']) { @@ -611,10 +615,10 @@ class Activity { if($i['id'] != $i['parent']) { $reply = true; - // inReplyTo needs to be set in the activity for followup actiions (Like, Dislike, Attend, Announce, etc.), - // but *not* for comments, where it should only be present in the object - - if (! in_array($ret['type'],[ 'Create','Update' ])) { + // inReplyTo needs to be set in the activity for followup actions (Like, Dislike, Announce, etc.), + // but *not* for comments and RSVPs, where it should only be present in the object + + if (! in_array($ret['type'],[ 'Create','Update','Accept','Reject','TentativeAccept','TentativeReject' ])) { $ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent'])); } @@ -672,6 +676,9 @@ class Activity { return []; } + if(array_path_exists('object/type',$ret) && $ret['object']['type'] === 'Event' && $ret['type'] === 'Create') { + $ret['type'] = 'Invite'; + } if($i['target']) { if(! is_array($i['target'])) { @@ -822,7 +829,8 @@ class Activity { 'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow', 'http://purl.org/zot/activity/attendyes' => 'Accept', 'http://purl.org/zot/activity/attendno' => 'Reject', - 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept' + 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept', + 'Invite' => 'Invite', ]; call_hooks('activity_mapper',$acts); @@ -868,7 +876,8 @@ class Activity { 'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow', 'http://purl.org/zot/activity/attendyes' => 'Accept', 'http://purl.org/zot/activity/attendno' => 'Reject', - 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept' + 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept', + 'Invite' => 'Invite', ]; call_hooks('activity_decode_mapper',$acts); @@ -902,6 +911,7 @@ class Activity { 'http://purl.org/zot/activity/thing' => 'Object', 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', + 'Invite' => 'Invite', ]; @@ -941,7 +951,7 @@ class Activity { 'http://purl.org/zot/activity/thing' => 'Object', 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', - + 'Invite' => 'Invite', ]; call_hooks('activity_obj_mapper',$objs); @@ -1664,15 +1674,23 @@ class Activity { if($act->type === 'Dislike') { $content['content'] = sprintf( t('Doesn\'t like %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; } - if($act->type === 'Accept' && $act->obj['type'] === 'Event' ) { - $content['content'] = sprintf( t('Will attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; - } - if($act->type === 'Reject' && $act->obj['type'] === 'Event' ) { - $content['content'] = sprintf( t('Will not attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; - } - if($act->type === 'TentativeAccept' && $act->obj['type'] === 'Event' ) { - $content['content'] = sprintf( t('May attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; + + // handle event RSVPs + if (($act->obj['type'] === 'Event') || ($act->obj['type'] === 'Invite' && array_path_exists('object/type',$act->obj) && $act->obj['object']['type'] === 'Event')) { + if ($act->type === 'Accept') { + $content['content'] = sprintf( t('Will attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } + if ($act->type === 'Reject') { + $content['content'] = sprintf( t('Will not attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } + if ($act->type === 'TentativeAccept') { + $content['content'] = sprintf( t('May attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } + if ($act->type === 'TentativeReject') { + $content['content'] = sprintf( t('May not attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } } + if($act->type === 'Announce') { $content['content'] = sprintf( t('🔁 Repeated %1$s\'s %2$s'), $mention, $act->obj['type']); } @@ -1703,28 +1721,42 @@ class Activity { $s['obj_type'] = ACTIVITY_OBJ_COMMENT; } + $eventptr = null; + + if ($act->obj['type'] === 'Invite' && array_path_exists('object/type',$act->obj) && $act->obj['object']['type'] === 'Event') { + $eventptr = $act->obj['object']; + $s['mid'] = $s['parent_mid'] = $act->obj['id']; + } + if($act->obj['type'] === 'Event') { + if ($act->type === 'Invite') { + $s['mid'] = $s['parent_mid'] = $act->id; + } + $eventptr = $act->obj; + } + + if ($eventptr) { $s['obj'] = []; - $s['obj']['asld'] = $act->obj; + $s['obj']['asld'] = $eventptr; $s['obj']['type'] = ACTIVITY_OBJ_EVENT; - $s['obj']['id'] = $act->obj['id']; - $s['obj']['title'] = $act->obj['name']; + $s['obj']['id'] = $eventptr['id']; + $s['obj']['title'] = $eventptr['name']; if(strpos($act->obj['startTime'],'Z')) $s['obj']['adjust'] = true; else $s['obj']['adjust'] = false; - $s['obj']['dtstart'] = datetime_convert('UTC','UTC',$act->obj['startTime']); + $s['obj']['dtstart'] = datetime_convert('UTC','UTC',$eventptr['startTime']); if($act->obj['endTime']) - $s['obj']['dtend'] = datetime_convert('UTC','UTC',$act->obj['endTime']); + $s['obj']['dtend'] = datetime_convert('UTC','UTC',$eventptr['endTime']); else $s['obj']['nofinish'] = true; - $s['obj']['description'] = $act->obj['content']; + $s['obj']['description'] = $eventptr['content']; - if(array_path_exists('location/content',$act->obj)) - $s['obj']['location'] = $act->obj['location']['content']; + if(array_path_exists('location/content',$eventptr)) + $s['obj']['location'] = $eventptr['location']['content']; } else { @@ -1957,9 +1989,15 @@ class Activity { $s['plink'] = $s['mid']; } - if($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) + if ($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) $s['item_private'] = 1; + if (is_array($act->obj)) { + if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) { + $s['item_private'] = 2; + } + } + set_iconfig($s,'activitypub','recips',$act->raw_recips); $parent = (($s['parent_mid'] && $s['parent_mid'] === $s['mid']) ? true : false); diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 006744aff..d8bd72943 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -101,7 +101,13 @@ class ActivityStreams { $this->actor = $this->get_actor('attributedTo',$this->obj); } } + + // fetch recursive or embedded activities + if ($this->obj && is_array($this->obj) && array_key_exists('object',$this->obj)) { + $this->obj['object'] = $this->get_compound_property($this->obj['object']); + } + if($this->obj && is_array($this->obj) && $this->obj['actor']) $this->obj['actor'] = $this->get_actor('actor',$this->obj); if($this->tgt && is_array($this->tgt) && $this->tgt['actor']) diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 69996b49d..9d60e9eae 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -74,7 +74,6 @@ class Apps { 'Directory', 'Search', 'Help', - 'Mail', 'Profile Photo' ]); diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index bc2710ee1..f6f8ad0cb 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -811,10 +811,10 @@ class Enotify { else { $itemem_text = (($item['item_thread_top']) ? t('created a new post') - : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); + : sprintf( t('commented on %s\'s post'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')); if($item['verb'] === ACTIVITY_SHARE) { - $itemem_text = sprintf( t('repeated %s\'s post'), $item['author']['xchan_name']); + $itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]'); } } @@ -849,7 +849,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), - 'message' => strip_tags(bbcode($itemem_text)), + 'message' => bbcode(escape_tags($itemem_text)), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 100d45c05..ad00aa97a 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1220,8 +1220,8 @@ class Libzot { $arr['owner_xchan'] = $env['sender']; } - if($private) { - $arr['item_private'] = true; + if ($private && (! intval($arr['item_private']))) { + $arr['item_private'] = 1; } if ($arr['mid'] === $arr['parent_mid']) { diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 301ce1a18..2386a1f0d 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -346,7 +346,7 @@ class ThreadItem { $viewthread = z_root() . '/channel/' . $owner_address . '?f=&mid=' . urlencode(gen_link_id($item['mid'])); $comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); - $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : ''); + $list_unseen_txt = (($unseen_comments) ? sprintf( t('%d unseen'),$unseen_comments) : ''); $children = $this->get_children(); @@ -377,7 +377,7 @@ class ThreadItem { 'template' => $this->get_template(), 'mode' => $mode, 'item_type' => intval($item['item_type']), - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + //'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'body' => $body['html'], 'tags' => $body['tags'], 'categories' => $body['categories'], @@ -395,8 +395,8 @@ class ThreadItem { 'consensus' => $consensus, 'conlabels' => $conlabels, 'canvote' => $canvote, - 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url'])), - 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url'])), + 'linktitle' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), + 'olinktitle' => (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url']), 'llink' => $item['llink'], 'viewthread' => $viewthread, 'to' => t('to'), @@ -414,7 +414,7 @@ class ThreadItem { 'sparkle' => $sparkle, 'title' => $item['title'], 'title_tosource' => get_pconfig($conv->get_profile_owner(),'system','title_tosource'), - 'ago' => relative_date($item['created']), + //'ago' => relative_date($item['created']), 'app' => $item['app'], 'str_app' => sprintf( t('from %s'), $item['app']), 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 82c156a9c..e0206bd43 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -42,7 +42,7 @@ class Acl extends \Zotlabs\Web\Controller { // $type = - // 'm' => autocomplete private mail recipient (checks post_mail permission) + // 'm' => autocomplete private mail recipient (checks post_mail permission and displays only zot, diaspora, friendica-over-diaspora xchan_network xchan's) // 'a' => autocomplete connections (mod_connections, mod_poke, mod_sources, mod_photos) // 'x' => nav search bar autocomplete (match any xchan) // $_REQUEST['query'] contains autocomplete search text. @@ -286,6 +286,7 @@ class Acl extends \Zotlabs\Web\Controller { FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and xchan_deleted = 0 + and xchan_network IN ('zot', 'diaspora', 'friendica-over-diaspora') $sql_extra3 ORDER BY xchan_name ASC ", intval(local_channel()) diff --git a/Zotlabs/Module/Activity.php b/Zotlabs/Module/Activity.php new file mode 100644 index 000000000..93b5a15fc --- /dev/null +++ b/Zotlabs/Module/Activity.php @@ -0,0 +1,175 @@ +<?php +namespace Zotlabs\Module; + +use Zotlabs\Lib\IConfig; +use Zotlabs\Lib\Enotify; +use Zotlabs\Web\Controller; +use Zotlabs\Daemon\Master; +use Zotlabs\Lib\Activity as ZlibActivity; +use Zotlabs\Lib\ActivityStreams; +use Zotlabs\Lib\LDSignatures; +use Zotlabs\Web\HTTPSig; +use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\ThreadListener; +use App; + + +class Activity extends Controller { + + function init() { + + if (Libzot::is_zot_request()) { + + $item_id = argv(1); + + if (! $item_id) + http_status_exit(404, 'Not found'); + + $portable_id = EMPTY_STR; + + $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 "; + + $i = null; + + // do we have the item (at all)? + + $r = q("select * from item where mid = '%s' $item_normal limit 1", + dbesc(z_root() . '/activity/' . $item_id) + ); + + if (! $r) { + http_status_exit(404,'Not found'); + } + + // process an authenticated fetch + + $sigdata = HTTPSig::verify(EMPTY_STR); + if($sigdata['portable_id'] && $sigdata['header_valid']) { + $portable_id = $sigdata['portable_id']; + observer_auth($portable_id); + + // first see if we have a copy of this item's parent owned by the current signer + // include xchans for all zot-like networks - these will have the same guid and public key + + $x = q("select * from xchan where xchan_hash = '%s'", + dbesc($sigdata['portable_id']) + ); + + if ($x) { + $xchans = q("select xchan_hash from xchan where xchan_hash = '%s' OR ( xchan_guid = '%s' AND xchan_pubkey = '%s' ) ", + dbesc($sigdata['portable_id']), + dbesc($x[0]['xchan_guid']), + dbesc($x[0]['xchan_pubkey']) + ); + + if ($xchans) { + $hashes = ids_to_querystr($xchans,'xchan_hash',true); + $i = q("select id as item_id from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1", + dbesc($r[0]['parent_mid']) + ); + } + } + } + + // if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access + // with a bias towards those items owned by channels on this site (item_wall = 1) + + $sql_extra = item_permissions_sql(0); + + if (! $i) { + $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1", + dbesc($r[0]['parent_mid']) + ); + } + + if(! $i) { + http_status_exit(403,'Forbidden'); + } + + $parents_str = ids_to_querystr($i,'item_id'); + + $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal ", + dbesc($parents_str) + ); + + if(! $items) { + http_status_exit(404, 'Not found'); + } + + xchan_query($items,true); + $items = fetch_post_tags($items,true); + + $observer = App::get_observer(); + $parent = $items[0]; + $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []); + $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null); + $nitems = []; + foreach($items as $i) { + + $mids = []; + + if(intval($i['item_private'])) { + if(! $observer) { + continue; + } + // ignore private reshare, possibly from hubzilla + if($i['verb'] === 'Announce') { + if(! in_array($i['thr_parent'],$mids)) { + $mids[] = $i['thr_parent']; + } + continue; + } + // also ignore any children of the private reshares + if(in_array($i['thr_parent'],$mids)) { + continue; + } + + if((! $to) || (! in_array($observer['xchan_url'],$to))) { + continue; + } + + } + $nitems[] = $i; + } + + if(! $nitems) + http_status_exit(404, 'Not found'); + + $chan = channelx_by_n($nitems[0]['uid']); + + if(! $chan) + http_status_exit(404, 'Not found'); + + if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream')) + http_status_exit(403, 'Forbidden'); + + $i = ZlibActivity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection'); + if($portable_id) { + ThreadListener::store(z_root() . '/activity/' . $item_id,$portable_id); + } + + if(! $i) + http_status_exit(404, 'Not found'); + + $x = array_merge(['@context' => [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], $i); + + $headers = []; + $headers['Content-Type'] = 'application/x-zot+json' ; + $x['signature'] = LDSignatures::sign($x,$chan); + $ret = json_encode($x, JSON_UNESCAPED_SLASHES); + $headers['Digest'] = HTTPSig::generate_digest_header($ret); + $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; + $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan)); + HTTPSig::set_headers($h); + echo $ret; + killme(); + + } + + } + +} diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 5529db70e..170b81787 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -419,6 +419,7 @@ class Channel extends Controller { '$nouveau' => '0', '$wall' => '1', '$fh' => '0', + '$dm' => '0', '$static' => $static, '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1), '$search' => $search, diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php new file mode 100644 index 000000000..0fa65e948 --- /dev/null +++ b/Zotlabs/Module/Dircensor.php @@ -0,0 +1,52 @@ +<?php + +namespace Zotlabs\Module; + +use App; +use Zotlabs\Web\Controller; + + +class Dircensor extends Controller { + + function get() { + if(! is_site_admin()) { + return; + } + + $dirmode = intval(get_config('system','directory_mode')); + + if (! ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE)) { + return; + } + + $xchan = argv(1); + if(! $xchan) { + return; + } + + $r = q("select * from xchan where xchan_hash = '%s'", + dbesc($xchan) + ); + + if(! $r) { + return; + } + + $val = (($r[0]['xchan_censored']) ? 0 : 1); + + q("update xchan set xchan_censored = $val where xchan_hash = '%s'", + dbesc($xchan) + ); + + if($val) { + info( t('Entry censored') . EOL); + } + else { + info( t('Entry uncensored') . EOL); + } + + goaway(z_root() . '/directory'); + + } + +} diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index dee22721d..3eafd9f71 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -2,15 +2,19 @@ namespace Zotlabs\Module; +use App; +use Zotlabs\Web\Controller; + require_once('include/socgraph.php'); require_once('include/dir_fns.php'); require_once('include/bbcode.php'); +require_once('include/html2plain.php'); -class Directory extends \Zotlabs\Web\Controller { +class Directory extends Controller { function init() { - \App::set_pager_itemspage(60); + App::set_pager_itemspage(60); if(local_channel() && x($_GET,'ignore')) { q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ", @@ -21,7 +25,7 @@ class Directory extends \Zotlabs\Web\Controller { } if(local_channel()) - \App::$profile_uid = local_channel(); + App::$profile_uid = local_channel(); $observer = get_observer_hash(); $global_changed = false; @@ -140,9 +144,15 @@ class Directory extends \Zotlabs\Web\Controller { $dirmode = intval(get_config('system','directory_mode')); + $directory_admin = false; + if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { $url = z_root() . '/dirsearch'; - } + if (is_site_admin()) { + $directory_admin = true; + } + } + if(! $url) { $directory = find_upstream_directory($dirmode); if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url'])) @@ -182,7 +192,7 @@ class Directory extends \Zotlabs\Web\Controller { $query .= '&t=' . $token; if(! $globaldir) - $query .= '&hub=' . \App::get_hostname(); + $query .= '&hub=' . App::get_hostname(); if($search) $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search); @@ -204,8 +214,8 @@ class Directory extends \Zotlabs\Web\Controller { if($sort_order) $query .= '&order=' . urlencode($sort_order); - if(\App::$pager['page'] != 1) - $query .= '&p=' . \App::$pager['page']; + if(App::$pager['page'] != 1) + $query .= '&p=' . App::$pager['page']; logger('mod_directory: query: ' . $query); @@ -283,12 +293,15 @@ class Directory extends \Zotlabs\Web\Controller { $marital = ((x($profile,'marital') == 1) ? t('Status: ') . $profile['marital']: False); $homepage = ((x($profile,'homepage') == 1) ? t('Homepage: ') : False); - $homepageurl = ((x($profile,'homepage') == 1) ? $profile['homepage'] : ''); - - $hometown = ((x($profile,'hometown') == 1) ? $profile['hometown'] : False); + $homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : ''); - $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'])) : False); + $hometown = ((x($profile,'hometown') == 1) ? html2plain($profile['hometown']) : False); + $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'], ['tryoembed' => false])) : False); + if ($about && $safe_mode) { + $about = html2plain($about); + } + $keywords = ((x($profile,'keywords')) ? $profile['keywords'] : ''); @@ -343,9 +356,11 @@ class Directory extends \Zotlabs\Web\Controller { 'canrate' => (($rating_enabled && local_channel()) ? true : false), 'pdesc' => $pdesc, 'pdesc_label' => t('Description:'), + 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] : ''), + 'censor_label' => (($rr['censored']) ? t('Uncensor') : t('Censor')), 'marital' => $marital, 'homepage' => $homepage, - 'homepageurl' => linkify($homepageurl, true), + 'homepageurl' => (($safe_mode) ? $homepageurl : linkify($homepageurl)), 'hometown' => $hometown, 'hometown_label' => t('Hometown:'), 'about' => $about, @@ -387,7 +402,7 @@ class Directory extends \Zotlabs\Web\Controller { ksort($entries); // Sort array by key so that foreach-constructs work as expected if($j['keywords']) { - \App::$data['directory_keywords'] = $j['keywords']; + App::$data['directory_keywords'] = $j['keywords']; } logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA); @@ -438,7 +453,7 @@ class Directory extends \Zotlabs\Web\Controller { echo $o; killme(); } - if(\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) { + if(App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) { goaway(z_root() . '/chanview/?f=&address=' . $search); } info( t("No entries (some entries may be hidden).") . EOL); diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index 92b33df0c..62af75f4c 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -1,14 +1,17 @@ <?php namespace Zotlabs\Module; +use App; +use Zotlabs\Web\Controller; + require_once('include/dir_fns.php'); -class Dirsearch extends \Zotlabs\Web\Controller { +class Dirsearch extends Controller { function init() { - \App::set_pager_itemspage(60); + App::set_pager_itemspage(60); } @@ -25,7 +28,8 @@ class Dirsearch extends \Zotlabs\Web\Controller { $ret['message'] = t('This site is not a directory server'); json_return_and_die($ret); } - + + $access_token = $_REQUEST['t']; $token = get_config('system','realm_token'); @@ -286,29 +290,29 @@ class Dirsearch extends \Zotlabs\Web\Controller { else $entry['total_ratings'] = 0; - $entry['name'] = $rr['xchan_name']; - $entry['hash'] = $rr['xchan_hash']; - + $entry['name'] = $rr['xchan_name']; + $entry['hash'] = $rr['xchan_hash']; + $entry['censored'] = $rr['xchan_censored']; + $entry['selfcensored'] = $rr['xchan_selfcensored']; $entry['public_forum'] = (intval($rr['xchan_pubforum']) ? true : false); - - $entry['url'] = $rr['xchan_url']; - $entry['photo_l'] = $rr['xchan_photo_l']; - $entry['photo'] = $rr['xchan_photo_m']; - $entry['address'] = $rr['xchan_addr']; - $entry['description'] = $rr['xprof_desc']; - $entry['locale'] = $rr['xprof_locale']; - $entry['region'] = $rr['xprof_region']; - $entry['postcode'] = $rr['xprof_postcode']; - $entry['country'] = $rr['xprof_country']; - $entry['birthday'] = $rr['xprof_dob']; - $entry['age'] = $rr['xprof_age']; - $entry['gender'] = $rr['xprof_gender']; - $entry['marital'] = $rr['xprof_marital']; - $entry['sexual'] = $rr['xprof_sexual']; - $entry['about'] = $rr['xprof_about']; - $entry['homepage'] = $rr['xprof_homepage']; - $entry['hometown'] = $rr['xprof_hometown']; - $entry['keywords'] = $rr['xprof_keywords']; + $entry['url'] = $rr['xchan_url']; + $entry['photo_l'] = $rr['xchan_photo_l']; + $entry['photo'] = $rr['xchan_photo_m']; + $entry['address'] = $rr['xchan_addr']; + $entry['description'] = $rr['xprof_desc']; + $entry['locale'] = $rr['xprof_locale']; + $entry['region'] = $rr['xprof_region']; + $entry['postcode'] = $rr['xprof_postcode']; + $entry['country'] = $rr['xprof_country']; + $entry['birthday'] = $rr['xprof_dob']; + $entry['age'] = $rr['xprof_age']; + $entry['gender'] = $rr['xprof_gender']; + $entry['marital'] = $rr['xprof_marital']; + $entry['sexual'] = $rr['xprof_sexual']; + $entry['about'] = $rr['xprof_about']; + $entry['homepage'] = $rr['xprof_homepage']; + $entry['hometown'] = $rr['xprof_hometown']; + $entry['keywords'] = $rr['xprof_keywords']; $entries[] = $entry; diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index cf38aba1a..777d183e1 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -224,6 +224,7 @@ class Display extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Module/Event.php b/Zotlabs/Module/Event.php new file mode 100644 index 000000000..22a1341cc --- /dev/null +++ b/Zotlabs/Module/Event.php @@ -0,0 +1,76 @@ +<?php +namespace Zotlabs\Module; + +use Zotlabs\Web\Controller; +use Zotlabs\Lib\ActivityStreams; +use Zotlabs\Lib\Activity; +use Zotlabs\Lib\LDSignatures; +use Zotlabs\Web\HTTPSig; + +class Event extends Controller { + + function init() { + + if(ActivityStreams::is_as_request()) { + $item_id = argv(1); + + if(! $item_id) + return; + + $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 + and item.item_delayed = 0 and item.item_blocked = 0 "; + + $sql_extra = item_permissions_sql(0); + + $r = q("select * from item where mid like '%s' $item_normal $sql_extra limit 1", + dbesc(z_root() . '/activity/' . $item_id . '%') + ); + + if(! $r) { + $r = q("select * from item where mid like '%s' $item_normal limit 1", + dbesc(z_root() . '/activity/' . $item_id . '%') + ); + + if($r) { + http_status_exit(403, 'Forbidden'); + } + http_status_exit(404, 'Not found'); + } + + xchan_query($r,true); + $items = fetch_post_tags($r,true); + + $channel = channelx_by_n($items[0]['uid']); + + if(! is_array($items[0]['obj'])) { + $obj = json_decode($items[0]['obj'],true); + } + else { + $obj = $items[0]['obj']; + } + + $x = array_merge(['@context' => [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], $obj ); + + $headers = []; + $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ; + $x['signature'] = LDSignatures::sign($x,$channel); + $ret = json_encode($x, JSON_UNESCAPED_SLASHES); + $headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'); + $headers['Digest'] = HTTPSig::generate_digest_header($ret); + $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; + + $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel)); + HTTPSig::set_headers($h); + + echo $ret; + killme(); + + } + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index d8c540fb9..5b331f4c1 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -179,6 +179,7 @@ class Hq extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 14881844d..1a25e54df 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -42,8 +42,6 @@ class Item extends Controller { if (Libzot::is_zot_request()) { - $conversation = false; - $item_id = argv(1); if (! $item_id) diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 052d51d43..e4636a4a6 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -75,7 +75,12 @@ class Like extends \Zotlabs\Web\Controller { return EMPTY_STR; } - + $is_rsvp = false; + if (in_array($activity, [ ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ])) { + $is_rsvp = true; + } + + $extended_like = false; $object = $target = null; $post_type = EMPTY_STR; @@ -381,7 +386,7 @@ class Like extends \Zotlabs\Web\Controller { $arr = array(); $arr['uuid'] = $uuid; - $arr['mid'] = z_root() . '/item/' . $uuid; + $arr['mid'] = z_root() . (($is_rsvp) ? '/activity/' : '/item/') . $uuid; if($extended_like) { $arr['item_thread_top'] = 1; diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php deleted file mode 100644 index 636fc4e33..000000000 --- a/Zotlabs/Module/Mail.php +++ /dev/null @@ -1,449 +0,0 @@ -<?php -namespace Zotlabs\Module; - -require_once('include/acl_selectors.php'); -require_once('include/message.php'); -require_once('include/zot.php'); -require_once("include/bbcode.php"); - - - - -class Mail extends \Zotlabs\Web\Controller { - - function post() { - - if(! local_channel()) - return; - - $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); - $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); - $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); - $recipient = ((x($_REQUEST,'messageto')) ? notags(trim(urldecode($_REQUEST['messageto']))) : ''); - $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); - $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); - $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); - $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); - $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); - - $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : ''); - if(strpos($sig,'b64.') === 0) - $sig = base64_decode(str_replace('b64.', '', $sig)); - - if($preview) { - - if($raw) { - $body = mail_prepare_binary(['id' => 'M0']); - echo json_encode(['preview' => $body]); - } - else { - $body = cleanup_bbcode($body); - $results = linkify_tags($body, local_channel()); - - if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { - $attachments = array(); - foreach($match[2] as $mtch) { - $hash = substr($mtch,0,strpos($mtch,',')); - $rev = intval(substr($mtch,strpos($mtch,','))); - $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); - if($r['success']) { - $attachments[] = array( - 'href' => z_root() . '/attach/' . $r['data']['hash'], - 'length' => $r['data']['filesize'], - 'type' => $r['data']['filetype'], - 'title' => urlencode($r['data']['filename']), - 'revision' => $r['data']['revision'] - ); - } - $body = trim(str_replace($match[1],'',$body)); - } - } - echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); - } - killme(); - } - - // If we have a raw string for a recipient which hasn't been auto-filled, - // it means they probably aren't in our address book, hence we don't know - // if we have permission to send them private messages. - // finger them and find out before we try and send it. - - if(! $recipient) { - $channel = \App::get_channel(); - - $j = \Zotlabs\Zot\Finger::run(punify($rstr),$channel); - - if(! $j['success']) { - notice( t('Unable to lookup recipient.') . EOL); - return; - } - - logger('message_post: lookup: ' . $rstr . ' ' . print_r($j,true)); - - if(! $j['guid']) { - notice( t('Unable to communicate with requested channel.')); - return; - } - - $x = import_xchan($j); - - if(! $x['success']) { - notice( t('Cannot verify requested channel.')); - return; - } - - $recipient = $x['hash']; - - $their_perms = 0; - - if($j['permissions']['data']) { - $permissions = crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']); - if($permissions) - $permissions = json_decode($permissions, true); - logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA); - } - else - $permissions = $j['permissions']; - - if(! ($permissions['post_mail'])) { - notice( t('Selected channel has private message restrictions. Send failed.')); - // reported issue: let's still save the message and continue. We'll just tell them - // that nothing useful is likely to happen. They might have spent hours on it. - // return; - - } - } - - require_once('include/text.php'); - linkify_tags($body, local_channel()); - - - if(! $recipient) { - notice('No recipient found.'); - \App::$argc = 2; - \App::$argv[1] = 'new'; - return; - } - - // We have a local_channel, let send_message use the session channel and save a lookup - - $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw, $sig); - - if($ret['success']) { - xchan_mail_query($ret['mail']); - build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true)))); - } - else { - notice($ret['message']); - } - - goaway(z_root() . '/mail/combined'); - - } - - function get() { - - $o = ''; - nav_set_selected('Mail'); - - if(! local_channel()) { - notice( t('Permission denied.') . EOL); - return login(); - } - - $channel = \App::get_channel(); - - head_set_icon($channel['xchan_photo_s']); - - $cipher = get_pconfig(local_channel(),'system','default_cipher'); - if(! $cipher) - $cipher = 'aes256'; - - $tpl = get_markup_template('mail_head.tpl'); - $header = replace_macros($tpl, array( - '$header' => t('Messages'), - )); - - if(argc() == 3 && intval(argv(1)) && argv(2) === 'download') { - - $r = q("select * from mail where id = %d and channel_id = %d", - intval(argv(1)), - intval(local_channel()) - ); - - if($r) { - - header('Content-type: ' . $r[0]['mail_mimetype']); - header('Content-disposition: attachment; filename="' . t('message') . '-' . $r[0]['id'] . '"' ); - $body = (($r[0]['mail_obscured']) ? base64url_decode(str_rot47($r[0]['body'])) : $r[0]['body']); - echo $body; - killme(); - } - - } - - - if((argc() == 4) && (argv(2) === 'drop')) { - if(! intval(argv(3))) - return; - $cmd = argv(2); - $mailbox = argv(1); - $r = private_messages_drop(local_channel(), argv(3)); - if($r) { - //info( t('Message deleted.') . EOL ); - } - goaway(z_root() . '/mail/' . $mailbox); - } - - if((argc() == 4) && (argv(2) === 'recall')) { - if(! intval(argv(3))) - return; - $cmd = argv(2); - $mailbox = argv(1); - $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d", - intval(argv(3)), - intval(local_channel()) - ); - $x = q("select * from mail where id = %d and channel_id = %d", - intval(argv(3)), - intval(local_channel()) - ); - if($x) { - build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true))); - } - - \Zotlabs\Daemon\Master::Summon(array('Notifier','mail',intval(argv(3)))); - - if($r) { - info( t('Message recalled.') . EOL ); - } - goaway(z_root() . '/mail/' . $mailbox . '/' . argv(3)); - - } - - if((argc() == 4) && (argv(2) === 'dropconv')) { - if(! intval(argv(3))) - return; - $cmd = argv(2); - $mailbox = argv(1); - $r = private_messages_drop(local_channel(), argv(3), true); - if($r) - info( t('Conversation removed.') . EOL ); - goaway(z_root() . '/mail/' . $mailbox); - } - - if((argc() > 1) && (argv(1) === 'new')) { - - $plaintext = true; - - $tpl = get_markup_template('msg-header.tpl'); - - $header = replace_macros($tpl, array( - '$baseurl' => z_root(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$nickname' => $channel['channel_address'], - '$linkurl' => t('Please enter a link URL:'), - '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') - )); - - \App::$page['htmlhead'] .= $header; - - $prename = ''; - $preid = ''; - - if(x($_REQUEST,'hash')) { - - $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash - where abook_channel = %d and abook_xchan = '%s' limit 1", - intval(local_channel()), - dbesc($_REQUEST['hash']) - ); - - if(!$r) { - $r = q("select * from xchan where xchan_hash = '%s' and xchan_network = 'zot' limit 1", - dbesc($_REQUEST['hash']) - ); - } - - if($r) { - $prename = (($r[0]['abook_id']) ? $r[0]['xchan_name'] : $r[0]['xchan_addr']); - $preurl = $r[0]['xchan_url']; - $preid = (($r[0]['abook_id']) ? ($r[0]['xchan_hash']) : ''); - } - else { - notice( t('Requested channel is not in this network') . EOL ); - } - - } - - $tpl = get_markup_template('prv_message.tpl'); - $o .= replace_macros($tpl,array( - '$new' => true, - '$header' => t('Send Private Message'), - '$to' => t('To:'), - '$prefill' => $prename, - '$preid' => $preid, - '$subject' => t('Subject:'), - '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''), - '$text' => ((x($_REQUEST,'body')) ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : ''), - '$yourmessage' => t('Your message:'), - '$parent' => '', - '$attach' => t('Attach file'), - '$insert' => t('Insert web link'), - '$submit' => t('Send'), - '$defexpire' => '', - '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false), - '$expires' => t('Set expiration date'), - '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false), - '$encrypt' => t('Encrypt text'), - '$cipher' => $cipher, - )); - - return $o; - } - - $direct_mid = 0; - - switch(argv(1)) { - case 'combined': - $mailbox = 'combined'; - break; - case 'inbox': - $mailbox = 'inbox'; - break; - case 'outbox': - $mailbox = 'outbox'; - break; - default: - $mailbox = 'combined'; - - // notifications direct to mail/nn - - if(intval(argv(1))) - $direct_mid = intval(argv(1)); - break; - } - - - $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); - - $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; - - if($direct_mid) - $mid = $direct_mid; - - - $plaintext = true; - - // if( local_channel() && feature_enabled(local_channel(),'richtext') ) - // $plaintext = false; - - - - if($mailbox == 'combined') { - $messages = private_messages_fetch_conversation(local_channel(), $mid, true); - } - else { - $messages = private_messages_fetch_message(local_channel(), $mid, true); - } - - if(! $messages) { - //info( t('Message not found.') . EOL); - return; - } - - if($messages[0]['to_xchan'] === $channel['channel_hash']) - \App::$poi = $messages[0]['from']; - else - \App::$poi = $messages[0]['to']; - - $tpl = get_markup_template('msg-header.tpl'); - - \App::$page['htmlhead'] .= replace_macros($tpl, array( - '$nickname' => $channel['channel_address'], - '$baseurl' => z_root(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$linkurl' => t('Please enter a link URL:'), - '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') - )); - - $mails = array(); - - $seen = 0; - $unknown = false; - - foreach($messages as $message) { - - $s = theme_attachments($message); - - if($message['mail_raw']) - $message['body'] = mail_prepare_binary([ 'id' => $message['id'] ]); - else - $message['body'] = zidify_links(smilies(bbcode($message['body']))); - - $mails[] = array( - 'mailbox' => $mailbox, - 'id' => $message['id'], - 'mid' => $message['mid'], - 'from_name' => $message['from']['xchan_name'], - 'from_url' => chanlink_hash($message['from_xchan']), - 'from_photo' => $message['from']['xchan_photo_s'], - 'to_name' => $message['to']['xchan_name'], - 'to_url' => chanlink_hash($message['to_xchan']), - 'to_photo' => $message['to']['xchan_photo_s'], - 'subject' => $message['title'], - 'body' => $message['body'], - 'attachments' => $s, - 'delete' => t('Delete message'), - 'dreport' => t('Delivery report'), - 'recall' => t('Recall message'), - 'can_recall' => ($channel['channel_hash'] == $message['from_xchan']), - 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''), - 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'), - 'sig' => base64_encode($message['sig']) - ); - - $seen = $message['seen']; - - } - - $recp = (($message['from_xchan'] === $channel['channel_hash']) ? 'to' : 'from'); - - $tpl = get_markup_template('mail_display.tpl'); - $o = replace_macros($tpl, array( - '$mailbox' => $mailbox, - '$prvmsg_header' => $message['title'], - '$thread_id' => $mid, - '$thread_subject' => $message['title'], - '$thread_seen' => $seen, - '$delete' => t('Delete Conversation'), - '$canreply' => (($unknown) ? false : '1'), - '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), - '$mails' => $mails, - - // reply - '$header' => t('Send Reply'), - '$to' => t('To:'), - '$reply' => true, - '$subject' => t('Subject:'), - '$subjtxt' => $message['title'], - '$yourmessage' => sprintf(t('Your message for %s (%s):'), $message[$recp]['xchan_name'], $message[$recp]['xchan_addr']), - '$text' => '', - '$parent' => $message['parent_mid'], - '$recphash' => $message[$recp]['xchan_hash'], - '$attach' => t('Attach file'), - '$insert' => t('Insert web link'), - '$submit' => t('Submit'), - '$defexpire' => '', - '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false), - '$expires' => t('Set expiration date'), - '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false), - '$encrypt' => t('Encrypt text'), - '$cipher' => $cipher, - )); - - return $o; - - } - -} diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 1c16e34ef..a8efd0d9e 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -69,6 +69,7 @@ class Network extends \Zotlabs\Web\Controller { $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); + $dm = ((x($_REQUEST,'dm')) ? $_REQUEST['dm'] : 0); $order = get_pconfig(local_channel(), 'mod_network', 'order', 0); @@ -363,6 +364,7 @@ class Network extends \Zotlabs\Web\Controller { '$conv' => (($conv) ? $conv : '0'), '$spam' => (($spam) ? $spam : '0'), '$fh' => '0', + '$dm' => (($dm) ? $dm : '0'), '$nouveau' => (($nouveau) ? $nouveau : '0'), '$wall' => '0', '$static' => $static, @@ -418,6 +420,10 @@ class Network extends \Zotlabs\Web\Controller { if(strlen($file)) { $sql_extra .= term_query('item',$file,TERM_FILE); } + + if ($dm) { + $sql_extra .= " AND item_private = 2 "; + } if($conv) { $item_thread_top = ''; diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 84ac42f72..92ef44696 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -62,6 +62,11 @@ class Pubstream extends \Zotlabs\Web\Controller { $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); $net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : ''); + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => (($hashtags) ? '#' . htmlspecialchars($hashtags, ENT_COMPAT,'UTF-8') : '') + )); + + $o = (($hashtags) ? $title : ''); if(local_channel() && (! $update)) { @@ -94,7 +99,7 @@ class Pubstream extends \Zotlabs\Web\Controller { 'reset' => t('Reset form') ); - $o = '<div id="jot-popup">'; + $o .= '<div id="jot-popup">'; $o .= status_editor($a,$x,false,'Pubstream'); $o .= '</div>'; } @@ -139,6 +144,7 @@ class Pubstream extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '1', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$list' => '0', @@ -285,7 +291,7 @@ class Pubstream extends \Zotlabs\Web\Controller { } // fake it - $mode = ('pubstream'); + $mode = (($hashtags) ? 'search' : 'pubstream'); $o .= conversation($items,$mode,$update,$page_mode); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 214ece9a3..686afb2d2 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -128,6 +128,7 @@ class Search extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Update/_1235.php b/Zotlabs/Update/_1235.php new file mode 100644 index 000000000..e457a35d2 --- /dev/null +++ b/Zotlabs/Update/_1235.php @@ -0,0 +1,25 @@ +<?php + +namespace Zotlabs\Update; + +class _1235 { + + function run() { + + q("START TRANSACTION"); + + $r = q("DELETE FROM app WHERE app_name = '%s' AND app_system = 1", + dbesc('Mail') + ); + + if($r) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + + } + +} diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 32ab10c77..ae5c0af6e 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -16,6 +16,18 @@ class Activity_filter { $tabs = []; + if(x($_GET,'dm')) { + $dm_active = (($_GET['dm'] == 1) ? 'active' : ''); + $filter_active = 'dm'; + } + + $tabs[] = [ + 'label' => t('Direct Messages'), + 'icon' => 'envelope-o', + 'url' => z_root() . '/' . $cmd . '/?f=&dm=1', + 'sel' => $dm_active, + 'title' => t('Show direct (private) messages') + ]; if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) { $groups = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", |