From c629d185c0af2e0b0257b12db60e0c8ad9ccc696 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 14 Dec 2010 21:16:21 +0000 Subject: [PATCH] support new titlebar --- lam/lib/types/asteriskExt.inc | 19 +++++++++++++++ lam/lib/types/dhcp.inc | 39 ++++++++++++++++++++++++++++++ lam/lib/types/group.inc | 45 ++++++++++++++++++++++++++++++++++- lam/lib/types/host.inc | 40 +++++++++++++++++++++++++++++++ lam/lib/types/mailAlias.inc | 20 +++++++++++++++- lam/lib/types/netgroup.inc | 41 ++++++++++++++++++++++++++++++- lam/lib/types/smbDomain.inc | 41 ++++++++++++++++++++++++++++++- 7 files changed, 241 insertions(+), 4 deletions(-) diff --git a/lam/lib/types/asteriskExt.inc b/lam/lib/types/asteriskExt.inc index 6b9503b7..88511411 100644 --- a/lam/lib/types/asteriskExt.inc +++ b/lam/lib/types/asteriskExt.inc @@ -4,6 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) Copyright (C) 2009 Pozdnyak Pavel + 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -94,6 +95,24 @@ class asteriskExt extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New extension"); + } + // check if a common name is set + if (isset($attributes['cn'][0])) { + return htmlspecialchars($attributes['cn'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + } diff --git a/lam/lib/types/dhcp.inc b/lam/lib/types/dhcp.inc index d2bb1412..e344795f 100644 --- a/lam/lib/types/dhcp.inc +++ b/lam/lib/types/dhcp.inc @@ -97,6 +97,45 @@ class dhcp extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New DHCP"); + } + // check if a common name is set + if (isset($attributes['cn'][0])) { + return htmlspecialchars($attributes['cn'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarSubtitle($attributes) { + if ($attributes == null) { + return null; + } + $subtitle = ''; + // check if an description can be shown + if (isset($attributes['dhcpComments'][0])) { + $subtitle .= htmlspecialchars($attributes['dhcpComments'][0]); + } + if ($subtitle == '') { + return null; + } + return $subtitle; + } + } /** diff --git a/lam/lib/types/group.inc b/lam/lib/types/group.inc index 4863b671..9e4c9a1e 100644 --- a/lam/lib/types/group.inc +++ b/lam/lib/types/group.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2005 - 2009 Roland Gruber + Copyright (C) 2005 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -97,6 +97,49 @@ class group extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New group"); + } + // check if a group name is set + if (isset($attributes['gid'][0])) { + return htmlspecialchars($attributes['gid'][0]); + } + // check if a common name is set + if (isset($attributes['cn'][0])) { + return htmlspecialchars($attributes['cn'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarSubtitle($attributes) { + if ($attributes == null) { + return null; + } + $subtitle = ''; + // check if an description can be shown + if (isset($attributes['description'][0])) { + $subtitle .= htmlspecialchars($attributes['description'][0]); + } + if ($subtitle == '') { + return null; + } + return $subtitle; + } + } /** diff --git a/lam/lib/types/host.inc b/lam/lib/types/host.inc index 895a743e..426e128c 100644 --- a/lam/lib/types/host.inc +++ b/lam/lib/types/host.inc @@ -97,6 +97,46 @@ class host extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New host"); + } + // check if a user name is set + if (isset($attributes['uid'][0])) { + return htmlspecialchars($attributes['uid'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarSubtitle($attributes) { + if ($attributes == null) { + return null; + } + // check if a common name is set + if (isset($attributes['cn'][0])) { + return htmlspecialchars($attributes['cn'][0]); + } + // check if a display name is set + if (isset($attributes['displayName'][0])) { + return htmlspecialchars($attributes['displayName'][0]); + } + // fall back to default + return parent::getTitleBarSubtitle($attributes); + } + } diff --git a/lam/lib/types/mailAlias.inc b/lam/lib/types/mailAlias.inc index d715b71f..02f7d19d 100644 --- a/lam/lib/types/mailAlias.inc +++ b/lam/lib/types/mailAlias.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2005 - 2009 Roland Gruber + Copyright (C) 2005 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -93,6 +93,24 @@ class mailAlias extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New alias"); + } + // check if a common name is set + if (isset($attributes['cn'][0])) { + return htmlspecialchars($attributes['cn'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + } diff --git a/lam/lib/types/netgroup.inc b/lam/lib/types/netgroup.inc index 81f22bbf..b3d56293 100644 --- a/lam/lib/types/netgroup.inc +++ b/lam/lib/types/netgroup.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -95,6 +95,45 @@ class netgroup extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New group"); + } + // check if a common name is set + if (isset($attributes['cn'][0])) { + return htmlspecialchars($attributes['cn'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarSubtitle($attributes) { + if ($attributes == null) { + return null; + } + $subtitle = ''; + // check if an description can be shown + if (isset($attributes['description'][0])) { + $subtitle .= htmlspecialchars($attributes['description'][0]); + } + if ($subtitle == '') { + return null; + } + return $subtitle; + } + } diff --git a/lam/lib/types/smbDomain.inc b/lam/lib/types/smbDomain.inc index aba72075..13c192fc 100644 --- a/lam/lib/types/smbDomain.inc +++ b/lam/lib/types/smbDomain.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2005 - 2009 Roland Gruber + Copyright (C) 2005 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -93,6 +93,45 @@ class smbDomain extends baseType { ); } + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarTitle($attributes) { + if ($attributes == null) { + return _("New domain"); + } + // check if a domain name is set + if (isset($attributes['sambaDomainName'][0])) { + return htmlspecialchars($attributes['sambaDomainName'][0]); + } + // fall back to default + return parent::getTitleBarTitle($attributes); + } + + /** + * Returns the the title text for the title bar on the new/edit page. + * + * @param array $attributes list of LDAP attributes for the displayed account (null, if new account) + * @return String title text + */ + public function getTitleBarSubtitle($attributes) { + if ($attributes == null) { + return null; + } + $subtitle = ''; + // check if a SID can be shown + if (isset($attributes['sambaSID'][0])) { + $subtitle .= htmlspecialchars($attributes['sambaSID'][0]); + } + if ($subtitle == '') { + return null; + } + return $subtitle; + } + }