Changeset 1135
- Timestamp:
- 09/15/12 08:52:16 (12 years ago)
- Location:
- trunk
- Files:
-
- 20 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts-Web/MANIFEST
r1132 r1135 15 15 lib/LATMOS/Accounts/Web/Controller/Admin/Requests.pm 16 16 lib/LATMOS/Accounts/Web/Controller/Ajax.pm 17 lib/LATMOS/Accounts/Web/Controller/Ajax/Services/Mailing.pm 17 18 lib/LATMOS/Accounts/Web/Controller/Aliases.pm 18 19 lib/LATMOS/Accounts/Web/Controller/Create.pm … … 25 26 lib/LATMOS/Accounts/Web/Controller/Rpc.pm 26 27 lib/LATMOS/Accounts/Web/Controller/Search.pm 28 lib/LATMOS/Accounts/Web/Controller/Services/Mailing.pm 27 29 lib/LATMOS/Accounts/Web/Controller/Sites.pm 28 30 lib/LATMOS/Accounts/Web/Controller/Summary/Departments.pm … … 54 56 root/html/ajax/select_freeip_select.tt 55 57 root/html/ajax/select_objects_list.tt 58 root/html/ajax/services/mailing/dest_list.tt 59 root/html/ajax/services/mailing/users_list.tt 56 60 root/html/ajax/set_attrs.tt 57 61 root/html/ajax/user_to_group_form.tt … … 95 99 root/html/request/recorded.tt 96 100 root/html/search/index.tt 101 root/html/services/mailing/filter.tt 102 root/html/services/mailing/index.tt 103 root/html/services/mailing/send.tt 104 root/html/services/mailing/to.tt 97 105 root/html/sites/default.tt 98 106 root/html/sites/index.tt … … 122 130 root/static/icons/document-save-as.png 123 131 root/static/icons/document-save.png 132 root/static/icons/editclear.png 124 133 root/static/icons/emblem-favorite.png 125 134 root/static/icons/emblem-urgent.png 126 135 root/static/icons/expired.png 136 root/static/icons/find.png 127 137 root/static/icons/gnome-session-logout.png 128 138 root/static/icons/gnome-stock-mail-snd.png … … 139 149 root/static/icons/gtk-home.png 140 150 root/static/icons/gtk-jump-to-rtl.png 151 root/static/icons/gtk-refresh.png 141 152 root/static/icons/help-contents.png 142 153 root/static/icons/icon_edit.png … … 198 209 t/04config_load.t 199 210 t/controller_About.t 211 t/controller_Ajax-Services-Mailing.t 200 212 t/controller_Ajax.t 201 213 t/controller_Aliases.t … … 206 218 t/controller_Request.t 207 219 t/controller_Search.t 220 t/controller_Services-Mailing.t 208 221 t/controller_Sites.t 209 222 t/controller_Summary-Department.t -
trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Ajax.pm
r1107 r1135 46 46 47 47 sub displayattr : Local { 48 my ($self, $c, $otype ) = @_;49 my $attribute = $c->model('Accounts')->db->attribute($otype,50 $c->req->param('attr')) or return;48 my ($self, $c, $otype, $attr) = @_; 49 $attr ||= $c->req->param('attr'); 50 my $attribute = $c->model('Accounts')->db->attribute($otype, $attr) or return; 51 51 $c->stash->{value} = $attribute->display($c->req->param('id')); 52 52 } … … 56 56 57 57 my $base = $c->model('Accounts')->db; 58 my $val = $c->req->param('val'); 59 $c->stash->{'complete'} = $c->prototype->auto_complete_result([ 58 my $val = $c->req->param('val') || ''; 59 $c->stash->{values} = [ 60 sort 60 61 grep { /^\Q$val\E/ } $base->attributes_summary($otype, $attr) 61 ] );62 ]; 62 63 63 64 } -
trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrFilter.pm
r1131 r1135 41 41 42 42 my @objlist = (); 43 if ($c->req->params->{'q'}) { 44 my %objs; 45 foreach my $attr (@{ $c->config->{objects}{$otype}{quick_search} || [ 'cn' ]}) { 46 foreach ($base->search_objects( 47 $otype, "$attr~" . $c->req->params->{'q'})) { 48 $objs{$_} = 1; 43 if ($c->req->params->{'q'} || exists($c->req->params->{'attr'}) ) { 44 my %objs = (); 45 if ($c->req->params->{'q'}) { 46 foreach my $attr (@{ $c->config->{objects}{$otype}{quick_search} || [ 'cn' ]}) { 47 foreach ($base->search_objects( 48 $otype, "$attr~" . $c->req->params->{'q'})) { 49 $objs{$_} = 1; 50 } 51 @objlist = sort keys %objs; 49 52 } 50 @objlist = sort keys %objs;51 53 } 52 } elsif (exists($c->req->params->{'attr'})) { 53 $self->{filter}{'attr'} = [ $c->req->param('attr') ]; 54 $self->{filter}{'attrval'} = [ $c->req->param('attrval') ]; 55 my @filter = $self->filter; 56 @objlist = $base->search_objects($otype, @filter); 54 55 if (exists($c->req->params->{'attr'})) { 56 $self->{filter}{'attr'} = [ $c->req->param('attr') ]; 57 $self->{filter}{'attrval'} = [ $c->req->param('attrval') ]; 58 my @filter = $self->filter; 59 @objlist = $base->search_objects($otype, @filter); 60 if ($c->req->params->{'q'}) { 61 @objlist = grep { $objs{$_} } @objlist; 62 } 63 } 57 64 } else { 58 65 @objlist = $base->list_objects($otype); -
trunk/LATMOS-Accounts-Web/root/html/ajax/attrvalues.tt
r971 r1135 1 [% complete %] 1 [% IF c.req.param('type') == 'select' %] 2 <select name="toto"> 3 <option value="">--</option> 4 [% FOREACH v = values %] 5 <option value="[% v | html %]">[% v | html %]</option> 6 [% END %] 7 </select> 8 [% ELSE %] 9 [% c.prototype.auto_complete_result(values) %] 10 [% END %] -
trunk/LATMOS-Accounts-Web/root/html/includes/select_objects_list.tt
r1131 r1135 9 9 [% IF objectslist.size < 20 %] 10 10 [% object = c.model('Accounts').db.get_object(ofilter.otype, name) %] 11 <option value="[% name | html %]">[% name | html %] ([% 12 object.get_attributes('displayName') | html %])</option> 11 <option value="[% name | html %]">[% name | html %] 12 [% disp = object.get_attributes('displayName') %] 13 [% IF disp %] 14 ([%disp | html %]) 15 [% END %] 16 </option> 13 17 [% ELSE %] 14 18 <option value="[% name | html %]">[% name | html %]</option> -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm
r1100 r1135 120 120 } 121 121 122 sub _sync_dyn_group { 123 my ($self) = @_; 124 125 my @groups = $self->search_objects('group', 'autoMemberFilter=*'); 126 127 foreach (@groups) { 128 my $g = $self->get_object('group', $_) or next; 129 $g->populate_dyn_group; 130 } 131 } 132 122 133 sub _commit { 123 134 my ($self) = @_; 135 136 $self->_sync_dyn_group; 137 124 138 if ($ENV{LA_NO_COMMIT}) { 125 139 $self->log(LA_DEBUG, 'DB::COMMIT (ignore due to LA_NO_COMMIT)'); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
r1023 r1135 41 41 ro => sub { 42 42 $_[0] && 43 ($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ 43 (($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ 44 || $_[0]->_get_c_field('autoMemberFilter')) 44 45 ? 1 : 0 45 46 }, … … 52 53 ro => sub { 53 54 $_[0] && 54 ($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ 55 (($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ 56 || $_[0]->_get_c_field('autoMemberFilter')) 55 57 ? 1 : 0 56 58 }, … … 70 72 reference => 'sutype', 71 73 }, 74 autoMemberFilter => { 75 multiple => 1, 76 } 72 77 } 73 78 ) … … 96 101 } 97 102 103 sub _set_group_members { 104 my ($self, $members) = @_; 105 my %member; 106 my $res = 0; 107 foreach (@{ $self->get_field('memberUID') }) { 108 $member{$_}{c} = 1; 109 } 110 foreach (ref $members ? @{ $members || []} : $members) { 111 $_ or next; # avoid undef 112 $member{$_}{n} = 1; 113 } 114 115 foreach (keys %member) { 116 $member{$_}{c} && $member{$_}{n} and next; # no change ! 117 my $user = $self->base->get_object('user', $_) or next; 118 if ($member{$_}{n}) { 119 my $sth = $self->db->prepare_cached( 120 q{insert into group_attributes_users (value, attr, okey) values (?,?,?)} 121 ); 122 $sth->execute($_, 'memberUID', $self->_get_ikey); 123 $res++; 124 } elsif ($member{$_}{c}) { 125 if (($user->get_c_field('department') || '') eq $self->id) { 126 $self->base->log(LA_WARN, 127 "Don't removing user %s from group %s: is it's department", 128 $user->id, $self->id); 129 next; 130 } 131 my $sth = $self->db->prepare_cached( 132 q{delete from group_attributes_users where value = ? and attr = ? and okey = ?} 133 ); 134 $sth->execute($_, 'memberUID', $self->_get_ikey); 135 $res++; 136 } # else {} # can't happend 137 } 138 return $res; 139 } 140 98 141 sub set_fields { 99 142 my ($self, %data) = @_; … … 102 145 foreach my $attr (keys %data) { 103 146 $attr =~ /^memberUID|member$/ and do { 104 if (($self->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/) { 147 if (($self->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ || 148 $self->get_field('autoMemberFilter')) { 105 149 $self->base->log(LA_WARN, 106 150 "Group %s is managed, ignoring member set request", … … 108 152 next; 109 153 } 110 my %member; 111 foreach (@{ $self->get_field('memberUID') }) { 112 $member{$_}{c} = 1; 113 } 114 foreach (ref $data{$attr} ? @{ $data{$attr} || []} : $data{$attr}) { 115 $_ or next; # avoid undef 116 $member{$_}{n} = 1; 117 } 118 119 foreach (keys %member) { 120 $member{$_}{c} && $member{$_}{n} and next; # no change ! 121 my $user = $self->base->get_object('user', $_) or next; 122 if ($member{$_}{n}) { 123 my $sth = $self->db->prepare_cached( 124 q{insert into group_attributes_users (value, attr, okey) values (?,?,?)} 125 ); 126 $sth->execute($_, 'memberUID', $self->_get_ikey); 127 $res++; 128 } elsif ($member{$_}{c}) { 129 if (($user->get_c_field('department') || '') eq $self->id) { 130 $self->base->log(LA_WARN, 131 "Don't removing user %s from group %s: is it's department", 132 $user->id, $self->id); 133 next; 134 } 135 my $sth = $self->db->prepare_cached( 136 q{delete from group_attributes_users where value = ? and attr = ? and okey = ?} 137 ); 138 $sth->execute($_, 'memberUID', $self->_get_ikey); 139 $res++; 140 } # else {} # can't happend 141 } 154 $self->_set_group_members($data{$attr}); 142 155 next; 143 156 }; 144 157 $fdata{$attr} = $data{$attr}; 145 158 } 159 146 160 if (keys %fdata) { 147 161 my $setres = $self->SUPER::set_fields(%fdata); 162 if (exists($fdata{autoMemberFilter})) { 163 $res += $self->populate_dyn_group; 164 } 148 165 if (defined($setres)) { return $res + $setres; } 149 166 else { return; } … … 153 170 } 154 171 172 sub populate_dyn_group { 173 my ($self) = @_; 174 175 if (!$self->get_field('autoMemberFilter')) { 176 return; 177 } 178 $self->base->log(LA_DEBUG, 179 "Populating group %s from autoMemberFilter attribute", 180 $self->id 181 ); 182 my $filter = $self->get_field('autoMemberFilter'); 183 $self->_set_group_members( 184 [ $self->base->search_objects( 185 'user', 186 ref $filter ? @{ $filter } : $filter 187 ) ] 188 ) 189 } 190 155 191 1; 156 192 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SyncManager.pm
r1083 r1135 36 36 return; 37 37 }; 38 39 if ( !grep { 40 lc($ini->val($_, 'type', '')) eq 'basessynchro' 41 } $ini->Sections ) { 42 $ini->newval('_basesync', 'type', 'basessynchro'); 43 } 44 if ( !grep { 45 lc($ini->val($_, 'type', '')) eq 'refreshexpired' 46 } $ini->Sections ) { 47 $ini->newval('_refreshexpired', 'type', 'refreshexpired'); 48 } 49 50 $ini->newval('_automatedrequest', 'type', 'automatedrequest'); 38 51 39 52 bless { -
trunk/LATMOS-Accounts/man/man8/latmos-accounts-base-sql.pod
r1073 r1135 10 10 containing the server, the database name, user and password, etc... 11 11 12 =head1 FEATURES 13 14 =head2 Group AutoMemberFilter 15 16 Group objects contains users members by setting either C<members> or 17 C<memberUID> attributes. 18 19 Sometimes it can be usefull to have group automatically populated by arbitrary 20 rules. 21 22 This is possible by setting a filter in the C<autoMemberFilter> attribute, 23 The filter format is the same the one used by L<la-search>, the attribute is 24 multivaluable. 25 26 So for example one can create an account automatically a group containing people 27 having "Olivier" as first name: 28 29 autoMemberFilter: givenBame=Olivier 30 31 A probably more usefull example is a group containing people from two others 32 groups: 33 34 autoMemberFilter: memberOf=group1 35 autoMemberFilter: memberOf=group2 36 37 The C<members> or C<memberUID> attribute becomes read-only attribute once 38 C<autoMemberFilter> attribute is set. -
trunk/LATMOS-Accounts/sqldata/attributes.csv
r1099 r1135 28 28 "group","gidNumber","" 29 29 "group","expire","" 30 "group","autoMemberFilter" 30 31 "nethost","description","" 31 32 "nethost","owner",""
Note: See TracChangeset
for help on using the changeset viewer.