...
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   layout/projects-main.xml
#	modified:   projects/main.py
#
diff --git a/layout/projects-main.xml b/layout/projects-main.xml
index e845a90..a233094 100755
--- a/layout/projects-main.xml
+++ b/layout/projects-main.xml
@@ -1,143 +1,188 @@
 <vc>
     <body>
         <pad xmlns:bind="bind">
-            <vc>
-                <bind:collection bind="projects" id="projects">
+            <tabs>
+                <tab title="Users" id="users-config">
+                    <bind:collection 
+                            id="users"
+                            bind="users" 
+                            values="lambda c: c.values()"
+                            add_item="lambda i,c: c.update({i.name: i})"
+                            delete_item="lambda i,c: c.pop(i.name) if i.name != 'root' else None">
+                        <vc>
+                            <dt bind="__items">
+                                <dtr>
+                                    <dth text="Username" />
+                                    <dth text="Password" />
+                                    <dth text="Status" />
+                                    <dth text="On projects" />
+                                    <dth />
+                                </dtr>
+                            </dt>
+                            <bind:template>
+                                <dtr>
+                                    <dtd>
+                                        <hc>
+                                            <icon icon="user" />
+                                            <editable bind="name" style="mini" id="name-edit" />
+                                            <label bind="name" style="mini" id="name-label" />
+                                        </hc>
+                                    </dtd>
+                                    <dtd>
+                                        <editable id="password" placeholder="{Change password}" icon="lock" />
+                                    </dtd>
+                                    <dtd><label id="status"/></dtd>
+                                    <dtd><label id="projects"/></dtd>
+                                    <dtd>
+                                        <button bind="__delete" icon="remove" style="mini" warning="{Confirm deletion}" />
+                                    </dtd>
+                                </dtr>
+                            </bind:template>
+                            <button bind="__add" icon="plus" text="{Create}" />
+                        </vc>
+                    </bind:collection>
+                </tab>
+
+                <tab title="Projects">
                     <vc>
-                        <dt bind="__items" />
-                        <bind:template>
-                            <collapserow>
-                                <box>
-                                    <right>
-                                        <button bind="__delete" icon="remove" style="icon" warning="Confirm deletion" />
-                                    </right>
-                                    <hc>
-                                        <icon icon="suitcase" />
-                                        <box width="300">
-                                            <label bind="name" />
+                        <bind:collection bind="projects" id="projects">
+                            <vc>
+                                <dt bind="__items" />
+                                <bind:template>
+                                    <collapserow>
+                                        <box>
+                                            <right>
+                                                <button bind="__delete" icon="remove" style="icon" warning="Confirm deletion" />
+                                            </right>
+                                            <hc>
+                                                <icon icon="suitcase" />
+                                                <box width="300">
+                                                    <label bind="name" />
+                                                </box>
+                                                <label bind="description" />
+                                            </hc>   
                                         </box>
-                                        <label bind="description" />
-                                    </hc>   
-                                </box>
-                                
-                                <indent>
-                                    <tabs>
-                                        <tab title="Basic">
-                                            <vc>
-                                                <formgroup text="Options">
-                                                    <formline text="Name">
-                                                        <textbox bind="name" />
-                                                    </formline>
-                                                    <formline text="Description">
-                                                        <textbox bind="description" />
-                                                    </formline>
-                                                    <formline text="Long description">
-                                                        <codearea bind="long_description" width="300" />
-                                                    </formline>
-                                                </formgroup>
-                                                <formgroup text="Access control">
-                                                    <bind:collection id="permissions" bind="permissions">
-                                                        <formline text="Allow users">
-                                                            <vc>
-                                                                <vc bind="__items" />
-                                                                <button bind="__add" icon="plus" text="Add" />
-                                                            </vc>
-                                                        </formline>
-                                                        <bind:template>
-                                                            <vc>
-                                                                <box>
-                                                                    <right>
-                                                                        <button bind="__delete" icon="remove" style="icon" />
-                                                                    </right>
-                                                                    <hc>
-                                                                        <icon icon="key" />
-                                                                        <dropdown bind="user" id="user-dropdown" />
-                                                                    </hc>   
-                                                                </box>
-                                                            </vc>
-                                                        </bind:template>
-                                                    </bind:collection>
-                                                </formgroup>
-                                            </vc>
-                                        </tab>
+                                        
+                                        <indent>
+                                            <tabs>
+                                                <tab title="Basic">
+                                                    <vc>
+                                                        <formgroup text="Options">
+                                                            <formline text="Name">
+                                                                <textbox bind="name" />
+                                                            </formline>
+                                                            <formline text="Description">
+                                                                <textbox bind="description" />
+                                                            </formline>
+                                                            <formline text="Long description">
+                                                                <codearea bind="long_description" width="300" />
+                                                            </formline>
+                                                        </formgroup>
+                                                        <formgroup text="Access control">
+                                                            <bind:collection id="permissions" bind="permissions">
+                                                                <formline text="Allow users">
+                                                                    <vc>
+                                                                        <vc bind="__items" />
+                                                                        <button bind="__add" icon="plus" text="Add" />
+                                                                    </vc>
+                                                                </formline>
+                                                                <bind:template>
+                                                                    <vc>
+                                                                        <box>
+                                                                            <right>
+                                                                                <button bind="__delete" icon="remove" style="icon" />
+                                                                            </right>
+                                                                            <hc>
+                                                                                <icon icon="key" />
+                                                                                <dropdown bind="user" id="user-dropdown" />
+                                                                            </hc>   
+                                                                        </box>
+                                                                    </vc>
+                                                                </bind:template>
+                                                            </bind:collection>
+                                                        </formgroup>
+                                                    </vc>
+                                                </tab>
 
