64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Leantime\Domain\Wiki\Hxcontrollers;
|
|
|
|
use Leantime\Core\Auth\Permissions\RequiresPermission;
|
|
use Leantime\Core\Controller\HtmxController;
|
|
use Leantime\Domain\Wiki\Permissions\WikiPermissions;
|
|
use Leantime\Domain\Wiki\Services\Wiki;
|
|
|
|
/**
|
|
* HTMX Controller for wiki article activity feed
|
|
*/
|
|
class ArticleActivity extends HtmxController
|
|
{
|
|
protected static string $view = 'wiki::partials.activityFeed';
|
|
|
|
private Wiki $wikiService;
|
|
|
|
public function init(Wiki $wikiService): void
|
|
{
|
|
$this->wikiService = $wikiService;
|
|
}
|
|
|
|
/**
|
|
* Get the activity feed for an article. The service's getArticleActivity() is the precise
|
|
* per-article-project IDOR fence; this VIEW gate stops non-viewers at dispatch.
|
|
*/
|
|
#[RequiresPermission(WikiPermissions::VIEW, entityScoped: true)]
|
|
public function get(): void
|
|
{
|
|
$articleId = (int) $this->incomingRequest->query->get('articleId', 0);
|
|
|
|
if ($articleId <= 0) {
|
|
$this->tpl->assign('activity', []);
|
|
$this->tpl->assign('articleId', 0);
|
|
|
|
return;
|
|
}
|
|
|
|
// Get the article for created/modified fallback
|
|
$article = $this->wikiService->getArticle($articleId);
|
|
|
|
$activity = $this->wikiService->getArticleActivity($articleId, 20);
|
|
|
|
// Always append the article's created date as the final entry
|
|
if ($article && ! empty($article->created)) {
|
|
$activity[] = [
|
|
'type' => 'baseline',
|
|
'action' => 'article.create',
|
|
'date' => $article->created,
|
|
'firstname' => $article->firstname ?? '',
|
|
'lastname' => $article->lastname ?? '',
|
|
'profileId' => $article->profileId ?? '',
|
|
'values' => [],
|
|
];
|
|
}
|
|
|
|
$this->tpl->assign('activity', $activity);
|
|
$this->tpl->assign('articleId', $articleId);
|
|
}
|
|
}
|