<NME> __init__.py
<BEF> # -*- coding: utf-8 -*-

from modoboa.lib import parameters, events
from django.utils.translation import ugettext as _, ugettext_lazy
from django.db.utils import DatabaseError
from models import Extension

parameters.register_admin("AUTHENTICATION_TYPE", type="list", deflt="local",
                          values=[('local', ugettext_lazy("Local")),
                                  ('ldap', "LDAP")],
                          help=ugettext_lazy("The backend used for authentication"))
parameters.register_admin("CREATE_DIRECTORIES", type="list_yesno", deflt="yes",
			  help=ugettext_lazy("Modoboa will handle mailbox creation on filesystem"))
parameters.register_admin("STORAGE_PATH", type="string", deflt="/var/vmail",
                          help=ugettext_lazy("Path to the root directory where messages are stored"))
parameters.register_admin("VIRTUAL_UID", type="string", deflt="vmail",
                          help=ugettext_lazy("UID of the virtual user which owns domains/mailboxes/messages on the filesystem"))
parameters.register_admin("VIRTUAL_GID", type="string", deflt="vmail",
                          help=ugettext_lazy("GID of the virtual user which owns domains/mailboxes/messages on the filesystem"))
parameters.register_admin("MAILBOX_TYPE", type="list", deflt="maildir",
                          values=[("maildir", "maildir"), ("mbox", "mbox")],
                          help=ugettext_lazy("Mailboxes storage format"))
parameters.register_admin("MAILDIR_ROOT", type="string", deflt=".maildir",
                          visible_if="MAILBOX_TYPE=maildir",
                          help=ugettext_lazy("Sub-directory (inside the mailbox) where messages are stored when using the maildir format"))
parameters.register_admin(
    "AUTO_ACCOUNT_REMOVAL", type="list_yesno", deflt="no",
    help=ugettext_lazy("When a mailbox is removed, also remove the associated account")
            ("plain", "plain")],
    help=ugettext_lazy("Scheme used to crypt mailbox passwords")
    )
parameters.register_admin("ITEMS_PER_PAGE", type="int", deflt=30,
                          help=ugettext_lazy("Number of displayed items per page"))

def enabled_applications():
    """Return the list of currently enabled extensions

<MSG> Added support for modification callbacks.

fix #264

<DFF> @@ -1,28 +1,60 @@
-# -*- coding: utf-8 -*-
+# coding: utf-8
 
 from modoboa.lib import parameters, events
 from django.utils.translation import ugettext as _, ugettext_lazy
 from django.db.utils import DatabaseError
-from models import Extension
+from models import Extension, Mailbox
 
-parameters.register_admin("AUTHENTICATION_TYPE", type="list", deflt="local",
-                          values=[('local', ugettext_lazy("Local")),
-                                  ('ldap', "LDAP")],
-                          help=ugettext_lazy("The backend used for authentication"))
-parameters.register_admin("CREATE_DIRECTORIES", type="list_yesno", deflt="yes",
-			  help=ugettext_lazy("Modoboa will handle mailbox creation on filesystem"))
-parameters.register_admin("STORAGE_PATH", type="string", deflt="/var/vmail",
-                          help=ugettext_lazy("Path to the root directory where messages are stored"))
-parameters.register_admin("VIRTUAL_UID", type="string", deflt="vmail",
-                          help=ugettext_lazy("UID of the virtual user which owns domains/mailboxes/messages on the filesystem"))
-parameters.register_admin("VIRTUAL_GID", type="string", deflt="vmail",
-                          help=ugettext_lazy("GID of the virtual user which owns domains/mailboxes/messages on the filesystem"))
-parameters.register_admin("MAILBOX_TYPE", type="list", deflt="maildir",
-                          values=[("maildir", "maildir"), ("mbox", "mbox")],
-                          help=ugettext_lazy("Mailboxes storage format"))
-parameters.register_admin("MAILDIR_ROOT", type="string", deflt=".maildir",
-                          visible_if="MAILBOX_TYPE=maildir",
-                          help=ugettext_lazy("Sub-directory (inside the mailbox) where messages are stored when using the maildir format"))
+def update_uid(value):
+    """VIRTUAL_UID modification callback
+
+    Update all mailboxes with the new UID value
+
+    :param value: the new UID
+    """
+    Mailbox.objects.all().update(uid=Mailbox.resolve_uid(value))
+
+def update_gid(value):
+    """VIRTUAL_GID modification callback
+
+    Update all mailboxes with the new GID value
+    
+    :param value: the new GID
+    """
+    Mailbox.objects.all().update(gid=Mailbox.resolve_gid(value))
+
+parameters.register_admin(
+    "AUTHENTICATION_TYPE", type="list", deflt="local",
+    values=[('local', ugettext_lazy("Local")),
+            ('ldap', "LDAP")],
+    help=ugettext_lazy("The backend used for authentication")
+)
+parameters.register_admin(
+    "CREATE_DIRECTORIES", type="list_yesno", deflt="yes",
+    help=ugettext_lazy("Modoboa will handle mailbox creation on filesystem")
+    )
+parameters.register_admin(
+    "STORAGE_PATH", type="string", deflt="/var/vmail",
+    help=ugettext_lazy("Path to the root directory where messages are stored")
+)
+parameters.register_admin(
+    "VIRTUAL_UID", type="string", deflt="vmail", modify_cb=update_uid,
+    help=ugettext_lazy("UID of the virtual user which owns domains/mailboxes/messages on the filesystem")
+    )
+parameters.register_admin(
+    "VIRTUAL_GID", type="string", deflt="vmail", modify_cb=update_gid,
+    help=ugettext_lazy("GID of the virtual user which owns domains/mailboxes/messages on the filesystem")
+    )
+parameters.register_admin(
+    "MAILBOX_TYPE", type="list", deflt="maildir",
+    values=[("maildir", "maildir"), ("mbox", "mbox")],
+    help=ugettext_lazy("Mailboxes storage format")
+)
+parameters.register_admin(
+    "MAILDIR_ROOT", type="string", deflt=".maildir",
+    visible_if="MAILBOX_TYPE=maildir",
+    help=ugettext_lazy("Sub-directory (inside the mailbox) where messages are stored when using the maildir format")
+    )
 parameters.register_admin(
     "AUTO_ACCOUNT_REMOVAL", type="list_yesno", deflt="no",
     help=ugettext_lazy("When a mailbox is removed, also remove the associated account")
@@ -36,8 +68,10 @@ parameters.register_admin(
             ("plain", "plain")],
     help=ugettext_lazy("Scheme used to crypt mailbox passwords")
     )
-parameters.register_admin("ITEMS_PER_PAGE", type="int", deflt=30,
-                          help=ugettext_lazy("Number of displayed items per page"))
+parameters.register_admin(
+    "ITEMS_PER_PAGE", type="int", deflt=30,
+    help=ugettext_lazy("Number of displayed items per page")
+    )
 
 def enabled_applications():
     """Return the list of currently enabled extensions

Added support for modification callbacks.