Commits

Zhang Huangbin committed 259fa6b

[ldap] Able to manage first/last name in user/admin profile page.

Comments (0)

Files changed (5)

 = 0.2.1 =
     * Improvements:
+        + [ldap] Able to manage first/last name in user/admin profile page.
         + New password schemes support: SSHA, SSHA512.
           Note: SSHA512 requires Dovecot-2.0 (and later), Python-2.5 (or
           later).

libs/ldaplib/attrs.py

                       'domainGlobalAdmin', 'enabledService',
                       'objectClass',
                      ]
-ADMIN_ATTRS_ALL = ADMIN_SEARCH_ATTRS
+ADMIN_ATTRS_ALL = ADMIN_SEARCH_ATTRS + ['sn', 'givenName']
 
 # ---------------------------------------------------------
 # Domain related.
 
 USER_ATTRS_ALL = [
     'mail', 'cn', 'accountStatus', 'mailQuota', 'jpegPhoto',
+    'sn', 'givenName',
     'enabledService', 'memberOfGroup', 'employeeNumber', 'preferredLanguage',
     'telephoneNumber', 'userRecipientBccAddress', 'userSenderBccAddress',
     'mailForwardingAddress', 'mtaTransport',

templates/default/ldap/admin/profile.html

 
 {% set entry = profile[0][1] %}
 {% set cn = entry.get('cn', [''])[0].decode('utf-8') %}
+{% set first_name = entry.get('givenName', [''])[0].decode('utf-8') |e %}
+{% set last_name = entry.get('sn', [''])[0].decode('utf-8') |e %}
 {% set accountStatus = entry.get('accountStatus', ['disabled'])[0] %}
 
 {% block breadcrumb %}
                                 <div class="bt-space0">&nbsp;</div>
                             {% endif %}
 
-                            {{ display_input_cn(cn=cn, accountType='admin') }}
+                            {{ display_input_cn(cn,
+                                                tooltip=_('Full name'),
+                                                show_first_last_name=true,
+                                                first_name=first_name,
+                                                last_name=last_name) }}
                             {{ display_preferred_language(value=entry.get('preferredLanguage', ['en_US'])[0], languagemaps=languagemaps) }}
                         </div>
                     </div>{# .columns #}

templates/default/ldap/user/profile.html

     {% set mobile = entries.get('mobile', [''])[0] |e %}
     {% set telephoneNumber = entries.get('telephoneNumber', []) %}
     {% set mailQuota = '%d' % (entries.get('mailQuota', [0])[0] |int /1024/1024) %}
+
+    {% set first_name = entries.get('givenName', [''])[0].decode('utf-8') |e %}
+    {% set last_name = entries.get('sn', [''])[0].decode('utf-8') |e %}
 {% endif %}
 
 {% block breadcrumb %}
                 ) }}
 
                 <div class="bt-space10"></div>
-                {{ display_input_cn(cn) }}
+                {{ display_input_cn(cn,
+                                    tooltip=_('Full name'),
+                                    show_first_last_name=true,
+                                    first_name=first_name,
+                                    last_name=last_name) }}
                 {{ display_preferred_language(value=entries.get('preferredLanguage', ['en_US'])[0], languagemaps=languagemaps) }}
                 {{ display_quota(value=mailQuota, show_value_in_input=true) }}
 

templates/default/macros/general.html

         });
 
         {# tooltip #}
-        $("a[title], img[title], span[title]").tooltip({
+        $("a[title], img[title], span[title], input[title]").tooltip({
             position: "top center",
             offset: [-5, 0],
             predelay: 300,
             opacity: 1
         });
 
-        $("input[title]").tooltip({
-            position: "center right",
-            offset: [-2, 10],
-            delay: 100,
-            effect: "fade",
-            opacity: 1
-        });
-
         {% if 'tablesorter' in plugins %}
             $(".tablesorter").tablesorter(
                 {% if nonSortedCols |length > 0 %}
 {%- endmacro %}
 
 
-{% macro display_input_cn(cn='', name='cn', accountType='user', tooltip='', size="size-250") -%}
+{% macro display_input_cn(cn='', name='cn', accountType='user', tooltip='', size="size-250", show_first_last_name=false, first_name='', last_name='') -%}
+
     {% if cn is sameas none %}
         {% set cn = '' %}
     {% endif %}
             <input type="text" name="{{ name |e }}" value="{{ cn |e }}" size="35" class="text" {% if tooltip != '' %}title="{{ tooltip |e }}"{% endif %} />
         </span>
     </div>
+
+    {% if show_first_last_name is sameas true %}
+    <div class="form-field clear">
+        <h4 class="size-250 fl-space">&nbsp;</h4>
+        <span class="clean-padding bt-space20">
+            <input type="text" name="first_name" value="{{ first_name |e }}" size="15" class="text" title="{{ _('First name') }}" />
+            <input type="text" name="last_name" value="{{ last_name |e }}" size="15" class="text" title="{{ _('Last name') }}"/>
+        </span>
+    </div>
+    {% endif %}
 {%- endmacro %}
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.