Skip to content

Commit

Permalink
Merge pull request #836 from nextcloud/release/7.0.0
Browse files Browse the repository at this point in the history
Release 7.0.0
  • Loading branch information
nickvergessen authored Sep 12, 2024
2 parents 911153c + 3e9ba83 commit 1364ca6
Show file tree
Hide file tree
Showing 9 changed files with 413 additions and 224 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

## 7.0.0 – 2024-09-12
### Added
- Compatibility with Nextcloud 30
- Added CLI commands to list, announce and remove announcements
- Added option to schedule announcements
- Added option to automatically delete announcements

### Changed
- Updated dependencies
- Removed Nextcloud 26 and Nextcloud 27

## 6.8.1 – 2024-03-21
### Fixed
- Fix searching for groups in the compose form
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
⚡ Activities integration
🔔 Notifications integration]]></description>
<version>7.0.0-dev.0</version>
<version>7.0.0</version>
<licence>agpl</licence>
<author>Joas Schilling</author>
<namespace>AnnouncementCenter</namespace>
Expand All @@ -35,7 +35,7 @@
<screenshot>https://github.com/nextcloud/announcementcenter/raw/main/docs/AnnouncementCenterFrontpage.png</screenshot>

<dependencies>
<nextcloud min-version="28" max-version="31" />
<nextcloud min-version="28" max-version="30" />
</dependencies>

<background-jobs>
Expand Down
14 changes: 7 additions & 7 deletions lib/Command/Announce.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$notificationOptions = $this->notificationType->setNotificationTypes($activities, $notifications, $emails);

$result = $this->manager->announce($subject, $message, $plainMessage, $user, $this->time->getTime(), $groups, $comments, $notificationOptions, $scheduleTime, $deleteTime);
$output->writeln("Created announcement #" . $result->getId() . ": " . $result->getSubject());
$output->writeln('Created announcement #' . $result->getId() . ': ' . $result->getSubject());

if ($scheduleTime) {
$output->writeln("Scheduled announcement for '" . date("D M j G:i:s T Y", $scheduleTime) . "'");
$output->writeln("Scheduled announcement for '" . date('D M j G:i:s T Y', $scheduleTime) . "'");
}

if ($deleteTime) {
$output->writeln("Scheduled deletion for '" . date("D M j G:i:s T Y", $deleteTime) . "'");
$output->writeln("Scheduled deletion for '" . date('D M j G:i:s T Y', $deleteTime) . "'");
}

$this->logger->info('Admin ' . $user . ' posted a new announcement: "' . $result->getSubject() . '" over CLI');
Expand All @@ -174,10 +174,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/**
* Parses an arbitrary $argument into a timestamp
* @param null|int|string $argument argument provided by CLI for a time
* Examples 1:
* '1711440621' a plain unix timestamp
* Examples 2 see strtotime (https://www.php.net/manual/de/function.strtotime.php):
* 'now', 10 September 200', '+1 day', 'tomorrow'
* Examples 1:
* '1711440621' a plain unix timestamp
* Examples 2 see strtotime (https://www.php.net/manual/de/function.strtotime.php):
* 'now', 10 September 200', '+1 day', 'tomorrow'
* @return int|null a timestamp, returns null if $argument is null
* @throws \InvalidArgumentException If the time could not be interpreted or the time is in the past
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/Command/AnnouncementDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$deleteId = $this->parseId($input->getArgument('id'));
$this->manager->delete($deleteId);
} catch (DoesNotExistException) {
$output->writeln("Announcement with #" . $deleteId . " does not exist!");
$output->writeln('Announcement with #' . $deleteId . ' does not exist!');
return 1;
} catch (InvalidArgumentException $e) {
$output->writeln($e->getMessage());
return 1;
}
$output->writeln("Successfully deleted #" . $deleteId);
$output->writeln('Successfully deleted #' . $deleteId);
$this->logger->info('Admin deleted announcement #' . $deleteId . ' over CLI');
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/Command/AnnouncementList.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$widthMessage = max($minimalWidthText, $width - $minimalWidth - $widthSubject);

$widths = [$minimalWidth - 2, $widthSubject, $widthMessage];
$text = $this->formatTableRow(["ID", "Subject", "Message"], $widths);
$text = $this->formatTableRow(['ID', 'Subject', 'Message'], $widths);
$output->writeln($text);
$text = $this->formatTableRow(["", "", ""], $widths, "-");
$text = $this->formatTableRow(['', '', ''], $widths, '-');
$output->writeln($text);

foreach ($announcements as $index => $ann) {
if ($index === $ulimit) {
$output->writeln("And more ...");
$output->writeln('And more ...');
break;
}
$texts = [$ann->getId(), $ann->getParsedSubject(), $ann->getPlainMessage()];
Expand All @@ -84,14 +84,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

private function ellipseAndPadText(string $text, int $width, string $sep = " "): string {
private function ellipseAndPadText(string $text, int $width, string $sep = ' '): string {
$text = str_replace(["\r", "\n"], ' ', $text);
$text = str_pad($text, $width, $sep, STR_PAD_RIGHT);
$text = strlen($text) > $width ? substr($text, 0, $width - 2) . "" : $text;
$text = strlen($text) > $width ? substr($text, 0, $width - 2) . '' : $text;
return $text;
}

private function formatTableRow(array $texts, array $widths, string $sep = " "): string {
private function formatTableRow(array $texts, array $widths, string $sep = ' '): string {
$callback = function ($a, $b) use ($sep) {
return $this->ellipseAndPadText($a, $b, $sep);
};
Expand All @@ -100,6 +100,6 @@ private function formatTableRow(array $texts, array $widths, string $sep = " "):
$texts,
$widths
);
return implode("|", $formattedTexts);
return implode('|', $formattedTexts);
}
}
Loading

0 comments on commit 1364ca6

Please sign in to comment.