Index: /WAeUP_SRP/trunk/PatchBasicWidgetsCPSStringWidget.py
===================================================================
--- /WAeUP_SRP/trunk/PatchBasicWidgetsCPSStringWidget.py	(revision 879)
+++ /WAeUP_SRP/trunk/PatchBasicWidgetsCPSStringWidget.py	(revision 880)
@@ -3,3 +3,3 @@
 from Products.CPSSchemas.BasicWidgets import CPSEmailWidget
 CPSStringWidget.display_width = 30
-CPSEmailWidgetdisplay_width = 30
+CPSEmailWidget.display_width = 30
Index: /WAeUP_SRP/trunk/PatchCPSUserFolderUserFolderWithGroups.py
===================================================================
--- /WAeUP_SRP/trunk/PatchCPSUserFolderUserFolderWithGroups.py	(revision 880)
+++ /WAeUP_SRP/trunk/PatchCPSUserFolderUserFolderWithGroups.py	(revision 880)
@@ -0,0 +1,126 @@
+from AccessControl import ClassSecurityInfo
+from ExtensionClass import Base
+from Acquisition import Implicit
+from Acquisition import aq_base, aq_parent, aq_inner
+
+security = ClassSecurityInfo()
+
+security.declarePublic('getRolesInContext')
+def getRolesInContext(self, object):
+    """Return the list of roles assigned to the user,
+       including local roles assigned in context of
+       the passed in object."""
+    name = self.getUserName()
+    roles = self.getRoles()
+    groups = self.getGroups() + ('role:Anonymous',)
+    if 'Authenticated' in roles:
+        groups = groups + ('role:Authenticated',)
+    local = {}
+    stop_loop = 0
+    object = aq_inner(object)
+    while 1:
+        # Collect all roles info
+        lrd = {}
+        local_roles = getattr(object, '__ac_local_roles__', None)
+        if local_roles:
+            if callable(local_roles):
+                local_roles = local_roles() or {}
+            for r in local_roles.get(name, ()):
+                if r:
+                    lrd[r] = None
+        local_group_roles = getattr(object, '__ac_local_group_roles__', None)
+        if local_group_roles:
+            if callable(local_group_roles):
+                local_group_roles = local_group_roles() or {}
+            for g in groups:
+                for r in local_group_roles.get(g, ()):
+                    if r:
+                        lrd[r] = None
+        lr = lrd.keys()
+        # Positive role assertions
+        for r in lr:
+            if r[0] != '-':
+                if not local.has_key(r):
+                    local[r] = 1 # acquired role
+        # Negative (blocking) role assertions
+        for r in lr:
+            if r[0] == '-':
+                r = r[1:]
+                if not r:
+                    # role '-' blocks all acquisition
+                    stop_loop = 1
+                    break
+                if not local.has_key(r):
+                    local[r] = 0 # blocked role
+        if stop_loop:
+            break
+        inner = getattr(object, 'aq_inner', object)
+        parent = getattr(inner, 'aq_parent', None)
+        if parent is not None:
+            object = parent
+            continue
+        if hasattr(object, 'im_self'):
+            object = object.im_self
+            object = getattr(object, 'aq_inner', object)
+            continue
+        break
+    roles = list(roles)
+    for r, v in local.items():
+        if v: # only if not blocked
+            roles.append(r)
+    ## patch to assign dynamic roles for WAeUP
+    info = self.getStudentInfo()
+    while 1:
+        if info is None:
+            break
+        if info['course'] is None:
+            break
+        res = self.portal_catalog(portal_type="Department",id=info['course_doc'].department)
+        if len(res) != 1:
+            break
+        dynamic_roles = self.getRolesInContext(res[0].getObject())
+        for dr in self.getDynamicRoles():
+            if dr in dynamic_roles:
+                roles.append(dr)
+        break
+    return roles
+
+security.declarePublic('allowed')
+def allowed(self, object, object_roles=None):
+    """Check whether the user has access to object. The user must
+       have one of the roles in object_roles to allow access."""
+
+    if object_roles is _what_not_even_god_should_do:
+        return 0
+
+    # Short-circuit the common case of anonymous access.
+    if object_roles is None or 'Anonymous' in object_roles:
+        return 1
+
+    # Provide short-cut access if object is protected by 'Authenticated'
+    # role and user is not nobody
+    if 'Authenticated' in object_roles and (
+        self.getUserName() != 'Anonymous User'):
+        return 1
+
+    # Check for a role match with the normal roles given to
+    # the user, then with local roles only if necessary. We
+    # want to avoid as much overhead as possible.
+    user_roles = self.getRoles()
+    for role in object_roles:
+        if role in user_roles:
+            if self._check_context(object):
+                return 1
+            return None
+
+    # Check local roles, calling getRolesInContext to avoid too much
+    # complexity, at the expense of speed.
+    for role in self.getRolesInContext(object):
+        if role in object_roles:
+            return 1
+
+    return None
+
+from Products.CPSUserFolder import UserFolderWithGroups  
+UserFolderWithGroups.getRolesInContext = getRolesInContext
+UserFolderWithGroups.allowed = allowed
Index: /WAeUP_SRP/trunk/__init__.py
===================================================================
--- /WAeUP_SRP/trunk/__init__.py	(revision 879)
+++ /WAeUP_SRP/trunk/__init__.py	(revision 880)
@@ -15,4 +15,5 @@
 import PatchCPSSchemasAttributeStorageAdapter
 import PatchBasicWidgetsCPSStringWidget
