#!/usr/bin/perl -T
# edit-member.pl - edit user's member information.
# Copyright Board of Trustees of the University of Illinois at UC, April 1995
# This is used via a URL like:
# http://www.hypernews.org/HyperNews/edit-member.pl?user
# Add current directory to load path.
$0 = $ENV{SCRIPT_FILENAME} if $0 =~ m{^/dev};
$0 =~ m{^(.*)/[^/]+$ }x; $hnbin = $1 || '.';
unshift(@INC, $hnbin, "$hnbin/.scripts");
require "Admin/hnrc";
&feval('&EditMember()');
sub EditMember {
local $debug = 0;
require "urc.pl";
require "member-lib.pl";
require "edit-lib.pl";
require 'formlib.pl';
my %form = &GetFormArgs();
# Check for server or cookie authentication, or maybe login.
&checkAuthenticated($form{UserID}, $form{Password},
$form{remoteUser}, $form{adminPassword});
my $isAdmin = $authenticated && &isAdmin($remoteUser);
# &HNMsg("hndocs: $hndocs");
# &HNMsg("SCRIPT_NAME: $ENV{SCRIPT_NAME}");
# &HNMsg("hnprefix: $hnprefix");
# &HNMsg("hnbinURL: $hnbinURL");
my $whoami = &sustring($remoteUser);
if ($whoami) { $whoami = "You are: $whoami
"; }
my $whoisthat;
my $adminEmail = &addressOf(@hnAdmin[0]) || @hnAdmin[0];
$qs = $ENV{QUERY_STRING};
&HNMsg("Query string: '$qs'") if $debug;
my %args = &parseQueryString();
$userid = $args{userid} || $qs || $remoteUser; # allow ?user
&HNMsg("userid is '$userid', Remote User is '$remoteUser'") if $debug;
my %member = &getMember($userid);
&printAssoc("Member '$userid'", %member) if $debug;
my $registering = $args{new};
my $thisURL = $ENV{REQUEST_URI};
$thisURL ||= ($qs ? "$editMemberURL?$qs" : $editMemberURL);
$thisURL = &URLencode($thisURL);
my $redirectURL = "$loginURL?userid=$userid&url=$thisURL";
# We are not changing anything yet, but still must do access control.
# (But this does not check the right thing yet.)
# &access1($joinSF, 2, $userid, $remoteUser,
# "You, '$remoteUser', can not update membership info for
# user '$userid'",
# $authenticated);
# Special access check for inquiries.
if (($authenticateInquiries || $hideUserIDs) && %member) {
if ($userid && !$authenticated) { # && $manualSecurity
# Try logging in first. This may not be workable.
# Maybe should require manualSecurity.
&printRedirect($redirectURL);
}
elsif ($userid && ($userid ne $remoteUser) && !$isAdmin) {
&HNUserError( qq{
You, $remoteUser, are not permitted to inquire about
other members - all member data is private. If you want to edit your
own member data, go to here.
});
}
}
# my $URL = $ENV{'PATH_INFO'};
if ($userid) {
# &HNMsg("Getting New Member info for $userid");
# &printAssoc('member', %member);
$newUserID = $member{'UserID'};
#&HNMsg("userid: $userid newUserID: $newUserID");
$emailAddress = $member{'Email'};
$userName = $member{'Name'};
$userURL = $member{'UserURL'};
$userPhone = $member{'Phone'} || $member{'UserPhone'};
$userAddress = $member{'MailAddress'} || $member{'UserAddress'};
$content = $member{'Content'};
$format = $member{'Format'};
my $memberOrAdmin = "a member";
if (&isAdmin($userid)) { # In what group?
$memberOrAdmin = "an administrator";
}
if ($hnGroup) {
$groupScope = " in group $hnGroup";
}
my $groupName = $hnGroup;
$groupName =~ s,^/,,;
if ($newUserID) {
if ($newUserID ne $remoteUser) {
if ($newUserID ne $userid) {
$whoisthat = "\"$userid\" has $UserIDorHandle \"$newUserID\".";
$userid = $newUserID;
}
if ($hnGroup) {
if (-e "$hnPeople$hnGroup/$userid") {
$whoisthat .= " $userid is $memberOrAdmin of \"$groupName\".";
}
else { $whoisthat .= " $userid is not a member of \"$groupName\"."; }
} else { $whoisthat ||= " \"$userid\" is $memberOrAdmin."; }
}
} else { $whoisthat .= " \"$userid\" is not a member."; }
$whoisthat = " \n $whoisthat
\n" if $whoisthat; } if (!$authenticated) { # $joinSF == 1 && !$authenticateInquiries # if ($joinSF == 2) { $orMember = "or Current Member"; } if (!$registering) { $passwordOption = qq{
(Ignore this unless you are an Administrator $orMember making updates for the User)
Administrator $orMember:
Admin $orMember Password:
};
if ($resetPasswordSF && !$externalSecurity) {
$resetOption = qq{
(If you have a password but cannot remember it, you can }; if ($resetPasswordSF == 2) { $resetOption .= 'ask another member to '; } elsif ($resetPasswordSF == 3) { $resetOption .= qq{ ask an administrator ($adminEmail) to }; } my $yourUserID = ", '$userid', " if $userid; my $thisURL = $editMemberURL; $thisURL .= "?userid=$userid" if $userid; $resetOption .= qq{ reset it to a random password. Be sure to mention your $UserIDorHandle$yourUserID and this URL: $thisURL.)
};
} # $resetPasswordSF
} # !$authenticated
else {
# Pass these through to reauthenticate.
$adminline = qq{
};
}
#============================================
&print_HTML_HEAD("$hnSystemName Membership Form");
my $siteIntro;
if (-e "$hndocs/.intro.html") {
open PH, "$hndocs/.intro.html";
my @lines =
};
}
if (!$authenticated && $joinSF && $joinSF < 3) {
my $shouldOrMust = ($requirePasswords ? 'must' : 'should');
my $passwordMsg;
$passwordMsg = qq{You $shouldOrMust provide a new password
since it protects you from unauthorized use of your $UserIDorHandle.}
if !$generatePasswords;
my $nameMsg = qq{
You should
provide a Name since it is used to identify you in messages.
} if $getPersonalData;
if ($manualSecurity && ($UseCookies eq 'always')) {
$loginMsg = qq{
};
}
$registerMsg = qq{
};
$registerMsg .= qq{
Finally, select Register and click on 'Do It'.
};
}
else {
if (!$authenticated) {
$submitControls = qq{
};
$registerMsg .= qq{
Finally, click on the $registerOrUpdate button.
};
}
else {
$submitControls = qq{
};
$registerMsg .= qq{
Finally, click on the Update button.
};
}
}
if ($member{Status} eq 'invited') {
$welcomeMsg = qq{
Thank you for acting on our invitation to join us. Please fill out
and submit this membership registration form to officially accept the
invitation.
You can then participate in the forums.
Note that this site uses the HyperNews system (version
$hnversion).
This site is called "$hnSystemName"$top_URL_msg.
The administrator is $adminEmail.
$privMsg
};
}
my $changeURL = ($authenticated ? $SECUREDchangeMemberURL :
$changeMemberURL);
print qq{
Access Restrictions at $hnSystemName
};
@who = ('No one', 'Anyone', 'Only members', 'Only administrators');
$priv .= qq{
};
}
if ($ENV{REMOTE_USER}) {
# Server authenticated.
$updateMemberURL = $SECUREDupdateMemberURL;
}
if (!$authenticateInquiries && !$hideUserIDs && !$registering && !$viewMembers) {
# This stuff is probably not useful here anymore - see view-member.pl
$inquireMsg = 'Or you can inquire about an existing member.';
$inquireMsg2 = qq{
};
}
if ($hnReadSF == 1) {
$secureMsg = qq{
As a member, only you
can use your $UserIDorHandle or Email Address; the system will request your
password to prove it is you.
};
}
if ($showPriv) {
my $top_URL_msg = qq{, and it is located at
$topURL} if 0;
#Each HyperNews site has its own set of members,
# so being a member here does not mean you are a member at other sites.
$introMsg = qq{
With this form, you can $registerOrUpdate2 update your
current membership information.
$inquireMsg
$secureMsg
Membership applies to all forums at this site.
$hnSystemName Membership
$siteIntro
$welcomeMsg
$introMsg
$priv
$sitePolicy
};
print qq{
[ Help for $hnSystemName ]
} if $instructionsURL;
&printEnd();
}