mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:00:16 +00:00
Mark, file and starring does now work for all items
This commit is contained in:
parent
e146a5983c
commit
473adaf463
10 changed files with 48 additions and 26 deletions
|
@ -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']);
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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'] != 0) ? $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
|
||||
];
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
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 +50,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]);
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue