| | 1696 | =item B<revert_user_interface> |
| | 1697 | |
| | 1698 | If C<password> is not supplied then a form for entering the password |
| | 1699 | will be displayed, along with a list of all the edits the user made. |
| | 1700 | |
| | 1701 | If the password is given, will delete all of these versions. |
| | 1702 | =cut |
| | 1703 | sub revert_user_interface { |
| | 1704 | my ($self, %args) = @_; |
| | 1705 | |
| | 1706 | my $password = $args{password} || ''; |
| | 1707 | my $return_tt_vars = $args{return_tt_vars} || 0; |
| | 1708 | my $return_output = $args{return_output} || 0; |
| | 1709 | |
| | 1710 | my $wiki = $self->wiki; |
| | 1711 | my $formatter = $self->wiki->formatter; |
| | 1712 | my $script_name = $self->config->script_name; |
| | 1713 | |
| | 1714 | my ($type,$value); |
| | 1715 | if($args{'username'}) { |
| | 1716 | ($type,$value) = ('username', $args{'username'}); |
| | 1717 | } |
| | 1718 | if($args{'host'}) { |
| | 1719 | ($type,$value) = ('host', $args{'host'}); |
| | 1720 | } |
| | 1721 | unless($type && $value) { |
| | 1722 | croak("One of username or host must be given"); |
| | 1723 | } |
| | 1724 | |
| | 1725 | # Grab everything they've touched, ever |
| | 1726 | my @user_edits = $self->wiki->list_recent_changes( |
| | 1727 | since => 1, |
| | 1728 | metadata_is => { $type => $value }, |
| | 1729 | ); |
| | 1730 | |
| | 1731 | if ($password) { |
| | 1732 | if ($password ne $self->config->admin_pass) { |
| | 1733 | croak("Bad password supplied"); |
| | 1734 | } else { |
| | 1735 | # Delete all these versions |
| | 1736 | foreach my $edit (@user_edits) { |
| | 1737 | $self->wiki->delete_node( |
| | 1738 | name => $edit->{name}, |
| | 1739 | version => $edit->{version}, |
| | 1740 | ); |
| | 1741 | } |
| | 1742 | |
| | 1743 | # Grab new list |
| | 1744 | @user_edits = $self->wiki->list_recent_changes( |
| | 1745 | since => 1, |
| | 1746 | metadata_is => { $type => $value }, |
| | 1747 | ); |
| | 1748 | } |
| | 1749 | } else { |
| | 1750 | # Don't do anything |
| | 1751 | } |
| | 1752 | |
| | 1753 | # Set up our TT variables, including the search parameters |
| | 1754 | my %tt_vars = ( |
| | 1755 | not_editable => 1, |
| | 1756 | not_deletable => 1, |
| | 1757 | deter_robots => 1, |
| | 1758 | |
| | 1759 | edits => \@user_edits, |
| | 1760 | username => $args{username}, |
| | 1761 | host => $args{host}, |
| | 1762 | by_type => $type, |
| | 1763 | by => $value, |
| | 1764 | |
| | 1765 | script_name => $script_name |
| | 1766 | ); |
| | 1767 | return %tt_vars if $return_tt_vars; |
| | 1768 | |
| | 1769 | # Render to the page |
| | 1770 | my $output = $self->process_template( |
| | 1771 | id => "", |
| | 1772 | template => "admin_revert_user.tt", |
| | 1773 | tt_vars => \%tt_vars, |
| | 1774 | ); |
| | 1775 | return $output if $return_output; |
| | 1776 | print $output; |
| | 1777 | } |
| | 1778 | |