-                                        <tab title="Advanced">
-                                            <vc>
-                                                <formgroup text="Sharing">
-                                                    <formline text="Share using">
-                                                        <checkbox bind="share_nfs" text="NFS" />
-                                                        <checkbox bind="share_smb" text="Samba" />
-                                                        <checkbox bind="share_afp" text="AFP" />
-                                                    </formline>
-                                                </formgroup>
-                                                <formgroup text="Emulation">
-                                                    <formline text="Emulate">
-                                                        <checkbox bind="emulate_avid" text="Avid Workspace" />
-                                                    </formline>
-                                                </formgroup>
-                                            </vc>
-                                        </tab>
+                                                <tab title="Advanced">
+                                                    <vc>
+                                                        <formgroup text="Sharing">
+                                                            <formline text="Share using">
+                                                                <checkbox bind="share_nfs" text="NFS" />
+                                                                <checkbox bind="share_smb" text="Samba" />
+                                                                <checkbox bind="share_afp" text="AFP" />
+                                                            </formline>
+                                                        </formgroup>
+                                                        <formgroup text="Emulation">
+                                                            <formline text="Emulate">
+                                                                <checkbox bind="emulate_avid" text="Avid Workspace" />
+                                                            </formline>
+                                                        </formgroup>
+                                                    </vc>
+                                                </tab>
 
-                                        <tab title="Quotas">
-                                            <vc>
-                                                <formline text="Soft limit (Gb)">
-                                                    <textbox bind="quota_size_soft" type="integer" />
-                                                </formline>
-                                                <formline text="Hard limit (Gb)">
-                                                    <textbox bind="quota_size_hard" type="integer" />
-                                                </formline>
-                                            </vc>
-                                        </tab>
-                                    </tabs>
-                                </indent>
-                            </collapserow>
-                        </bind:template>
-                            
-                        <hc>
-                            <label text="Project name:" />
-                            <textbox id="new-project-name" />
-                            <button id="new-project" icon="plus" text="Create" />
-                        </hc>
-                    </vc>
-                </bind:collection>
+                                                <tab title="Quotas">
+                                                    <vc>
+                                                        <formline text="Soft limit (Gb)">
+                                                            <textbox bind="quota_size_soft" type="integer" />
+                                                        </formline>
+                                                        <formline text="Hard limit (Gb)">
+                                                            <textbox bind="quota_size_hard" type="integer" />
+                                                        </formline>
+                                                    </vc>
+                                                </tab>
+                                            </tabs>
+                                        </indent>
+                                    </collapserow>
+                                </bind:template>
+                                    
+                                <hc>
+                                    <label text="Project name:" />
+                                    <textbox id="new-project-name" />
+                                    <button id="new-project" icon="plus" text="Create" />
+                                </hc>
+                            </vc>
+                        </bind:collection>
 
 
-                <label style="bold" text="Quota usage" />
-                <bind:collection bind="projects" id="projects">
-                    <dt bind="__items">
-                        <dtr>
-                            <dth text="Name" />
-                            <dth text="Status" />
-                            <dth text="Used (Gb)" />
-                            <dth text="Soft Limit (Gb)" />
-                            <dth text="Hard Limit (Gb)" />
-                            <dth text="Usage" />
-                        </dtr>
-                    </dt>
-                    <bind:template>
-                        <dtr>
-                            <dtd>
-                                <label bind="name" />
-                            </dtd>
-                            <dtd>
-                                <label bind="quota_size_status" />
-                            </dtd>
-                            <dtd>
-                                <label bind="quota_size_current" />
-                            </dtd>
-                            <dtd>
-                                <label bind="quota_size_soft" />
-                            </dtd>
-                            <dtd>
-                                <label bind="quota_size_hard" />
-                            </dtd>
-                            <dtd>
-                                <progressbar bind="quota_size_usage" width="200" />
-                            </dtd>
-                        </dtr>
-                    </bind:template>
-                </bind:collection>
-            </vc>
+                        <label style="bold" text="Quota usage" />
+                        <bind:collection bind="projects" id="projects">
+                            <dt bind="__items">
+                                <dtr>
+                                    <dth text="Name" />
+                                    <dth text="Status" />
+                                    <dth text="Used (Gb)" />
+                                    <dth text="Soft Limit (Gb)" />
+                                    <dth text="Hard Limit (Gb)" />
+                                    <dth text="Usage" />
+                                </dtr>
+                            </dt>
+                            <bind:template>
+                                <dtr>
+                                    <dtd>
+                                        <label bind="name" />
+                                    </dtd>
+                                    <dtd>
+                                        <label bind="quota_size_status" />
+                                    </dtd>
+                                    <dtd>
+                                        <label bind="quota_size_current" />
+                                    </dtd>
+                                    <dtd>
+                                        <label bind="quota_size_soft" />
+                                    </dtd>
+                                    <dtd>
+                                        <label bind="quota_size_hard" />
+                                    </dtd>
+                                    <dtd>
+                                        <progressbar bind="quota_size_usage" width="200" />
+                                    </dtd>
+                                </dtr>
+                            </bind:template>
+                        </bind:collection>
+                    </vc>
+                </tab>
+            </tabs>
         </pad> 
     </body>
 
diff --git a/projects/main.py b/projects/main.py
index a414b74..6465aed 100755
--- a/projects/main.py
+++ b/projects/main.py
@@ -14,6 +14,8 @@ from ajenti.ui.binder import Binder
 from ajenti.plugins import manager
 
 from reconfigure.configs import SambaConfig, ExportsConfig, NetatalkConfig
+from reconfigure.items.ajenti import UserData
+
 import reconfigure.items.samba
 import reconfigure.items.netatalk
 import reconfigure.items.exports
@@ -39,7 +41,6 @@ class ElementsProject (object):
         if not hasattr(self, 'directory') or not self.directory:
             self.directory = slugify(self.name)
         defaults = {
-            'lock': None,
             'description': '',
             'long_description': '',
             'emulate_avid': False,
@@ -99,24 +100,29 @@ class ElementsProjectManager (BasePlugin):
         for p in self.projects:
             p.verify()
 
+        self.active_users = {}
+
     def get_project(self, name):
         for p in self.projects:
             if p.name == name:
                 return p
         return None
 
-    def lock(self, name, user):
+    def login(self, name, user):
         p = self.get_project(name)
-        if p.lock and p.lock != user:
-            return False
-        p.lock = user
+        self.active_users.setdefault(user, set())
+        if p:
+            self.active_users[user].add(p)
         return True
 
-    def unlock(self, name, user):
+    def logout(self, name, user):
         p = self.get_project(name)
-        if not p.lock or p.lock == user:
-            p.lock = None
-            return True
+        self.active_users.setdefault(user, set())
+        if p:
+            if p in self.active_users[user]:
+                self.active_users[user].remove(p)
+        else:
+            del self.active_users[user]
         return False
 
     def __call_quota(self, p, args):
@@ -254,12 +260,23 @@ class ElementsProjects (SectionPlugin):
 
         self.mgr = ElementsProjectManager.get(manager.context)
         self.binder = Binder(None, self)
+        self.binder_users = Binder(ajenti.config.tree, self.find('users-config'))
+
+        def post_user_bind(o, c, i, u):
+            u.find('name-edit').visible = i.name != 'root'
+            u.find('name-label').visible = i.name == 'root'
+            u.find('status').text = 'Online' if i.name in self.mgr.active_users else 'Offline'
+            u.find('projects').text = ', '.join(x.name for x in self.mgr.active_users.get(i.name, []))
+
+        self.find('users').post_item_bind = post_user_bind
+        self.find('users').new_item = lambda c: UserData()
 
     def on_page_load(self):
         self.refresh()
 
     def refresh(self):
         self.binder.reset(self.mgr).autodiscover().populate()
+        self.binder_users.reset().autodiscover().populate()
 
     @on('new-project', 'click')
     def on_new_project(self):
@@ -276,6 +293,8 @@ class ElementsProjects (SectionPlugin):
     @on('save', 'click')
     def save(self):
         self.binder.update()
+        self.binder_users.update()
+        ajenti.config.save()
         self.mgr.save()
         self.refresh()
 
@@ -297,17 +316,12 @@ class ElementsProjectServer (HttpPlugin):
         if endpoint[0] == 'test':
             return 'ok'
 
-        if endpoint[0] == 'lock-project':
-            self.mgr.lock(endpoint[1], context.session.identity)
-            return 'ok'
-
-        if endpoint[0] == 'unlock-project':
-            self.mgr.unlock(endpoint[1], context.session.identity)
+        if endpoint[0] == 'login':
+            self.mgr.login(endpoint[1], context.session.identity)
             return 'ok'
 
-        if endpoint[0] == 'unlock-all':
-            for p in self.mgr.projects:
-                self.mgr.unlock(p.name, context.session.identity)
+        if endpoint[0] == 'logout':
+            self.mgr.logout(endpoint[1], context.session.identity)
             return 'ok'
 
         if endpoint[0] == 'list-projects':
