Changeset 959 for LATMOS-Accounts-Web
- Timestamp:
- 05/15/12 03:30:21 (12 years ago)
- Location:
- LATMOS-Accounts-Web
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Request.pm
r946 r959 54 54 $c->stash->{datarequest} = 55 55 LATMOS::Accounts::Bases::Sql::DataRequest->new($accreq); 56 $c->stash->{datarequest}->set_ptr_object($c->stash->{object}) 57 if ($c->stash->{object}); 58 56 59 $c->stash->{form} = $c->model( 57 60 'AttrForms', 58 61 '', 59 $c->stash->{ object},62 $c->stash->{datarequest}, 60 63 $c->model('Accounts')->db 61 64 ); 65 66 # Default apply date: 67 my @date = localtime( time + 3600 * 24 ); 68 $c->stash->{default_apply_date} = sprintf( 69 '%02d/%02d/%d', 70 @date[3,4], 71 $date[5] + 1900 72 ); 73 74 if ($c->req->param('send')) { 75 my %attrs; 76 foreach ($c->stash->{datarequest}->attributes) { 77 my $htmlname = $c->stash->{form}->attr_field_name($_); 78 my @vals = $c->req->param($htmlname); 79 $attrs{$_} = @vals > 1 ? \@vals : $vals[0]; 80 } 81 if ($c->stash->{datarequest}->register( 82 $c->user->{username}, 83 $c->req->param('apply') || $c->stash->{default_apply_date}, 84 %attrs, 85 )) { 86 $c->go('recorded'); 87 } 88 } 89 62 90 } 63 91 92 sub recorded : Private { 93 my ($self, $c) = @_; 64 94 95 my %attrs = $c->stash->{datarequest}->get_values; 96 $c->stash->{values} = \%attrs; 97 } 65 98 66 99 =head1 AUTHOR -
LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrFilter.pm
r861 r959 91 91 sub search_field { 92 92 my ($self, $count) = @_; 93 my $form = $self->{c}->model('AttrForms' );93 my $form = $self->{c}->model('AttrForms', '', $self->otype, $self->{c}->stash->{db}); 94 94 my $html = '<select name="attr"> 95 95 <option value=""></option>'; -
LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm
r955 r959 216 216 217 217 sub attr_label { 218 my ($self, $attr) = @_; 219 my ($hint, $label) = ('', ''); 218 my ($self, $attr, $label, $hint) = @_; 219 $label ||= ''; 220 $hint ||= ''; 220 221 LATMOS::Accounts::Web->config->{attrs} ||= {}; 221 my $htmlname = ($self->{object} ? $self->{object}->id . '_' : '') . $attr; 222 my $attribute = $self->base->attribute($self->otype, $attr); 223 my $htmlname = $self->escape($self->attr_field_name($attr)); 222 224 if (my $attr_config = LATMOS::Accounts::Web->config->{attrs}{$attr}) { 223 $label = $attr_config->{label} || '';225 $label ||= $attr_config->{label} || ''; 224 226 #utf8::is_utf8($label) && utf8::encode($label); 225 $hint = $attr_config->{hint} || '';227 $hint ||= $attr_config->{hint} || ''; 226 228 #utf8::is_utf8($hint) && utf8::encode($hint); 227 229 } … … 243 245 244 246 sub attr_raw_value { 245 my ($self, $attr) = @_; 246 return $self->{c}->req->param($attr) || 247 ($self->{object} ? $self->{object}->get_attributes($attr) : '') 247 my ($self, $attribute) = @_; 248 my @val = grep { $_ } 249 ($self->{c}->req->param($attribute->name)) 250 || ($self->{object} 251 ? ($self->{object}->get_attributes($attribute->name)) 252 : ()); 253 254 if (@val) { 255 return @val; 256 } else { 257 return (grep { $_ } ($attribute->default_value)) 258 } 248 259 } 249 260 … … 251 262 my ($self, $attr) = @_; 252 263 my $id = $self->{object} 253 ? $self->{object}->id . '_'264 ? ($self->{object}->id || '') 254 265 : ''; 266 $id .= '_' if ($id); 255 267 $id =~ s/\./_/g; 256 268 $id =~ s/-/_/g; … … 403 415 last; 404 416 }; 405 406 warn $_;407 417 } 408 418 return ''; … … 450 460 frequency => 1, 451 461 with => "'val='+element.value" . 452 ($self->{object} ? "+'&exclude=" . $self->{object}->id . "'" : 453 ''), 462 ($self->{object} ? 463 "+'&exclude=" . ($self->{object}->id || '') . "'" 464 : ''), 454 465 } 455 466 ) … … 463 474 my ($self, $attr, $type) = @_; 464 475 465 my $attr_info = $type 466 ? { formtype => $type } 467 : undef; 468 469 my $attribute = ($self->{object} 470 ? $self->{object}->attribute($attr) 471 : $self->base->attribute($self->otype, $attr)); 472 473 $attribute ||= $self->base->attribute( 474 $self->otype, 475 { 476 name => $attr, 477 formtype => $type 478 }, 479 ); 476 my $attribute = ($type 477 ? ref $type 478 ? $self->base->attribute( 479 $self->otype, 480 { %$type, name => $attr },) 481 : $self->base->attribute( 482 $self->otype, 483 { formtype => $type , name => $attr },) 484 : ($self->{object} 485 ? $self->{object}->attribute($attr) 486 : $self->base->attribute($self->otype, $attr, { formtype => $type }))) 487 || $self->base->attribute($self->otype, { name => $attr }); 488 480 489 481 490 my $htmlname = $self->escape($self->attr_field_name($attr)); 482 491 483 492 my @html_fields; 484 foreach my $attr_raw_value ( 485 $attribute->multiple 486 ? (grep { $_ } $self->attr_raw_value($attr)) 487 : $self->attr_raw_value($attr) || '') { 493 494 # Force Array context: 495 my @attr_raw_value = (); 496 if ($attribute->multiple) { 497 @attr_raw_value = grep { $_ } $self->attr_raw_value($attribute); 498 } else { 499 my ($val) = $self->attr_raw_value($attribute); 500 @attr_raw_value = ($val || ''); 501 } 502 503 foreach my $attr_raw_value (@attr_raw_value) { 488 504 489 505 my $html_id = $htmlname . … … 501 517 } 502 518 503 if ($attribute->{multiple} ) {519 if ($attribute->{multiple} && !$attribute->readonly) { 504 520 my $html_id = $htmlname . '_m_SUBID'; 505 521 -
LATMOS-Accounts-Web/root/html/includes/header.tt
r888 r959 103 103 </span> 104 104 <span> 105 <a href="[% c.uri_for('/sites') %]"106 onMouseOver="document.getElementById('menui').innerHTML='Liste des sites';"107 onMouseOut="resetmenu();"108 >109 <img title="Sites" src="[% c.uri_for('/static', 'icons', 'xfce-internet.png') %]"></a>110 </span>111 [% # On cache volontairement les alias si l'utilisateur ne doit pas y112 toucher %]113 [% IF c.model('Accounts').db.check_acl('aliases', '@CREATE', 'w') %]114 <span>115 <a href="[% c.uri_for('/aliases') %]"116 onMouseOver="document.getElementById('menui').innerHTML=117 'Alias mail sans utilisateur';"118 onMouseOut="resetmenu();"119 >120 <img title="Alias mail" src="[% c.uri_for('/static', 'icons', 'mail_forward.png') %]"></a>121 </span>122 [% END %]123 <span>124 105 <a href="[% c.uri_for('/nethosts') %]" 125 106 onMouseOver="document.getElementById('menui').innerHTML='Liste des hÃŽtes réseau';" … … 135 116 [% END %] 136 117 </span> 137 [% # On cache volontaire les zones si l'utilisateur ne doit pas y138 toucher %]139 [% IF c.model('Accounts').db.check_acl('netzone', '@CREATE', 'w') %]140 118 <span> 141 <a href="[% c.uri_for('/ netzones') %]"142 onMouseOver="document.getElementById('menui').innerHTML=' Liste des zones réseaux';"119 <a href="[% c.uri_for('/request') %]" 120 onMouseOver="document.getElementById('menui').innerHTML='Demandes';" 143 121 onMouseOut="resetmenu();" 144 122 > 145 <img title="Gestion Réseau" src="[% c.uri_for('/static', 'icons', 'network-workgroup.png') %]"></a> 146 <a href="[% c.uri_for('/create', 'netzone') %]" 147 onMouseOver="document.getElementById('menui').innerHTML='Ajouter une zones réseau';" 123 <img title="Demandes" src="[% c.uri_for('/static', 'icons', 'logviewer.png') %]"></a> 124 </span> 125 <span> 126 <a href="[% c.uri_for('/admin') %]" 127 onMouseOver="document.getElementById('menui').innerHTML='Administrer...';" 148 128 onMouseOut="resetmenu();" 149 ><img title="Ajouter une zone" src="[% c.uri_for('/static', 'icons', 'add.png') %]"></a> 129 > 130 <img title="Administrer..." src="[% c.uri_for('/static', 'icons', 'gtk-execute.png') %]"></a> 150 131 </span> 151 [% END %]152 132 <span> 153 133 <a href="[% c.uri_for('/about') %]" -
LATMOS-Accounts-Web/root/html/request/default.tt
r952 r959 1 1 <!-- $Id$ --> 2 3 <h2>[% accreq.get_attributes('description') | html %]</h2> 2 4 3 5 [% IF select_object %] … … 25 27 [% ELSE %] 26 28 29 [% IF accreq.get_attributes('requireObject') %] 30 <h3>[% datarequest.get_attributes('displayName') || datarequest.id %]</h3> 31 [% END %] 32 27 33 <form action="[% c.uri_for('/request', accreq.id, object.id) %]"> 28 34 [% FOREACH attr = datarequest.attributes %] … … 31 37 [% END %] 32 38 <tr> 33 <th>[% form.attr_label(attr) %]</th> 39 [% attrinfo = datarequest.attribute_info(attr) %] 40 <th>[% form.attr_label(attr, attrinfo.label) %]</th> 34 41 <td>[% form.attr_field(attr) %]</td> 35 42 </tr> 36 43 [% IF loop.last %] 37 44 <tr> 45 <th>Date d'application</th> 46 <td> 47 [% form.attr_field('apply', { formtype => 'date', _noacl => 1, default => default_apply_date } ) %] 48 </td> 49 </tr> 50 <tr><td></td><td> 51 <input type="submit" name="send"> 52 </td></tr> 38 53 </table> 39 54 [% END %] 40 55 [% END %] 41 [% form.attr_field('apply', 'DATE') %]42 <input type="submit" name="send">43 56 </form> 44 57 -
LATMOS-Accounts-Web/root/html/request/index.tt
r946 r959 1 1 <!-- $Id$ --> 2 2 3 <h2>Formuler une demande:</h2> 4 3 5 [% FOREACH h = c.model('Accounts').db.search_objects('accreq', 'exported=*') %] 6 [% IF loop.first %] 7 <ul> 8 [% END %] 4 9 [% o = c.model('Accounts').db.get_object('accreq', h) %] 10 <li> 5 11 <a href="[% c.uri_for(h) %]"> 6 12 [% o.get_attributes('description') || o.id | html %] 7 13 </a> 8 <br> 9 14 </li> 15 [% IF loop.last %] 16 </ul> 10 17 [% END %] 18 [% END %]
Note: See TracChangeset
for help on using the changeset viewer.