Author: Jim Winstead (jimwins)
Date: 2024-08-23T16:42:44-07:00
Commit:
https://github.com/php/web-news/commit/798f0ec762f4376c9f782be88d2e99d253d37a0c
Raw diff:
https://github.com/php/web-news/commit/798f0ec762f4376c9f782be88d2e99d253d37a0c.diff
Add header for each group with closed/moderated and subscription address
Changed paths:
M group.php
M lib/common.php
Diff:
diff --git a/group.php b/group.php
index 91f101e..0c93455 100644
--- a/group.php
+++ b/group.php
@@ -69,6 +69,36 @@
echo '</nav>';
echo '<section class="content">';
echo '<h1>' . htmlspecialchars($group, ENT_QUOTES, "UTF-8") . '</h1>';
+ if ($i == 0) {
+ /* Special header of info for the main page for a group */
+ $groups = $nntpClient->listGroups($group);
+
+ if ($groups[$group]['status'] == 'n') {
+?>
+ <p class="warning">
+ <strong>Warning:</strong> This list is closed to new posts
and subscribers.
+ </p>
+<?php
+ } else {
+ if ($groups[$group]['status'] == 'm') {
+?>
+ <p class="warning">
+ <strong>Note:</strong> This list is only for
+ announcements, so only approved posters can send messages.
+ </p>
+<?php
+ }
+ $subscription_address =
htmlspecialchars(get_subscribe_address($group));
+?>
+ <p>
+ Subscribe to this list by sending a blank email to
+ <a href="mailto:<?= $subscription_address ?>">
+ <?= $subscription_address ?>
+ </a>
+ </p>
+<?php
+ }
+ }
navbar($group, $overview['group']['low'], $overview['group']['high'],
$overview['group']['start']);
echo ' <div class="responsive-table">' . "\n";
echo ' <table class="standard">' . "\n";
diff --git a/lib/common.php b/lib/common.php
index 149ab12..f0936dd 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -217,3 +217,34 @@ function format_date($d)
$d = gmdate('r', $d);
return str_replace(" ", " ", $d);
}
+
+/*
+ * Translate a group name to a subscription address for the list. It's almost
+ * easy but then we have a bunch of special cases.
+ */
+function get_subscribe_address($group)
+{
+ $address = str_replace('.', '-', $group); // php.internals -> php-internals
+ $address = str_replace('php-doc-', 'doc-', $address); // php-doc-fr ->
doc-fr
+ $address = str_replace('php-pear-', 'pear-', $address); // php-pear-dev ->
pear-dev
+ $address = str_replace('php-pecl-', 'pecl-', $address); // php-pecl-dev ->
pecl-dev
+ $address = str_replace('php-standards', 'standards-', $address); //
php-standards-cvs -> standards-cvs
+
+ $special = [
+ 'doc-chm' => 'php-doc-chm', # revert earlier removal of php-
+ 'php-internals' => 'internals',
+ 'php-internals-win' => 'internals-win',
+ 'php-doc' => 'phpdoc',
+ 'php-general-bg' => 'general-bg',
+ 'php-general-es' => 'general-es',
+ 'php-git-pulls' => 'git-pulls',
+ 'php-pres' => 'pres',
+ 'php-pdo' => 'pdo',
+ ];
+
+ if (array_key_exists($address, $special)) {
+ $address = $special[$address];
+ }
+
+ return $address . '[email protected]';
+}