Index: /trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm
===================================================================
--- /trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm	(revision 1781)
+++ /trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm	(revision 1782)
@@ -138,4 +138,5 @@
             managedAlsoBy
             autoMemberFilter
+            autoFromSutype
             sutype
             services
@@ -208,4 +209,5 @@
             comment
             autoMemberFilter
+            autoFromSutype
             autoExclude
             create
Index: /trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm
===================================================================
--- /trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm	(revision 1781)
+++ /trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm	(revision 1782)
@@ -161,4 +161,14 @@
                 label => l('Automatics filters'),
             },
+            autoFromSutype => {
+                multiple => 1,
+                set => sub {
+                    my ($self, $data) = @_;
+                    $self->object->set_fields($self->name, $data) or return;
+                    $self->object->populate_dyn_aliases;
+                    return 1;
+                },
+                label => l('From group type'),
+            },
             autoExclude => {
                 multiple => 1,
@@ -227,5 +237,6 @@
 
 
-    if (!$self->get_field('autoMemberFilter')) {
+    if (!$self->get_field('autoMemberFilter')
+     && !$self->get_field('autoFromSutype') ) {
         return 0;
     }
@@ -246,14 +257,25 @@
 
     my %email = $self->base->attributes_summary_by_object('user', 'mail');
-
-    my $filter = $self->get_field('autoMemberFilter');
+    my %users;
+
     my $autoex = $self->get_field('autoExclude');
     my %exclude = map { $_ => 1 } grep { $_  } (ref $autoex ? @$autoex : $autoex);
 
-    my @users = $self->base->search_objects('user', ref $filter ? @{ $filter } : $filter);
+    if (my $filter = $self->get_field('autoMemberFilter')) {
+        $users{$_} = 1 foreach( $self->base->search_objects('user', ref $filter ? @{ $filter } : $filter) );
+    }
+
+    if (my $filter = $self->get_field('autoFromSutype')) {
+        my @suTypeFilter = map { "sutype=$_" } (ref $filter ? @{ $filter } : $filter);
+        foreach my $group ($self->base->search_objects('group', @suTypeFilter)) {
+            foreach ($self->base->search_objects('user', "memberOf=$group")) {
+                $users{$_} = 1;
+            }
+        }
+    }
 
     my %forward = ();
 
-    foreach my $user (@users) {
+    foreach my $user (keys %users) {
         $exclude{$user} and next;
         $email{$user} or next;
Index: /trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
===================================================================
--- /trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm	(revision 1781)
+++ /trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm	(revision 1782)
@@ -46,5 +46,6 @@
                     $_[0] && 
                     (($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/
-                     || $_[0]->_get_c_field('autoMemberFilter'))
+                     || $_[0]->_get_c_field('autoMemberFilter')
+                     || $_[0]->_get_c_field('autoFromSutype'))
                     ? 1 : 0 
                 },
@@ -82,5 +83,6 @@
                     $_[0] && 
                     (($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/
-                     || $_[0]->_get_c_field('autoMemberFilter'))
+                     || $_[0]->_get_c_field('autoMemberFilter')
+                     || $_[0]->_get_c_field('autoFromSutype'))
                     ? 1 : 0 
                 },
@@ -125,4 +127,5 @@
                 monitored => 1,
                 label => l('Structure'),
+                multiple => 1,
             },
             autoMemberFilter => {
@@ -135,4 +138,15 @@
                 },
                 label => l('Automatics filters'),
+            },
+            autoFromSutype => {
+                reference => 'sutype',
+                multiple => 1,
+                set => sub {
+                    my ($self, $data) = @_;
+                    $self->object->set_fields($self->name, $data) or return;
+                    $self->object->populate_dyn_group;
+                    return 1;
+                },
+                label => l('From group type'),
             },
             label => {
@@ -206,18 +220,36 @@
     my ($self) = @_;
 
-    if (!$self->get_field('autoMemberFilter')) {
+    if (
+           !$self->get_field('autoMemberFilter')
+        && !$self->get_field('autoFromSutype')) {
         return 0;
     }
     $self->base->log(LA_DEBUG,
-        "Populating group %s from autoMemberFilter attribute",
+        "Populating group %s from autoMemberFilter/autoFromSutype attribute",
         $self->id
     );
-    my $filter = $self->get_field('autoMemberFilter');
-    my $res = $self->_set_group_members(
-        [ $self->base->search_objects(
-            'user',
-            ref $filter ? @{ $filter } : $filter
-        ) ]
-    );
+
+    my %users;
+
+    if (my $filter = $self->get_field('autoFromSutype')) {
+        my @suTypeFilter = map { "sutype=$_" } (ref $filter ? @{ $filter } : $filter);
+        foreach my $group ($self->base->search_objects('group', @suTypeFilter)) {
+            foreach ($self->base->search_objects('user', "memberOf=$group")) {
+                $users{$_} = 1;
+            }
+        }
+    }
+
+    
+    if (my $filter = $self->get_field('autoMemberFilter')) {
+        foreach ($self->base->search_objects(
+                'user',
+                ref $filter ? @{ $filter } : $filter)) {
+            $users{$_} = 1;
+        }
+    }
+
+    my $res = $self->_set_group_members([ keys %users ]);
+
     $res;
 }
Index: /trunk/LATMOS-Accounts/man/man8/latmos-accounts-base-sql.pod
===================================================================
--- /trunk/LATMOS-Accounts/man/man8/latmos-accounts-base-sql.pod	(revision 1781)
+++ /trunk/LATMOS-Accounts/man/man8/latmos-accounts-base-sql.pod	(revision 1782)
@@ -213,2 +213,20 @@
 The C<forward> attributes is automatically set with email address of selected
 user, user w/o email address are ignored.
+
+=head2 Group AutoFromSutype
+
+Group object can be tagged with the C<sutype> attribute.
+
+When C<autoFromSutype> is set the group member will be computed from member of
+all groups having C<sutype> set this value.
+
+The goal of this attribute is to setup magic group like with the
+C<autoMemberFilter> but working even a new group is created.
+
+=head2 Aliases AutoFromSutype
+
+This attribute allow to create automatics dynamics aliases according filter
+rules exactly like L<Group AutoFromType> works.
+
+The C<forward> attributes is automatically set with email address of selected
+user, user w/o email address are ignored.
