%INCLUDE{"%MAINWEB%.%WIKINAME%LeftBar" warn="
Create personal sidebar"}%
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki.pm Sun Oct 24 09:02:05 2004
@@ -1033,34 +1033,10 @@
sub getEmailOfUser
{
my( $wikiName ) = @_; # WikiName without web prefix
+ # TODO: assert that it does not contain %MAINWEB%
- my @list = ();
- # Ignore guest entry and non-existent pages
- if ( $wikiName ne "TWikiGuest" &&
- TWiki::Store::topicExists( $mainWebname, $wikiName ) ) {
- if ( $wikiName =~ /Group$/ ) {
- # Page is for a group, get all users in group
- ##writeDebug "using group: $mainWebname . $wikiName";
- my @userList = TWiki::Access::getUsersOfGroup( $wikiName );
- foreach my $user ( @userList ) {
- $user =~ s/^.*\.//; # Get rid of 'Main.' part.
- foreach my $email ( getEmailOfUser($user) ) {
- push @list, $email;
- }
- }
- } else {
- # Page is for a user
- ##writeDebug "reading home page: $mainWebname . $wikiName";
- foreach ( split ( /\n/, &TWiki::Store::readWebTopic(
- $mainWebname, $wikiName ) ) ) {
- if (/^\s\*\sEmail:\s+([\w\-\.\+]+\@[\w\-\.\+]+)/) {
- # Add email address to list
- push @list, $1;
- }
- }
- }
- }
- return (@list);
+ use TWiki::User;
+ return TWiki::User::getEmail($wikiName);
}
=pod
@@ -1188,9 +1164,10 @@
Translates intranet username (e.g. jsmith) to WikiName (e.g. JaneSmith)
userToWikiListInit must be called before this function is used.
-Unless $dontAddWeb is set, "Main." is prepended to the returned WikiName.
+Unless $flag is set, "Main." is prepended to the returned WikiName.
-if you give an invalid username, we just return that (no appending Main. blindy)
+if you give an invalid username, we just return that (no appending Main. blindy),
+unless flag is set to 2, in which case it returns undef.
SMELL: the userToWikiList cache should really contain the WebName so its possible
to have userTopics in more than just the MainWeb (what if you move a user topic?)
@@ -1199,18 +1176,34 @@
sub userToWikiName
{
- my( $loginUser, $dontAddWeb ) = @_;
+ my( $loginUser, $flag ) = @_;
if( !$loginUser ) {
return "";
}
$loginUser =~ s/$securityFilter//go;
- my $wUser = $userToWikiList{ $loginUser } || $loginUser;
- if( $dontAddWeb ) {
- return $wUser;
+ my $wUser = $userToWikiList{ $loginUser };
+
+ # New behaviour for RegisterCgiScriptRewrite
+ if ($flag && ($flag == 2)) { # return the real mapping, even if it is undef
+ return $wUser;
}
- return "$mainWebname.$wUser";
+
+ # Original behaviour - map existing entries
+ unless ($wUser) {
+ $wUser = $loginUser;
+ }
+
+ # return with webName
+ unless ($flag) {
+ return "$mainWebname.$wUser";
+ }
+
+ # v2 - blindy return loginName if mapping not present.
+ return $wUser;
+
+
}
=pod
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki/Store.pm Sat Oct 23 16:57:57 2004
@@ -1530,18 +1530,21 @@
while( $text =~ /%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/s ) {
$text =~ s/%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/&_readTemplateFile( $1, $theSkin, $theWeb )/geo;
}
-
+# die $text;
if( ! ( $text =~ /%TMPL\:/s ) ) {
# no template processing
$text =~ s|^(( {3})+)|"\t" x (length($1)/3)|geom; # leading spaces to tabs
return $text;
}
-
+# die $text;
my $result = "";
my $key = "";
my $val = "";
my $delim = "";
+ my $count = 0;
foreach( split( /(%TMPL\:)/, $text ) ) {
+ $count++;
+# print "
$count
\n".$_."
".$text."";
if( /^(%TMPL\:)$/ ) {
$delim = $1;
} elsif( ( /^DEF{[\s\"]*(.*?)[\"\s]*}%[\n\r]*(.*)/s ) && ( $1 ) ) {
@@ -1565,13 +1568,41 @@
} else {
$result .= "$delim$_";
}
+# print "
$count
$key / $val / ".$result;
+# print "".Dumper(\%templateVars)."
";
+# print "";
}
+# diagnoseReadTemplate(\%templateVars, $result);
+# die;
# handle %TMPL:P{"..."}% recursively
$result =~ s/%TMPL\:P{[\s\"]*(.*?)[\"\s]*}%/&handleTmplP($1)/geo;
$result =~ s|^(( {3})+)|"\t" x (length($1)/3)|geom; # leading spaces to tabs
+
return $result;
}
+
+=pod
+
+---++ diagnoseReadTemplate($templateVarsRef, $result)
+
+Call this to illustrate the state of the readTemplate sub
+
+=cut
+
+sub diagnoseReadTemplate {
+ my ($templateVarsRef, $result) = @_;
+ print "Content-type: text/html\n\n";
+ use Data::Dumper;
+
+ $Data::Dumper::Pad = " ";
+ print "
".Dumper($templateVarsRef)."
".$result."";
+
+ unless ($result) {
+ print "
Result was empty!";
+ }
+}
+
=pod
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki/Store/RcsFile.pm Sat Oct 23 16:58:01 2004
@@ -636,12 +636,17 @@
umask( 0 );
mkdir( $tempPath, 0775 );
}
+
+ unless (-f $theTmpFilename) {
+ die "No such file $theTmpFilename";
+ }
# FIXME share with move - part of init?
# save uploaded file
my $newFile = $self->{file};
copy($theTmpFilename, $newFile) or warn "copy($theTmpFilename, $newFile) failed: $!";
+
# FIXME more consistant way of dealing with errors
umask( 002 );
chmod( 0644, $newFile ); # FIXME config permission for new attachment
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki/UI/Manage.pm Tue Oct 26 04:23:01 2004
@@ -91,68 +91,6 @@
return;
}
-=pod
-
----+++ changePassword( $webName, $topic, $query )
-Change the user's password. Details of the user and password
-are passed in CGI parameters.
-| =username= | |
-| =password= | |
-| =passwordA= | |
-| =TopicName= | |
-
-=cut
-
-sub changePassword {
- my( $webName, $topic, $query ) = @_;
-
- my $wikiName = $query->param( 'username' );
- my $passwordA = $query->param( 'password' );
- my $passwordB = $query->param( 'passwordA' );
- my $topicName = $query->param( 'TopicName' );
-
- # check if required fields are filled in
- if( ! $wikiName || ! $passwordA ) {
- TWiki::UI::oops( $webName, $topic, "regrequ", );
- return;
- }
-
- # check if user entry exists
- #TODO: need to handle the NoPasswdUser case (UserPasswordExists will retun false here)
- if( ( $wikiName ) && (! TWiki::User::UserPasswordExists( $wikiName ) ) ) {
- TWiki::UI::oops( $webName, $topic, "notwikiuser", $wikiName );
- return;
- }
-
- # check if passwords are identical
- if( $passwordA ne $passwordB ) {
- TWiki::UI::oops( $webName, $topic, "regpasswd" );
- return;
- }
-
- # c h a n g e
- my $oldpassword = $query->param( 'oldpassword' );
-
- # check if required fields are filled in
- if( ! $oldpassword ) {
- TWiki::UI::oops( $webName, $topic, "regrequ" );
- return;
- }
-
- my $pw = TWiki::User::CheckUserPasswd( $wikiName, $oldpassword );
- if( ! $pw ) {
- # NO - wrong old password
- TWiki::UI::oops( $webName, $topic, "wrongpassword");
- return;
- }
-
- # OK - password may be changed
- TWiki::User::UpdateUserPassword($wikiName, $oldpassword, $passwordA );
-
- # OK - password changed
- TWiki::UI::oops( $webName, $topic, "changepasswd" );
-}
-
# PRIVATE Prepare a template var for expansion in a message
sub _template {
my $theTmplVar = shift;
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki/UI/Oops.pm Sat Oct 23 16:58:12 2004
@@ -44,6 +44,7 @@
my $tmplName = $query->param( 'template' ) || "oops";
my $skin = $query->param( "skin" ) || TWiki::Prefs::getPreferencesValue( "SKIN" );
my $tmplData = TWiki::Store::readTemplate( $tmplName, $skin );
+
if( ! $tmplData ) {
TWiki::writeHeader( $query );
print "\n"
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki/User.pm Sat Oct 23 16:58:18 2004
@@ -58,9 +58,9 @@
# FIXME: Move elsewhere?
# template variable hash: (built from %TMPL:DEF{"key"}% ... %TMPL:END%)
-use vars qw( %templateVars $UserImpl ); # init in TWiki.pm so okay for modPerl
+use vars qw( %templateVars $PasswordImpl ); # init in TWiki.pm so okay for modPerl
-$UserImpl = "";
+$PasswordImpl = "";
# ===========================
=pod
@@ -74,34 +74,34 @@
%templateVars = ();
if ( # (-e $TWiki::htpasswdFilename ) && #<<< maybe
( $TWiki::htpasswdFormatFamily eq "htpasswd" ) ) {
- $UserImpl = "TWiki::User::HtPasswdUser";
+ $PasswordImpl = "TWiki::User::HtPasswdUser";
# } elseif ($TWiki::htpasswdFormatFamily eq "something?") {
-# $UserImpl = "TWiki::User::SomethingUser";
+# $PasswordImpl = "TWiki::User::SomethingUser";
} else {
- $UserImpl = "TWiki::User::NoPasswdUser";
+ $PasswordImpl = "TWiki::User::NoPasswdUser";
}
- eval "use ".$UserImpl;
+ eval "use ".$PasswordImpl;
}
# ===========================
=pod
----++ sub _getUserHandler ( $web, $topic, $attachment )
+---++ sub _getPasswordHandler ( $web, $topic, $attachment )
Not yet documented.
=cut
-sub _getUserHandler
+sub _getPasswordHandler
{
my( $web, $topic, $attachment ) = @_;
$attachment = "" if( ! $attachment );
- my $handlerName = $UserImpl;
+ my $passwordHandlerName = $PasswordImpl;
- my $handler = $handlerName->new( );
- return $handler;
+ my $passwordHandler = $passwordHandlerName->new( );
+ return $passwordHandler;
}
#=========================
@@ -119,9 +119,9 @@
{
my ( $user ) = @_;
- my $handler = _getUserHandler();
+ my $passwordHandler = _getPasswordHandler();
- return $handler->UserPasswordExists($user);
+ return $passwordHandler->UserPasswordExists($user);
}
#=========================
@@ -147,8 +147,8 @@
return;
}
- my $handler = _getUserHandler();
- return $handler->UpdateUserPassword($user, $oldUserPassword, $newUserPassword);
+ my $passwordHandler = _getPasswordHandler();
+ return $passwordHandler->UpdateUserPassword($user, $oldUserPassword, $newUserPassword);
}
#=========================
@@ -173,8 +173,8 @@
return;
}
- my $handler = _getUserHandler();
- return $handler->AddUserPassword($user, $newUserPassword);
+ my $passwordHandler = _getPasswordHandler();
+ return $passwordHandler->AddUserPassword($user, $newUserPassword);
}
#=========================
@@ -192,8 +192,8 @@
{
my ( $user ) = @_;
- my $handler = _getUserHandler();
- return $handler->RemoveUser($user);
+ my $passwordHandler = _getPasswordHandler();
+ return $passwordHandler->RemoveUser($user);
}
# =========================
@@ -212,8 +212,8 @@
{
my ( $user, $password ) = @_;
- my $handler = _getUserHandler();
- return $handler->CheckUserPasswd($user, $password);
+ my $passwordHandler = _getPasswordHandler();
+ return $passwordHandler->CheckUserPasswd($user, $password);
}
# =========================
@@ -230,6 +230,8 @@
sub addUserToTWikiUsersTopic
{
+# use Data::Dumper;
+# die Dumper(\@_);
my ( $wikiName, $remoteUser ) = @_;
my $today = &TWiki::formatTime(time(), "\$day \$mon \$year", "gmtime");
my $topicName = $TWiki::wikiUsersTopicname;
@@ -281,7 +283,73 @@
return $topicName;
}
+sub getEmail {
+ my ($wikiName) = @_;
+ my $mainWebname = $TWiki::mainWebname;
+
+ # Ignore guest entry and non-existent pages
+ unless (TWiki::Store::topicExists( $mainWebname, $wikiName )) {
+ return;
+ }
+
+ if ($wikiName eq "TWikiGuest") {
+ return;
+ }
+
+ my @list = ();
+
+ if ( $wikiName =~ /Group$/ ) {
+ # Page is for a group, get all users in group
+ ##writeDebug "using group: $mainWebname . $wikiName";
+ my @userList = TWiki::Access::getUsersOfGroup( $wikiName );
+ foreach my $user ( @userList ) {
+ $user =~ s/^.*\.//;# Get rid of 'Main.' part.
+ foreach my $email ( TWiki::getEmailOfUser($user) ) {
+ push @list, $email;
+ }
+ }
+ } else {
+ # Page is for a user
+ ##writeDebug "reading home page: $mainWebname . $wikiName";
+ push @list, getEmailAddressesFromPage($mainWebname, $wikiName);
+ }
+ use Data::Dumper;
+ return (@list);
+}
+
+=pod
+Returns the email addresses bulletfield / metafield on the page
+Each should be handled by separate implementation classes.
+
+=cut
+
+sub getEmailAddressesFromPage {
+ my ($mainWebname, $wikiName) = @_;
+ my @emailAddresses = ();
+
+# die Dumper(\@_);
+ foreach (
+ split ( /\n/,
+ TWiki::Store::readWebTopic(
+ $mainWebname,
+ $wikiName )
+ )
+ )
+ {
+ # REFACTOR UserData::BulletFieldsImpl
+ if (/^\s\*\sEmail:\s+([\w\-\.\+]+\@[\w\-\.\+]+)/) {
+ # Add email address to list
+ push @emailAddresses, $1;
+ }
+
+ # REFACTOR UserData::MetaFieldsImpl
+ if (/^\%META\:FIELD\{name="Email"(.*?)value="(.*)"\}%/) {
+ push @emailAddresses, $2;
+ }
+ }
+ return @emailAddresses;
+}
1;
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../lib/TWiki/User/HtPasswdUser.pm Sat Oct 23 16:58:29 2004
@@ -283,7 +283,8 @@
my ( $self, $user ) = @_;
my $userEntry = $user.":"._htpasswdReadPasswd( $user );
- return $self->htpasswdUpdateUser( $userEntry, "#".$userEntry);
+ return $self->htpasswdUpdateUser( $userEntry, "" );
+#"#".$userEntry
}
# =========================
@@ -303,6 +304,7 @@
my $currentEncryptedPasswordEntry = _htpasswdReadPasswd( $user );
my $encryptedPassword = _htpasswdGeneratePasswd($user, $password , 1);
+# die "current = $currentEncryptedPasswordEntry; new = $encryptedPassword";
# OK
if( $encryptedPassword eq $currentEncryptedPasswordEntry ) {
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../templates/oopsnotwikiuser.tmpl Sat Oct 23 16:58:35 2004
@@ -1,12 +1,11 @@
%TMPL:INCLUDE{"twiki"}%
%TMPL:DEF{"titleaction"}%(oops) %TMPL:END%
%TMPL:DEF{"webaction"}% *Attention* %TMPL:END%
-%TMPL:DEF{"heading"}%You are not registered%TMPL:END%
+%TMPL:DEF{"heading"}%No such Login %TMPL:END%
%TMPL:DEF{"message"}%
Can't find the username
%PARAM1%.
-Make sure you spelled the User Name correctly and try again.
-Remember, a %TWIKIWEB%.WikiName is case sensitive.
+Please make sure you spelled the %TWIKIWEB%.LoginName correctly and try again. If you get stuck, please mail %WIKIWEBMASTER%.
See %MAINWEB%.TWikiUsers for a list of existing users or register as new user in
%TWIKIWEB%.TWikiRegistration. %TMPL:END%
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../templates/oopsregexist.tmpl Sat Oct 23 16:58:41 2004
@@ -3,10 +3,13 @@
%TMPL:DEF{"webaction"}% *Attention* %TMPL:END%
%TMPL:DEF{"heading"}%You are already registered%TMPL:END%
%TMPL:DEF{"message"}%
-Can't register twice, the username %PARAM1% is already registered.
+You cannot register twice, the username '%PARAM1%' is already registered.
-Please contact
-
%WIKIWEBMASTER%
-if you have any questions. %TMPL:END%
+Did you want to [[TWiki.ResetPassword][reset !%PARAM1%'s password]]?
+
+Alternatively hit back to go back to TWiki.TWikiRegistration and choose a different username.
+
+Please contact
%WIKIWEBMASTER%
+if you have any questions. %TMPL:END%
%TMPL:DEF{"topicaction"}% %TMPL:END%
%TMPL:P{"oops"}%
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../templates/oopsresetpasswd.tmpl Sat Oct 23 16:58:52 2004
@@ -1,11 +1,14 @@
%TMPL:INCLUDE{"twiki"}%
%TMPL:DEF{"titleaction"}%(note) %TMPL:END%
%TMPL:DEF{"webaction"}% *Note* %TMPL:END%
-%TMPL:DEF{"heading"}%How to reset your TWiki password%TMPL:END%
+%TMPL:DEF{"heading"}%Your TWiki password has been changed%TMPL:END%
%TMPL:DEF{"message"}%
-The following *bold* string is your encrypted password entry: *%PARAM1%*
-Please copy this information into a friendly e-mail to
-
%WIKIWEBMASTER% %TMPL:END%
-%TMPL:DEF{"topicaction"}% %TMPL:END%
+A new *system-generated* password has been sent to *%PARAM1%*.
+
+Please proceed to %TWIKIWEB%.ChangePassword to change it to something memorable.
+
+%TMPL:END%
+%TMPL:DEF{"topicaction"}% [[%TWIKIWEB%.ChangePassword][OK]] %TMPL:END%
+
%TMPL:P{"oops"}%
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../templates/registernotify.tmpl Sat Oct 23 16:59:02 2004
@@ -1,14 +1,10 @@
From: %WIKIWEBMASTER%
-To: %EMAILADDRESS%
-BCC: %WIKIWEBMASTER%
+To: %FIRSTLASTNAME% <%EMAILADDRESS%>
Subject: %WIKITOOLNAME% - Registration for %WIKINAME%
MIME-Version: 1.0
Content-Type: text/plain; charset=%CHARSET%
Content-Transfer-Encoding: 7bit
-This is an automated email notification of user registration
-in %WIKITOOLNAME%.
-
Thank you for registering in the %WIKITOOLNAME% collaboration
platform. Please save this email for future reference.
@@ -22,7 +18,7 @@
You can customize it as you like:
* Some people turn it into a personal portal with favorite
- links, what they work on etc.
+ links, what they work on, what help they'd like, etc.
* Some add schedule information and vacation notice.
* How about attaching your photo?
@@ -31,6 +27,11 @@
%FORMDATA%
Note:
-If you got this email by mistake: Somebody (%FIRSTLASTNAME%)
-registered at the %WIKITOOLNAME% site using your mail address
-%EMAILADDRESS% . Contact %WIKIWEBMASTER% if needed.
+ 1 If you got this email by mistake: Somebody (%FIRSTLASTNAME%)
+ registered at the %WIKITOOLNAME% site using your mail address
+ %EMAILADDRESS%
+ Contact %WIKIWEBMASTER% if this is in error.
+ 2 You can change your password at via
+ %SCRIPTURL%/view%SCRIPTSUFFIX%/%TWIKIWEB%/ChangePassword
+ 3 If you haven't set a password yet or you want to reset it, go to:
+ %SCRIPTURL%/view%SCRIPTSUFFIX%/%TWIKIWEB%/ResetPassword
--- /home/mrjc/testwiki.mrjc.com/twiki/pub/TWiki/DistributionContrib/remoteFileSavedLocallyFrom Fri Oct 29 05:22:00 2004
+++ ../templates/view.pattern.tmpl Sat Oct 23 16:59:07 2004
@@ -25,7 +25,7 @@
%TMPL:DEF{"toolbar"}%
%TMPL:END%