diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2024-10-23 14:56:41 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2024-10-23 14:56:41 +0200 |
commit | 8f4c3a2f88d3770e6cfebaa61671f54fa17a34e1 (patch) | |
tree | 2f95124f88bcd7d568f86d53f420190ae56e2178 /Zotlabs | |
parent | e2ae8f0c4d83060b2606f03b1c86d040c3161f18 (diff) | |
parent | e530476e6c5d2319f3a0a09dfe73ec181e923325 (diff) | |
download | volse-hubzilla-8f4c3a2f88d3770e6cfebaa61671f54fa17a34e1.tar.gz volse-hubzilla-8f4c3a2f88d3770e6cfebaa61671f54fa17a34e1.tar.bz2 volse-hubzilla-8f4c3a2f88d3770e6cfebaa61671f54fa17a34e1.zip |
Merge branch 'dev' into make-db-upgrade-static-method
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Cron.php | 3 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Filer.php | 63 | ||||
-rw-r--r-- | Zotlabs/Module/Hq.php | 1 | ||||
-rw-r--r-- | Zotlabs/Widget/Messages.php | 61 |
5 files changed, 89 insertions, 41 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index d2c863572..3f5ce28eb 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -178,9 +178,6 @@ class Cron { } } - require_once('include/attach.php'); - attach_upgrade(); - // once daily run birthday_updates and then expire in background // FIXME: add birthday updates, both locally and for xprof for use diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 60a314da0..d21d85105 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -187,7 +187,7 @@ class ThreadItem { $drop = [ 'dropping' => true, 'delete' => t('Admin Delete') ]; } - $filer = ((($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) ? t("Save to Folder") : false); + $filer = (((local_channel() && $conv->get_profile_owner() === local_channel()) || (local_channel() && App::$module === 'pubstream')) ? t("Save to Folder") : false); $profile_avatar = $item['author']['xchan_photo_s']; $profile_link = chanlink_hash($item['author_xchan']); diff --git a/Zotlabs/Module/Filer.php b/Zotlabs/Module/Filer.php index c2747e6c2..bf472eb67 100644 --- a/Zotlabs/Module/Filer.php +++ b/Zotlabs/Module/Filer.php @@ -1,43 +1,54 @@ <?php namespace Zotlabs\Module; -require_once('include/security.php'); -require_once('include/bbcode.php'); -require_once('include/items.php'); - - +use App; class Filer extends \Zotlabs\Web\Controller { function get() { - - if(! local_channel()) { + + if(!local_channel()) { killme(); } - - $term = unxmlify(trim($_GET['term'])); - $item_id = ((\App::$argc > 1) ? intval(\App::$argv[1]) : 0); - + + $term = unxmlify(trim($_GET['term'] ?? '')); + $item_id = ((App::$argc > 1) ? intval(App::$argv[1]) : 0); + logger('filer: tag ' . $term . ' item ' . $item_id); - + if($item_id && strlen($term)){ + + $sys = get_sys_channel(); + + $r = q("SELECT * FROM item WHERE (uid = %d OR uid = %d) AND id = %d + and item_type in (0,6,7) and item_deleted = 0 and item_unpublished = 0 + and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1", + intval(local_channel()), + intval($sys['channel_id']), + intval($item_id) + ); + + if ($r && $r[0]['uid'] === $sys['channel_id']) { + $r = [copy_of_pubitem(App::get_channel(), $r[0]['mid'])]; + } + + if(!$r) { + killme(); + } + + $item_id = $r[0]['id']; + // file item store_item_tag(local_channel(),$item_id,TERM_OBJ_POST,TERM_FILE,$term,''); - + // protect the entire conversation from periodic expiration - - $r = q("select parent from item where id = %d and uid = %d limit 1", - intval($item_id), + + q("update item set item_retained = 1, changed = '%s' where id = %d and uid = %d", + dbesc(datetime_convert()), + intval($r[0]['parent']), intval(local_channel()) ); - if($r) { - $x = q("update item set item_retained = 1, changed = '%s' where id = %d and uid = %d", - dbesc(datetime_convert()), - intval($r[0]['parent']), - intval(local_channel()) - ); - } - } + } else { $filetags = array(); $r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc", @@ -55,10 +66,10 @@ class Filer extends \Zotlabs\Web\Controller { '$title' => t('Save to Folder'), '$cancel' => t('Cancel') )); - + echo $o; } killme(); } - + } diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index c8e6efe38..51caa179c 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -230,6 +230,7 @@ class Hq extends \Zotlabs\Web\Controller { $options['offset'] = $_REQUEST['offset'] ?? 0; $options['type'] = $_REQUEST['type'] ?? ''; $options['author'] = ((isset($_REQUEST['author'])) ? urldecode($_REQUEST['author']) : ''); + $options['file'] = ((isset($_REQUEST['file'])) ? urldecode($_REQUEST['file']) : ''); $ret = Messages::get_messages_page($options); diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index 294a982b1..f90b4f99e 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -23,20 +23,35 @@ class Messages { $_SESSION['messages_loadtime'] = datetime_convert(); + $r = q("SELECT DISTINCT(term) FROM term WHERE uid = %d AND ttype = %d ORDER BY term", + intval(local_channel()), + intval(TERM_FILE) + ); + + if ($r) { + foreach($r as $rr) { + $file_tags[] = $rr['term']; + } + } + $tpl = get_markup_template('messages_widget.tpl'); $o = replace_macros($tpl, [ '$entries' => $page['entries'] ?? [], '$offset' => $page['offset'] ?? 0, '$feature_star' => feature_enabled(local_channel(), 'star_posts'), + '$feature_file' => feature_enabled(local_channel(), 'filing'), + '$file_tags' => $file_tags, '$strings' => [ 'messages_title' => t('Public and restricted messages'), 'direct_messages_title' => t('Direct messages'), 'starred_messages_title' => t('Starred messages'), + 'filed_messages_title' => t('Filed messages'), 'notice_messages_title' => t('Notices'), 'loading' => t('Loading'), 'empty' => t('No messages'), 'unseen_count' => t('Unseen'), - 'filter' => t('Filter by name or address') + 'filter' => t('Filter by name or address'), + 'file_filter' => t('Filter by file name') ] ]); @@ -50,6 +65,7 @@ class Messages { $offset = $options['offset'] ?? 0; $type = $options['type'] ?? ''; $author = $options['author'] ?? ''; + $file = $options['file'] ?? ''; if ($offset == -1) { return; @@ -67,8 +83,9 @@ class Messages { $item_normal_c = str_replace('item.', 'c.', $item_normal); $entries = []; $limit = 30; + $order_sql = 'i.created DESC'; $dummy_order_sql = ''; - $author_sql = ''; + $filter_sql = ''; $loadtime = (($offset) ? $_SESSION['messages_loadtime'] : datetime_convert()); $vnotify = get_pconfig(local_channel(), 'system', 'vnotify', -1); @@ -84,43 +101,55 @@ class Messages { $vnotify_sql_i = " AND i.verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } - if($author) { - $author_sql = " AND (i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "') "; + if($type !== 'filed' && $author) { + $filter_sql = " AND (i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "') "; + } + + if($type === 'filed' && $file) { + $filed_filter_sql = " AND (term.term = '" . protect_sprintf(dbesc($file)) . "') "; } switch($type) { case 'direct': - $type_sql = ' AND i.item_private = 2 '; + $type_sql = ' AND i.item_private = 2 AND i.item_thread_top = 1 '; // $dummy_order_sql has no other meaning but to trick // some mysql backends into using the right index. $dummy_order_sql = ', i.received DESC '; break; case 'starred': - $type_sql = ' AND i.item_starred = 1 '; + $type_sql = ' AND i.item_starred = 1 AND i.item_thread_top = 1 '; + break; + case 'filed': + $type_sql = ' AND i.id IN (SELECT term.oid FROM term WHERE term.ttype = ' . TERM_FILE . ' AND term.uid = i.uid ' . $filed_filter_sql . ')'; break; default: - $type_sql = ' AND i.item_private IN (0, 1) '; + $type_sql = ' AND i.item_private IN (0, 1) AND i.item_thread_top = 1 '; } $items = q("SELECT *, (SELECT count(*) FROM item c WHERE c.uid = %d AND c.parent = i.parent AND c.item_unseen = 1 AND c.item_thread_top = 0 $item_normal_c $vnotify_sql_c) AS unseen_count - FROM item i WHERE i.uid = %d + FROM item i + WHERE i.uid = %d AND i.created <= '%s' $type_sql - AND i.item_thread_top = 1 - $author_sql + $filter_sql $item_normal_i - ORDER BY i.created DESC $dummy_order_sql + ORDER BY $order_sql $dummy_order_sql LIMIT $limit OFFSET $offset", intval(local_channel()), intval(local_channel()), dbescdate($loadtime) ); + if ($type === 'filed') { + $items = fetch_post_tags($items); + } + xchan_query($items, false); $i = 0; $entries = []; + $ids = []; foreach($items as $item) { @@ -149,6 +178,16 @@ class Messages { $info .= t('via') . ' ' . $item['source']['xchan_name']; } + if ($type == 'filed') { + $info = ''; + foreach ($item['term'] as $t) { + if ($t['ttype'] !== TERM_FILE) { + continue; + } + $info .= '<span class="badge rounded-pill bg-danger me-1"><i class="bi bi-folder"></i> ' . $t['term'] . '</span>'; + } + } + $summary = $item['title']; if (!$summary) { $summary = $item['summary']; |