Skip to content

Commit

Permalink
DomainName add delete method for admin users
Browse files Browse the repository at this point in the history
  • Loading branch information
ukfsn committed Sep 16, 2010
1 parent a458ff7 commit 4097d79
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 29 additions & 2 deletions Kirin/Plugin/DomainName.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ my @fieldmap = (

sub list {
my ($self, $mm) = @_;
my (@names) = Kirin::DB::DomainName->search(customer => $mm->{customer});
$mm->respond("plugins/domain_name/list", names => \@names);
my %args = ();
$args{names} = [Kirin::DB::DomainName->search(customer => $mm->{customer})];
if ( $mm->{user}->is_root ) {
$args{admin}++;
}
$mm->respond("plugins/domain_name/list", %args);
}

sub view {
Expand Down Expand Up @@ -605,6 +609,29 @@ sub _setup_db {
);
}

sub delete {
my ($self, $mm, $id) = @_;
if (!$mm->{user}->is_root) { return $mm->respond("403handler") }
my %rv = $self->_get_domain($mm, $id);
return $rv{response} if exists $rv{response};

my ($domain, $handle) = ($rv{object}, $rv{reghandle});
if (!$domain) {
$mm->message('That domain is not in the database.');
return $self->list($mm);
}
my $registered = undef;
eval { $registered = $handle->domain_info($domain->domain); };
if ( $registered ) {
# XXX check whether the domain is actually still registered with us.
# if so do NOT delete it
}
else {
$domain->delete;
}
return $self->list($mm);
}

sub admin {
my ($self, $mm) = @_;
if (!$mm->{user}->is_root) { return $mm->respond("403handler") }
Expand Down
2 changes: 2 additions & 0 deletions templates/plugins/domain_name/list
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
[% FOR n = names %]
<tr> <th> [%n.domain%] </th>
<td> Expires [% n.expires.ymd %] </td>
<td> <a href="/domain_name/view/[%n.id%]">View Domain</a></td>
<td> <a href="/domain_name/change_contacts/[%n.id%]">Change contacts</a></td>
<td> <a href="/domain_name/change_nameservers/[%n.id%]">Change nameservers</a></td>
<td> <a href="/domain_name/renew/[%n.id%]">Renew</a></td>
[% IF admin %]<td> <a href="/domain_name/delete/[%n.id%]">Delete</a></td>[%END%]
</tr>
[% END %]
</table>
Expand Down

0 comments on commit 4097d79

Please sign in to comment.