Add overrides option to disable changing name/email display in Configure.

This commit is contained in:
Retro_Guy 2024-02-19 16:33:44 -07:00
parent 0c9674d36e
commit 3d9c35f01a
3 changed files with 54 additions and 42 deletions

View File

@ -416,7 +416,7 @@ function check_rate_limit($name, $set = 0, $gettime = 0)
*/
function message_post($subject, $from, $newsgroups, $ref, $body, $encryptthis = null, $encryptto = null, $authname = null, $fromname, $followupto = null, $do_attach = null)
{
global $server, $port, $send_poster_host, $text_error, $CONFIG;
global $server, $port, $send_poster_host, $text_error, $CONFIG, $OVERRIDES;
global $www_charset, $config_dir, $spooldir;
global $msgid_generate, $msgid_fqdn, $rslight_version;
@ -497,21 +497,24 @@ function message_post($subject, $from, $newsgroups, $ref, $body, $encryptthis =
}
}
}
// Check for custom name/email from user configuration
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . $authname . '.config'));
if(trim($user_config['display_name']) == '') {
unset($user_config['display_name']);
}
if(trim($user_config['display_email']) == '') {
unset($user_config['display_email']);
}
if (isset($user_config['display_name']) && isset($user_config['display_email'])) {
fputs($ns, 'From: ' . $user_config['display_name'] .' <' .$user_config['display_email'] . ">\r\n");
if ($OVERRIDES['disable_change_name'] != true) {
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . $authname . '.config'));
if (trim($user_config['display_name']) == '') {
unset($user_config['display_name']);
}
if (trim($user_config['display_email']) == '') {
unset($user_config['display_email']);
}
if (isset($user_config['display_name']) && isset($user_config['display_email'])) {
fputs($ns, 'From: ' . $user_config['display_name'] . ' <' . $user_config['display_email'] . ">\r\n");
} else {
fputs($ns, 'From: ' . $from . "\r\n");
}
} else {
fputs($ns, 'From: ' . $from . "\r\n");
}
if ($followupto !== null) {
fputs($ns, 'Followup-To: ' . $followupto . "\r\n");
}

View File

@ -408,16 +408,19 @@ if ($show == 1) {
echo '<input class="post" type="password" name="' . md5($fieldencrypt . "email") . '"';
echo 'size="40" maxlength="40">';
}
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . strtolower($name) . '.config'));
if (isset($user_config['display_name']) && trim($user_config['display_name']) != '') {
if (isset($user_config['display_email']) && trim($user_config['display_email']) != '') {
echo '<tr><td align="right">';
echo '<b>From: </b></td>';
$showemail = '<' . $user_config['display_email'] . '>';
echo '<td align="left">';
echo '<input class="post" type="text" value="' . $user_config['display_name'] . ' ' . htmlspecialchars($showemail) . '" size="40" maxlength="40" readonly>';
// echo $user_config['display_name'] . ' ' . htmlspecialchars($showemail);
echo '</td></tr>';
// Check for custom name/email from user configuration
if ($OVERRIDES['disable_change_name'] != true) {
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . strtolower($name) . '.config'));
if (isset($user_config['display_name']) && trim($user_config['display_name']) != '') {
if (isset($user_config['display_email']) && trim($user_config['display_email']) != '') {
echo '<tr><td align="right">';
echo '<b>From: </b></td>';
$showemail = '<' . $user_config['display_email'] . '>';
echo '<td align="left">';
echo '<input class="post" type="text" value="' . $user_config['display_name'] . ' ' . htmlspecialchars($showemail) . '" size="40" maxlength="40" readonly>';
// echo $user_config['display_name'] . ' ' . htmlspecialchars($showemail);
echo '</td></tr>';
}
}
}
echo '<input class="post" type="hidden" name="fromname" value="' . $fromname . '">';

View File

@ -204,8 +204,10 @@ if ($_POST['command'] != 'Configuration' && $_POST['command'] != 'SaveConfig') {
}
// Apply Config
if (isset($_POST['command']) && $_POST['command'] == 'SaveConfig') {
$user_config['display_name'] = $_POST['display_name'];
$user_config['display_email'] = $_POST['display_email'];
if ($OVERRIDES['disable_change_name'] != true) {
$user_config['display_name'] = $_POST['display_name'];
$user_config['display_email'] = $_POST['display_email'];
}
$user_config['signature'] = $_POST['signature'];
$user_config['xface'] = $_POST['xface'];
$user_config['timezone'] = $_POST['timezone'];
@ -247,16 +249,18 @@ if (is_dir($themedir)) {
}
// Get settings for name and email
if (isset($user_config['display_name'])) {
$display_name = $user_config['display_name'];
} else {
$display_name = $_POST['username'];
}
if (isset($user_config['display_email'])) {
$display_email = $user_config['display_email'];
} else {
if (($display_email = get_user_config($_POST['username'], 'email')) == false) {
$display_email = $_POST['username'] . '@' . $CONFIG['email_tail'];
if ($OVERRIDES['disable_change_name'] != true) {
if (isset($user_config['display_name'])) {
$display_name = $user_config['display_name'];
} else {
$display_name = $_POST['username'];
}
if (isset($user_config['display_email'])) {
$display_email = $user_config['display_email'];
} else {
if (($display_email = get_user_config($_POST['username'], 'email')) == false) {
$display_email = $_POST['username'] . '@' . $CONFIG['email_tail'];
}
}
}
sort($themes);
@ -267,14 +271,16 @@ if (isset($_POST['command']) && $_POST['command'] == 'Configuration') {
echo '<tr class="np_thread_head"><td class="np_thread_head"><h2>Settings for ' . $_POST['username'] . ':</h2></td></tr>';
echo '<form method="post" action="user.php">';
echo '<tr class="np_result_line1">';
// User Display Name
echo '<td class="np_result_line1" style="word-wrap:break-word";><h3>Display Name for posts: </h3>';
echo '<input name="display_name" type="text" id="username"value="' . $display_name . '" maxlength="40"></td>';
echo '</tr>';
// User Display Email
echo '<td class="np_result_line1" style="word-wrap:break-word";><h3>Display Email for posts: </h3>';
echo '<input name="display_email" type="text" id="username"value="' . $display_email . '" maxlength="40"></td>';
echo '</tr>';
if ($OVERRIDES['disable_change_name'] != true) {
// User Display Name
echo '<td class="np_result_line1" style="word-wrap:break-word";><h3>Display Name for posts: </h3>';
echo '<input name="display_name" type="text" id="username"value="' . $display_name . '" maxlength="40"></td>';
echo '</tr>';
// User Display Email
echo '<td class="np_result_line1" style="word-wrap:break-word";><h3>Display Email for posts: </h3>';
echo '<input name="display_email" type="text" id="username"value="' . $display_email . '" maxlength="40"></td>';
echo '</tr>';
}
// Signature
echo '<td class="np_result_line1" style="word-wrap:break-word";><h3>Signature:</h3></td>';
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><textarea class="configuration" id="signature" name="signature" rows="6" cols="70">' . $user_config['signature'];