commit b53992613ddc3c987d10d2e147afe4932d79920f Author: Sven Wappler Date: Mon Aug 10 22:31:02 2026 +0200 TYPO3 v15 dev-main snapshot () diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57872d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor/ diff --git a/Classes/Controller/BackendLogController.php b/Classes/Controller/BackendLogController.php new file mode 100644 index 0000000..f5d9e20 --- /dev/null +++ b/Classes/Controller/BackendLogController.php @@ -0,0 +1,346 @@ +settings['dateFormat'])) { + $this->settings['dateFormat'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'd-m-Y'; + } + if (!isset($this->settings['timeFormat'])) { + $this->settings['timeFormat'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']; + } + // Static format needed for date picker (flatpickr), see BackendController::generateJavascript() and #91606 + $this->settings['dateTimeFormat'] = 'H:i d-m-Y'; + $constraintConfiguration = $this->arguments->getArgument('constraint')->getPropertyMappingConfiguration(); + $constraintConfiguration->allowAllProperties(); + $constraintConfiguration->forProperty('manualDateStart')->setTypeConverterOption(DateTimeConverter::class, DateTimeConverter::CONFIGURATION_DATE_FORMAT, DateTimeFormat::ISO8601_LOCALTIME); + $constraintConfiguration->forProperty('manualDateStop')->setTypeConverterOption(DateTimeConverter::class, DateTimeConverter::CONFIGURATION_DATE_FORMAT, DateTimeFormat::ISO8601_LOCALTIME); + } + + /** + * Show general information and the installed modules + */ + public function listAction(?Constraint $constraint = null, string $operation = ''): ResponseInterface + { + if ($operation === 'reset-filters') { + $constraint = new Constraint(); + } elseif ($constraint === null) { + $constraint = $this->getConstraintFromBeUserData(); + } + + $access = true; + $pageId = $constraint->getPageId(); + $permsClause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW); + if ($pageId === 0 || (BackendUtility::readPageAccess($pageId, $permsClause) ?: []) === []) { + if (!$this->getBackendUser()->isAdmin()) { + // User does not have access to selected site + $access = false; + } + + if ($pageId === 0) { + // In case no page is selected, set depth to 0 to display only "global" logs + $constraint->setDepth(0); + } + } + + $this->persistConstraintInBeUserData($constraint); + $this->resetConstraintsOnMemoryExhaustionError(); + $this->setStartAndEndTimeFromTimeSelector($constraint); + $showWorkspaceSelector = $this->forceWorkspaceSelectionIfInWorkspace($constraint); + + $viewVariables = [ + 'access' => $access, + 'settings' => $this->settings, + 'pageId' => $pageId, + 'constraint' => $constraint, + 'userGroups' => $this->createUserAndGroupListForSelectOptions(), + 'selectableNumberOfLogEntries' => $this->createSelectableNumberOfLogEntriesOptions(), + 'workspaces' => $this->createWorkspaceListForSelectOptions(), + 'pageDepths' => $this->createPageDepthOptions(), + 'channels' => $this->logEntryRepository->getUsedChannels(), + 'channel' => $constraint->getChannel(), + 'levels' => $this->logEntryRepository->getUsedLevels(), + 'level' => $constraint->getLevel(), + 'showWorkspaceSelector' => $showWorkspaceSelector, + ]; + + if ($access) { + // Only fetch log entries if user has access + $logEntries = $this->logEntryRepository->findByConstraint($constraint); + $groupedLogEntries = $this->groupLogEntriesDay($logEntries); + $viewVariables['groupedLogEntries'] = $groupedLogEntries; + } + + $view = $this->moduleTemplateFactory->create($this->request); + $view->getDocHeaderComponent()->setShortcutContext( + 'system_log', + $this->getLanguageService()->translate('title', 'belog.module') + ); + return $view->setFlashMessageQueue($this->getFlashMessageQueue()) + ->setTitle(LocalizationUtility::translate('title', 'belog.module')) + ->assignMultiple($viewVariables) + ->renderResponse('BackendLog/List'); + } + + public function initializeDeleteMessageAction(): void + { + $this->assertAllowedHttpMethod($this->request, 'POST'); + } + + /** + * Delete all log entries that share the same message with the log entry given + * in $errorUid + */ + public function deleteMessageAction(int $errorUid): ResponseInterface + { + $logEntry = $this->logEntryRepository->findByUid($errorUid); + if (!$logEntry) { + $this->addFlashMessage(LocalizationUtility::translate('actions.delete.noRowFound', 'belog') ?? '', '', ContextualFeedbackSeverity::WARNING); + return $this->redirect('list'); + } + $numberOfDeletedRows = $this->logEntryRepository->deleteByMessageDetails($logEntry); + $this->addFlashMessage(sprintf(LocalizationUtility::translate('actions.delete.message', 'belog') ?? '', $numberOfDeletedRows)); + BackendUtility::setUpdateSignal('updateSystemInformationMenu'); + return $this->redirect('list'); + } + + /** + * Get module states (the constraint object) from user data + */ + protected function getConstraintFromBeUserData(): Constraint + { + $serializedConstraint = $this->request->getAttribute('moduleData')->get('constraint'); + $constraint = null; + if (is_string($serializedConstraint) && !empty($serializedConstraint)) { + $constraint = @unserialize($serializedConstraint, ['allowed_classes' => [Constraint::class, \DateTime::class]]); + } + return $constraint ?: GeneralUtility::makeInstance(Constraint::class); + } + + /** + * Save current constraint object in be user settings (uC) + */ + protected function persistConstraintInBeUserData(Constraint $constraint): void + { + $moduleData = $this->request->getAttribute('moduleData'); + $moduleData->set('constraint', serialize($constraint)); + $this->getBackendUser()->pushModuleData($moduleData->getModuleIdentifier(), $moduleData->toArray()); + } + + /** + * In case the script execution fails, because the user requested too many results + * (memory exhaustion in php), reset the constraints in be user settings, so + * the belog can be accessed again in the next call. + */ + protected function resetConstraintsOnMemoryExhaustionError(): void + { + $reservedMemory = new \SplFixedArray(187500); // 3M + register_shutdown_function(function () use (&$reservedMemory): void { + $reservedMemory = null; // free the reserved memory + $error = error_get_last(); + if (str_contains($error['message'] ?? '', 'Allowed memory size of')) { + $constraint = GeneralUtility::makeInstance(Constraint::class); + $this->persistConstraintInBeUserData($constraint); + } + }); + } + + /** + * Create a sorted array for day from the query result of the sys log repository. + * + * pid is always -1 to render a flat list. + * '12345' is a sub array to split entries by day, number is first second of day + * + * [pid][dayTimestamp][items] + * + * @param array $logEntries + */ + protected function groupLogEntriesDay(array $logEntries): array + { + $targetStructure = []; + foreach ($logEntries as $entry) { + $pid = -1; + // Create array if it is not defined yet + if (!is_array($targetStructure[$pid] ?? false)) { + $targetStructure[-1] = []; + } + // Get day timestamp of log entry and create sub array if needed + $timestampDay = strtotime($entry->getTstamp()->format('Y-m-d')); + if (!is_array($targetStructure[$pid][$timestampDay] ?? false)) { + $targetStructure[$pid][$timestampDay] = []; + } + // Add row + $targetStructure[$pid][$timestampDay][] = $entry; + } + ksort($targetStructure); + return $targetStructure; + } + + /** + * Create options for the user / group drop down. + * This is not moved to a repository by intention to not mix up this 'meta' data + * with real repository work. + */ + protected function createUserAndGroupListForSelectOptions(): array + { + $items = []; + foreach (BackendUtility::getGroupNames() as $group) { + $items['groups']['gr-' . $group['uid']] = BackendUtility::getRecordTitle('be_groups', $group); + } + foreach (BackendUtility::getUserNames() as $user) { + $items['users']['us-' . $user['uid']] = BackendUtility::getRecordTitle('be_users', $user); + } + return $items; + } + + /** + * Options for the "max" drop down + */ + protected function createSelectableNumberOfLogEntriesOptions(): array + { + return [ + 50 => 50, + 100 => 100, + 200 => 200, + 500 => 500, + 1000 => 1000, + 1000000 => LocalizationUtility::translate('any', 'Belog'), + ]; + } + + /** + * Create options for the workspace selector + * + * @return array Key is uid of workspace, value its label + */ + protected function createWorkspaceListForSelectOptions(): array + { + if (!ExtensionManagementUtility::isLoaded('workspaces')) { + return []; + } + $workspaceArray = []; + // Two meta entries: 'all' and 'live' + $workspaceArray[-99] = LocalizationUtility::translate('any', 'Belog'); + $workspaceArray[0] = LocalizationUtility::translate('live', 'Belog'); + $resultSet = $this->connectionPool->getQueryBuilderForTable('sys_workspace') + ->select('uid', 'title') + ->from('sys_workspace') + ->executeQuery(); + while ($row = $resultSet->fetchAssociative()) { + $workspaceArray[$row['uid']] = $row['uid'] . ': ' . $row['title']; + } + return $workspaceArray; + } + + /** + * If the user is in a workspace different than LIVE, + * we force to show only log entries from the selected workspace, + * and the workspace selector is not shown. + */ + protected function forceWorkspaceSelectionIfInWorkspace(Constraint $constraint): bool + { + if (!ExtensionManagementUtility::isLoaded('workspaces')) { + return false; + } + + if ($this->getBackendUser()->workspace !== 0) { + $constraint->setWorkspaceUid($this->getBackendUser()->workspace); + return false; + } + return true; + } + + /** + * Create options for the 'depth of page levels' selector. + * + * @return array Key is depth identifier (1 = One level), value the localized select option label + */ + protected function createPageDepthOptions(): array + { + return [ + 0 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'), + 1 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'), + 2 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'), + 3 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'), + 4 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'), + 999 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi'), + ]; + } + + /** + * Calculate the start- and end timestamp + */ + protected function setStartAndEndTimeFromTimeSelector(Constraint $constraint): void + { + $startTime = $constraint->getManualDateStart() ? $constraint->getManualDateStart()->getTimestamp() : 0; + $endTime = $constraint->getManualDateStop() ? $constraint->getManualDateStop()->getTimestamp() : 0; + if ($endTime <= $startTime) { + $endTime = $GLOBALS['EXEC_TIME']; + } + $constraint->setStartTimestamp($startTime); + $constraint->setEndTimestamp($endTime); + } + + protected function getBackendUser(): BackendUserAuthentication + { + return $GLOBALS['BE_USER']; + } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } +} diff --git a/Classes/Domain/Model/Constraint.php b/Classes/Domain/Model/Constraint.php new file mode 100644 index 0000000..c511f03 --- /dev/null +++ b/Classes/Domain/Model/Constraint.php @@ -0,0 +1,192 @@ +" for a group, "us-" for a user or -1 for "all users" + */ + protected string $userOrGroup = '0'; + + /** + * Number of log rows to show + */ + protected int $number = 20; + + /** + * UID of selected workspace + */ + protected int $workspaceUid = -99; + + /** + * Selected channel + */ + protected string $channel = ''; + + /** + * Selected level + */ + protected string $level = LogLevel::DEBUG; + + /** + * Calculated start timestamp + */ + protected int $startTimestamp = 0; + + /** + * Calculated end timestamp + */ + protected int $endTimestamp = 0; + + /** + * Manual date start + */ + protected ?\DateTime $manualDateStart = null; + + /** + * Manual date stop + */ + protected ?\DateTime $manualDateStop = null; + + /** + * Selected page ID in page context + */ + protected int $pageId = 0; + + /** + * Page level depth + */ + protected int $depth = 0; + + public function setUserOrGroup(string $user): void + { + $this->userOrGroup = $user; + } + + public function getUserOrGroup(): string + { + return $this->userOrGroup; + } + + public function setNumber(int $number): void + { + $this->number = $number; + } + + public function getNumber(): int + { + return $this->number; + } + + public function setWorkspaceUid(int $workspace): void + { + $this->workspaceUid = $workspace; + } + + public function getWorkspaceUid(): int + { + return $this->workspaceUid; + } + + public function setChannel(string $channel): void + { + $this->channel = $channel; + } + + public function getChannel(): string + { + return $this->channel; + } + + public function setLevel(string $level): void + { + $this->level = $level; + } + + public function getLevel(): string + { + return $this->level; + } + + public function setStartTimestamp(int $timestamp): void + { + $this->startTimestamp = $timestamp; + } + + public function getStartTimestamp(): int + { + return $this->startTimestamp; + } + + public function setEndTimestamp(int $timestamp): void + { + $this->endTimestamp = $timestamp; + } + + public function getEndTimestamp(): int + { + return $this->endTimestamp; + } + + public function setPageId(?int $id): void + { + $this->pageId = $id ?? 0; + } + + public function getPageId(): int + { + return $this->pageId; + } + + public function setDepth(int $depth): void + { + $this->depth = $depth; + } + + public function getDepth(): int + { + return $this->depth; + } + + public function setManualDateStart(?\DateTime $manualDateStart = null): void + { + $this->manualDateStart = $manualDateStart; + } + + public function getManualDateStart(): ?\DateTime + { + return $this->manualDateStart; + } + + public function setManualDateStop(?\DateTime $manualDateStop = null): void + { + $this->manualDateStop = $manualDateStop; + } + + public function getManualDateStop(): ?\DateTime + { + return $this->manualDateStop; + } +} diff --git a/Classes/Domain/Model/LogEntry.php b/Classes/Domain/Model/LogEntry.php new file mode 100644 index 0000000..e28bf21 --- /dev/null +++ b/Classes/Domain/Model/LogEntry.php @@ -0,0 +1,248 @@ + + */ + protected int $uid = 0; + + /** + * This is not a relation to BeUser model, since the user does + * not always exist, but we want the uid in then anyway. + * This case is ugly in extbase, the best way we + * have found now is to resolve the username (if it exists) in a + * view helper and just use the uid of the be user here. + */ + protected int $backendUserUid = 0; + + /** + * Action ID of the action that happened, for example 3 was a file action + */ + protected int $action = 0; + + /** + * UID of the record the event happened to + */ + protected int $recordUid = 0; + + /** + * Table name + */ + protected string $tableName = ''; + + /** + * PID of the record the event happened to + */ + protected int $recordPid = 0; + + /** + * Error code + */ + protected int $error = 0; + + /** + * This is the log message itself, but possibly with %s substitutions. + */ + protected string $details = ''; + + /** + * Timestamp when the log entry was written + */ + protected \DateTimeInterface $tstamp; + + /** + * Type code + */ + protected int $type = 0; + + /** + * Channel name. + */ + protected string $channel = ''; + + /** + * Level. + */ + protected string $level = ''; + + /** + * IP address of client + */ + protected string $ip = ''; + + /** + * Serialized log data. This is a serialized array with substitutions for $this->details. + */ + protected string $logData = ''; + + /** + * Event PID + */ + protected int $eventPid = 0; + + /** + * This is only the UID and not the full workspace object for the same reason as in $beUserUid. + */ + protected int $workspaceUid = 0; + + public function getUid(): int + { + return $this->uid; + } + + public function getBackendUserUid(): int + { + return $this->backendUserUid; + } + + public function getAction(): int + { + return $this->action; + } + + public function getRecordUid(): int + { + return $this->recordUid; + } + + public function getTableName(): string + { + return $this->tableName; + } + + public function getRecordPid(): int + { + return $this->recordPid; + } + + public function setError(int $error): void + { + $this->error = $error; + } + + public function getError(): int + { + return $this->error; + } + + public function getErrorIconClass(): string + { + return match ($this->getError()) { + 1 => 'status-dialog-warning', + 2, 3 => 'status-dialog-error', + default => 'empty-empty', + }; + } + + public function getDetails(): string + { + if ($this->type === 255) { + return str_replace('###IP###', $this->ip, $this->details); + } + return $this->details; + } + + public function getTstamp(): \DateTimeInterface + { + return $this->tstamp; + } + + public function getType(): int + { + return $this->type; + } + + public function getChannel(): string + { + return $this->channel; + } + + public function getLevel(): string + { + return $this->level; + } + + public function getIp(): string + { + return $this->ip; + } + + public function setLogData(string $logData): void + { + $this->logData = $logData; + } + + public function getLogData(): array + { + if ($this->logData === '') { + return []; + } + $logData = $this->unserializeLogData($this->logData); + return $logData ?? []; + } + + public function getLogDataRaw(): string + { + return $this->logData; + } + + public function getEventPid(): int + { + return $this->eventPid; + } + + public function getWorkspaceUid(): int + { + return $this->workspaceUid; + } + + public static function createFromDatabaseRecord(array $row): self + { + $obj = new self(); + $obj->uid = $row['uid'] ?? $obj->uid; + $obj->tstamp = new \DateTimeImmutable(date('Y-m-d\TH:i:s', $row['tstamp'] ?? 0)); + $obj->backendUserUid = $row['userid'] ?? $obj->backendUserUid; + $obj->action = $row['action'] ?? $obj->action; + $obj->recordUid = $row['recuid'] ?? $obj->recordUid; + $obj->tableName = $row['tablename'] ?? $obj->tableName; + $obj->recordPid = $row['recpid'] ?? $obj->recordPid; + $obj->error = $row['error'] ?? $obj->error; + $obj->type = $row['type'] ?? $obj->type; + $obj->details = $row['details'] ?? $obj->details; + $obj->ip = $row['IP'] ?? $obj->ip; + $obj->logData = $row['log_data'] ?? $obj->logData; + $obj->eventPid = $row['event_pid'] ?? $obj->eventPid; + $obj->workspaceUid = $row['workspace'] ?? $obj->workspaceUid; + $obj->channel = $row['channel'] ?? $obj->channel; + $obj->level = $row['level'] ?? $obj->level; + return $obj; + } +} diff --git a/Classes/Domain/Repository/LogEntryRepository.php b/Classes/Domain/Repository/LogEntryRepository.php new file mode 100644 index 0000000..bc92e7b --- /dev/null +++ b/Classes/Domain/Repository/LogEntryRepository.php @@ -0,0 +1,209 @@ +connectionPool->getQueryBuilderForTable('sys_log'); + $row = $queryBuilder + ->select('*') + ->from('sys_log') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT)) + ) + ->fetchAssociative(); + return $row ? LogEntry::createFromDatabaseRecord($row) : null; + } + + /** + * Finds all log entries that match all given constraints. + * + * @return array + */ + public function findByConstraint(Constraint $constraint): array + { + $query = $this->connectionPool->getQueryBuilderForTable('sys_log'); + $query->select('*') + ->from('sys_log') + ->orderBy('uid', 'DESC'); + $queryConstraints = $this->createQueryConstraints($query, $constraint); + $stmt = $query + ->where(...$queryConstraints) + ->setMaxResults($constraint->getNumber()) + ->executeQuery(); + $result = []; + while ($row = $stmt->fetchAssociative()) { + $result[] = LogEntry::createFromDatabaseRecord($row); + } + return $result; + } + + /** + * Create an array of query constraints from constraint object + */ + protected function createQueryConstraints(QueryBuilder $query, Constraint $constraint): array + { + // User / group handling + $queryConstraints = $this->addUsersAndGroupsToQueryConstraints($constraint, $query); + // Workspace + if ($constraint->getWorkspaceUid() !== -99) { + $queryConstraints[] = $query->expr()->eq('workspace', $query->createNamedParameter($constraint->getWorkspaceUid(), Connection::PARAM_INT)); + } + // Channel + if ($channel = $constraint->getChannel()) { + $queryConstraints[] = $query->expr()->eq('channel', $query->createNamedParameter($channel)); + } + // Level + if ($level = $constraint->getLevel()) { + $queryConstraints[] = $query->expr()->in('level', $query->createNamedParameter(Typo3LogLevel::atLeast($level), Connection::PARAM_STR_ARRAY)); + } + // Start / endtime handling: The timestamp calculation was already done + // in the controller, since we need those calculated values in the view as well. + $queryConstraints[] = $query->expr()->gte('tstamp', $query->createNamedParameter($constraint->getStartTimestamp(), Connection::PARAM_INT)); + $queryConstraints[] = $query->expr()->lt('tstamp', $query->createNamedParameter($constraint->getEndTimestamp(), Connection::PARAM_INT)); + // Page and level constraint if in page context + $constraint = $this->addPageTreeConstraintsToQuery($constraint, $query); + if ($constraint) { + $queryConstraints[] = $constraint; + } + return $queryConstraints; + } + + /** + * Adds constraints for the page(s) to the query; this could be one single page or a whole subtree beneath a given + * page. + */ + protected function addPageTreeConstraintsToQuery(Constraint $constraint, QueryBuilder $query): ?string + { + $pageIds = []; + // Check if we should get a whole tree of pages and not only a single page + if ($constraint->getDepth() > 0) { + $repository = GeneralUtility::makeInstance(PageTreeRepository::class); + $repository->setAdditionalWhereClause($GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)); + $pages = $repository->getFlattenedPages([$constraint->getPageId()], $constraint->getDepth()); + foreach ($pages as $page) { + $pageIds[] = (int)$page['uid']; + } + } + if (!empty($constraint->getPageId())) { + $pageIds[] = $constraint->getPageId(); + } + if (!empty($pageIds)) { + return $query->expr()->in('event_pid', $query->createNamedParameter($pageIds, Connection::PARAM_INT_ARRAY)); + } + return null; + } + + /** + * Adds users and groups to the query constraints. + */ + protected function addUsersAndGroupsToQueryConstraints(Constraint $constraint, QueryBuilder $query): array + { + $userOrGroup = $constraint->getUserOrGroup(); + if ($userOrGroup === '') { + return []; + } + $queryConstraints = []; + // Constraint for a group + if (str_starts_with($userOrGroup, 'gr-')) { + $groupId = (int)substr($userOrGroup, 3); + $userIds = $this->groupResolver->findAllUsersInGroups([$groupId], 'be_groups', 'be_users'); + if (!empty($userIds)) { + $userIds = array_column($userIds, 'uid'); + $userIds = array_map(intval(...), $userIds); + $queryConstraints[] = $query->expr()->in('userid', $query->createNamedParameter($userIds, Connection::PARAM_INT_ARRAY)); + } else { + // If there are no group members -> use -1 as constraint to not find anything + $queryConstraints[] = $query->expr()->eq('userid', $query->createNamedParameter(-1, Connection::PARAM_INT)); + } + } elseif (str_starts_with($userOrGroup, 'us-')) { + $queryConstraints[] = $query->expr()->in('userid', $query->createNamedParameter((int)substr($userOrGroup, 3), Connection::PARAM_INT)); + } elseif ($userOrGroup === '-1') { + $queryConstraints[] = $query->expr()->in('userid', $query->createNamedParameter((int)$GLOBALS['BE_USER']->user['uid'], Connection::PARAM_INT)); + } + return $queryConstraints; + } + + /** + * Deletes all messages which have the same message details + */ + public function deleteByMessageDetails(LogEntry $logEntry): int + { + $queryBuilder = $this->connectionPool->getQueryBuilderForTable('sys_log'); + return $queryBuilder->delete('sys_log') + ->where($queryBuilder->expr()->eq('details', $queryBuilder->createNamedParameter($logEntry->getDetails()))) + ->executeStatement(); + } + + public function getUsedChannels(): array + { + $channels = $this->connectionPool->getQueryBuilderForTable('sys_log') + ->select('channel') + ->distinct() + ->from('sys_log') + ->orderBy('channel') + ->executeQuery() + ->fetchFirstColumn(); + return array_combine($channels, $channels); + } + + public function getUsedLevels(): array + { + static $allLevels = [ + LogLevel::EMERGENCY, + LogLevel::ALERT, + LogLevel::CRITICAL, + LogLevel::ERROR, + LogLevel::WARNING, + LogLevel::NOTICE, + LogLevel::INFO, + LogLevel::DEBUG, + ]; + $levels = $this->connectionPool->getQueryBuilderForTable('sys_log') + ->select('level') + ->distinct() + ->from('sys_log') + ->executeQuery() + ->fetchFirstColumn(); + $levelsUsed = array_intersect($allLevels, $levels); + return array_combine($levelsUsed, $levelsUsed); + } +} diff --git a/Classes/EventListener/SystemInformationEventListener.php b/Classes/EventListener/SystemInformationEventListener.php new file mode 100644 index 0000000..e22fc10 --- /dev/null +++ b/Classes/EventListener/SystemInformationEventListener.php @@ -0,0 +1,110 @@ +connectionPool->getQueryBuilderForTable('sys_log'); + $count = $queryBuilder->count('error') + ->from('sys_log') + ->where( + $queryBuilder->expr()->gte( + 'tstamp', + $queryBuilder->createNamedParameter($this->fetchLastAccessTimestamp(), Connection::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'error', + $queryBuilder->createNamedParameter([-1, 1, 2], Connection::PARAM_INT_ARRAY) + ), + $queryBuilder->expr()->eq( + 'channel', + $queryBuilder->createNamedParameter('php', Connection::PARAM_STR) + ) + ) + ->executeQuery() + ->fetchOne(); + + if ($count > 0) { + $moduleIdentifier = 'system_log'; + $moduleParams = ['constraint' => ['channel' => 'php']]; + $text = $this->getLanguageService()->translate( + 'systemmessage.errorsInPeriod', + 'belog.messages', + [ + $count, + (string)$this->uriBuilder->buildUriFromRoute($moduleIdentifier, $moduleParams), + ] + ); + $systemInformationToolbarItem = $event->getToolbarItem(); + $systemInformationToolbarItem->addSystemMessage( + $text, + InformationStatus::ERROR, + $count, + $moduleIdentifier, + http_build_query($moduleParams) + ); + } + } + + private function fetchLastAccessTimestamp(): int + { + if (!isset($this->getBackendUser()->uc['systeminformation'])) { + return 0; + } + $systemInformationUc = json_decode($this->getBackendUser()->uc['systeminformation'], true, 512, JSON_THROW_ON_ERROR); + return (int)($systemInformationUc['system_log']['lastAccess'] ?? 0); + } + + private function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } + + private function getBackendUser(): BackendUserAuthentication + { + return $GLOBALS['BE_USER']; + } +} diff --git a/Classes/ViewHelpers/FormatDetailsViewHelper.php b/Classes/ViewHelpers/FormatDetailsViewHelper.php new file mode 100644 index 0000000..bf6eeb8 --- /dev/null +++ b/Classes/ViewHelpers/FormatDetailsViewHelper.php @@ -0,0 +1,75 @@ + + * ``` + * + * @internal + */ +final class FormatDetailsViewHelper extends AbstractViewHelper +{ + use LogDataTrait; + + public function initializeArguments(): void + { + $this->registerArgument('logEntry', LogEntry::class, 'Log entry instance to be rendered', true); + } + + /** + * Create formatted detail string from log row. + * + * The method handles two properties of the model: details and logData + * Details is a string with possible %s placeholders, and logData an array + * with the substitutions. + * Furthermore, possible files in logData are stripped to their basename if + * the action logged was a file action + */ + public function render(): string + { + /** @var LogEntry $logEntry */ + $logEntry = $this->arguments['logEntry']; + $detailString = $logEntry->getDetails(); + $substitutes = $logEntry->getLogData(); + // Strip paths from file names if the log was a file action + if ($logEntry->getType() === 2) { + $substitutes = self::stripPathFromFilenames($substitutes); + } + return self::formatLogDetailsStatic($detailString, $substitutes); + } + + /** + * Strips path from array of file names + */ + private static function stripPathFromFilenames(array $files = []): array + { + foreach ($files as $key => $file) { + $files[$key] = PathUtility::basename((string)$file); + } + return $files; + } +} diff --git a/Classes/ViewHelpers/UsernameViewHelper.php b/Classes/ViewHelpers/UsernameViewHelper.php new file mode 100644 index 0000000..e1b8e01 --- /dev/null +++ b/Classes/ViewHelpers/UsernameViewHelper.php @@ -0,0 +1,60 @@ + + * ``` + * + * @internal + */ +final class UsernameViewHelper extends AbstractViewHelper +{ + public function __construct( + #[Autowire(service: 'cache.runtime')] + private readonly FrontendInterface $usernameRuntimeCache + ) {} + + public function initializeArguments(): void + { + $this->registerArgument('uid', 'int', 'Uid of the user', true); + } + + /** + * Resolve username from backend user id. Can return empty string if there is no user with that UID. + */ + public function render(): string + { + $uid = $this->arguments['uid']; + $cacheIdentifier = 'belog-viewhelper-username_' . $uid; + if ($this->usernameRuntimeCache->has($cacheIdentifier)) { + return $this->usernameRuntimeCache->get($cacheIdentifier); + } + $username = BackendUtility::getRecord('be_users', $uid)['username'] ?? ''; + $this->usernameRuntimeCache->set($cacheIdentifier, $username); + return $username; + } +} diff --git a/Classes/ViewHelpers/WorkspaceTitleViewHelper.php b/Classes/ViewHelpers/WorkspaceTitleViewHelper.php new file mode 100644 index 0000000..a5c7793 --- /dev/null +++ b/Classes/ViewHelpers/WorkspaceTitleViewHelper.php @@ -0,0 +1,77 @@ + + * ``` + * + * @internal + */ +final class WorkspaceTitleViewHelper extends AbstractViewHelper +{ + public function __construct( + #[Autowire(service: 'cache.runtime')] + private readonly FrontendInterface $workspaceTitleRuntimeCache + ) {} + + public function initializeArguments(): void + { + $this->registerArgument('uid', 'int', 'UID of the workspace', true); + } + + /** + * Return resolved workspace title or empty string if it can not be resolved. + * + * @throws \InvalidArgumentException + */ + public function render(): string + { + $uid = $this->arguments['uid']; + $cacheIdentifier = 'belog-viewhelper-workspace-title_' . $uid; + if ($this->workspaceTitleRuntimeCache->has($cacheIdentifier)) { + return $this->workspaceTitleRuntimeCache->get($cacheIdentifier); + } + if ($uid === 0) { + $this->workspaceTitleRuntimeCache->set($cacheIdentifier, htmlspecialchars(self::getLanguageService()->sL( + 'LLL:EXT:belog/Resources/Private/Language/locallang.xlf:live' + ))); + } elseif (!ExtensionManagementUtility::isLoaded('workspaces')) { + $this->workspaceTitleRuntimeCache->set($cacheIdentifier, ''); + } else { + $workspace = BackendUtility::getRecord('sys_workspace', $uid); + $this->workspaceTitleRuntimeCache->set($cacheIdentifier, $workspace['title'] ?? ''); + } + return $this->workspaceTitleRuntimeCache->get($cacheIdentifier); + } + + private static function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } +} diff --git a/Configuration/Backend/Modules.php b/Configuration/Backend/Modules.php new file mode 100644 index 0000000..21c92bd --- /dev/null +++ b/Configuration/Backend/Modules.php @@ -0,0 +1,24 @@ + [ + 'parent' => 'admin', + 'position' => ['after' => 'integrations'], + 'access' => 'user', + 'iconIdentifier' => 'module-belog', + 'labels' => 'belog.module', + 'path' => '/module/system/log', + 'aliases' => ['system_BelogLog'], + 'extensionName' => 'Belog', + 'controllerActions' => [ + BackendLogController::class => [ + 'list', 'deleteMessage', + ], + ], + ], +]; diff --git a/Configuration/JavaScriptModules.php b/Configuration/JavaScriptModules.php new file mode 100644 index 0000000..c008596 --- /dev/null +++ b/Configuration/JavaScriptModules.php @@ -0,0 +1,11 @@ + [ + 'backend', + 'core', + ], + 'imports' => [ + '@typo3/belog/' => 'EXT:belog/Resources/Public/JavaScript/', + ], +]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..3dea960 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + TYPO3\CMS\Belog\: + resource: '../Classes/*' diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..16979f9 --- /dev/null +++ b/README.rst @@ -0,0 +1,14 @@ +========================= +TYPO3 extension ``belog`` +========================= + +View logs from the sys_log table in the TYPO3 backend modules System>Log and +Web>Info>Log. + +The TYPO3 backend module System>Log provides a system wide overview and +Web>Info>Log shows logs related to specific pages. + +:Repository: https://github.com/typo3/typo3 +:Issues: https://forge.typo3.org/ +:Read online: https://docs.typo3.org/ +:Packagist: https://packagist.org/packages/typo3/cms-belog diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf new file mode 100644 index 0000000..99b640c --- /dev/null +++ b/Resources/Private/Language/locallang.xlf @@ -0,0 +1,359 @@ + + + +
+ + + Administration log + + + [All users] + + + [Any] + + + via + + + LIVE + + + Draft + + + Self + + + Group + + + Filter + + + Reset + + + [all] + + + All + + + Database + + + File + + + Cache + + + Settings + + + Login + + + Errors + + + Group + + + User + + + Users + + + Time + + + Max + + + Show History + + + Action + + + Channel + + + Levels + + + Workspace + + + Overview + + + DB + + + Insert + + + Update + + + Delete + + + Move + + + Check + + + Referer host '%s' and server host '%s' did not match! + + + Attempt to insert record on page '%s' (%s) where this table, %s, is not allowed + + + Attempt to insert a record on page '%s' (%s) from table '%s' without permissions. Or non-existing page. + + + Attempt to modify table '%s' without permission + + + Attempt to modify record '%s' (%s) without permission. Or non-existing page. + + + Record '%s' (%s) was updated. + + + MySQL error: '%s' (%s) + + + Attempt to move record '%s' (%s) to after a non-existing record (uid=%s) + + + Moved record '%s' (%s) to page '%s' (%s) + + + Moved record '%s' (%s) from page '%s' (%s) + + + Moved record '%s' (%s) on page '%s' (%s) + + + Attempt to move page '%s' (%s) to inside of its own rootline (at page '%s' (%s)) + + + Attempt to insert record on page '%s' (%s) where this table, %s, is not allowed + + + Attempt to insert a record on page '%s' (%s) from table '%s' without permissions. Or non-existing page. + + + Attempt to move record '%s' (%s) to after another record, although the table has no sorting row. + + + Attempt to move record '%s' (%s) without having permissions to do so + + + You cannot change the 'doktype' of page '%s' to the desired value. + + + 'doktype' of page '%s' could not be changed because the page contains records from disallowed tables; %s + + + Too few items in the list of values. (%s) + + + Could not delete file '%s' (does not exist). (%s) + + + Copying file '%s' failed!: No destination file (%s) possible!. (%s) + + + File extension '%s' is not allowed. (%s) + + + File size (%s) of file '%s' exceeds limit (%s). (%s) + + + The destination (%s) or the source file (%s) does not exist. (%s) + + + Copying to file '%s' failed! (%s) + + + Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s) + + + The value of the field "%s" has been changed from "%s" to "%s" as it is required to be unique. + + + FILE + + + Upload + + + Copy + + + Move + + + Delete + + + Rename + + + New + + + Unzip + + + New file + + + Edit + + + File saved to '%s', bytes: %s, MD5: %s + + + CACHE + + + Clear Cache + + + EXTENSION + + + ERROR + + + Error handler + + + SETTING + + + Change + + + LOGIN + + + LOGIN + + + LOGOUT + + + ATTEMPT + + + Admin Changelog + + + All users + + + Self + + + This week + + + Last week + + + Last 7 days + + + This month + + + Last month + + + Last 31 days + + + No limit + + + Time + + + User + + + Action + + + Channel + + + Type + + + Level + + + Table + + + Details + + + Users + + + Page + + + Depth + + + Time + + + system log.]]> + + + Actions + + + Delete similar errors + + + Delete similar warnings + + + Total entries deleted: %1$d + + + Log entry could not be found. + + + No records found. + + + No page selected + + + Select a page to display logs for. + + + No access! + + + You don't have access to the selected page. + + + + diff --git a/Resources/Private/Language/module.xlf b/Resources/Private/Language/module.xlf new file mode 100644 index 0000000..a4c4dd8 --- /dev/null +++ b/Resources/Private/Language/module.xlf @@ -0,0 +1,17 @@ + + + +
+ + + Log + + + Viewing log + + + Allows you access to the full backend changelog in TYPO3. + + + + diff --git a/Resources/Private/Partials/Content/Filter.fluid.html b/Resources/Private/Partials/Content/Filter.fluid.html new file mode 100644 index 0000000..b593bae --- /dev/null +++ b/Resources/Private/Partials/Content/Filter.fluid.html @@ -0,0 +1,157 @@ + + + + + +
+ +
+ + + {f:translate(key:'allUsers')} + {f:translate(key:'self')} + + + {label} + + + + + {label} + + + +
+ +
+ + +
+ + +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ {f:translate(key: 'set')} + {f:translate(key: 'reset')} +
+
+
+ + diff --git a/Resources/Private/Partials/Content/LogEntries.fluid.html b/Resources/Private/Partials/Content/LogEntries.fluid.html new file mode 100644 index 0000000..205427e --- /dev/null +++ b/Resources/Private/Partials/Content/LogEntries.fluid.html @@ -0,0 +1,135 @@ + + + + + + +

