/[transports]/trunk/web/templates/fragments/user_on_landscape
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/web/templates/fragments/user_on_landscape

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations)
Thu Jun 8 12:50:05 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 1476 byte(s)
cleanup and refactore, report errors
1 <%args>
2 $user_id
3 $op => '';
4 $landscape_id => 0
5 </%args>
6 <%init>
7
8 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();
12 $u->load_by_cols(
13 user_on => $user_id,
14 landscape => $landscape_id
15 );
16 if ($u->delete) {
17 # $m->out("Deleted ", $u->landscape->name);
18 } else {
19 $m->out("Problem while deleting ", $u->landscape->name);
20 }
21
22 } elsif ($op eq 'add') {
23 my $u = Transports::Model::UserOnLandscape->new();
24 if($u->create(
25 user_on => $user_id,
26 landscape => $landscape_id,
27 )) {
28 # $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();
35 $landscapes->limit(
36 column => 'user_on',
37 value => $user_id,
38 quote_value => 0,
39 );
40
41 my $selected_landscape;
42 map { $selected_landscape->{ $_->landscape->id }++ } @{ $landscapes->items_array_ref };
43
44 my $all_landscapes = Transports::Model::LandscapeCollection->new();
45 $all_landscapes->unlimit;
46
47 </%init>
48
49 <div>
50 Landscapes:
51
52 <ul>
53 % while (my $l = $all_landscapes->next ) {
54 <li>
55 % if ($selected_landscape->{ $l->id }) {
56 <% $l->name %>
57 <% Jifty->web->link(
58 label => 'remove' ,
59 onclick => { args => { op => 'delete', landscape_id => $l->id }}
60 ) %>
61 % } else {
62 <del><% $l->name %></del>
63 <% Jifty->web->link(
64 label => 'add' ,
65 onclick => { args => { op => 'add', landscape_id => $l->id }}
66 ) %>
67 % }
68 </li>
69 % }
70 </ul>
71
72 </div>
73

  ViewVC Help
Powered by ViewVC 1.1.26