mirror of
https://github.com/friendica/friendica
synced 2024-11-10 04:22:54 +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);
|
$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)) {
|
if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
|
||||||
$title = ucfirst($item['content-warning']);
|
$title = ucfirst($item['content-warning']);
|
||||||
|
|
|
@ -173,7 +173,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$uri_id = $_REQUEST['uri_id'];
|
$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 (!empty($item)) {
|
||||||
if ($item['uid'] != 0) {
|
if ($item['uid'] != 0) {
|
||||||
$a->setProfileOwner($item['uid']);
|
$a->setProfileOwner($item['uid']);
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Item
|
||||||
* Return array with details for categories and folders for an item
|
* Return array with details for categories and folders for an item
|
||||||
*
|
*
|
||||||
* @param array $item
|
* @param array $item
|
||||||
|
* @param int $uid
|
||||||
* @return [array, array]
|
* @return [array, array]
|
||||||
*
|
*
|
||||||
* [
|
* [
|
||||||
|
@ -58,13 +59,15 @@ class Item
|
||||||
* ]
|
* ]
|
||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
public function determineCategoriesTerms(array $item)
|
public function determineCategoriesTerms(array $item, int $uid = 0)
|
||||||
{
|
{
|
||||||
$categories = [];
|
$categories = [];
|
||||||
$folders = [];
|
$folders = [];
|
||||||
$first = true;
|
$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'])) {
|
if (!empty($item['author-link'])) {
|
||||||
$url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
|
$url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,7 +76,7 @@ class Item
|
||||||
$categories[] = [
|
$categories[] = [
|
||||||
'name' => $savedFolderName,
|
'name' => $savedFolderName,
|
||||||
'url' => $url,
|
'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,
|
'first' => $first,
|
||||||
'last' => false
|
'last' => false
|
||||||
];
|
];
|
||||||
|
@ -84,12 +87,12 @@ class Item
|
||||||
$categories[count($categories) - 1]['last'] = true;
|
$categories[count($categories) - 1]['last'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local_user() == $item['uid']) {
|
if (local_user() == $uid) {
|
||||||
foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::FILE) as $savedFolderName) {
|
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
|
||||||
$folders[] = [
|
$folders[] = [
|
||||||
'name' => $savedFolderName,
|
'name' => $savedFolderName,
|
||||||
'url' => "#",
|
'url' => "#",
|
||||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
|
'removeurl' => ((local_user() == $uid) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
|
||||||
'first' => $first,
|
'first' => $first,
|
||||||
'last' => false
|
'last' => false
|
||||||
];
|
];
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
namespace Friendica\Module\Item;
|
namespace Friendica\Module\Item;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
@ -48,11 +50,25 @@ class Star extends BaseModule
|
||||||
|
|
||||||
$itemId = intval($parameters['id']);
|
$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)) {
|
if (empty($item)) {
|
||||||
throw new HTTPException\NotFoundException();
|
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'];
|
$starred = !(bool)$item['starred'];
|
||||||
|
|
||||||
Item::update(['starred' => $starred], ['id' => $itemId]);
|
Item::update(['starred' => $starred], ['id' => $itemId]);
|
||||||
|
|
|
@ -74,8 +74,8 @@ class Filed extends BaseSearch
|
||||||
if (count($posts) == 0) {
|
if (count($posts) == 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$item_condition = ['uid' => local_user(), 'uri-id' => $posts];
|
$item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts];
|
||||||
$item_params = ['order' => ['uri-id' => true]];
|
$item_params = ['order' => ['uri-id' => true, 'uid' => true]];
|
||||||
|
|
||||||
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
|
$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'];
|
$profile_name = $item['author-name'];
|
||||||
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
||||||
|
@ -296,7 +296,7 @@ class Post
|
||||||
$tagger = '';
|
$tagger = '';
|
||||||
|
|
||||||
if ($this->isToplevel()) {
|
if ($this->isToplevel()) {
|
||||||
if(local_user()) {
|
if (local_user()) {
|
||||||
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user());
|
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user());
|
||||||
if ($item['mention'] || $ignored) {
|
if ($item['mention'] || $ignored) {
|
||||||
$ignore = [
|
$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 ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
|
||||||
if ($origin) {
|
if ($origin) {
|
||||||
$ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
|
$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 = [
|
$tagger = [
|
||||||
'add' => DI::l10n()->t('Add tag'),
|
'add' => DI::l10n()->t('Add tag'),
|
||||||
'class' => "",
|
'class' => "",
|
||||||
|
@ -366,7 +366,7 @@ class Post
|
||||||
|
|
||||||
$body_html = Item::prepareBody($item, true);
|
$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)) {
|
if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
|
||||||
$title = ucfirst($item['content-warning']);
|
$title = ucfirst($item['content-warning']);
|
||||||
|
|
|
@ -210,6 +210,7 @@ function enableOnUser(){
|
||||||
// if(timer) clearTimeout(timer);
|
// if(timer) clearTimeout(timer);
|
||||||
// timer = setTimeout(NavUpdate,3000);
|
// timer = setTimeout(NavUpdate,3000);
|
||||||
liking = 1;
|
liking = 1;
|
||||||
|
force_update = true;
|
||||||
$.colorbox.close();
|
$.colorbox.close();
|
||||||
} else {
|
} else {
|
||||||
$("#id_term").css("border-color","#FF0000");
|
$("#id_term").css("border-color","#FF0000");
|
||||||
|
|
|
@ -273,6 +273,7 @@
|
||||||
// if(timer) clearTimeout(timer);
|
// if(timer) clearTimeout(timer);
|
||||||
// timer = setTimeout(NavUpdate,3000);
|
// timer = setTimeout(NavUpdate,3000);
|
||||||
liking = 1;
|
liking = 1;
|
||||||
|
force_update = true;
|
||||||
$.colorbox.close();
|
$.colorbox.close();
|
||||||
} else {
|
} else {
|
||||||
$("#id_term").css("border-color","#FF0000");
|
$("#id_term").css("border-color","#FF0000");
|
||||||
|
|
|
@ -313,7 +313,7 @@ function frio_display_item(App $a, &$arr)
|
||||||
$followThread = [];
|
$followThread = [];
|
||||||
if (
|
if (
|
||||||
local_user()
|
local_user()
|
||||||
&& local_user() == $arr['item']['uid']
|
&& in_array($arr['item']['uid'], [0, local_user()])
|
||||||
&& $arr['item']['gravity'] == GRAVITY_PARENT
|
&& $arr['item']['gravity'] == GRAVITY_PARENT
|
||||||
&& !$arr['item']['self']
|
&& !$arr['item']['self']
|
||||||
&& !$arr['item']['mention']
|
&& !$arr['item']['mention']
|
||||||
|
|
|
@ -240,6 +240,7 @@ function enableOnUser(){
|
||||||
// if(timer) clearTimeout(timer);
|
// if(timer) clearTimeout(timer);
|
||||||
// timer = setTimeout(NavUpdate,3000);
|
// timer = setTimeout(NavUpdate,3000);
|
||||||
liking = 1;
|
liking = 1;
|
||||||
|
force_update = true;
|
||||||
$.colorbox.close();
|
$.colorbox.close();
|
||||||
} else {
|
} else {
|
||||||
$("#id_term").css("border-color","#FF0000");
|
$("#id_term").css("border-color","#FF0000");
|
||||||
|
|
Loading…
Reference in a new issue