Changeset 680


Ignore:
Timestamp:
01/20/10 18:28:39 (14 years ago)
Author:
nanardon
Message:
  • online check login name validity and user does not exists
Location:
LATMOS-Accounts-Web
Files:
1 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Ajax.pm

    r679 r680  
    6666} 
    6767 
     68sub check_new_name : Local { 
     69    my ($self, $c, $otype) = @_; 
     70    my $base = $c->model('Accounts')->db; 
     71    my $val = $c->req->param('val'); 
     72 
     73    warn $otype; 
     74    if ($c->stash->{validity} = (lc($otype) eq 'user' || lc($otype) eq 'group') 
     75        ? LATMOS::Accounts::Utils::check_ug_validity($val) 
     76        : LATMOS::Accounts::Utils::check_oid_validity($val)) { 
     77        warn $c->stash->{validity}; 
     78        return; 
     79    } 
     80 
     81    if (my $obj = $base->get_object($otype, $val)) { 
     82        $c->stash->{validity} = "$val exists " . 
     83            ($obj->get_attributes('displayName') || '') 
     84    } 
     85} 
     86 
    6887sub objattrexist : Local { 
    6988    my ($self, $c, $otype, $attr) = @_; 
     
    100119} 
    101120 
    102 sub check_ug_validity { 
     121sub check_ug_validity : Local { 
    103122    my ( $self, $c ) = @_; 
    104123    my $val = $c->req->param('val'); 
  • LATMOS-Accounts-Web/root/html/ajax/check_ug_validity.tt

    r679 r680  
    1 [% IF validty %] 
     1[% IF validity %] 
    22<img src="[% c.uri_for('/static', 'images', 'dialog-cancel.png') %]"> 
    3 ([% validty %]) 
     3([% validity %]) 
    44[% END %] 
  • LATMOS-Accounts-Web/root/html/create/user.tt

    r679 r680  
    99</td></tr> 
    1010[% c.prototype.observe_field('name', { 
    11     url => c.uri_for('/ajax', 'check_ug_validity'), 
     11    url => c.uri_for('/ajax', 'check_new_name', 'user'), 
    1212    with   => "'val='+value", 
    1313    update => 'name_validity', 
     
    2020<tr><td>[% form.attr_label('description') %]</td><td>[% form.attr_field('description') %]</td></tr> 
    2121[% IF ! step %] 
    22 <tr><td>Login (si pas de nom)</th><td><input type="text" name="id" value="[% c.req.param('id') | html %]"></td></tr> 
     22<tr><td>Login (si pas de nom)</th><td><input type="text" id="name" name="id" value="[% c.req.param('id') | html %]"> 
     23<span id="name_validity"></span> 
     24</td></tr> 
     25[% c.prototype.observe_field('name', { 
     26    url => c.uri_for('/ajax', 'check_new_name', 'user'), 
     27    with   => "'val='+value", 
     28    update => 'name_validity', 
     29    frequency => 1, 
     30    min_chars => 1, 
     31}) %] 
    2332<input type="hidden" name="step" value="1"> 
    2433 
Note: See TracChangeset for help on using the changeset viewer.