Merge pull request #10596 from annando/mark-file-star-for-all

Follow, file and star does now work for all items
This commit is contained in:
Hypolite Petovan 2021-08-12 12:20:55 -04:00 committed by GitHub
commit 1e305e748d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 129 additions and 108 deletions

View file

@ -481,7 +481,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
$body_html = Item::prepareBody($item, true, $preview);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user());
if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);

View file

@ -173,7 +173,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
if ($update) {
$uri_id = $_REQUEST['uri_id'];
$item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => $update_uid]);
$item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => [0, $update_uid]]);
if (!empty($item)) {
if ($item['uid'] != 0) {
$a->setProfileOwner($item['uid']);

View file

@ -35,6 +35,7 @@ class Item
* Return array with details for categories and folders for an item
*
* @param array $item
* @param int $uid
* @return [array, array]
*
* [
@ -58,13 +59,15 @@ class Item
* ]
* ]
*/
public function determineCategoriesTerms(array $item)
public function determineCategoriesTerms(array $item, int $uid = 0)
{
$categories = [];
$folders = [];
$first = true;
foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::CATEGORY) as $savedFolderName) {
$uid = $item['uid'] ?: $uid;
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::CATEGORY) as $savedFolderName) {
if (!empty($item['author-link'])) {
$url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
} else {
@ -73,7 +76,7 @@ class Item
$categories[] = [
'name' => $savedFolderName,
'url' => $url,
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""),
'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];
@ -84,12 +87,12 @@ class Item
$categories[count($categories) - 1]['last'] = true;
}
if (local_user() == $item['uid']) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::FILE) as $savedFolderName) {
if (local_user() == $uid) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];

View file

@ -24,6 +24,7 @@ namespace Friendica\Module\Item;
use Friendica\BaseModule;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
@ -48,11 +49,25 @@ class Star extends BaseModule
$itemId = intval($parameters['id']);
$item = Post::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]);
$item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]);
if (empty($item)) {
throw new HTTPException\NotFoundException();
}
if ($item['uid'] == 0) {
$stored = Item::storeForUserByUriId($item['uri-id'], local_user());
if (!empty($stored)) {
$item = Post::selectFirst(['starred'], ['id' => $stored]);
if (!DBA::isResult($item)) {
throw new HTTPException\NotFoundException();
}
$itemId = $stored;
} else {
throw new HTTPException\NotFoundException();
}
}
$starred = !(bool)$item['starred'];
Item::update(['starred' => $starred], ['id' => $itemId]);

View file

@ -74,8 +74,8 @@ class Filed extends BaseSearch
if (count($posts) == 0) {
return '';
}
$item_condition = ['uid' => local_user(), 'uri-id' => $posts];
$item_params = ['order' => ['uri-id' => true]];
$item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts];
$item_params = ['order' => ['uri-id' => true, 'uid' => true]];
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));

View file