+ @{dayTimestamp} +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + {logItem.tstamp} + + + + + + + + + + [{logItem.backendUserUid}] + + + ({f:translate(key:'viaUser')} + + + + + [{logItem.logData.originalUser}] + + ) + + +
+ + + + [{logItem.workspaceUid}] + + +
+
+ + + {logItem.tableName} + + + {logItem.level} + + + + {logItem.channel} + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+ + + +
+ + diff --git a/Resources/Private/Templates/BackendLog/List.fluid.html b/Resources/Private/Templates/BackendLog/List.fluid.html new file mode 100644 index 0000000..a3f4a59 --- /dev/null +++ b/Resources/Private/Templates/BackendLog/List.fluid.html @@ -0,0 +1,34 @@ + + + + + + + + +

+ +

+ + + + + + + + +

+
+
+ + +

+
+
+
+ +
+ + diff --git a/Resources/Public/Icons/Extension.png b/Resources/Public/Icons/Extension.png new file mode 100644 index 0000000..dab77a5 Binary files /dev/null and b/Resources/Public/Icons/Extension.png differ diff --git a/Resources/Public/JavaScript/backend-log.js b/Resources/Public/JavaScript/backend-log.js new file mode 100644 index 0000000..bd7597f --- /dev/null +++ b/Resources/Public/JavaScript/backend-log.js @@ -0,0 +1,13 @@ +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ +import a from"@typo3/backend/modal.js";import n from"@typo3/core/document-service.js";import s from"@typo3/backend/date-time-picker.js";import"@typo3/backend/input/clearable.js";import{MessageUtility as m}from"@typo3/backend/utility/message-utility.js";class o{constructor(){this.clearableElements=null,this.dateTimePickerElements=null,this.elementBrowserElements=null,n.ready().then(()=>{this.clearableElements=document.querySelectorAll(".t3js-clearable"),this.dateTimePickerElements=document.querySelectorAll(".t3js-datetimepicker"),this.elementBrowserElements=document.querySelectorAll(".t3js-element-browser"),this.initializeClearableElements(),this.initializeDateTimePickerElements(),this.initializeElementBrowserElements(),this.initializeElementBrowserEventListener()})}initializeClearableElements(){this.clearableElements.forEach(e=>e.clearable())}initializeDateTimePickerElements(){this.dateTimePickerElements.forEach(e=>s.initialize(e))}initializeElementBrowserElements(){this.elementBrowserElements.forEach(e=>{const t=document.getElementById(e.dataset.triggerFor);e.dataset.fieldReference=t.name,e.dataset.allowedTypes="pages",e.addEventListener("click",r=>{r.preventDefault();const i=r.currentTarget,l=new URLSearchParams({mode:i.dataset.mode,fieldReference:i.dataset.fieldReference,allowedTypes:i.dataset.allowedTypes});a.advanced({type:a.types.iframe,content:i.dataset.target+"&"+l.toString(),size:a.sizes.large})})})}initializeElementBrowserEventListener(){window.addEventListener("message",e=>{if(!m.verifyOrigin(e.origin)||e.data.actionName!=="typo3:elementBrowser:elementAdded"||typeof e.data.fieldName!="string"||typeof e.data.value!="string")return;const t=document.querySelector('input[name="'+e.data.fieldName+'"]');t&&(t.value=e.data.value.split("_").pop())})}}var d=new o;export{d as default}; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e31aa29 --- /dev/null +++ b/composer.json @@ -0,0 +1,56 @@ +{ + "name": "typo3/cms-belog", + "type": "typo3-cms-framework", + "description": "TYPO3 CMS Log - View logs from the sys_log table in the TYPO3 backend modules System>Log", + "homepage": "https://typo3.community/", + "funding": [ + { + "type": "membership", + "url": "https://typo3.org/membership" + } + ], + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "TYPO3 Core Team", + "email": "typo3cms@typo3.org", + "role": "Developer" + } + ], + "support": { + "issues": "https://forge.typo3.org/issues/", + "forum": "https://talk.typo3.org/", + "source": "https://github.com/TYPO3/typo3/", + "docs": "https://docs.typo3.org/", + "rss": "https://news.typo3.com/rss/", + "chat": "https://typo3.community/meet/slack/", + "security": "https://typo3.org/security/" + }, + "config": { + "sort-packages": true + }, + "require": { + "typo3/cms-core": "15.0.*@dev" + }, + "conflict": { + "typo3/cms": "*" + }, + "extra": { + "branch-alias": { + "dev-main": "15.0.x-dev" + }, + "typo3/cms": { + "Package": { + "partOfFactoryDefault": true + }, + "extension-key": "belog" + } + }, + "autoload": { + "psr-4": { + "TYPO3\\CMS\\Belog\\": "Classes/" + } + } +}