+import PatchCPSUserFolderUserFolderWithGroups
 # Only for CPS 3.4.1. In 3.4.2 and later this should be fixed.
 import PatchCPSDefaultImportExport
Index: /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 879)
+++ /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 880)
@@ -102,5 +102,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -110,5 +112,7 @@
 
   <guard>
-   <guard-expression>here/owner_guard</guard-expression>
+   <guard-role>Owner</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -118,5 +122,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -135,5 +141,7 @@
 
   <guard>
-   <guard-expression>here/owner_guard</guard-expression>
+   <guard-role>Owner</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
   <transition-behavior behavior_id="allow-sub-create"/>
@@ -144,5 +152,7 @@
 
   <guard>
-   <guard-expression>here/owner_guard</guard-expression>
+   <guard-role>Owner</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -152,5 +162,7 @@
 
   <guard>
-   <guard-expression>here/owner_guard</guard-expression>
+   <guard-role>Owner</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -160,5 +172,7 @@
 
   <guard>
-   <guard-expression>here/owner_guard</guard-expression>
+   <guard-role>Owner</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -168,5 +182,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -176,5 +192,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -184,5 +202,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -192,5 +212,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -200,5 +222,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -208,5 +232,7 @@
 
   <guard>
-   <guard-expression>here/clearance_officer_guard</guard-expression>
+   <guard-role>ClearanceOfficer</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -216,5 +242,7 @@
 
   <guard>
-   <guard-expression>here/owner_guard</guard-expression>
+   <guard-role>Owner</guard-role>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
@@ -223,5 +251,4 @@
   <description>Time of the last transition</description>
   <default>
-
    <expression>state_change/getDateTime</expression>
   </default>
Index: /WAeUP_SRP/trunk/skins/waeup_default/getDynamicRoles.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/getDynamicRoles.py	(revision 880)
+++ /WAeUP_SRP/trunk/skins/waeup_default/getDynamicRoles.py	(revision 880)
@@ -0,0 +1,15 @@
+## Script (Python) "getDynamicRoles"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id: $
+"""
+return the dynamic roles
+"""
+return ('ClearanceOfficer','CourseAdviser')
+
Index: eUP_SRP/trunk/skins/waeup_student/clearance_officer_guard.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/clearance_officer_guard.py	(revision 879)
+++ 	(revision )
@@ -1,30 +1,0 @@
-## Script (Python) "clearance_officer_guard"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=
-##title=
-##
-# $Id$
-"""
-check if the current action is allowed for the clearance_officer
-
-"""
-wftool = context.portal_workflow
-mtool = context.portal_membership
-member = mtool.getAuthenticatedMember()
-roles = member.getRolesInContext(context)
-
-def intersection(a,b):
-    r = []
-    for i in a:
-        if i in b:
-            r.append(i)
-    return r
-if intersection(('Manager', 'SectionManager'),roles)\
-                  or context.isClearanceOfficer():
-    return True
-return False
-
Index: eUP_SRP/trunk/skins/waeup_student/owner_guard.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/owner_guard.py	(revision 879)
+++ 	(revision )
@@ -1,28 +1,0 @@
-## Script (Python) "owner_guard"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=
-##title=
-##
-# $Id$
-"""
-check if the current action is allowed for the + owner
-"""
-
-mtool = context.portal_membership
-member = mtool.getAuthenticatedMember()
-roles = member.getRolesInContext(context)
-
-def intersection(a,b):
-    r = []
-    for i in a:
-        if i in b:
-            r.append(i)
-    return r
-
-if len(intersection(('Manager', 'SectionManager','Owner'),roles)) > 0:
-    return True
-return True