@ -236,7 +236,7 @@ class Post
];
}
$filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t('Save to folder') : false);
$filer = local_user() ? DI::l10n()->t('Save to folder') : false;
$profile_name = $item['author-name'];
if (!empty($item['author-link']) && empty($item['author-name'])) {
@ -296,7 +296,7 @@ class Post
$tagger = '';
if ($this->isToplevel()) {
if(local_user()) {
if (local_user()) {
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user());
if ($item['mention'] || $ignored) {
$ignore = [
@ -309,6 +309,17 @@ class Post
];
}
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = [
'do' => DI::l10n()->t('Add star'),
'undo' => DI::l10n()->t('Remove star'),
'toggle' => DI::l10n()->t('Toggle star status'),
'classdo' => $item['starred'] ? "hidden" : "",
'classundo' => $item['starred'] ? "" : "hidden",
'starred' => DI::l10n()->t('Starred'),
];
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
if ($origin) {
$ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
@ -323,17 +334,6 @@ class Post
];
}
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = [
'do' => DI::l10n()->t('Add star'),
'undo' => DI::l10n()->t('Remove star'),
'toggle' => DI::l10n()->t('Toggle star status'),
'classdo' => $item['starred'] ? "hidden" : "",
'classundo' => $item['starred'] ? "" : "hidden",
'starred' => DI::l10n()->t('Starred'),
];
$tagger = [
'add' => DI::l10n()->t('Add tag'),
'class' => "",
@ -366,7 +366,7 @@ class Post
$body_html = Item::prepareBody($item, true);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user());
if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2021.09-dev\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-09 15:40+0000\n"
"POT-Creation-Date: 2021-08-12 06:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -865,7 +865,7 @@ msgstr ""
#: src/Module/Debug/ItemBody.php:37 src/Module/Diaspora/Receive.php:51
#: src/Module/Item/Follow.php:42 src/Module/Item/Ignore.php:41
#: src/Module/Item/Pin.php:42 src/Module/Item/Pin.php:57
#: src/Module/Item/Star.php:42
#: src/Module/Item/Star.php:43
msgid "Access denied."
msgstr ""
@ -903,21 +903,21 @@ msgstr ""
msgid "Next"
msgstr ""
#: mod/cal.php:257 mod/events.php:431 src/Model/Event.php:450
#: mod/cal.php:257 mod/events.php:431 src/Model/Event.php:474
msgid "today"
msgstr ""
#: mod/cal.php:258 mod/events.php:432 src/Model/Event.php:451
#: mod/cal.php:258 mod/events.php:432 src/Model/Event.php:475
#: src/Util/Temporal.php:330
msgid "month"
msgstr ""
#: mod/cal.php:259 mod/events.php:433 src/Model/Event.php:452
#: mod/cal.php:259 mod/events.php:433 src/Model/Event.php:476
#: src/Util/Temporal.php:331
msgid "week"
msgstr ""
#: mod/cal.php:260 mod/events.php:434 src/Model/Event.php:453
#: mod/cal.php:260 mod/events.php:434 src/Model/Event.php:477
#: src/Util/Temporal.php:332
msgid "day"
msgstr ""
@ -1066,7 +1066,7 @@ msgid "Description:"
msgstr ""
#: mod/events.php:568 src/Content/Widget/VCard.php:98 src/Model/Event.php:86
#: src/Model/Event.php:113 src/Model/Event.php:459 src/Model/Event.php:945
#: src/Model/Event.php:113 src/Model/Event.php:483 src/Model/Event.php:969
#: src/Model/Profile.php:358 src/Module/Contact.php:607
#: src/Module/Directory.php:150 src/Module/Notifications/Introductions.php:166
#: src/Module/Profile/Profile.php:194
@ -3965,137 +3965,137 @@ msgstr ""
msgid "Could not connect to database."
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:418
#: src/Core/L10n.php:377 src/Model/Event.php:442
#: src/Module/Settings/Display.php:183
msgid "Monday"
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:419
#: src/Core/L10n.php:377 src/Model/Event.php:443
msgid "Tuesday"
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:420
#: src/Core/L10n.php:377 src/Model/Event.php:444
msgid "Wednesday"
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:421
#: src/Core/L10n.php:377 src/Model/Event.php:445
msgid "Thursday"
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:422
#: src/Core/L10n.php:377 src/Model/Event.php:446
msgid "Friday"
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:423
#: src/Core/L10n.php:377 src/Model/Event.php:447
msgid "Saturday"
msgstr ""
#: src/Core/L10n.php:377 src/Model/Event.php:417
#: src/Core/L10n.php:377 src/Model/Event.php:441
#: src/Module/Settings/Display.php:183
msgid "Sunday"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:438
#: src/Core/L10n.php:381 src/Model/Event.php:462
msgid "January"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:439
#: src/Core/L10n.php:381 src/Model/Event.php:463
msgid "February"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:440
#: src/Core/L10n.php:381 src/Model/Event.php:464
msgid "March"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:441
#: src/Core/L10n.php:381 src/Model/Event.php:465
msgid "April"
msgstr ""
#: src/Core/L10n.php:381 src/Core/L10n.php:401 src/Model/Event.php:429
#: src/Core/L10n.php:381 src/Core/L10n.php:401 src/Model/Event.php:453
msgid "May"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:442
#: src/Core/L10n.php:381 src/Model/Event.php:466
msgid "June"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:443
#: src/Core/L10n.php:381 src/Model/Event.php:467
msgid "July"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:444
#: src/Core/L10n.php:381 src/Model/Event.php:468
msgid "August"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:445
#: src/Core/L10n.php:381 src/Model/Event.php:469
msgid "September"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:446
#: src/Core/L10n.php:381 src/Model/Event.php:470
msgid "October"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:447
#: src/Core/L10n.php:381 src/Model/Event.php:471
msgid "November"
msgstr ""
#: src/Core/L10n.php:381 src/Model/Event.php:448
#: src/Core/L10n.php:381 src/Model/Event.php:472
msgid "December"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:410
#: src/Core/L10n.php:397 src/Model/Event.php:434
msgid "Mon"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:411
#: src/Core/L10n.php:397 src/Model/Event.php:435
msgid "Tue"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:412
#: src/Core/L10n.php:397 src/Model/Event.php:436
msgid "Wed"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:413
#: src/Core/L10n.php:397 src/Model/Event.php:437
msgid "Thu"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:414
#: src/Core/L10n.php:397 src/Model/Event.php:438
msgid "Fri"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:415
#: src/Core/L10n.php:397 src/Model/Event.php:439
msgid "Sat"
msgstr ""
#: src/Core/L10n.php:397 src/Model/Event.php:409
#: src/Core/L10n.php:397 src/Model/Event.php:433
msgid "Sun"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:425
#: src/Core/L10n.php:401 src/Model/Event.php:449
msgid "Jan"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:426
#: src/Core/L10n.php:401 src/Model/Event.php:450
msgid "Feb"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:427
#: src/Core/L10n.php:401 src/Model/Event.php:451
msgid "Mar"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:428
#: src/Core/L10n.php:401 src/Model/Event.php:452
msgid "Apr"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:430
#: src/Core/L10n.php:401 src/Model/Event.php:454
msgid "Jun"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:431
#: src/Core/L10n.php:401 src/Model/Event.php:455
msgid "Jul"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:432
#: src/Core/L10n.php:401 src/Model/Event.php:456
msgid "Aug"
msgstr ""
@ -4103,15 +4103,15 @@ msgstr ""
msgid "Sep"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:434
#: src/Core/L10n.php:401 src/Model/Event.php:458
msgid "Oct"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:435
#: src/Core/L10n.php:401 src/Model/Event.php:459
msgid "Nov"
msgstr ""
#: src/Core/L10n.php:401 src/Model/Event.php:436
#: src/Core/L10n.php:401 src/Model/Event.php:460
msgid "Dec"
msgstr ""
@ -4482,71 +4482,71 @@ msgstr ""
msgid "Unable to retrieve contact information."
msgstr ""
#: src/Model/Event.php:52 src/Model/Event.php:857
#: src/Model/Event.php:52 src/Model/Event.php:881
#: src/Module/Debug/Localtime.php:38
msgid "l F d, Y \\@ g:i A"
msgstr ""
#: src/Model/Event.php:79 src/Model/Event.php:96 src/Model/Event.php:457
#: src/Model/Event.php:927
#: src/Model/Event.php:79 src/Model/Event.php:96 src/Model/Event.php:481
#: src/Model/Event.php:951
msgid "Starts:"
msgstr ""
#: src/Model/Event.php:82 src/Model/Event.php:102 src/Model/Event.php:458
#: src/Model/Event.php:931
#: src/Model/Event.php:82 src/Model/Event.php:102 src/Model/Event.php:482
#: src/Model/Event.php:955
msgid "Finishes:"
msgstr ""
#: src/Model/Event.php:407
#: src/Model/Event.php:431
msgid "all-day"
msgstr ""
#: src/Model/Event.php:433
#: src/Model/Event.php:457
msgid "Sept"
msgstr ""
#: src/Model/Event.php:455
#: src/Model/Event.php:479
msgid "No events to display"
msgstr ""
#: src/Model/Event.php:573
#: src/Model/Event.php:597
msgid "l, F j"
msgstr ""
#: src/Model/Event.php:604
#: src/Model/Event.php:628
msgid "Edit event"
msgstr ""
#: src/Model/Event.php:605
#: src/Model/Event.php:629
msgid "Duplicate event"
msgstr ""
#: src/Model/Event.php:606
#: src/Model/Event.php:630
msgid "Delete event"
msgstr ""
#: src/Model/Event.php:858
#: src/Model/Event.php:882
msgid "D g:i A"
msgstr ""
#: src/Model/Event.php:859
#: src/Model/Event.php:883
msgid "g:i A"
msgstr ""
#: src/Model/Event.php:946 src/Model/Event.php:948
#: src/Model/Event.php:970 src/Model/Event.php:972
msgid "Show map"
msgstr ""
#: src/Model/Event.php:947
#: src/Model/Event.php:971
msgid "Hide map"
msgstr ""
#: src/Model/Event.php:1039
#: src/Model/Event.php:1063
#, php-format
msgid "%s's birthday"
msgstr ""
#: src/Model/Event.php:1040
#: src/Model/Event.php:1064
#, php-format
msgid "Happy Birthday %s"
msgstr ""
@ -7763,7 +7763,7 @@ msgstr ""
msgid "Posts that mention or involve you"
msgstr ""
#: src/Module/Conversation/Network.php:258 src/Object/Post.php:334
#: src/Module/Conversation/Network.php:258 src/Object/Post.php:320
msgid "Starred"
msgstr ""
@ -10194,34 +10194,34 @@ msgstr ""
msgid "Toggle ignore status"
msgstr ""
#: src/Object/Post.php:317
msgid "Pin"
msgstr ""
#: src/Object/Post.php:318
msgid "Unpin"
msgstr ""
#: src/Object/Post.php:319
msgid "Toggle pin status"
msgstr ""
#: src/Object/Post.php:322
msgid "Pinned"
msgstr ""
#: src/Object/Post.php:329
#: src/Object/Post.php:315
msgid "Add star"
msgstr ""
#: src/Object/Post.php:330
#: src/Object/Post.php:316
msgid "Remove star"
msgstr ""
#: src/Object/Post.php:331
#: src/Object/Post.php:317
msgid "Toggle star status"
msgstr ""
#: src/Object/Post.php:328
msgid "Pin"
msgstr ""
#: src/Object/Post.php:329
msgid "Unpin"
msgstr ""
#: src/Object/Post.php:330
msgid "Toggle pin status"
msgstr ""
#: src/Object/Post.php:333
msgid "Pinned"
msgstr ""
#: src/Object/Post.php:338
msgid "Add tag"
msgstr ""
@ -10331,7 +10331,7 @@ msgstr ""
msgid "Show fewer"
msgstr ""
#: src/Protocol/Diaspora.php:3443
#: src/Protocol/Diaspora.php:3448
msgid "Attachments:"
msgstr ""

View file

@ -210,6 +210,7 @@ function enableOnUser(){
// if(timer) clearTimeout(timer);
// timer = setTimeout(NavUpdate,3000);
liking = 1;
force_update = true;
$.colorbox.close();
} else {
$("#id_term").css("border-color","#FF0000");

View file

@ -273,6 +273,7 @@
// if(timer) clearTimeout(timer);
// timer = setTimeout(NavUpdate,3000);
liking = 1;
force_update = true;
$.colorbox.close();
} else {
$("#id_term").css("border-color","#FF0000");

View file

@ -313,7 +313,7 @@ function frio_display_item(App $a, &$arr)
$followThread = [];
if (
local_user()
&& local_user() == $arr['item']['uid']
&& in_array($arr['item']['uid'], [0, local_user()])
&& $arr['item']['gravity'] == GRAVITY_PARENT
&& !$arr['item']['self']
&& !$arr['item']['mention']

View file

@ -240,6 +240,7 @@ function enableOnUser(){
// if(timer) clearTimeout(timer);
// timer = setTimeout(NavUpdate,3000);
liking = 1;
force_update = true;
$.colorbox.close();
} else {
$("#id_term").css("border-color","#FF0000");