1 |
<%args> |
<%args> |
2 |
$user_id |
$user_id |
3 |
$delete_user_on_landscape_id => 0 |
$op => ''; |
4 |
$add_user_to_landscape_id => 0 |
$landscape_id => 0 |
5 |
</%args> |
</%args> |
6 |
<%init> |
<%init> |
7 |
|
|
8 |
if ($delete_user_on_landscape_id) { |
warn "user_id: $user_id, op: $op, landscape_id: $landscape_id\n"; |
9 |
|
|
10 |
|
if ($op eq 'delete') { |
11 |
my $u = Transports::Model::UserOnLandscape->new(); |
my $u = Transports::Model::UserOnLandscape->new(); |
12 |
$u->load_by_cols( |
$u->load_by_cols( |
13 |
user_on => $user_id, |
user_on => $user_id, |
14 |
landscape => $delete_user_on_landscape_id |
landscape => $landscape_id |
15 |
); |
); |
16 |
# $m->out("Deleted ", $u->landscape->name); |
if ($u->delete) { |
17 |
$u->delete; |
# $m->out("Deleted ", $u->landscape->name); |
18 |
} |
} else { |
19 |
|
$m->out("Problem while deleting ", $u->landscape->name); |
20 |
|
} |
21 |
|
|
22 |
if ($add_user_to_landscape_id) { |
} elsif ($op eq 'add') { |
23 |
my $u = Transports::Model::UserOnLandscape->new(); |
my $u = Transports::Model::UserOnLandscape->new(); |
24 |
$u->create( |
if($u->create( |
25 |
user_on => $user_id, |
user_on => $user_id, |
26 |
landscape => $add_user_to_landscape_id, |
landscape => $landscape_id, |
27 |
); |
)) { |
28 |
# $m->out("Added ", $u->landscape->name); |
# $m->out("Added ", $u->landscape->name); |
29 |
|
} else { |
30 |
|
$m->out("Problem while adding ", $landscape_id); |
31 |
|
} |
32 |
} |
} |
33 |
|
|
34 |
my $landscapes = Transports::Model::UserOnLandscapeCollection->new(); |
my $landscapes = Transports::Model::UserOnLandscapeCollection->new(); |
56 |
<% $l->name %> |
<% $l->name %> |
57 |
<% Jifty->web->link( |
<% Jifty->web->link( |
58 |
label => 'remove' , |
label => 'remove' , |
59 |
onclick => { args => { delete_user_on_landscape_id => $l->id }} |
onclick => { args => { op => 'delete', landscape_id => $l->id }} |
60 |
) %> |
) %> |
61 |
% } else { |
% } else { |
62 |
<del><% $l->name %></del> |
<del><% $l->name %></del> |
63 |
<% Jifty->web->link( |
<% Jifty->web->link( |
64 |
label => 'add' , |
label => 'add' , |
65 |
onclick => { args => { add_user_to_landscape_id => $l->id }} |
onclick => { args => { op => 'add', landscape_id => $l->id }} |
66 |
) %> |
) %> |
67 |
% } |
% } |
68 |
</li> |
</li> |