fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-10-07 05:34 am

[dw-free] rename admin page

[commit: http://hg.dwscoalition.org/dw-free/rev/64df494b7cfe]

http://bugs.dwscoalition.org/show_bug.cgi?id=3100

Add an admin page for renames options.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Controller/Rename.pm
  • cgi-bin/DW/RenameToken.pm
  • cgi-bin/DW/User/Rename.pm
  • t/rename.t
  • views/admin/rename.tt
  • views/admin/rename.tt.text
  • views/admin/rename_edit.tt
  • views/admin/rename_edit.tt.text
--------------------------------------------------------------------------------
diff -r c611987401d5 -r 64df494b7cfe cgi-bin/DW/Controller/Rename.pm
--- a/cgi-bin/DW/Controller/Rename.pm	Wed Oct 06 14:44:16 2010 +0800
+++ b/cgi-bin/DW/Controller/Rename.pm	Thu Oct 07 13:34:01 2010 +0800
@@ -29,6 +29,9 @@ use DW::Shop;
 # we validate the token inside and return an appropriate message (instead of 404)
 # ideally, should be: /rename, or /rename/(20 character token)
 DW::Routing->register_regex( qr!^/rename(?:/([A-Z0-9]*))?$!i, \&rename_handler, app => 1 );
+
+DW::Routing->register_string( "/admin/rename", \&rename_admin_handler, app => 1 );
+DW::Routing->register_string( "/admin/rename/edit", \&rename_admin_edit_handler, app => 1 );
 
 sub rename_handler {
     my $r = DW::Request->get;
@@ -119,13 +122,13 @@ sub rename_handler {
 }
 
 sub handle_post {
-    my ( $token, $post_args ) = @_;
+    my ( $token, $post_args, %opts ) = @_;
 
     return ( 0, [ LJ::Lang::ml( '/rename.tt.error.invalidform' ) ] ) unless LJ::check_form_auth( $post_args->{lj_form_auth} );
 
     my $errref = [];
 
-    # the journal we are going to rename; yourself or (eventually) a community you maintain
+    # the journal we are going to rename: yourself or a community you maintain
     my $journal = LJ::get_authas_user( $post_args->{authas} );
     push @$errref, LJ::Lang::ml( '/rename.tt.error.nojournal' ) unless $journal;
 
@@ -161,4 +164,149 @@ sub handle_post {
     # return the list of errors, because we want to print out other things as well...
     return ( 0, $errref );
 }
+
+sub rename_admin_handler {
+    my ( $ok, $rv ) = controller( privcheck => [ "siteadmin:rename" ] );
+    return $rv unless $ok;
+
+    my $r = DW::Request->get;
+    my $post_args = $r->post_args || {};
+    my $get_args = $r->get_args || {};
+
+    # just get the username, and not a user object, because username may no longer be valid for a user
+    my $user = $post_args->{user} || $get_args->{user};
+
+    my @renames;
+    if ( $user ) {
+        my @rename_tokens = sort { $a->rendate <=> $b->rendate }
+            @{ DW::RenameToken->by_username( user => $user ) || [] };
+        foreach my $token ( @rename_tokens ) {
+            push @renames, {
+                token   => $token->token,
+                from    => $token->fromuser,
+                to      => $token->touser,
+
+                # FIXME: these should probably just be in DW::RenameToken instead
+                owner   => LJ::load_userid( $token->ownerid ),
+                target  => LJ::load_userid( $token->renuserid ),
+                date    => LJ::mysql_time( $token->rendate ),
+            }
+        }
+    }
+
+    my $vars = {
+        %$rv,
+
+        # lookup a list of renames involving a username
+        user => $user,
+        renames => $user ? \@renames : undef,
+    };
+
+    return DW::Template->render_template( "admin/rename.tt", $vars );
+}
+
+sub rename_admin_edit_handler {
+    my ( $ok, $rv ) = controller( privcheck => [ "siteadmin:rename" ] );
+    return $rv unless $ok;
+
+    my $r = DW::Request->get;
+    my $post_args = $r->post_args || {};
+    my $get_args = $r->get_args || {};
+
+    my $token = DW::RenameToken->new( token => $get_args->{token} );
+
+    my $u = LJ::load_userid( $token->renuserid );
+    my $form = {
+        from    => $token->fromuser,
+        to      => $token->touser,
+        byuser  => LJ::load_userid( $token->ownerid ),
+        user    => $u,
+        journaltype => $u ? $u->journaltype : "P",
+
+        rel_types => [ qw( trusted_by watched_by trusted watched communities ) ],
+    };
+
+    # load up the old values
+    my $token_details = $token->details;
+    $form->{redirect} = $token_details->{redirect}->{username} ? "forward" : "disconnect";
+    $form->{rel_options} = { map { $_ => ! $token_details->{del}->{$_} } @{$form->{rel_types}} };
+    $form->{others}->{email} = $token_details->{redirect}->{email};
+
+    my $vars = {
+        %$rv,
+        form => $form,
+        token => $token,
+    };
+
+    if ( LJ::did_post() ) {
+        my ( $post_ok, $rv ) = handle_admin_post( $token, $post_args,
+                    journal     => $u,
+                    from_user    => $token->fromuser,
+                    to_user      => $token->touser,
+        );
+        return $rv if $post_ok;
+
+        $vars->{error_list} = $rv;
+    }
+
+    return DW::Template->render_template( "admin/rename_edit.tt", $vars );
+}
+
+sub handle_admin_post {
+    my ( $token, $post_args, %opts ) = @_;
+
+    return ( 0, [ LJ::Lang::ml( '/rename.tt.error.invalidform' ) ] ) unless LJ::check_form_auth( $post_args->{lj_form_auth} );
+
+    my $errref = [];
+    my %rename_opts = ( user => LJ::get_remote(), from => $opts{from_user}, to => $opts{to_user} );
+
+    if ( $post_args->{override_redirect} ) {
+        if ( LJ::isu( $opts{journal} ) && $opts{from_user} && $opts{to_user} ) {
+            my $redirect_journal = $post_args->{redirect} && $post_args->{redirect} eq "disconnect" ? 0 : 1;
+            $rename_opts{break_redirect}->{username} = ! $redirect_journal;
+        } else {
+            push @$errref, "Cannot do redirect; invalid journal, or no username provided to rename from/to.";
+        }
+    }
+
+
+    if( $post_args->{override_relationships} ) {
+        # since you can't recover deleted relationships, but you can delete the relationships later if something was missed
+        # negate the form submission so we're explicitly stating which rels we want to delete, rather than deleting everything not listed
+        my %keep_rel = map { $_ => 1 } $post_args->get( "rel_options" );
+        my %del_rel = map { +"del_$_" => ! $keep_rel{$_} } qw( trusted_by watched_by trusted watched communities );
+
+        $rename_opts{del} = \%del_rel;
+    }
+
+
+    if( $post_args->{override_others} ) {
+        my %other_opts = map { $_ => 1 } $post_args->get( "others" );
+
+        # force email to false if we can't support forwarding for this user
+        if ( $other_opts{email} ) {
+            if ( $post_args->{redirect} ne "forward" ) {
+                push @$errref, LJ::Lang::ml( '/rename.tt.error.emailnotforward', { emaildomain => "\@$LJ::USER_DOMAIN" } );
+                $other_opts{email} = 0;
+            }
+
+            unless ( $LJ::USER_EMAIL && $opts{journal}->can_have_email_alias ) {
+                push @$errref, LJ::Lang::ml( '/rename.tt.error.emailnoalias' );
+                $other_opts{email} = 0;
+            }
+        }
+
+        $rename_opts{break_redirect}->{email} = ! $other_opts{email};
+    }
+
+    $opts{journal}->apply_rename_opts( %rename_opts );
+
+    return ( 1, DW::Template->render_template(
+        'success.tt', { message => "Successfully changed settings." }
+    ) ) unless @$errref;
+
+    # return the list of errors, because we want to print out other things as well...
+    return ( 0, $errref );
+}
+
 1;
diff -r c611987401d5 -r 64df494b7cfe cgi-bin/DW/RenameToken.pm
--- a/cgi-bin/DW/RenameToken.pm	Wed Oct 06 14:44:16 2010 +0800
+++ b/cgi-bin/DW/RenameToken.pm	Thu Oct 07 13:34:01 2010 +0800
@@ -183,6 +183,42 @@ sub by_owner_unused {
     return @tokens ? [ @tokens ] : undef;
 }
 
+=head2 C<< $class->by_username( user => username ) >>
+
+Return a list of renames involving this username (either to this username, or from this username)
+
+=cut
+
+sub by_username {
+    my ( $class, %opts ) = @_;
+
+    # this assumes that we haven't changed what makes a valid username
+    #   so that we would be querying a username that was valid but is now invalid
+    # seems safe enough to start with
+    my $user = LJ::canonical_username( $opts{user} );
+    return unless $user;
+
+    my $dbr = LJ::get_db_reader();
+    my $sth = $dbr->prepare( "SELECT renid, auth, cartid, ownerid, renuserid, fromuser, touser, rendate FROM renames " .
+                             "WHERE fromuser=? OR touser=?" )
+        or die "Unable to retrieve list of rename tokens involving a username";
+
+    $sth->execute( $user, $user )
+        or die "Unable to retrieve list of rename tokens involving a username";
+
+    my @tokens;
+
+    while (my $token = $sth->fetchrow_hashref) {
+        my $ret = fields::new( $class );
+        while (my ($k, $v) = each %$token) {
+            $ret->{$k} = $v;
+        }
+        push @tokens, $ret;
+    }
+
+    return @tokens ? [ @tokens ] : undef;
+}
+
 =head2 C<< $class->_encode( $id, $auth ) >>
 
 Internal. Given a rename token id and a 13-digit auth code, returns a 20-digit
@@ -275,6 +311,57 @@ sub apply {
     }
 
     return 1;
+}
+
+=head2 C<< $self->details >>
+
+Get the details from the log for admin use. Not cached and pretty inefficient.
+Also, does not check for privs (leave that to the caller)
+
+=cut
+
+sub details {
+    my $self = $_[0];
+
+    my $u = LJ::load_userid( $self->renuserid );
+    return unless LJ::isu( $u );
+
+    # get more than we need and filter, just in case the timestamps don't match up perfectly
+    my $results = $u->selectall_arrayref(
+        "SELECT userid, logtime, action, extra FROM userlog "
+        . "WHERE userid=? AND action='rename' AND logtime >= ? ORDER BY logtime LIMIT 3",
+        { Slice => {} } , $u->userid, $self->rendate );
+
+    foreach my $row ( @{$results || []} ) {
+        my $extra = {};
+        LJ::decode_url_string( $row->{extra}, $extra );
+
+        if ( $extra->{from} eq $self->fromuser && $extra->{to} eq $self->touser ) {
+            $row->{from} = $extra->{from};
+            $row->{to} = $extra->{to};
+
+            foreach ( split( ":", $extra->{redir} ) ) {
+                $row->{redirect}->{ {
+                        J => "username", #journal/username
+                        E => "email",
+                }->{$_} } = 1;
+            }
+
+            foreach ( split( ":", $extra->{del} ) ) {
+                $row->{del}->{ {
+                        TB => "trusted_by",
+                        WB => "watched_by",
+                        T  => "trusted",
+                        W  => "watched",
+                        C  => "communities",
+                }->{$_} } = 1;
+            }
+
+            return $row;
+        }
+    }
+
+    return {};
 }
 
 # accessors
diff -r c611987401d5 -r 64df494b7cfe cgi-bin/DW/User/Rename.pm
--- a/cgi-bin/DW/User/Rename.pm	Wed Oct 06 14:44:16 2010 +0800
+++ b/cgi-bin/DW/User/Rename.pm	Thu Oct 07 13:34:01 2010 +0800
@@ -283,33 +283,23 @@ sub _rename {
 
     $token->apply( userid => $self->userid, from => $fromusername, to => $tousername );
 
-    $self->break_redirects;
-    DW::User::Rename->create_redirect_journal( $fromusername, $tousername ) if $opts{redirect};
-
-    my $del = "";
-    if ( $self->is_personal ) {
-        $del = $self->delete_relationships(
-            del_trusted_by => $opts{del_trusted_by},
-            del_watched_by => $opts{del_watched_by},
-            del_trusted => $opts{del_trusted},
-            del_watched => $opts{del_watched},
-            del_communities => $opts{del_communities} );
-    }
-
-    # this deletes the email under the old username
-    DW::User::Rename->break_email_redirection( $fromusername, $tousername ) unless $opts{redirect} && $opts{redirect_email};
+    $self->apply_rename_opts(
+        from     => $fromusername,
+        to       => $tousername,
+        redirect => {
+            username => $opts{redirect},
+            email    => $opts{redirect_email},
+        },
+        del => {
+            map { $_ => $opts{$_} } qw( del_trusted_by del_watched_by del_trusted del_watched del_communities ),
+        }, 
+        user => $opts{user},
+    );
 
     # update current object to new username, and update the email under the new username
     $self->{user} = $tousername;
     $self->update_email_alias;
 
-    my @redir;
-    push @redir, "J" if $opts{redirect};
-    push @redir, "E" if $opts{redirect} && $opts{redirect_email};
-
-    my $remote = LJ::isu( $opts{user} ) ? $opts{user} : $self;
-    $self->log_event( 'rename', { from => $fromusername, to => $tousername, remote => $remote, del => $del, redir => join( ":", @redir ) } );
-    
     # infohistory
     LJ::infohistory_add( $self, "username", $fromusername );
 
@@ -321,6 +311,92 @@ sub _rename {
     })->fire;
 
     return 1;
+}
+
+=head2 C<< $self->apply_rename_opts >>
+
+Apply the stated rename options. Will log.
+
+
+Arguments are:
+=item from, original username (required)
+=item to, new username (required)
+=item user, user doing the work if separate from user being renamed, e.g., admin of a community (optional)
+=item redirect => hashref. (optional) If provided, will handle initial redirect information. If false, will leave as-is.
+=item del      => hashref. (optional) If provided, will delete all relationships of the provided types.
+=item break_redirect => hashref. (optional) If provided, will break existing redirects
+
+redirect/break_redirect hashref:
+=item username, bool, forward or disconnect username. Default disconnect
+=item email, bool, forward or disconnect email. Default disconnect
+
+del hashref:
+=item del_trusted_by
+=item del_watched_by
+=item del_trusted
+=item del_watched
+=item del_communities 
+
+=cut
+sub apply_rename_opts {
+    my ( $self, %opts ) = @_;
+
+    my $from = delete $opts{from};
+    my $to = delete $opts{to};
+
+    my $user = delete $opts{user};
+
+    my %extra_args;
+
+    if ( exists $opts{redirect} && $from && $to ) {
+        if ( exists $opts{redirect}->{username} ) {
+            # break outgoing redirects
+            # we don't want this journal pointing anywhere else, to avoid long chains or possible loops
+            $self->break_redirects;
+            DW::User::Rename->create_redirect_journal( $from, $to )
+                if $opts{redirect}->{username};
+        }
+
+        # this deletes the email under the old username
+        DW::User::Rename->break_email_redirection( $from, $to )
+            unless $opts{redirect}->{username} && $opts{redirect}->{email};
+
+        my @redir;
+        push @redir, "J" if $opts{redirect}->{username};
+        push @redir, "E" if $opts{redirect}->{username} && $opts{redirect}->{email};
+
+        $extra_args{redir} = join( ":", @redir );
+    }
+
+    if ( exists $opts{break_redirect} ) {
+        # break incoming redirects
+        if ( $opts{break_redirect}->{username} ) {
+            my $redirect_u = LJ::load_user( $from );
+            $redirect_u->break_redirects;
+            $redirect_u->set_statusvis( "D" );
+        }
+
+        DW::User::Rename->break_email_redirection( $from, $to )
+            if $opts{break_redirect}->{email};
+
+        my @break;
+        push @break, "J" if $opts{break_redirect}->{username};
+        push @break, "E" if $opts{break_redirect}->{email};
+
+        $extra_args{break} = join( ":", @break );
+    }
+
+    $extra_args{del} = $self->delete_relationships( %{$opts{del}} )
+        if %{$opts{del} || {}};
+
+    $extra_args{from} = $from if $from;
+    $extra_args{to} = $to if $to;
+    
+    my $remote = LJ::isu( $user ) ? $user : $self;
+    $self->log_event( 'rename', {
+        remote => $remote,
+        %extra_args,
+    } );
 }
 
 =head2 C<< $self->break_redirects >>
@@ -488,6 +564,7 @@ sub _rename_to_ex {
 *LJ::User::rename = \&rename;
 *LJ::User::swap_usernames = \&swap_usernames;
 
+*LJ::User::apply_rename_opts = \&apply_rename_opts;
 *LJ::User::break_redirects = \&break_redirects;
 *LJ::User::delete_relationships = \&delete_relationships;
 
diff -r c611987401d5 -r 64df494b7cfe t/rename.t
--- a/t/rename.t	Wed Oct 06 14:44:16 2010 +0800
+++ b/t/rename.t	Thu Oct 07 13:34:01 2010 +0800
@@ -3,7 +3,7 @@ use warnings;
 use warnings;
 
 use Test::More;
-plan tests => 96;
+plan tests => 137;
 
 use lib "$ENV{LJHOME}/cgi-bin";
 require 'ljlib.pl';
@@ -134,6 +134,89 @@ note( "-- user-to-user, with redirect" )
     ok( $orig_u->is_redirect, "Chose to redirect this rename" );
     is( $orig_u->get_renamed_user->user, $tousername, "Confirm redirect from $fromusername to $tousername" );
 
+}
+
+note ( "-- rename opts: deleting relationships" );
+{
+    my ( $u ) = temp_user();
+    my $tousername = $u->user . "_renameto";
+
+    my $watcher = temp_user();
+    my $truster = temp_user();
+    my $watched = temp_user();
+    my $trusted = temp_user();
+    my $comm = temp_comm();
+
+    $watcher->add_edge( $u, watch => { nonotify => 1 } );
+    $truster->add_edge( $u, trust => { nonotify => 1 } );
+    $u->add_edge( $watched, watch => { nonotify => 1 } );
+    $u->add_edge( $trusted, trust => { nonotify => 1 } );
+    $u->add_edge( $comm, watch => { nonotify => 1 } );
+
+    ok( $watcher->watches( $u ), "User has a watcher." );
+    ok( $truster->trusts( $u ), "User has a truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( $u->watches( $comm ), "User watches a comm." );
+
+    # no arguments means nothing was deleted
+    $u->apply_rename_opts();
+    ok( $watcher->watches( $u ), "User has a watcher." );
+    ok( $truster->trusts( $u ), "User has a truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( $u->watches( $comm ), "User watches a comm." );
+
+    $u->apply_rename_opts( del => { del_watched_by => 1 } );
+    ok( ! $watcher->watches( $u ), "User has no watcher." );
+    ok( $truster->trusts( $u ), "User has a truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( $u->watches( $comm ), "User watches a comm." ); 
+    $watcher->add_edge( $u, watch => { nonotify => 1 } );
+
+    $u->apply_rename_opts( del => { del_trusted_by => 1 } );
+    ok( $watcher->watches( $u ), "User has a watcher." );
+    ok( ! $truster->trusts( $u ), "User has no truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( $u->watches( $comm ), "User watches a comm." );
+    $truster->add_edge( $u, trust => { nonotify => 1 } );
+
+    $u->apply_rename_opts( del => { del_watched => 1 } );
+    ok( $watcher->watches( $u ), "User has a watcher." );
+    ok( $truster->trusts( $u ), "User has a truster." );
+    ok( ! $u->watches( $watched ), "User does not watch anyone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( $u->watches( $comm ), "User watches a comm." );
+    $u->add_edge( $watched, watch => { nonotify => 1 } );
+
+    $u->apply_rename_opts( del => { del_trusted => 1 } );
+    ok( $watcher->watches( $u ), "User has a watcher." );
+    ok( $truster->trusts( $u ), "User has a truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( ! $u->trusts( $watched ), "User does not trust anyone." );
+    ok( $u->watches( $comm ), "User watches a comm." );
+    $u->add_edge( $trusted, trust => { nonotify => 1 } );
+
+    $u->apply_rename_opts( del => { del_communities => 1 } );
+    ok( $watcher->watches( $u ), "User has a watcher." );
+    ok( $truster->trusts( $u ), "User has a truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( ! $u->watches( $comm ), "User does not watch a comm." );
+
+    ok( $u->rename( $tousername, token => new_token( $u ), redirect => 0, del_trusted_by => 1, del_watched_by => 1 ), "Rename, break watchers and trusters" );
+    ok( ! $watcher->watches( $u ), "User has no watcher." );
+    ok( ! $truster->trusts( $u ), "User has no truster." );
+    ok( $u->watches( $watched ), "User watches someone." );
+    ok( $u->trusts( $trusted ), "User trusts someone." );
+    ok( ! $u->watches( $comm ), "User does not watch a comm." );
+}
+
+note( "-- rename opts: breaking email redirection" );
+TODO: {
+    local $TODO = "-- rename opts: breaking email redirection";
 }
 
 note( "-- personal-to-personal, authorization" );
diff -r c611987401d5 -r 64df494b7cfe views/admin/rename.tt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/admin/rename.tt	Thu Oct 07 13:34:01 2010 +0800
@@ -0,0 +1,46 @@
+[%# admin/rename.tt
+
+Admin page for renames
+
+Authors:
+    Afuna <coder.dw@afunamatata.com>
+
+This program is free software; you may redistribute it and/or modify it under
+the same terms as Perl itself.  For a copy of the license, please reference
+'perldoc perlartistic' or 'perldoc perlgpl'.
+%]
+
+[% sections.title = '.title' | ml %]
+
+[% IF renames %]
+    [% IF renames.size == 0 %]
+        <p>[% '.renames.list.empty' | ml( user = user ) | html %]</p>
+    [% ELSE %]
+        <table>
+            <tr><th>From</th><th>To</th><th>Renamed by</th><th>Account renamed</th><th>Renamed on</th></tr>
+        
+            [% FOREACH rename = renames %]
+            <tr>
+                <td>[%rename.from | html %]</td>
+                <td>[%rename.to | html %]</td>
+                <td>[%rename.owner.ljuser_display %]</td>
+                <td>[%rename.target.ljuser_display %]</td>
+                <td>[%rename.date%]</td>
+                <td><a href="[%site.root%]/admin/rename/edit?token=[%rename.token%]">[% '.renames.list.item.details' | ml | html %]</a></td>
+            </tr>
+            [% END %]
+        </table>
+    [% END %]
+[% END %]
+
+[% IF user %]
+<p>
+<a href="[%site.root%]/admin/rename">Return to renames lookup</a>
+</p>
+[% ELSE %]
+<form method="GET">
+    <label for="user">Username:</label> <input type="text" name="user" id="user"/>
+    <input type="submit" value="Look up user name" />
+</form>
+[% END %]
+
diff -r c611987401d5 -r 64df494b7cfe views/admin/rename.tt.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/admin/rename.tt.text	Thu Oct 07 13:34:01 2010 +0800
@@ -0,0 +1,7 @@
+;; -*- coding: utf-8 -*-
+
+.renames.list.empty=No renames involving "[[user]]".
+
+.renames.list.item.details=More / edit
+
+.title=Renames Admin Page
diff -r c611987401d5 -r 64df494b7cfe views/admin/rename_edit.tt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/admin/rename_edit.tt	Thu Oct 07 13:34:01 2010 +0800
@@ -0,0 +1,85 @@
+[%# rename_edit.tt
+
+Interface to edit rename options.
+
+Authors:
+    Afuna <coder.dw@afunamatata.com>
+
+This program is free software; you may redistribute it and/or modify it under
+the same terms as Perl itself.  For a copy of the license, please reference
+'perldoc perlartistic' or 'perldoc perlgpl'.
+%]
+
+[%- sections.title = "Detailed Rename View"; -%]
+[%- dw.need_res( 'stc/rename.css' ) -%]
+
+[% IF error_list %]
+    <p>Error</p>
+    <ul class='error-list'>
+        [% FOREACH error = error_list %]
+            <li>[% error %] </li>
+        [% END %]
+    </ul>
+[% END %]
+
+[% IF token %]
+    <form method="POST" id="renameform">
+        [%- dw.form_auth # hidden input field HTML -%]
+
+        <fieldset class="rename">
+            <legend>Account information</legend>
+            <div class="formfield">
+                <label>Rename: </label>     [% form.from %] --> [% form.to %]
+            </div>
+            <div class="formfield">
+                <label>Account: </label>    [% form.user.ljuser_display %]
+            </div>
+            <div class="formfield">
+                <label>Renamed by: </label> [% form.byuser.ljuser_display %]
+            </div>
+
+        </fieldset>
+
+        [% scope = dw.ml_scope( ); CALL dw.ml_scope( '/rename.tt' ) %]
+        <h2>Options chosen</h2>
+        <p>You will need to check the "override" to override the displayed options.</p>
+        <fieldset>
+        <legend>Username redirection options</legend>
+        <input type="checkbox" name="override_redirect" id="override_redirect" /><label for="override_redirect">Override</label>
+        <div class="formfield">
+            <input type="radio" name="redirect" value="forward" id="redirect_forward" disabled="disabled" [% 'checked="checked"' IF form.redirect == "forward" %]/><label for="redirect_forward">[%- '.form.rename.forward.label.' _ form.journaltype | ml %]</label>
+            <p class="note">Cannot reconnect the journal once disconnected.</p>
+        </div>
+        <div class="formfield">
+            <input type="radio" name="redirect" value="disconnect" id="redirect_disconnect" [% 'checked="checked"' IF form.redirect == 'disconnect' %]/><label for="redirect_disconnect">[%- '.form.rename.disconnect.label.' _ form.journaltype | ml %]</label>
+        </div>
+        </fieldset>
+
+        [% IF form.rel_types.size > 0 %]
+        <fieldset class="relationships">
+            <legend>[% '.form.relationships.header' | ml %]</legend>
+            <input type="checkbox" name="override_relationships" id="override_relationships" /><label for="override_relationships">Override</label>
+            <p class="note">be careful when leaving these unchecked! We cannot recover the list once the relationships have been broken, so make sure you don't carry over old opts. Otherwise you may delete everyone the user has added since they renamed</p>
+            [% FOREACH rel IN form.rel_types %]
+                <div class="formfield">
+                    <input type="checkbox" name="rel_options" value="[% rel %]" id="rel_[% rel %]" [%- 'checked="checked"' IF form.rel_options.$rel -%] /><label for="rel_[% rel %]">[% ".form.relationships.$rel" | ml %]</label>
+                </div>
+            [% END %]
+        </fieldset>
+        [% END %]
+
+        <fieldset class="others">        
+            <legend>[% '.form.others.header' | ml %]</legend>
+            <input type="checkbox" name="override_others" id="override_others" /><label for="override_others">Override</label>
+            <div class="formfield">
+                <input type="checkbox" name="others" value="email" id="others_email" [%- 'checked="checked"' IF form.others.email -%]/><label for="others_email">[% '.form.others.email' | ml( sitename = site.nameshort ) %] <span id="others_email_note">([% '.form.others.email.note' | ml %])</span></label>
+                <p class="note">Cannot reconnect the email once disconnected.</p>
+            </div>
+        </fieldset>
+
+        <input type="submit" value="Override rename options" />
+    </form>
+    [% CALL dw.ml_scope( scope ); %]
+[% ELSE %]
+Need to provide token. <a href="[%site.root%]/admin/rename">Back to start?</a>
+[% END %]
diff -r c611987401d5 -r 64df494b7cfe views/admin/rename_edit.tt.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/admin/rename_edit.tt.text	Thu Oct 07 13:34:01 2010 +0800
@@ -0,0 +1,5 @@
+;; -*- coding: utf-8 -*-
+
+.form.rename.header=Options chosen
+
+.title=Renames Admin Page
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
No Subject Icon Selected
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org