diff --git a/lam/config/lam.conf_sample b/lam/config/lam.conf_sample index 434e3504..0605208a 100644 --- a/lam/config/lam.conf_sample +++ b/lam/config/lam.conf_sample @@ -11,39 +11,9 @@ admins: cn=Manager,dc=my-domain,dc=com # password to change these preferences via webfrontend passwd: lam -# suffix of users -# e.g. ou=People,dc=yourdomain,dc=org -usersuffix: ou=people,dc=my-domain,dc=com - -# suffix of groups -# e.g. ou=Groups,dc=yourdomain,dc=org -groupsuffix: ou=groups,dc=my-domain,dc=com - -# suffix of Samba hosts -# e.g. ou=machines,dc=yourdomain,dc=org -hostsuffix: ou=machines,dc=my-domain,dc=com - -# suffix of Samba 3 domains -# e.g. ou=domains,dc=yourdomain,dc=org -domainsuffix: ou=domains,dc=my-domain,dc=com - -# list of attributes to show in user list -# entries can either be predefined values (e.g. '#cn' or '#uid') -# or individual ones (e.g. 'uid:User ID' or 'host:Host Name') -# values have to be seperated by semicolons -userlistAttributes: #uid;#givenName;#sn;#uidNumber;#gidNumber - -# list of attributes to show in group list -# entries can either be predefined values (e.g. '#cn' or '#gidNumber') -# or individual ones (e.g. 'cn:Group Name') -# values have to be seperated by semicolons -grouplistAttributes: #cn;#gidNumber;#memberUID;#description - -# list of attributes to show in host list -# entries can either be predefined values (e.g. '#cn' or '#uid') -# or individual ones (e.g. 'cn:Host Name') -# values have to be seperated by semicolons -hostlistAttributes: #cn;#description;#uidNumber;#gidNumber +# suffix of tree view +# e.g. dc=yourdomain,dc=org +treesuffix: dc=yourdomain,dc=org # maximum number of rows to show in user/group/host lists maxlistentries: 30 @@ -60,15 +30,6 @@ scriptServer: # Number of minutes LAM caches LDAP searches. cachetimeout: 5 -# List of used user modules -usermodules: shadowAccount,inetOrgPerson,posixAccount,sambaSamAccount - -# List of used group modules -groupmodules: posixGroup,sambaGroupMapping - -# List of used host modules -hostmodules: account,sambaSamAccount,posixAccount - # Module settings modules: posixAccount_minUID: 10000 @@ -80,3 +41,23 @@ modules: posixGroup_maxGID: 20000 modules: posixGroup_pwdHash: SSHA modules: posixAccount_pwdHash: SSHA +# List of active account types. +activeTypes: user,group,host,smbDomain + + +types: suffix_user: ou=People,dc=my-domain,dc=com +types: attr_user: #uid;#givenName;#sn;#uidNumber;#gidNumber +types: modules_user: inetOrgPerson,posixAccount,shadowAccount,sambaSamAccount + +types: suffix_group: ou=group,dc=my-domain,dc=com +types: attr_group: #cn;#gidNumber;#memberUID;#description +types: modules_group: posixGroup,sambaGroupMapping + +types: suffix_host: ou=machines,dc=my-domain,dc=com +types: attr_host: #cn;#description;#uidNumber;#gidNumber +types: modules_host: account,posixAccount,sambaSamAccount + +types: suffix_smbDomain: ou=domains,dc=my-domain,dc=com +types: attr_smbDomain: sambaDomainName:Domain name;sambaSID:Domain SID +types: modules_smbDomain: sambaDomain + diff --git a/lam/config/profiles/default.mailAlias b/lam/config/profiles/default.mailAlias new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/lam/config/profiles/default.mailAlias @@ -0,0 +1 @@ + diff --git a/lam/config/profiles/default.smbDomain b/lam/config/profiles/default.smbDomain new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/lam/config/profiles/default.smbDomain @@ -0,0 +1 @@ + diff --git a/lam/docs/devel/index.htm b/lam/docs/devel/index.htm index 71b6ec8b..fc89d400 100644 --- a/lam/docs/devel/index.htm +++ b/lam/docs/devel/index.htm @@ -90,7 +90,8 @@ browser

Howtos


diff --git a/lam/docs/devel/type_basics.htm b/lam/docs/devel/type_basics.htm new file mode 100644 index 00000000..8e6a351b --- /dev/null +++ b/lam/docs/devel/type_basics.htm @@ -0,0 +1,70 @@ + + + + Type HowTo - Basic concepts + + + +
+

Type HowTo - Basic concepts
+

+
+
+

+

1. Licensing

+LAM is licensed under the GNU +General Public License. This means your plugins need a compatible +license.
+LAM is distributed with a copy of the GPL license.
+
+
+

2. Naming and position in directory structure

+Type names are usually named after the group of accounts they manage. +However, you can use any name you want, it should be short and +containing only a-z and 0-9. The type name is only shown in the +configuration dialog, on all other pages LAM will show a provided alias name.
+All type modules are stored in lib/types. +The filename must end with .inc +and the file must have the same name as its inside class.
+
+Example: +Our example module will provide the class +smbDomain, +therefore the file will be called lib/types/smbDomain.inc.
+
+
+

3. Defining the class

+All type classes have baseType +as parent class. This provides common functionality and dummy functions +for all required class functions.
+
+Example:
+
+ + + + + + +
/**
+* The account type for Samba domains.
+*
+* @package types
+*/
+class
smbDomain extends baseType {
+
+}
+
+
+
+

+
+
+ + diff --git a/lam/docs/devel/type_css.htm b/lam/docs/devel/type_css.htm new file mode 100644 index 00000000..b70c071a --- /dev/null +++ b/lam/docs/devel/type_css.htm @@ -0,0 +1,39 @@ + + + + Type HowTo - CSS file + + + +
+

Type HowTo - CSS file

+
+

+Every account type has its own style sheet where it can define colors +and fonts.
+
+
+

1. File name

+The CSS files are saved in style/. +Your file must be named type_<your +type>.css.
+
+Example:
+
+The smbDomain type has the +CSS file style/type_smbDomain.css.
+
+
+

2. Contents

+Take the type_user.css file as template. It is well documented.
+You have to replace all occurrences of "user" with your account type.
+
+Example:
+
+Take a look at type_user.css and type_smbDomain.css.
+
+
+ + diff --git a/lam/docs/devel/type_general.htm b/lam/docs/devel/type_general.htm new file mode 100644 index 00000000..8691ea74 --- /dev/null +++ b/lam/docs/devel/type_general.htm @@ -0,0 +1,90 @@ + + + + Type HowTo - General type options + + + +
+

Type HowTo - General type options
+

+
+
+

+

1. Alias name

+The type name is very limited, therefore every type has an alias name. This alias name has no limitations and +can be translated. It may contain special characters but make sure that +it does not contain HTML special characters like "<".
+
+The alias name is specified +with getAlias().
+
+Example:
+
+Our smbDomain type will get +the alias "Samba domains".
+
+ + + + + + +
    /**
+    * Returns the alias name of this account type.
+    *
+    * @return string alias name
+    */
+    function + getAlias() {
+        return _("Samba domains");
+    }
+
+
+
+

2. Description
+

+Each type has a description so that the user knows what accounts he can +manage with that type. The description is displayed in the LAM +configuration editor.
+
+The description is specified with getDescription().
+
+Example:
+
+Our smbDomain type has the +description "Samba 3 domain entries".
+
+ + + + + + +
    /**
+    * Returns the description of this account type.
+    *
+    * @return string description
+    */
+    function + getDescription() {
+        return _("Samba 3 domain +entries");
+    }
+
+
+
+ +

+
+
+ + diff --git a/lam/docs/devel/type_icon.htm b/lam/docs/devel/type_icon.htm new file mode 100644 index 00000000..66a43937 --- /dev/null +++ b/lam/docs/devel/type_icon.htm @@ -0,0 +1,31 @@ + + + + Type HowTo - Icon + + + +
+

Type HowTo - Icon

+
+

+You have to provide an icon for your account type. This icon is +displayed in the upper frame next to the link to your account list.
+The format of the image must be PNG +and the size should be between 20x20 +and 25x25 pixels.
+
+The file is stored in graphics/ +with the file name <your +type>.png.
+
+
+Example:
+
+The smbDomain type has the +icon graphics/smbDomain.png.
+
+
+ + diff --git a/lam/docs/devel/type_index.htm b/lam/docs/devel/type_index.htm new file mode 100644 index 00000000..9e4618b9 --- /dev/null +++ b/lam/docs/devel/type_index.htm @@ -0,0 +1,36 @@ + + + + LAM type HowTo + + + +
+

Type HowTo

+
+
If you write new account modules they +may not fit in the existing group of account types (user, group, host, +...). In this case you can easily create a new account type.
+This document provides a step-by-step description to build a type +module. The smbDomain +module which handles Samba domains is used as example.
+
+
+
+

1. Defining the type
+

+

1. Basic concepts
+

+

2. General type options

+

3. Custom list view

+
+
+

2. The default profile

+
+

3. List icon

+
+

4. Type specific CSS file

+
+
+ + diff --git a/lam/docs/devel/type_list.htm b/lam/docs/devel/type_list.htm new file mode 100644 index 00000000..832752d7 --- /dev/null +++ b/lam/docs/devel/type_list.htm @@ -0,0 +1,181 @@ + + + + Type HowTo - Custom list view + + + +
+

Type HowTo - Custom list view
+

+
+
+

+

1. Default list attributes
+

+Here you can specify what attributes are shown as default in the list +view.
+
+The default attributes are +specified +with getDefaultListAttributes().
+
+Example:
+
+Our smbDomain type will show +the attributes "#sambaDomainName;#sambaSID" by default.
+
+ + + + + + +
    /**
+    * Returns the default attribute list for this +account type.
+    *
+    * @return string attribute list
+    */
+    function getDefaultListAttributes() {
+        return +"#sambaDomainName;#sambaSID";
+    }
+
+
+
+

2. Pretranslated attribute descriptions
+

+You can provide translated descriptions for common attributes. This way +the user only specifies the attributes and LAM will show a description +for each language.
+
+The descriptions are specified with getListAttributeDescriptions().
+
+Example:
+
+Our smbDomain type has +descriptions for sambaSID and sambaDomainName.
+
+ + + + + + +
    /**
+    * Returns a list of attributes which have a +translated description.
+    * This is used for the head row in the list view.
+    *
+    * @return array list of descriptions
+    */
+    function getListAttributeDescriptions() {
+        return array(
+            "sambaSID" +=> _("Domain SID"),
+            +"sambaDomainName" => _("Domain name")
+            );
+    }
+
+
+
+
+

3. Specifying a custom list view

+The default list view has only very generic labels for the buttons and +navigation bar. So you should at least provide some new labels which +fit to your type.
+
+The class name of your list view is specified with getListClassName().
+
+Example:
+
+Our smbDomain type sets the +list view class to lamSmbDomainList. +The list class is defined in the same file as your type class +(smbDomain.inc in this case).
+The labels are set in the constructor. Do not forget to call the parent +constructor first.
+
+If you want to change more than just the labels, take a look at lib/lists.inc and lib/types/user.inc. When a list is +displayed then the showPage() +function is called. You can overwrite this function to display a +completly new list or just one of the other functions.
+
+ + + + + + +
/**
+* Returns the class name for the list object.
+*
+* @return string class name
+*/
+function getListClassName() +{
+    return "lamSmbDomainList";
+}
+
+
+/**
+ * Generates the list view.
+ *
+ * @package lists
+ * @author Roland Gruber
+ *
+ */
+class lamSmbDomainList +extends lamList {
+
+    /**
+     * Constructor
+     *
+     * @param string $type account type
+     * @return lamList list object
+     */
+    function lamSmbDomainList($type) {
+        parent::lamList($type);
+        $this->labels = array(
+            'nav' => +_("%s domain(s) found"),
+            +'error_noneFound' => _("No domains found!"),
+            'newEntry' +=> _("New domain"),
+            'deleteEntry' +=> _("Delete domain"),
+            'createPDF' +=> _("Create PDF for selected domain(s)"),
+            'createPDFAll' +=> _("Create PDF for all domains"));
+    }
+
+}
+
+
+
+
+
+ +

+
+
+ + diff --git a/lam/docs/devel/type_profile.htm b/lam/docs/devel/type_profile.htm new file mode 100644 index 00000000..d1545ab0 --- /dev/null +++ b/lam/docs/devel/type_profile.htm @@ -0,0 +1,27 @@ + + + + Type HowTo - Default profile + + + +
+

Type HowTo - Default profile

+
+

+You have to provide a default profile for your account type. If you do +not want to specify default values then just provide an empty file.
+Save your profile as default.<your +type> in config/profiles.
+
+
+Example:
+
+The smbDomain type has only +an empty default profile. It is saved as config/profiles/default.smbDomain.
+
+
+ + diff --git a/lam/docs/devel/types-specification.htm b/lam/docs/devel/types-specification.htm new file mode 100644 index 00000000..13fceee2 --- /dev/null +++ b/lam/docs/devel/types-specification.htm @@ -0,0 +1,144 @@ + + + + + Type specification + + + +

This document describes the type +interface for LDAP Account Manager

+
+Account types are used to manage a group of accounts by grouping one or +more account modules. Examples for account types are user, group, host +and smbDomain.
+
+

1. Location and naming of types
+

+All LAM types are placed in lib/types/ and are named "<class +name>.inc".
+E.g. if you create a new type and its class name is "myUser" then the +filename would be "myUser.inc".
+
+The class name of a type must contain only a-z, A-Z, 0-9, -, and _.
+All type classes should extend the baseType class.
+
+

2. Functions

+

2.1. getAlias
+

+
+ + + + + + +
function getAlias()
+
+
+Returns the alias name for +this type. E.g. the alias for smbDomain is "Samba domains".
+
+

2.2. getDescription
+

+
+ + + + + + +
function getDescription()
+
+
+Returns a description for the +account type. This should be a short sentence describing the account +type.
+
+

2.3. getListClassName
+

+
+ + + + + + +
function getListClassName()
+
+
+Here you can specify your own class to handle the list view. The class +must be a subclass of lamList.
+
+

2.4. getDefaultListAttributes
+

+
+ + + + + + +
function getDefaultListAttributes()
+
+
+Returns the default setting +for the displayed list attributes. It is used as default for config and +the syntax is equal to the config setting.
+
+

2.5. getListAttributeDescriptions
+

+
+ + + + + + +
function getListAttributeDescriptions()
+
+
+Returns a hash array which contains predefined, translated descriptions +of LDAP attributes.
+
+
+Example:

+
+return array(
+    "sambaSID" => _("Domain SID"),
+    "sambaDomainName" => _("Domain name")
+    );
+
+
+
+
+
+ + + diff --git a/lam/graphics/group.png b/lam/graphics/group.png new file mode 100644 index 00000000..3e767c7c Binary files /dev/null and b/lam/graphics/group.png differ diff --git a/lam/graphics/mailAlias.png b/lam/graphics/mailAlias.png new file mode 100644 index 00000000..bd77affe Binary files /dev/null and b/lam/graphics/mailAlias.png differ diff --git a/lam/graphics/smbDomain.png b/lam/graphics/smbDomain.png new file mode 100644 index 00000000..2769a479 Binary files /dev/null and b/lam/graphics/smbDomain.png differ diff --git a/lam/help/help.inc b/lam/help/help.inc index 2c083288..91c2e7a6 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -153,21 +153,7 @@ $helpArray = array ( "601" => array ("ext" => "FALSE", "Headline" => _("OU-Editor") . " - " . _("New organizational unit"), "Text" => _("This will create a new organizational unit under the selected one.")), "602" => array ("ext" => "FALSE", "Headline" => _("OU-Editor") . " - " . _("Delete organizational unit"), - "Text" => _("This will delete the selected organizational unit. The OU has to be empty.")), - "651" => array ("ext" => "FALSE", "Headline" => _("Domain name"), - "Text" => _("The name of your Windows domain or workgroup.")), - "652" => array ("ext" => "FALSE", "Headline" => _("Suffix"), - "Text" => _("The domain entry will be saved under this suffix.")), - "653" => array ("ext" => "FALSE", "Headline" => _("Domain SID"), - "Text" => _("The SID of your Samba server. Get it with \"net getlocalsid\".")), - "654" => array ("ext" => "FALSE", "Headline" => _("Next RID"), - "Text" => _("Next RID to use when creating accounts.")), - "655" => array ("ext" => "FALSE", "Headline" => _("Next User RID"), - "Text" => _("Next RID to use when creating user accounts.")), - "656" => array ("ext" => "FALSE", "Headline" => _("Next Group RID"), - "Text" => _("Next RID to use when creating groups.")), - "657" => array ("ext" => "FALSE", "Headline" => _("Algorithmic RID Base"), - "Text" => _("Used for calculating RIDs from UID/GID. Do not change if unsure.")) + "Text" => _("This will delete the selected organizational unit. The OU has to be empty.")) ); diff --git a/lam/lib/account.inc b/lam/lib/account.inc index b4b5bae2..e02a58bd 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -357,50 +357,50 @@ function pwd_is_enabled($hash) { else return true; } - /** - * Returns an array with all Samba 3 domain entries under the given suffix - * - * @param string $suffix search suffix - * @return array list of samba3domain objects - */ - function search_domains($suffix) { - $ret = array(); - $attr = array("DN", "sambaDomainName", "sambaSID", "sambaNextRid", "sambaNextGroupRid", - "sambaNextUserRid", "sambaAlgorithmicRidBase"); - $sr = @ldap_search($_SESSION['ldap']->server(), $suffix, "objectClass=sambaDomain", $attr); - if ($sr) { - $units = ldap_get_entries($_SESSION['ldap']->server, $sr); - // delete count entry - unset($units['count']); - // extract attributes - for ($i = 0; $i < sizeof($units); $i++) { - $ret[$i] = new samba3domain(); - $ret[$i]->dn = $units[$i]['dn']; - $ret[$i]->name = $units[$i]['sambadomainname'][0]; - $ret[$i]->SID = $units[$i]['sambasid'][0]; - if (isset($units[$i]['sambanextrid'][0])) $ret[$i]->nextRID = $units[$i]['sambanextrid'][0]; - if (isset($units[$i]['sambanextgrouprid'][0])) $ret[$i]->nextGroupRID = $units[$i]['sambanextgrouprid'][0]; - if (isset($units[$i]['sambanextuserrid'][0])) $ret[$i]->nextUserRID = $units[$i]['sambanextuserrid'][0]; - if (isset($units[$i]['sambaalgorithmicridbase'][0])) $ret[$i]->RIDbase = $units[$i]['sambaalgorithmicridbase'][0]; - } - // sort array by domain name - usort($ret, "cmp_domain"); +/** +* Returns an array with all Samba 3 domain entries under the given suffix +* +* @return array list of samba3domain objects +*/ +function search_domains() { + $suffix = $_SESSION['config']->get_Suffix('smbDomain'); + $ret = array(); + $attr = array("DN", "sambaDomainName", "sambaSID", "sambaNextRid", "sambaNextGroupRid", + "sambaNextUserRid", "sambaAlgorithmicRidBase"); + $sr = @ldap_search($_SESSION['ldap']->server(), $suffix, "objectClass=sambaDomain", $attr); + if ($sr) { + $units = ldap_get_entries($_SESSION['ldap']->server, $sr); + // delete count entry + unset($units['count']); + // extract attributes + for ($i = 0; $i < sizeof($units); $i++) { + $ret[$i] = new samba3domain(); + $ret[$i]->dn = $units[$i]['dn']; + $ret[$i]->name = $units[$i]['sambadomainname'][0]; + $ret[$i]->SID = $units[$i]['sambasid'][0]; + if (isset($units[$i]['sambanextrid'][0])) $ret[$i]->nextRID = $units[$i]['sambanextrid'][0]; + if (isset($units[$i]['sambanextgrouprid'][0])) $ret[$i]->nextGroupRID = $units[$i]['sambanextgrouprid'][0]; + if (isset($units[$i]['sambanextuserrid'][0])) $ret[$i]->nextUserRID = $units[$i]['sambanextuserrid'][0]; + if (isset($units[$i]['sambaalgorithmicridbase'][0])) $ret[$i]->RIDbase = $units[$i]['sambaalgorithmicridbase'][0]; } - return $ret; + // sort array by domain name + usort($ret, "cmp_domain"); } + return $ret; +} - /** - * Helper function to sort the domains - * - * @param string $a first argument to compare - * @param string $b second argument to compare - * @return integer 0 if equal, 1 if $a is greater, -1 if $b is greater - */ - function cmp_domain($a, $b) { - if ($a->name == $b->name) return 0; - elseif ($a->name == max($a->name, $b->name)) return 1; - else return -1; - } +/** +* Helper function to sort the domains +* +* @param string $a first argument to compare +* @param string $b second argument to compare +* @return integer 0 if equal, 1 if $a is greater, -1 if $b is greater +*/ +function cmp_domain($a, $b) { + if ($a->name == $b->name) return 0; + elseif ($a->name == max($a->name, $b->name)) return 1; + else return -1; +} /** @@ -498,7 +498,7 @@ function get_preg($argument, $regexp) { $pregexpr = '/^(([a-zA-Z0-9\\.\\_-])+(,[a-zA-Z0-9\\.\\_-])*)*$/'; break; case "domainname": // Windows Domainname - $pregexpr = '/^([a-z0-9\\.\\_-])+$/'; + $pregexpr = '/^([A-Za-z0-9\\.\\_-])+$/'; break; case "unixhost": // Unix hosts $pregexpr = '/^([a-z0-9,\\.\\_-])*$/'; @@ -533,6 +533,8 @@ function get_preg($argument, $regexp) { case 'dn': // LDAP DN $pregexpr = '/^([^=,]+=[^=,]+)(,([^=,]+=[^=,]+))*$/'; break; + case 'domainSID': // Samba domain SID + $pregexpr = "/^S\\-[0-9]\\-[0-9]\\-[0-9]{2,2}\\-[0-9]+\\-[0-9]+\\-[0-9]+$/"; } if ($pregexpr!='') if (preg_match($pregexpr, $argument)) { diff --git a/lam/lib/baseType.inc b/lam/lib/baseType.inc new file mode 100644 index 00000000..9c905d09 --- /dev/null +++ b/lam/lib/baseType.inc @@ -0,0 +1,90 @@ + \ No newline at end of file diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 69e3a5d0..6a2ed81c 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -33,6 +33,8 @@ $Id$ include_once("status.inc"); /** Used to get module information. */ include_once("modules.inc"); +/** Used to get type information. */ +include_once("types.inc"); /** * Sets language settings for automatic translation @@ -129,28 +131,9 @@ class Config { /** Password to edit preferences */ var $Passwd; - /** LDAP suffix for users */ - var $usersuffix; - - /** LDAP suffix for groups */ - var $groupsuffix; - - /** LDAP suffix for Samba hosts */ - var $hostsuffix; - - /** LDAP suffix for Samba 3 domains */ - var $domainsuffix; - /** LDAP suffix for tree view */ var $treesuffix; - /** Attributes that are shown in the user list */ - var $userlistAttributes; - /** Attributes that are shown in the group list */ - var $grouplistAttributes; - /** Attributes that are shown in the host list */ - var $hostlistAttributes; - /** Maximum number of rows shown in user/group/host lists */ var $maxlistentries; @@ -160,6 +143,9 @@ class Config { /** module settings */ var $moduleSettings = array(); + /** type settings */ + var $typeSettings = array(); + /** * Path to external lamdaemon script on server where it is executed * @@ -179,20 +165,16 @@ class Config { /** LDAP cache timeout */ var $cachetimeout; - var $usermodules = "posixAccount,shadowAccount,quota"; - /** Account modules for groups */ - var $groupmodules = "posixGroup,quota"; - /** Account modules for hosts */ - var $hostmodules = "account,sambaSamAccount"; + /** Active account types */ + var $activeTypes = "user,group,host,smbDomain"; /** Name of configuration file */ var $file; /** List of all settings in config file */ - var $settings = array("ServerURL", "Passwd", "Admins", "usersuffix", "groupsuffix", "hostsuffix", "treesuffix", - "domainsuffix", "userlistAttributes", "grouplistAttributes", "hostlistAttributes", "maxlistentries", + var $settings = array("ServerURL", "Passwd", "Admins", "treesuffix", "maxlistentries", "defaultLanguage", "scriptPath", "scriptServer", "cachetimeout", - "usermodules", "groupmodules", "hostmodules", "modules"); + "modules", "activeTypes", "types"); /** @@ -233,7 +215,13 @@ class Config { if (strtolower(substr($line, 0, $keylen + 2)) == "modules: ") { $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2); $pos = strpos($option, ":"); - $this->moduleSettings[substr($option, 0, $pos)] = explode("+::+", substr($option, $pos + 2, strlen($option) - $pos - 2)); + $this->moduleSettings[substr($option, 0, $pos)] = explode("+::+", substr($option, $pos + 2)); + } + // type settings + elseif (strtolower(substr($line, 0, $keylen + 2)) == "types: ") { + $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2); + $pos = strpos($option, ":"); + $this->typeSettings[substr($option, 0, $pos)] = substr($option, $pos + 2); } // general settings else { @@ -246,7 +234,7 @@ class Config { fclose($file); } // check modules - $scopes = array('user', 'group', 'host'); + $scopes = $this->get_ActiveTypes(); for ($s = 0; $s < sizeof($scopes); $s++) { $scope = $scopes[$s]; $moduleVar = $scope . "modules"; @@ -293,6 +281,15 @@ class Config { $file_array[$i] = "modules: " . $name . ": " . implode("+::+", $this->moduleSettings[$name]) . "\n"; $mod_saved[] = $name; // mark keyword as saved } + // type settings + elseif (strtolower(substr($line, 0, $keylen + 2)) == "types: ") { + $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2); + $pos = strpos($option, ":"); + $name = substr($option, 0, $pos); + if (!isset($this->typeSettings[$name])) continue; + $file_array[$i] = "types: " . $name . ": " . $this->typeSettings[$name] . "\n"; + $mod_saved[] = $name; // mark keyword as saved + } // general settings else { $file_array[$i] = $keyword . ": " . $this->$keyword . "\n"; @@ -308,30 +305,14 @@ class Config { if (!in_array("Admins", $saved)) array_push($file_array, "\n\n# list of users who are allowed to use LDAP Account Manager\n" . "# names have to be seperated by semicolons\n" . "# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "admins: " . $this->Admins . "\n"); - if (!in_array("usersuffix", $saved)) array_push($file_array, "\n\n# suffix of users\n" . - "# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->usersuffix . "\n"); - if (!in_array("groupsuffix", $saved)) array_push($file_array, "\n\n# suffix of groups\n" . - "# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->groupsuffix . "\n"); - if (!in_array("hostsuffix", $saved)) array_push($file_array, "\n\n# suffix of hosts\n" . - "# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->hostsuffix . "\n"); - if (!in_array("domainsuffix", $saved)) array_push($file_array, "\n\n# suffix of Samba 3 domains\n" . - "# e.g. ou=domains,dc=yourdomain,dc=org\n" . "domainsuffix: " . $this->domainsuffix . "\n"); if (!in_array("treesuffix", $saved)) array_push($file_array, "\n\n# suffix of tree view\n" . "# e.g. dc=yourdomain,dc=org\n" . "treesuffix: " . $this->treesuffix . "\n"); - if (!in_array("userlistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in user list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" . - "\n# or individual ones (e.g. 'uid:User ID' or 'host:Host Name')\n# values have to be seperated by semicolons\n" . "userlistAttributes: " . $this->userlistAttributes . "\n"); - if (!in_array("grouplistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in group list\n# entries can either be predefined values (e.g. '#cn' or '#gidNumber')" . - "\n# or individual ones (e.g. 'cn:Group Name')\n# values have to be seperated by semicolons\n" . "grouplistAttributes: " . $this->grouplistAttributes . "\n"); - if (!in_array("hostlistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in host list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" . - "\n# or individual ones (e.g. 'cn:Host Name')\n# values have to be seperated by semicolons\n" . "hostlistAttributes: " . $this->hostlistAttributes . "\n"); if (!in_array("maxlistentries", $saved)) array_push($file_array, "\n\n# maximum number of rows to show in user/group/host lists\n" . "maxlistentries: " . $this->maxlistentries . "\n"); if (!in_array("defaultLanguage", $saved)) array_push($file_array, "\n\n# default language (a line from config/language)\n" . "defaultLanguage: " . $this->defaultLanguage . "\n"); if (!in_array("scriptPath", $saved)) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath . "\n"); if (!in_array("scriptServer", $saved)) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer . "\n"); if (!in_array("cachetimeout", $saved)) array_push($file_array, "\n\n# Number of minutes LAM caches LDAP searches.\n" . "cacheTimeout: " . $this->cachetimeout . "\n"); - if (!in_array("usermodules", $saved)) array_push($file_array, "\n\n# List of used user modules\n" . "usermodules: " . $this->usermodules . "\n"); - if (!in_array("groupmodules", $saved)) array_push($file_array, "\n\n# List of used group modules\n" . "groupmodules: " . $this->groupmodules . "\n"); - if (!in_array("hostmodules", $saved)) array_push($file_array, "\n\n# List of used host modules\n" . "hostmodules: " . $this->hostmodules . "\n"); + if (!in_array("activeTypes", $saved)) array_push($file_array, "\n\n# List of active account types.\n" . "activeTypes: " . $this->activeTypes . "\n"); // check if all module settings were added $m_settings = array_keys($this->moduleSettings); for ($i = 0; $i < sizeof($m_settings); $i++) { @@ -339,54 +320,27 @@ class Config { array_push($file_array, "modules: " . $m_settings[$i] . ": " . implode("+::+", $this->moduleSettings[$m_settings[$i]]) . "\n"); } } + // check if all type settings were added + $t_settings = array_keys($this->typeSettings); + for ($i = 0; $i < sizeof($t_settings); $i++) { + if (!in_array($t_settings[$i], $mod_saved)) { + array_push($file_array, "types: " . $t_settings[$i] . ": " . $this->typeSettings[$t_settings[$i]] . "\n"); + } + } $file = fopen($conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); fclose($file); @chmod ($conffile, 0600); + StatusMessage("INFO", _("Your settings were successfully saved.") , " (" . $conffile . ")"); } else { - StatusMessage("ERROR", "", _("Cannot open config file!") . " (" . $conffile . ")"); + StatusMessage("ERROR", _("Cannot open config file!") . " (" . $conffile . ")"); exit; } } } - /** Prints current preferences */ - function printconf() { - echo "" . _("Server address") . ": " . $this->ServerURL . "
\n"; - echo "" . _("Cache timeout") . ": " . $this->cachetimeout . "
\n"; - echo "" . _("UserSuffix") . ": " . $this->usersuffix . "
\n"; - echo "" . _("GroupSuffix") . ": " . $this->groupsuffix . "
\n"; - echo "" . _("HostSuffix") . ": " . $this->hostsuffix . "
\n"; - echo "" . _("DomainSuffix") . ": " . $this->domainsuffix . "
\n"; - echo "" . _("TreeSuffix") . ": " . $this->treesuffix . "
\n"; - echo "" . _("Attributes in User List") . ": " . $this->userlistAttributes . "
\n"; - echo "" . _("Attributes in Group List") . ": " . $this->grouplistAttributes . "
\n"; - echo "" . _("Attributes in Host List") . ": " . $this->hostlistAttributes . "
\n"; - echo "" . _("Maximum list entries") . ": " . $this->maxlistentries . "
\n"; - echo "" . _("Default language") . ": " . $this->defaultLanguage . "
\n"; - echo "" . _("Path to external script") . ": " . $this->scriptPath . "
\n"; - echo "" . _("Server of external script") . ": " . $this->scriptServer . "
\n"; - echo "" . _("List of valid users") . ": " . $this->Admins . "
\n"; - echo "" . _("User modules") . ": " . $this->usermodules . "
\n"; - echo "" . _("Group modules") . ": " . $this->groupmodules . "
\n"; - echo "" . _("Host modules") . ": " . $this->hostmodules . "

\n"; - echo "" . _("Module settings") . ":
\n"; - echo "\n"; - } - // functions to read/write preferences /** @@ -471,24 +425,12 @@ class Config { * @return string the LDAP suffix */ function get_Suffix($scope) { - switch ($scope) { - case 'user': - return $this->usersuffix; - break; - case 'group': - return $this->groupsuffix; - break; - case 'host': - return $this->hostsuffix; - break; - case 'domain': - return $this->domainsuffix; - break; - case 'tree': - return $this->treesuffix; - break; + if ($scope == "tree") { + return $this->treesuffix; + } + else { + return $this->typeSettings['suffix_' . $scope]; } - return ""; } /** @@ -503,22 +445,11 @@ class Config { elseif (!is_string($value)) { return false; } - switch ($scope) { - case 'user': - $this->usersuffix = $value; - break; - case 'group': - $this->groupsuffix = $value; - break; - case 'host': - $this->hostsuffix = $value; - break; - case 'domain': - $this->domainsuffix = $value; - break; - case 'tree': - $this->treesuffix = $value; - break; + if ($scope == "tree") { + $this->treesuffix = $value; + } + else { + $this->typeSettings['suffix_' . $scope] = $value; } return true; } @@ -530,20 +461,7 @@ class Config { * @return string the attribute list */ function get_listAttributes($scope) { - switch ($scope) { - case 'user': - return $this->userlistAttributes; - break; - case 'group': - return $this->grouplistAttributes; - break; - case 'host': - return $this->hostlistAttributes; - break; - default: - return ''; - break; - } + return $this->typeSettings['attr_' . $scope]; } /** @@ -555,20 +473,7 @@ class Config { */ function set_listAttributes($value, $scope) { if (is_string($value) && eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $value)) { - switch ($scope) { - case 'user': - $this->userlistAttributes = $value; - break; - case 'group': - $this->grouplistAttributes = $value; - break; - case 'host': - $this->hostlistAttributes = $value; - break; - default: - return false; - break; - } + $this->typeSettings['attr_' . $scope] = $value; return true; } else { @@ -576,20 +481,6 @@ class Config { } } - /** - * Sets the list of attributes to show in group list - * - * @param string $value new attribute string - * @return boolean true if $value has correct format - */ - function set_grouplistAttributes($value) { - if (is_string($value) && eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $value)) { - $this->grouplistAttributes = $value; - } - else return false; - return true; - } - /** * Returns the maximum number of rows in user/group/host lists * @@ -718,21 +609,12 @@ class Config { * @return array user modules */ function get_AccountModules($scope) { - switch ($scope) { - case 'user': - return explode(",", $this->usermodules); - break; - case 'group': - return explode(",", $this->groupmodules); - break; - case 'host': - return explode(",", $this->hostmodules); - break; - default: - return array(); - break; + if (isset($this->typeSettings["modules_" . $scope])) { + return explode(",", $this->typeSettings["modules_" . $scope]); + } + else { + return array(); } - } /** @@ -752,19 +634,7 @@ class Config { // check depends/conflicts if (check_module_conflicts($modules, getModulesDependencies($scope)) != false) return false; if (check_module_depends($modules, getModulesDependencies($scope)) != false) return false; - switch ($scope) { - case 'user': - $this->usermodules = implode(",", $modules); - break; - case 'group': - $this->groupmodules = implode(",", $modules); - break; - case 'host': - $this->hostmodules = implode(",", $modules); - break; - default: - break; - } + $this->typeSettings["modules_" . $scope] = implode(",", $modules); return true; } @@ -789,6 +659,45 @@ class Config { return $this->moduleSettings; } + /** + * Returns a list of active account types. + * + * @return array list of types + */ + function get_ActiveTypes() { + return explode(",", $this->activeTypes); + } + + /** + * Sets the list of active types. + * + * @param array list of types + */ + function set_ActiveTypes($types) { + $this->activeTypes = implode(",", $types); + } + + /** + * Sets the settings for the account types. + * + * @param array $settings list of type setting array(name => value) + * @return boolean true if $settings has correct format + */ + function set_typeSettings($settings) { + if (!is_array($settings)) return false; + $this->typeSettings = $settings; + return true; + } + + /** + * Returns a list of saved type settings + * + * @return array list of settings: array(name => value) + */ + function get_typeSettings() { + return $this->typeSettings; + } + } diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index e713aaae..3c72319b 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -29,72 +29,209 @@ $Id$ * @author Roland Gruber */ +/** Used to get type information. */ +include_once("types.inc"); +/** Used to get PDF information. */ +include_once("pdfstruct.inc"); + + /** -* Builds the regular expressions from the filter values. -* -* @param array $attributes list of displayed attributes -* @return array filter data array($attribute => array('regex' => $reg, 'original' => $orig)) -* $reg is the regular expression to use, $orig the user's unmodified input string -*/ -function listBuildFilter($attributes) { - $filter = array(); - for ($i = 0; $i < sizeof($attributes); $i++) { - if (isset($_POST["filter" . strtolower($attributes[$i])]) && eregi('^([0-9a-z _\\*\\$-])+$', $_POST["filter" . strtolower($attributes[$i])])) { - $filter[$attributes[$i]]['original'] = $_POST["filter" . strtolower($attributes[$i])]; - $filter[$attributes[$i]]['regex'] = $_POST["filter" . strtolower($attributes[$i])]; - // replace special characters - $filter[$attributes[$i]]['regex'] = str_replace("*", "(.)*", $filter[$attributes[$i]]['regex']); - $filter[$attributes[$i]]['regex'] = str_replace('$', '[$]', $filter[$attributes[$i]]['regex']); - // add string begin and end - $filter[$attributes[$i]]['regex'] = "^" . $filter[$attributes[$i]]['regex'] . "$"; - } + * Generates the list view. + * + * @package lists + * @author Roland Gruber + * + */ +class lamList { + + /** Account type */ + var $type; + + /** current page number */ + var $page = 1; + + /** list of LDAP attributes */ + var $attrArray = array(); + + /** list of attribute descriptions */ + var $descArray = array(); + + /** maximum count of entries per page */ + var $maxPageEntries = 10; + + /** sort column name */ + var $sortColumn; + + /** LDAP suffix */ + var $suffix; + + /** refresh page switch */ + var $refresh = true; + + /** LDAP entries */ + var $entries; + + /** filter string to include in URL */ + var $filterText; + + /** list of possible LDAP suffixes(organizational units) */ + var $possibleSuffixes; + + /** list of account specific labels */ + var $labels; + + /** + * Constructor + * + * @param string $type account type + * @return lamList list object + */ + function lamList($type) { + $this->type = $type; + $this->labels = array( + 'nav' => _("%s object(s) found"), + 'error_noneFound' => _("No objects found!"), + 'newEntry' => _("New object"), + 'deleteEntry' => _("Delete object"), + 'createPDF' => _("Create PDF for selected object(s)"), + 'createPDFAll' => _("Create PDF for all objects")); + } + + /** + * Prints the HTML code to display the list view. + */ + function showPage() { + // do POST actions + $this->listDoPost(); + // get some parameters + $this->listGetParams(); + // print HTML head + $this->listPrintHeader(); + // refresh data if needed + if ($this->refresh) $this->listRefreshData(); + // filter entries + $filteredEntries = $this->listFilterAccounts(); + // sort rows by sort column + if ($filteredEntries) { + $filteredEntries = $this->listSort($filteredEntries); + } + // show form + echo ("
type . "&norefresh=true\" method=\"post\">\n"); + // draw account list if accounts were found + if (sizeof($filteredEntries) > 0) { + // navigation bar + $this->listDrawNavigationBar(sizeof($filteredEntries)); + echo ("
\n"); + // account table head + $this->listPrintTableHeader(); + // account table body + $this->listPrintTableBody($filteredEntries); + // navigation bar + $this->listDrawNavigationBar(sizeof($filteredEntries)); + echo ("
\n"); + // print combobox with possible sub-DNs + $this->listShowOUSelection(); + // buttons + $this->listPrintButtons(false); + } + else { + // account table head + $this->listPrintTableHeader(); + echo "
\n"; + // print combobox with possible sub-DNs + $this->listShowOUSelection(); + echo ("
\n"); + $this->listPrintButtons(true); + } + echo ("
\n"); + echo "\n"; } - return $filter; -} - -/** -* Removes all entries which do not fit to the filter. -* -* @param array $entries list of accounts -* @param array $filter attribute filter -* @return array filtered list of accounts -*/ -function listFilterAccounts($entries, $filter) { - $attributes = array_keys($filter); - for ($r = 0; $r < sizeof($entries); $r++) { - for ($a = 0; $a < sizeof($attributes); $a++) { - // check if filter fits - $found = false; - for ($i = 0; $i < sizeof($entries[$r][$attributes[$a]]); $i++) { - if (eregi($filter[$attributes[$a]]['regex'], $entries[$r][$attributes[$a]][$i])) { - $found = true; + /** + * Builds the regular expressions from the filter values. + * + * @return array filter data array($attribute => array('regex' => $reg, 'original' => $orig)) + * $reg is the regular expression to use, $orig the user's unmodified input string + */ + function listBuildFilter() { + $filter = array(); + // build filter array + for ($i = 0; $i < sizeof($this->attrArray); $i++) { + if (isset($_POST["filter" . strtolower($this->attrArray[$i])]) && eregi('^([0-9a-z _\\*\\$-])+$', $_POST["filter" . strtolower($this->attrArray[$i])])) { + $filter[$this->attrArray[$i]]['original'] = $_POST["filter" . strtolower($this->attrArray[$i])]; + $filter[$this->attrArray[$i]]['regex'] = $_POST["filter" . strtolower($this->attrArray[$i])]; + // replace special characters + $filter[$this->attrArray[$i]]['regex'] = str_replace("*", "(.)*", $filter[$this->attrArray[$i]]['regex']); + $filter[$this->attrArray[$i]]['regex'] = str_replace('$', '[$]', $filter[$this->attrArray[$i]]['regex']); + // add string begin and end + $filter[$this->attrArray[$i]]['regex'] = "^" . $filter[$this->attrArray[$i]]['regex'] . "$"; + } + } + // save filter string + $filterAttributes = array_keys($filter); + $searchFilter = array(); + for ($i = 0; $i < sizeof($filterAttributes); $i++) { + $searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original']; + } + if (sizeof($searchFilter) > 0) { + $searchFilter = "&" . implode("&", $searchFilter); + } + else { + $searchFilter = ""; + } + $this->filterText = $searchFilter; + return $filter; + } + + + /** + * Removes all entries which do not fit to the filter. + * + * @return array filtered list of accounts + */ + function listFilterAccounts() { + $entries = $this->entries; + $filter = $this->listBuildFilter(); + $attributes = array_keys($filter); + for ($r = 0; $r < sizeof($entries); $r++) { + for ($a = 0; $a < sizeof($attributes); $a++) { + // check if filter fits + $found = false; + for ($i = 0; $i < sizeof($entries[$r][$attributes[$a]]); $i++) { + if (eregi($filter[$attributes[$a]]['regex'], $entries[$r][$attributes[$a]][$i])) { + $found = true; + break; + } + } + if (!$found) { + // remove account and reindex array + unset($entries[$r]); + $entries = array_values($entries); + $r--; break; } } - if (!$found) { - // remove account and reindex array - unset($entries[$r]); - $entries = array_values($entries); - $r--; - break; - } } + if (sizeof($entries) == 0) StatusMessage("WARN", "", $this->labels['error_noneFound']); // TODO correct message + return $entries; } - return $entries; -} - - -/** -* Sorts an account list by a given attribute -* -* @param string $sort the attribute by which to sort -* @param array $attr_array array of displayed attributes -* @param array $info the account list -* @return array sorted account list -*/ -function listSort($sort, $attr_array, $info) { - + + + /** + * Sorts an account list by a given attribute + * + * @param array $info the account list + * @return array sorted account list + */ + function listSort($info) { + if (!is_array($this->attrArray)) return $info; + if (!is_string($this->sortColumn)) return $info; + // sort and return account list + usort($info, array($this, "cmp_array")); + return $info; + } + + /** * Compare function used for usort-method * @@ -107,328 +244,402 @@ function listSort($sort, $attr_array, $info) { */ function cmp_array($a, $b) { // sort specifies the sort column - global $sort; - global $attr_array; + $sort = $this->sortColumn; + $attr_array = $this->attrArray; // sort by first column if no attribute is given if (!$sort) $sort = strtolower($attr_array[0]); if ($sort != "dn") { // sort by first attribute with name $sort - if ($a[$sort][0] == $b[$sort][0]) return 0; - elseif ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; - else return -1; + return strcmp($a[$sort][0], $b[$sort][0]); } else { - if ($a[$sort] == $b[$sort]) return 0; - elseif ($a[$sort] == max($a[$sort], $b[$sort])) return 1; - else return -1; + return strcmp($a[$sort], $b[$sort]); } } - if (!is_array($attr_array)) return $info; - if (!is_string($sort)) return $info; - // sort and return account list - usort($info, "cmp_array"); - return $info; -} - - -/** -* Draws a navigation bar to switch between pages -* -* @param integer $count number of account entries -* @param integer $max_page_entries maximum number of account per page -* @param integer $page current page number -* @param string $sort sort attribute -* @param string $searchFilter LDAP search filter -* @param string $scope account type (user/group/host/domain) -* @param string $text string including the number of accounts -*/ -function listDrawNavigationBar($count, $max_page_entries, $page, $sort, $searchFilter, $scope, $text) { - - echo("\n"); - echo("\n"); - echo(""); - } - - echo(""); - - echo("
  "); - if ($page != 1) { - echo("<=\n"); - } - else { - echo("<="); - } - echo(" "); - - if ($page < ($count / $max_page_entries)) { - echo("=>\n"); - } - else { - echo("=>"); - echo" "; - printf($text, $count); - echo(""); - for ($i = 0; $i < ($count / $max_page_entries); $i++) { - if ($i == $page - 1) { - echo(" " . ($i + 1)); - } - else { - echo(" " . ($i + 1) . "\n"); - } - } - echo("
\n"); -} - -/** -* Prints the attribute and filter row at the account table head -* -* @param string $scope account type (user, group, host) -* @param string $searchFilter search filter for hyperlinks -* @param array $desc_array list of attribute descriptions -* @param array $attr_array list of attribute names -* @param array $_POST HTTP-POST values -* @param string $sort sort attribute -*/ -function listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $_POST, $sort) { - // print table header - echo "\n"; - echo "\n\n\n"; - // table header - for ($k = 0; $k < sizeof($desc_array); $k++) { - if (strtolower($attr_array[$k]) == $sort) { - echo "\n"; - } - else echo "\n"; - } - echo "\n"; + /** + * Draws a navigation bar to switch between pages + * + * @param integer $count number of account entries + */ + function listDrawNavigationBar($count) { - // print filter row - echo "\n"; - echo "\n"; - echo "\n"; - // print input boxes for filters - for ($k = 0; $k < sizeof ($desc_array); $k++) { - $value = ""; - if (isset($_POST["filter" . strtolower($attr_array[$k])])) { - $value = " value=\"" . $_POST["filter" . strtolower($attr_array[$k])] . "\""; + echo("
" . $desc_array[$k] . "" . $desc_array[$k] . "
"; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo ""; - echo ""; - echo "
type . "nav\" width=\"100%\" border=\"0\">\n"); + echo("\n"); + echo(""); + } + + echo(""); + + echo("
  "); + if ($this->page != 1) { + echo("type . "&norefresh=true&page=" . ($this->page - 1) . "&sort=" . $this->sortColumn . $this->filterText . "\"><=\n"); } - echo ""; - echo (""); + else { + echo("<="); + } + echo(" "); + + if ($this->page < ($count / $this->maxPageEntries)) { + echo("type . "&norefresh=true&page=" . ($this->page + 1) . "&sort=" . $this->sortColumn . $this->filterText . "\">=>\n"); + } + else { + echo("=>type . "nav-text\">"); + echo" "; + printf($this->labels['nav'], $count); + echo("type . "nav-activepage\" align=\"right\">"); + for ($i = 0; $i < ($count / $this->maxPageEntries); $i++) { + if ($i == $this->page - 1) { + echo(" " . ($i + 1)); + } + else { + echo(" type . "&norefresh=true&page=" . ($i + 1) . "&sort=" . $this->sortColumn . "\">" . ($i + 1) . "\n"); + } + } + echo("
\n"); + } + + /** + * Prints the attribute and filter row at the account table head + */ + function listPrintTableHeader() { + // print table header + echo "type . "list\" width=\"100%\">\n"; + echo "type . "list-head\">\n\n\n"; + // table header + for ($k = 0; $k < sizeof($this->descArray); $k++) { + if (strtolower($this->attrArray[$k]) == $this->sortColumn) { + echo "\n"; + } + else echo "\n"; + } + echo "\n"; + + // print filter row + echo "type . "list\">\n"; + echo "\n"; + echo "\n"; + // print input boxes for filters + for ($k = 0; $k < sizeof ($this->descArray); $k++) { + $value = ""; + if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) { + $value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\""; + } + echo "\n"; + } + echo "\n"; } - echo "\n"; -} -/** -* Manages all POST actions (e.g. button pressed) for the account lists. -* -* @param string $scope account type -*/ -function listDoPost($scope) { - // check if button was pressed and if we have to add/delete an account - if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){ - // add new account - if (isset($_POST['new'])){ - metaRefresh("../account/edit.php?type=" . $scope); - exit; - } - // delete account(s) - elseif (isset($_POST['del'])){ - // search for checkboxes - $accounts = array_keys($_POST, "on"); - $_SESSION['delete_dn'] = array(); - for ($i = 0; $i < sizeof($accounts); $i++) { - $_SESSION['delete_dn'][] = $_SESSION[$scope . 'info'][$accounts[$i]]['dn']; - } - if (sizeof($accounts) > 0) { - metaRefresh("../delete.php?type=" . $scope); - exit; - } - } - // PDF for selected accounts - elseif (isset($_POST['pdf'])){ - $pdf_structure = $_POST['pdf_structure']; - // search for checkboxes - $accounts = array_keys($_POST, "on"); - $list = array(); - // load accounts from LDAP - for ($i = 0; $i < sizeof($accounts); $i++) { - $_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i"); - $_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$accounts[$i]]['dn']); - $list[$i] = $_SESSION["accountPDF-$i"]; - } - if (sizeof($list) > 0) { - createModulePDF($list,$pdf_structure); - exit; - } - } - // PDF for all accounts - elseif (isset($_POST['pdf_all'])){ - $list = array(); - for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) { - $_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i"); - $_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']); - $list[$i] = $_SESSION["accountPDF-$i"]; - } - if (sizeof($list) > 0) { - createModulePDF($list,$_POST['pdf_structure']); - exit; - } - } - } -} - - -/** -* Returns the LDAP attribute names and their description for the user list -* -* @param string $scope account type -* @return array list of LDAP attributes and descriptions -*/ -function listGetAttributeArray($scope) { - switch ($scope) { - case 'user': - return array ( - "uid" => _("User ID"), - "uidnumber" => _("UID number"), - "gidnumber" => _("GID number"), - "cn" => _("User name"), - "host" => _("Allowed hosts"), - "givenname" => _("First name"), - "sn" => _("Last name"), - "homedirectory" => _("Home directory"), - "loginshell" => _("Login shell"), - "mail" => _("E-Mail"), - "gecos" => _("Description") - ); - break; - case 'group': - return array ( - "cn" => _("Group name"), - "gidnumber" => _("GID number"), - "memberuid" => _("Group members"), - "member" => _("Group member DNs"), - "description" => _("Group description") - ); - break; - case 'host': - return array ( - "uid" => _("Host name"), - "cn" => _("Host name"), - "rid" => _("RID (Windows UID)"), - "description" => _("Host description"), - "uidnumber" => _("UID number"), - "gidnumber" => _("GID number") - ); - break; - default: - return array(); - break; - } -} - -/** -* Prints a combobox with possible sub-DNs. -* -* @param array $units list of OUs -* @param string $suffix current LDAP suffix -*/ -function listShowOUSelection($units, $suffix) { - if (sizeof($units) > 1) { - echo ("

\n"); - echo ("" . _("Suffix") . ": "); - echo ("\n"); - echo (""); - echo ("

\n"); - } -} - -/** -* Prints JavaScript code needed for mouse-over effects. -*/ -function listPrintJavaScript() { - echo "\n"; -} - -/** -* Returns an hash array containing with all attributes to be shown and their descriptions. -* Format: array(attribute => description) -* -* @param string $scope account type -* @return array attribute list -*/ -function listGetAttributeDescriptionList($scope) { - $ret = array(); - $attr_string = $_SESSION["config"]->get_listAttributes($scope); - $temp_array = explode(";", $attr_string); - $hash_table = listGetAttributeArray($scope); - // generate column attributes and descriptions - for ($i = 0; $i < sizeof($temp_array); $i++) { - // if value is predifined, look up description in hash_table - if (substr($temp_array[$i],0,1) == "#") { - $attr = strtolower(substr($temp_array[$i],1)); - if (isset($hash_table[$attr])) { - $ret[$attr] = $hash_table[$attr]; + /** + * Prints the entry list + * + * @param array $info entries + */ + function listPrintTableBody($info) { + // calculate which rows to show + $table_begin = ($this->page - 1) * $this->maxPageEntries; + if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info); + else $table_end = ($this->page * $this->maxPageEntries); + // print account list + for ($i = $table_begin; $i < $table_end; $i++) { + echo("type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&DN=" . $info[$i]['dn'] . "'\">\n"); + if (isset($_GET['selectall'])) { + echo " \n"; } else { - $ret[$attr] = $attr; + echo " \n"; + } + echo (" \n"); + for ($k = 0; $k < sizeof($this->attrArray); $k++) { + echo ("\n"); + } + echo("\n"); + } + // display select all link + $colspan = sizeof($this->attrArray) + 1; + echo "type . "list\">\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ("
type . "list-sort\">type . "&". + "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . "type . "&". + "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&norefresh=y" . "\">" . $this->descArray[$k] . "
"; + // help link + echo ""; + echo "\"""; + echo "\n"; echo ""; + echo ""; + echo ""; + echo ("attrArray[$k]) ."\"" . $value . ">"); + echo "
type . "')\"" . + " type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\">type . "')\"" . + " type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\">type . "&DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . ""); + // print all attribute entries seperated by "; " + $attrName = strtolower($this->attrArray[$k]); + if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) { + // delete "count" entry + unset($info[$i][$attrName]['count']); + if (is_array($info[$i][$attrName])) { + // sort array + sort($info[$i][$attrName]); + echo implode("; ", $info[$i][$attrName]); + } + else echo $info[$i][$attrName]; + } + echo ("
\"select type . "&norefresh=y&page=" . $this->page . + "&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" . + "" . _("Select all") . "
"); + + echo ("
"); + } + + /** + * Manages all POST actions (e.g. button pressed) for the account lists. + */ + function listDoPost() { + // check if button was pressed and if we have to add/delete an account + if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){ + // add new account + if (isset($_POST['new'])){ + metaRefresh("../account/edit.php?type=" . $this->type); + exit; + } + // delete account(s) + elseif (isset($_POST['del'])){ + // search for checkboxes + $accounts = array_keys($_POST, "on"); + $_SESSION['delete_dn'] = array(); + for ($i = 0; $i < sizeof($accounts); $i++) { + $_SESSION['delete_dn'][] = $_SESSION[$this->type . 'info'][$accounts[$i]]['dn']; + } + if (sizeof($accounts) > 0) { + metaRefresh("../delete.php?type=" . $this->type); + exit; + } + } + // PDF for selected accounts + elseif (isset($_POST['pdf'])){ + $pdf_structure = $_POST['pdf_structure']; + // search for checkboxes + $accounts = array_keys($_POST, "on"); + $list = array(); + // load accounts from LDAP + for ($i = 0; $i < sizeof($accounts); $i++) { + $_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i"); + $_SESSION["accountPDF-$i"]->load_account($_SESSION[$this->type . 'info'][$accounts[$i]]['dn']); + $list[$i] = $_SESSION["accountPDF-$i"]; + } + if (sizeof($list) > 0) { + createModulePDF($list,$pdf_structure); + exit; + } + } + // PDF for all accounts + elseif (isset($_POST['pdf_all'])){ + $list = array(); + for ($i = 0; $i < sizeof($_SESSION[$this->type . 'info']); $i++) { + $_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i"); + $_SESSION["accountPDF-$i"]->load_account($_SESSION[$this->type . 'info'][$i]['dn']); + $list[$i] = $_SESSION["accountPDF-$i"]; + } + if (sizeof($list) > 0) { + createModulePDF($list,$_POST['pdf_structure']); + exit; + } } } - // if not predefined, the attribute is seperated by a ":" from description + } + + /** + * Prints a combobox with possible sub-DNs. + */ + function listShowOUSelection() { + if (sizeof($this->possibleSuffixes) > 1) { + echo ("

\n"); + echo ("" . _("Suffix") . ": "); + echo ("\n"); + echo (""); + echo ("

\n"); + } + } + + /** + * Prints the create, delete and PDF buttons. + * + * @param boolean $createOnly true if only the create button should be displayed + */ + function listPrintButtons($createOnly) { + // add/delete/PDF buttons + echo ("labels['newEntry'] . "\">\n"); + if (!$createOnly) { + echo ("labels['deleteEntry'] . "\">\n"); + echo ("


\n"); + echo "
PDF\n"; + echo ("" . _('PDF structure') . ":      \n"; + echo ("labels['createPDF'] . "\">\n"); + echo " "; + echo ("labels['createPDFAll'] . "\">\n"); + echo "
"; + } + } + + /** + * Prints the HTML head. + */ + function listPrintHeader() { + echo $_SESSION['header']; + echo "Account list\n"; + echo "\n"; + echo "type . ".css\">\n"; + echo "\n"; + $this->listPrintJavaScript(); + } + + /** + * Prints JavaScript code needed for mouse-over effects. + */ + function listPrintJavaScript() { + echo "\n"; + } + + /** + * Returns an hash array containing with all attributes to be shown and their descriptions. + * Format: array(attribute => description) + * + * @return array attribute list + */ + function listGetAttributeDescriptionList() { + $ret = array(); + $attr_string = $_SESSION["config"]->get_listAttributes($this->type); + $temp_array = explode(";", $attr_string); + $hash_table = getListAttributeDescriptions($this->type); + // generate column attributes and descriptions + for ($i = 0; $i < sizeof($temp_array); $i++) { + // if value is predifined, look up description in hash_table + if (substr($temp_array[$i],0,1) == "#") { + $attr = strtolower(substr($temp_array[$i],1)); + if (isset($hash_table[$attr])) { + $ret[$attr] = $hash_table[$attr]; + } + else { + $ret[$attr] = $attr; + } + } + // if not predefined, the attribute is seperated by a ":" from description + else { + $attr = explode(":", $temp_array[$i]); + if (isset($attr[1])) { + $ret[$attr[0]] = $attr[1]; + } + else { + $ret[$attr[0]] = $attr[0]; + } + } + } + return $ret; + } + + /** + * Sets some internal parameters. + */ + function listGetParams() { + // get current page + if (isset($_GET["page"])) $this->page = $_GET["page"]; + else $this->page = 1; + // generate attribute-description table + $temp_array = $this->listGetAttributeDescriptionList(); + $this->attrArray = array_keys($temp_array); // list of LDAP attributes to show + $this->descArray = array_values($temp_array); // list of descriptions for the attributes + // get maximum count of entries shown on one page + if ($_SESSION["config"]->get_MaxListEntries() <= 0) + $this->maxPageEntries = 10; // default setting, if not yet set + else + $this->maxPageEntries = $_SESSION["config"]->get_MaxListEntries(); + // get sorting column + if (isset($_GET["sort"])) $this->sortColumn = $_GET["sort"]; + else $this->sortColumn = strtolower($this->attrArray[0]); + // check search suffix + if ($_POST['suffix']) $this->suffix = $_POST['suffix']; // new suffix selected via combobox + elseif (!$this->suffix) $this->suffix = $_SESSION["config"]->get_Suffix($this->type); // default suffix + // check if LDAP data should be refreshed + $this->refresh = true; + if (isset($_GET['norefresh'])) $this->refresh = false; + if (isset($_POST['refresh'])) $this->refresh = true; + } + + /** + * Rereads the entries from LDAP. + */ + function listRefreshData() { + // configure search filter + $module_filter = get_ldap_filter($this->type); // basic filter is provided by modules + $filter = "(&" . $module_filter . ")"; + $attrs = $this->attrArray; + $sr = @ldap_search($_SESSION["ldap"]->server(), $this->suffix, $filter, $attrs); + if (ldap_errno($_SESSION["ldap"]->server()) == 4) { + StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); + } + if ($sr) { + $info = ldap_get_entries($_SESSION["ldap"]->server, $sr); + ldap_free_result($sr); + // delete first array entry which is "count" + unset($info['count']); + // save position in original $info + for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i; + // save results + $this->entries = $info; + } else { - $attr = explode(":", $temp_array[$i]); - if (isset($attr[1])) { - $ret[$attr[0]] = $attr[1]; - } - else { - $ret[$attr[0]] = $attr[0]; - } + $this->entries = array(); + StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), $this->labels['error_noneFound']); // TODO correct message } + // generate list of possible suffixes + $this->possibleSuffixes = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($this->type)); } - return $ret; -} +} ?> \ No newline at end of file diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 66430c6d..0c056512 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -317,6 +317,11 @@ function getConfigOptions($scopes) { */ function getConfigDescriptions() { $return = array('legend' => array(), 'descriptions' => array()); + $modules = array(); + $types = $_SESSION['config']->get_ActiveTypes(); + for ($i = 0; $i < sizeof($types); $i++) { + $modules = array_merge($modules, getAvailableModules($types[$i])); + } $modules = array_merge(getAvailableModules('user'), getAvailableModules('group'), getAvailableModules('host')); $modules = array_values(array_unique($modules)); for ($i = 0; $i < sizeof($modules); $i++) { @@ -375,15 +380,6 @@ function getAvailablePDFFields($scope) { return $return; } -/** - * Return a list of current available scopes - * - * @return array Available scopes - */ -function getAvailableScopes() { - return array('user','group','host', 'domain'); -} - /** * Returns an array containing all input columns for the file upload. * @@ -707,8 +703,6 @@ class accountContainer { if (!is_string($type)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); - // *** fixme use global variable to determine allowed types - if (!in_array($type, getAvailableScopes())) trigger_error('Account type not recognized.', E_USER_ERROR); $this->type = $type; $this->base = $base; // Set startpage @@ -900,6 +894,7 @@ class accountContainer { else echo _("Create new Account"); echo "\n"; echo "\n"; + echo "type . ".css\">\n"; echo "\n"; echo "
\n"; // Display error-messages @@ -937,7 +932,7 @@ class accountContainer { echo "
type."edit\">"; echo _('Please select page:'); - echo "\n"; + echo "
\n"; // calculate button width $buttonWidth = round(0.8 * strlen(utf8_decode(_("Reset changes")))); for ($b = 0; $b < sizeof($this->order); $b++) { @@ -971,7 +966,7 @@ class accountContainer { if ($this->subpage == 'finish') echo " disabled"; echo ">
\n"; } - echo "
\n"; + echo "\n"; echo "\n"; if ($this->current_page==0) { echo "
type."edit\">"; @@ -1177,7 +1172,7 @@ class accountContainer { $string = trim($string); // Add must foreach (explode(" $ ", $string) as $attribute) { - $return[$attribute] = array(''); + $return[$attribute] = array(); } } elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) { @@ -1186,7 +1181,7 @@ class accountContainer { $string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = trim($string); // Add must - $return[$string] = array(''); + $return[$string] = array(); } // create array with may-attributes // Get startposition in string @@ -1197,7 +1192,7 @@ class accountContainer { $string = trim($string); // Add may foreach (explode(" $ ", $string) as $attribute) { - $return[$attribute] = array(''); + $return[$attribute] = array(); } } elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) { @@ -1206,7 +1201,7 @@ class accountContainer { $string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = trim($string); // Add must - $return[$string] = array(''); + $return[$string] = array(); } // Get attributes of subclasses while (strpos($_SESSION['ldap']->objectClasses[$line], "SUP ")) { @@ -1227,7 +1222,7 @@ class accountContainer { $string = trim($string); // Add must foreach (explode(" $ ", $string) as $attribute) { - $return[$attribute] = array(''); + $return[$attribute] = array(); } } elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) { @@ -1236,7 +1231,7 @@ class accountContainer { $string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = trim($string); // Add must - $return[$string] = array(''); + $return[$string] = array(); } // create array with may-attributes // Get startposition in string @@ -1247,7 +1242,7 @@ class accountContainer { $string = trim($string); // Add may foreach (explode(" $ ", $string) as $attribute) { - $return[$attribute] = array(''); + $return[$attribute] = array(); } } elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) { @@ -1256,7 +1251,7 @@ class accountContainer { $string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = trim($string); // Add must - $return[$string] = array(''); + $return[$string] = array(); } } diff --git a/lam/lib/modules/nisMailAlias.inc b/lam/lib/modules/nisMailAlias.inc index f357f4ce..b8cd18b2 100644 --- a/lam/lib/modules/nisMailAlias.inc +++ b/lam/lib/modules/nisMailAlias.inc @@ -45,7 +45,7 @@ class nisMailAlias extends baseModule { function get_metaData() { $return = array(); // manages host accounts - $return["account_types"] = array("group"); + $return["account_types"] = array("mailAlias"); // base module $return["is_base"] = true; // LDAP filter diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index f1dfcb20..cfc54ddf 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -832,7 +832,7 @@ class posixGroup extends baseModule { $DNs = array_keys($result); for ($i=0; $iget_Suffix('domain')); + $sambaDomains = search_domains(); // Get Domain-SID from group SID $domainSID = substr($result[$DNs[$i]], 0, strrpos($result[$DNs[$i]], "-")); for ($i=0; $i "high"); + // LDAP filter + $return["ldap_filter"] = array('or' => "(objectClass=sambaDomain)"); + // module dependencies + $return['dependencies'] = array('depends' => array(), 'conflicts' => array()); + // help Entries + $return['help'] = array( + 'domainName' => array( + "Headline" => _("Domain name"), + "Text" => _("The name of your Windows domain or workgroup.") + ), + 'domainSID' => array( + "Headline" => _("Domain SID"), + "Text" => _("The SID of your Samba server. Get it with \"net getlocalsid\".") + ), + 'nextRID' => array( + "Headline" => _("Next RID"), + "Text" => _("Next RID to use when creating accounts (only used by Winbind).") + ), + 'nextUserRID' => array( + "Headline" => _("Next user RID"), + "Text" => _("Next RID to use when creating user accounts (only used by Winbind).") + ), + 'nextGroupRID' => array( + "Headline" => _("Next group RID"), + "Text" => _("Next RID to use when creating group accounts (only used by Winbind).") + ), + 'nextRID' => array( + "Headline" => _("RID base"), + "Text" => _("Used for calculating RIDs from UID/GID. Do not change if unsure.") + )); + // upload fields + $return['upload_columns'] = array( + array( + 'name' => 'sambaDomain_domainName', + 'description' => _('Domain name'), + 'help' => 'domainName', + 'example' => _('Workgroup'), + 'required' => true + ), + array( + 'name' => 'sambaDomain_domainSID', + 'description' => _('Domain SID'), + 'help' => 'domainSID', + 'example' => 'S-1-1-22-123-123-123', + 'required' => true + ), + array( + 'name' => 'sambaDomain_RIDbase', + 'description' => _('RID base'), + 'help' => 'RIDbase', + 'example' => '1000', + 'default' => 1000 + ), + array( + 'name' => 'sambaDomain_nextRID', + 'description' => _('Next RID'), + 'help' => 'nextRID', + 'example' => '12345' + ), + array( + 'name' => 'sambaDomain_nextUserRID', + 'description' => _('Next user RID'), + 'help' => 'nextUserRID', + 'example' => '12345' + ), + array( + 'name' => 'sambaDomain_nextGroupRID', + 'description' => _('Next group RID'), + 'help' => 'nextGroupRID', + 'example' => '12345' + ) + ); + // available PDF fields + $return['PDF_fields'] = array( + 'domainName', 'domainSID', 'nextRID', + 'nextUserRID', 'nextGroupRID', 'RIDbase' + ); + return $return; + } + + /** + * This function fills the error message array with messages + */ + function load_Messages() { + $this->messages['domainName'][0] = array('ERROR', _('Domain name is invalid!')); + $this->messages['domainName'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_domainName', _('Domain name is invalid!')); + $this->messages['domainSID'][0] = array('ERROR', _('Samba 3 domain SID is invalid!')); + $this->messages['domainSID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_domainSID', _('Samba 3 domain SID is invalid!')); + $this->messages['nextRID'][0] = array('ERROR', _('Next RID is not a number!')); + $this->messages['nextRID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_nextRID', _('Next RID is not a number!')); + $this->messages['nextUserRID'][0] = array('ERROR', _('Next user RID is not a number!')); + $this->messages['nextUserRID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_nextUserRID', _('Next user RID is not a number!')); + $this->messages['nextGroupRID'][0] = array('ERROR', _('Next group RID is not a number!')); + $this->messages['nextGroupRID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_nextGroupRID', _('Next group RID is not a number!')); + $this->messages['RIDbase'][0] = array('ERROR', _('Algorithmic RID base is not a number!')); + $this->messages['RIDbase'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_RIDbase', _('Algorithmic RID base is not a number!')); + } + + /** + * This function loads all needed attributes into the object. + * + * @param array $attr an array as it is retured from ldap_get_attributes + */ + function load_attributes($attr) { + $attributes = array('sambaAlgorithmicRidBase', 'sambaDomainName', 'sambaNextGroupRid', + 'sambaNextRid', 'sambaNextUserRid', 'sambaSID'); + $this->attributes['objectClass'] = array(); + $this->attributes['macAddress'] = array(); + $this->orig['objectClass'] = array(); + $this->orig['macAddress'] = array(); + if (isset($attr['objectClass'])) { + $this->attributes['objectClass'] = $attr['objectClass']; + $this->orig['objectClass'] = $attr['objectClass']; + } + for ($i = 0; $i < sizeof($attributes); $i++) { + if (isset($attr[$attributes[$i]])) { + $this->attributes[$attributes[$i]] = $attr[$attributes[$i]]; + $this->orig[$attributes[$i]] = $attr[$attributes[$i]]; + } + } + // add object class if needed + if (! in_array('sambaDomain', $this->orig['objectClass'])) { + $this->attributes['objectClass'][] = 'sambaDomain'; + } + return 0; + } + + /** + * Returns a list of modifications which have to be made to the LDAP account. + * + * @return array list of modifications + *
This function returns an array with 3 entries: + *
array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... ) + *
DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid) + *
"add" are attributes which have to be added to LDAP entry + *
"remove" are attributes which have to be removed from LDAP entry + *
"modify" are attributes which have to been modified in LDAP entry + */ + function save_attributes() { + return $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); + } + + /** + * This function will create the meta HTML code to show a page with all attributes. + * + * @param array $post HTTP-POST values + */ + function display_html_attributes(&$post) { + $return = array(); + // domain name + if ($_SESSION[$this->base]->isNewAccount) { + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Domain name').'*'), + 1 => array('kind' => 'input', 'name' => 'domainName', 'type' => 'text', 'value' => $this->attributes['sambaDomainName'][0]), + 2 => array('kind' => 'help', 'value' => 'domainName')); + } + else { + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Domain name')), + 1 => array('kind' => 'text', 'text' => $this->attributes['sambaDomainName'][0]), + 2 => array('kind' => 'help', 'value' => 'domainName')); + } + // domain SID + if ($_SESSION[$this->base]->isNewAccount) { + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Domain SID').'*'), + 1 => array('kind' => 'input', 'name' => 'domainSID', 'type' => 'text', 'value' => $this->attributes['sambaSID'][0]), + 2 => array('kind' => 'help', 'value' => 'domainSID')); + } + else { + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Domain SID')), + 1 => array('kind' => 'text', 'text' => $this->attributes['sambaSID'][0]), + 2 => array('kind' => 'help', 'value' => 'domainSID')); + } + // next RID + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Next RID')), + 1 => array('kind' => 'input', 'name' => 'nextRID', 'type' => 'text', 'value' => $this->attributes['sambaNextRid'][0]), + 2 => array('kind' => 'help', 'value' => 'nextRID')); + // next user RID + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Next user RID')), + 1 => array('kind' => 'input', 'name' => 'nextUserRID', 'type' => 'text', 'value' => $this->attributes['sambaNextUserRid'][0]), + 2 => array('kind' => 'help', 'value' => 'nextUserRID')); + // next group RID + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('Next group RID')), + 1 => array('kind' => 'input', 'name' => 'nextGroupRID', 'type' => 'text', 'value' => $this->attributes['sambaNextGroupRid'][0]), + 2 => array('kind' => 'help', 'value' => 'nextGroupRID')); + // RID base + if (!isset($this->attributes['sambaAlgorithmicRidBase'][0])) $this->attributes['sambaAlgorithmicRidBase'][0] = 1000; + if ($_SESSION[$this->base]->isNewAccount) { + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('RID base').'*'), + 1 => array('kind' => 'input', 'name' => 'RIDbase', 'type' => 'text', 'value' => $this->attributes['sambaAlgorithmicRidBase'][0]), + 2 => array('kind' => 'help', 'value' => 'RIDbase')); + } + else { + $return[] = array( + 0 => array('kind' => 'text', 'text' => _('RID base')), + 1 => array('kind' => 'text', 'text' => $this->attributes['sambaAlgorithmicRidBase'][0]), + 2 => array('kind' => 'help', 'value' => 'RIDbase')); + } + return $return; + } + + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages + */ + function process_attributes(&$post) { + $errors = array(); + if ($_SESSION[$this->base]->isNewAccount) { + // domain SID + if (!get_preg($_POST['domainSID'], 'domainSID')) { + $errors[] = $this->messages['domainSID'][0]; + } + else { + $this->attributes['sambaSID'][0] = $_POST['domainSID']; + } + // RID base + if (!get_preg($_POST['RIDbase'], 'digit') && !($_POST['RIDbase'] == '')) { + $errors[] = $this->messages['RIDbase'][0]; + } + else { + $this->attributes['sambaAlgorithmicRidBase'][0] = $_POST['RIDbase']; + } + // domain name + if (!get_preg($_POST['domainName'], 'domainname') && !($_POST['domainName'] == '')) { + $errors[] = $this->messages['domainName'][0]; + } + else { + $this->attributes['sambaDomainName'][0] = $_POST['domainName']; + } + } + // next RID + if (!get_preg($_POST['nextRID'], 'digit')) { + $errors[] = $this->messages['nextRID'][0]; + } + else { + $this->attributes['sambaNextRid'][0] = $_POST['nextRID']; + } + // next user RID + if (!get_preg($_POST['nextUserRID'], 'digit')) { + $errors[] = $this->messages['nextUserRID'][0]; + } + else { + $this->attributes['sambaNextUserRid'][0] = $_POST['nextUserRID']; + } + // next group RID + if (!get_preg($_POST['nextGroupRID'], 'digit')) { + $errors[] = $this->messages['nextGroupRID'][0]; + } + else { + $this->attributes['sambaNextGroupRid'][0] = $_POST['nextGroupRID']; + } + return $errors; + } + + /** + * In this function the LDAP account is built up. + * + * @param array $rawAccounts list of hash arrays (name => value) from user input + * @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP + * @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5) + * @return array list of error messages if any + */ + function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { + $messages = array(); + for ($i = 0; $i < sizeof($rawAccounts); $i++) { + // add object class + if (!in_array("sambaDomain", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "sambaDomain"; + // domain name + if (get_preg($rawAccounts[$i][$ids['sambaDomain_domainName']], 'domainname')) { + $partialAccounts[$i]['sambaDomainName'] = $rawAccounts[$i][$ids['sambaDomain_domainName']]; + } + else { + $errMsg = $this->messages['domainName'][1]; + array_push($errMsg, array($i)); + $messages[] = $errMsg; + } + // domain SID + if (get_preg($rawAccounts[$i][$ids['sambaDomain_domainSID']], 'domainSID')) { + $partialAccounts[$i]['sambaSID'] = $rawAccounts[$i][$ids['sambaDomain_domainSID']]; + } + else { + $errMsg = $this->messages['domainSID'][1]; + array_push($errMsg, array($i)); + $messages[] = $errMsg; + } + // RID base + if ($rawAccounts[$i][$ids['sambaDomain_RIDbase']]) { + if (get_preg($rawAccounts[$i][$ids['sambaDomain_RIDbase']], 'digit')) { + $partialAccounts[$i]['sambaAlgorithmicRidBase'] = $rawAccounts[$i][$ids['sambaDomain_RIDbase']]; + } + else { + $errMsg = $this->messages['RIDbase'][1]; + array_push($errMsg, array($i)); + $messages[] = $errMsg; + } + } + else { + $partialAccounts[$i]['sambaAlgorithmicRidBase'] = '1000'; + } + // next RID + if ($rawAccounts[$i][$ids['sambaDomain_nextRID']]) { + if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextRID']], 'digit')) { + $partialAccounts[$i]['sambaNextRid'] = $rawAccounts[$i][$ids['sambaDomain_nextRID']]; + } + else { + $errMsg = $this->messages['nextRID'][1]; + array_push($errMsg, array($i)); + $messages[] = $errMsg; + } + } + // next user RID + if ($rawAccounts[$i][$ids['sambaDomain_nextUserRID']]) { + if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextUserRID']], 'digit')) { + $partialAccounts[$i]['sambaNextUserRid'] = $rawAccounts[$i][$ids['sambaDomain_nextUserRID']]; + } + else { + $errMsg = $this->messages['nextUserRID'][1]; + array_push($errMsg, array($i)); + $messages[] = $errMsg; + } + } + // next group RID + if ($rawAccounts[$i][$ids['sambaDomain_nextGroupRID']]) { + if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextGroupRID']], 'digit')) { + $partialAccounts[$i]['sambaNextGroupRid'] = $rawAccounts[$i][$ids['sambaDomain_nextGroupRID']]; + } + else { + $errMsg = $this->messages['nextGroupRID'][1]; + array_push($errMsg, array($i)); + $messages[] = $errMsg; + } + } + } + return $messages; + } + + /** + * Returns the PDF entries for this module. + * + * @return array list of possible PDF entries + */ + function get_pdfEntries() { + $return = array(); + if (sizeof($this->attributes['sambaDomainName']) > 0) { + $return['sambaDomain_domainName'][0] = '' . _('Domain name') . '' . implode(', ', $this->attributes['sambaDomainName']) . ''; + } + if (sizeof($this->attributes['sambaSID']) > 0) { + $return['sambaDomain_domainSID'][0] = '' . _('Domain SID') . '' . implode(', ', $this->attributes['sambaSID']) . ''; + } + if (sizeof($this->attributes['sambaNextRid']) > 0) { + $return['sambaDomain_nextRID'][0] = '' . _('Next RID') . '' . implode(', ', $this->attributes['sambaNextRid']) . ''; + } + if (sizeof($this->attributes['sambaNextUserRid']) > 0) { + $return['sambaDomain_nextUserRID'][0] = '' . _('Next user RID') . '' . implode(', ', $this->attributes['sambaNextUserRid']) . ''; + } + if (sizeof($this->attributes['sambaNextGroupRid']) > 0) { + $return['sambaDomain_nextGroupRID'][0] = '' . _('Next group RID') . '' . implode(', ', $this->attributes['sambaNextGroupRid']) . ''; + } + if (sizeof($this->attributes['sambaAlgorithmicRidBase']) > 0) { + $return['sambaDomain_RIDbase'][0] = '' . _('RID base') . '' . implode(', ', $this->attributes['sambaAlgorithmicRidBase']) . ''; + } + return $return; + } + +} + + +?> diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index 440a1260..499347bf 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -83,7 +83,7 @@ class sambaGroupMapping extends baseModule { function init($base) { // call parent init parent::init($base); - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); if (sizeof($sambaDomains) == 0) { StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); return; @@ -100,7 +100,7 @@ class sambaGroupMapping extends baseModule { */ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { // search existing Samba 3 domains - $domains = search_domains($_SESSION['config']->get_Suffix('domain')); + $domains = search_domains(); $nameToSID = array(); // get domain SIDs for ($i = 0; $i < sizeof($domains); $i++) { @@ -168,7 +168,7 @@ class sambaGroupMapping extends baseModule { * It will output a complete html-table */ function display_html_attributes(&$post) { - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); if (sizeof($sambaDomains) == 0) { StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); return; @@ -243,7 +243,7 @@ class sambaGroupMapping extends baseModule { // upload fields // search existing Samba 3 domains if ($_SESSION['loggedIn']) { - $domains = search_domains($_SESSION['config']->get_Suffix('domain')); + $domains = search_domains(); $domainNames = array(); for ($i = 0; $i < sizeof($domains); $i++) $domainNames[] = $domains[$i]->name; $return['upload_columns'] = array( @@ -327,7 +327,7 @@ class sambaGroupMapping extends baseModule { function get_profileOptions() { $return = array(); // get list of domains - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++ ) { // extract names @@ -350,7 +350,7 @@ class sambaGroupMapping extends baseModule { function load_profile($profile) { if (isset($profile['sambaGroupMapping_sambaDomainName'][0])) { // get list of domains - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); for ($i = 0; $i < sizeof($sambaDomains); $i++) { if ($sambaDomains[$i]->name == $profile['sambaGroupMapping_sambaDomainName'][0]) { $this->attributes['sambaSID'][0] = $sambaDomains[$i]->SID . "-0"; @@ -394,7 +394,7 @@ class sambaGroupMapping extends baseModule { * @return array list of info/error messages */ function process_attributes(&$post) { - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); if (sizeof($sambaDomains) == 0) { return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.')))); } @@ -448,7 +448,7 @@ class sambaGroupMapping extends baseModule { */ function save_attributes() { // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); // Get Domain-SID from group SID $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); for ($i=0; $inoexpire = true; $this->nopwd = false; $this->deactivated = false; - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); if (sizeof($sambaDomains) == 0) { StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); return; @@ -468,7 +468,7 @@ class sambaSamAccount extends baseModule { * it's psssible uidNumber has changed */ // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); for ($i=0; $iattributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { $SID = $sambaDomains[$i]->SID; @@ -493,7 +493,7 @@ class sambaSamAccount extends baseModule { * @return array list of info/error messages */ function process_attributes(&$post) { - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); if (sizeof($sambaDomains) == 0) { return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.')))); } @@ -739,7 +739,7 @@ class sambaSamAccount extends baseModule { */ function display_html_attributes(&$post) { // Get Domain SID from user SID - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); if (sizeof($sambaDomains) == 0) { StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); return; @@ -1073,7 +1073,7 @@ class sambaSamAccount extends baseModule { 2 => array('kind' => 'help', 'value' => 'workstations') ); // domains - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++) { $sambaDomainNames[] = $sambaDomains[$i]->name; @@ -1092,7 +1092,7 @@ class sambaSamAccount extends baseModule { } elseif ($this->get_scope() == 'host') { // domains - $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); + $sambaDomains = search_domains(); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++) { $sambaDomainNames[] = $sambaDomains[$i]->name; @@ -1159,7 +1159,7 @@ class sambaSamAccount extends baseModule { // domain -> change SID if ($this->attributes['sambaSID'][0]) { if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) { - $domains = search_domains($_SESSION['config']->get_Suffix('domain')); + $domains = search_domains(); $domSID = ''; // find domain SID for ($i = 0; $i < sizeof($domains); $i++) { @@ -1208,7 +1208,7 @@ class sambaSamAccount extends baseModule { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { $triggered_messages = array(); // get list of Samba 3 domains - $domains = search_domains($_SESSION['config']->get_Suffix('domain')); + $domains = search_domains(); // get list of Unix groups and their sambaSID + gidNumber $groups = $_SESSION['cache']->get_cache(array('cn', 'sambaSID', 'gidNumber'), 'posixGroup', 'group'); $groups_k = array_keys($groups); diff --git a/lam/lib/tree.inc b/lam/lib/tree.inc index a2ae5175..212ce0b8 100644 --- a/lam/lib/tree.inc +++ b/lam/lib/tree.inc @@ -301,6 +301,8 @@ function get_icon( $dn ) return 'nt_machine.png'; if( in_array( 'sambaaccount', $object_classes ) ) return 'nt_user.png'; + elseif( in_array( 'sambadomain', $object_classes ) ) + return 'smbDomain.png'; elseif( in_array( 'person', $object_classes ) || in_array( 'organizationalperson', $object_classes ) || in_array( 'inetorgperson', $object_classes ) || diff --git a/lam/lib/types.inc b/lam/lib/types.inc new file mode 100644 index 00000000..6498d803 --- /dev/null +++ b/lam/lib/types.inc @@ -0,0 +1,124 @@ +read()) +if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($typesINC_dirname . '/'.$entry)) { + include_once($typesINC_dirname . '/'.$entry); +} + + +/** +* Returns a list of available account types. +* +* @return array list of types +*/ +function getTypes() { + $dirname = substr(__FILE__, 0, strlen(__FILE__) - 10) . "/types"; + $dir = dir($dirname); + $return = array(); + // get type names. + while ($entry = $dir->read()) + if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) { + $entry = substr($entry, 0, strpos($entry, '.')); + $return[] = $entry; + } + return $return; +} + +/** +* Returns the alias name of an account type. +* +* @param string $type type name +* @return string type alias +*/ +function getTypeAlias($type) { + $obj = new $type(); + return $obj->getAlias(); +} + +/** +* Returns the description of an account type. +* +* @param string $type type name +* @return string type description +*/ +function getTypeDescription($type) { + $obj = new $type(); + return $obj->getDescription(); +} + +/** +* Returns the class name for the list object. +* +* @param string $type account type +* @return string class name +*/ +function getListClassName($type) { + $obj = new $type(); + return $obj->getListClassName(); +} + +/** +* Returns the default attribute list for an account type. +* It is used as default value for the configuration editor. +* +* @param string $type account type +* @return string attribute list +*/ +function getDefaultListAttributes($type) { + $obj = new $type(); + return $obj->getDefaultListAttributes(); +} + +/** +* Returns a list of attributes which have a translated description. +* This is used for the head row in the list view. +* +* @param string $type account type +* @return array list of descriptions +*/ +function getListAttributeDescriptions($type) { + $obj = new $type(); + return $obj->getListAttributeDescriptions(); +} + +?> \ No newline at end of file diff --git a/lam/lib/types/group.inc b/lam/lib/types/group.inc new file mode 100644 index 00000000..90d06600 --- /dev/null +++ b/lam/lib/types/group.inc @@ -0,0 +1,190 @@ + _("Group name"), + "gidnumber" => _("GID number"), + "memberuid" => _("Group members"), + "member" => _("Group member DNs"), + "description" => _("Group description") + ); + } + +} + +/** + * Generates the list view. + * + * @package lists + * @author Roland Gruber + * + */ +class lamGroupList extends lamList { + + /** + * Constructor + * + * @param string $type account type + * @return lamList list object + */ + function lamGroupList($type) { + parent::lamList($type); + $this->labels = array( + 'nav' => _("%s group(s) found"), + 'error_noneFound' => _("No groups found!"), + 'newEntry' => _("New group"), + 'deleteEntry' => _("Delete group"), + 'createPDF' => _("Create PDF for selected group(s)"), + 'createPDFAll' => _("Create PDF for all groups")); + } + + /** + * Prints the entry list + * + * @param array $info entries + */ + function listPrintTableBody($info) { + // calculate which rows to show + $table_begin = ($this->page - 1) * $this->maxPageEntries; + if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info); + else $table_end = ($this->page * $this->maxPageEntries); + // print account list + for ($i = $table_begin; $i < $table_end; $i++) { + echo("type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&DN=" . $info[$i]['dn'] . "'\">\n"); + if (isset($_GET['selectall'])) { + echo " type . "')\"" . + " type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\">\n"; + } + else { + echo " type . "')\"" . + " type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\">\n"; + } + echo (" type . "&DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "\n"); + for ($k = 0; $k < sizeof($this->attrArray); $k++) { + echo (""); + // print all attribute entries seperated by "; " + $attrName = strtolower($this->attrArray[$k]); + if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) { + // delete "count" entry + unset($info[$i][$attrName]['count']); + // generate links for group members + if ($attrName == "memberuid") { + // sort array + sort($info[$i][$attrName]); + // make a link for each member of the group + $linklist = array(); + for ($d = 0; $d < sizeof($info[$i][$attrName]); $d++) { + $user = $info[$i][$attrName][$d]; // user name + $linklist[$d] = "" . $user . ""; + } + echo implode("; ", $linklist); + } + // print all other attributes + else { + if (is_array($info[$i][$attrName])) { + // sort array + sort($info[$i][$attrName]); + echo implode("; ", $info[$i][$attrName]); + } + else echo $info[$i][$attrName]; + } + } + echo ("\n"); + } + echo("\n"); + } + // display select all link + $colspan = sizeof($this->attrArray) + 1; + echo "type . "list\">\n"; + echo "\"select\n"; + echo " type . "&norefresh=y&page=" . $this->page . + "&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" . + "" . _("Select all") . "\n"; + echo "\n"; + echo (""); + + echo ("
"); + } + +} + + +?> \ No newline at end of file diff --git a/lam/lib/types/host.inc b/lam/lib/types/host.inc new file mode 100644 index 00000000..b5988605 --- /dev/null +++ b/lam/lib/types/host.inc @@ -0,0 +1,121 @@ + _("Host name"), + "cn" => _("Host name"), + "rid" => _("RID (Windows UID)"), + "description" => _("Host description"), + "uidnumber" => _("UID number"), + "gidnumber" => _("GID number") + ); + } + +} + + +/** + * Generates the list view. + * + * @package lists + * @author Roland Gruber + * + */ +class lamHostList extends lamList { + + /** + * Constructor + * + * @param string $type account type + * @return lamList list object + */ + function lamHostList($type) { + parent::lamList($type); + $this->labels = array( + 'nav' => _("%s host(s) found"), + 'error_noneFound' => _("No hosts found!"), + 'newEntry' => _("New host"), + 'deleteEntry' => _("Delete host"), + 'createPDF' => _("Create PDF for selected host(s)"), + 'createPDFAll' => _("Create PDF for all hosts")); + } + +} + + +?> \ No newline at end of file diff --git a/lam/lib/types/mailAlias.inc b/lam/lib/types/mailAlias.inc new file mode 100644 index 00000000..dd6ac5bb --- /dev/null +++ b/lam/lib/types/mailAlias.inc @@ -0,0 +1,117 @@ + _("Alias name"), + "rfc822MailMember" => _("Recipient list") + ); + } + +} + + +/** + * Generates the list view. + * + * @package lists + * @author Roland Gruber + * + */ +class lamMailAliasList extends lamList { + + /** + * Constructor + * + * @param string $type account type + * @return lamList list object + */ + function lamMailAliasList($type) { + parent::lamList($type); + $this->labels = array( + 'nav' => _("%s alias(es) found"), + 'error_noneFound' => _("No aliases found!"), + 'newEntry' => _("New alias"), + 'deleteEntry' => _("Delete alias"), + 'createPDF' => _("Create PDF for selected alias(es)"), + 'createPDFAll' => _("Create PDF for all aliases")); + } + +} + + +?> \ No newline at end of file diff --git a/lam/lib/types/smbDomain.inc b/lam/lib/types/smbDomain.inc new file mode 100644 index 00000000..98273828 --- /dev/null +++ b/lam/lib/types/smbDomain.inc @@ -0,0 +1,116 @@ + _("Domain SID"), + "sambaDomainName" => _("Domain name") + ); + } + +} + + +/** + * Generates the list view. + * + * @package lists + * @author Roland Gruber + * + */ +class lamSmbDomainList extends lamList { + + /** + * Constructor + * + * @param string $type account type + * @return lamList list object + */ + function lamSmbDomainList($type) { + parent::lamList($type); + $this->labels = array( + 'nav' => _("%s domain(s) found"), + 'error_noneFound' => _("No domains found!"), + 'newEntry' => _("New domain"), + 'deleteEntry' => _("Delete domain"), + 'createPDF' => _("Create PDF for selected domain(s)"), + 'createPDFAll' => _("Create PDF for all domains")); + } + +} + +?> \ No newline at end of file diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc new file mode 100644 index 00000000..e68f0f5b --- /dev/null +++ b/lam/lib/types/user.inc @@ -0,0 +1,247 @@ + _("User ID"), + "uidnumber" => _("UID number"), + "gidnumber" => _("GID number"), + "cn" => _("User name"), + "host" => _("Allowed hosts"), + "givenname" => _("First name"), + "sn" => _("Last name"), + "homedirectory" => _("Home directory"), + "loginshell" => _("Login shell"), + "mail" => _("E-Mail"), + "gecos" => _("Description") + ); + } + +} + +/** + * Generates the list view. + * + * @package lists + * @author Roland Gruber + * + */ +class lamUserList extends lamList { + + /** Controls if GID number is translated to group name */ + var $trans_primary = false; + + /** translates GID to group name */ + var $trans_primary_hash = array(); + + /** + * Constructor + * + * @param string $type account type + * @return lamList list object + */ + function lamUserList($type) { + parent::lamList($type); + $this->labels = array( + 'nav' => _("%s user(s) found"), + 'error_noneFound' => _("No users found!"), + 'newEntry' => _("New user"), + 'deleteEntry' => _("Delete user"), + 'createPDF' => _("Create PDF for selected user(s)"), + 'createPDFAll' => _("Create PDF for all users")); + } + + /** + * Manages all POST actions (e.g. button pressed) for the account lists. + */ + function listDoPost() { + parent::listDoPost(); + // check if primary group should be translated + if (isset($_POST['apply_trans_primary'])) { + $this->trans_primary = $_POST['trans_primary']; + } + // generate hash table for group translation + if ($this->trans_primary == "on" && ($this->refresh || (sizeof($this->trans_primary_hash) == 0))) { + $this->trans_primary_hash = array(); + $grp_suffix = $_SESSION['config']->get_Suffix('group'); + $filter = "objectClass=posixGroup"; + $attrs = array("cn", "gidNumber"); + $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); + if ($sr) { + $info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr); + unset($info['count']); // delete count entry + for ($i = 0; $i < sizeof($info); $i++) { + $this->trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0]; + } + } + } + } + + /** + * Prints the entry list + * + * @param array $info entries + */ + function listPrintTableBody($info) { + // calculate which rows to show + $table_begin = ($this->page - 1) * $this->maxPageEntries; + if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info); + else $table_end = ($this->page * $this->maxPageEntries); + // translate GIDs and resort array if selected + if ($this->trans_primary == "on") { + // translate GIDs + for ($i = 0; $i < sizeof($info); $i++) { + if (isset($this->trans_primary_hash[$info[$i]['gidnumber'][0]])) { + $info[$i]['gidnumber'][0] = $this->trans_primary_hash[$info[$i]['gidnumber'][0]]; + } + } + // resort if needed + if ($this->sortColumn == "gidnumber") { + $info = $this->listSort($info); + } + } + // print account list + for ($i = $table_begin; $i < $table_end; $i++) { + echo("type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" . + " onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&DN=" . $info[$i]['dn'] . "'\">\n"); + if (isset($_GET['selectall'])) { + echo " type . "')\"" . + " type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\">\n"; + } + else { + echo " type . "')\"" . + " type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\">\n"; + } + echo (" type . "&DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "\n"); + for ($k = 0; $k < sizeof($this->attrArray); $k++) { + echo (""); + // print all attribute entries seperated by "; " + $attrName = strtolower($this->attrArray[$k]); + if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) { + // delete "count" entry + unset($info[$i][$attrName]['count']); + if (is_array($info[$i][$attrName])) { + // sort array + sort($info[$i][$attrName]); + echo implode("; ", $info[$i][$attrName]); + } + else echo $info[$i][$attrName]; + } + echo ("\n"); + } + echo("\n"); + } + // display select all link + $colspan = sizeof($this->attrArray) + 1; + echo "type . "list\">\n"; + echo "\"select\n"; + echo " type . "&norefresh=y&page=" . $this->page . + "&sort=" . $this->sortColumn . $this->filterText . "&selectall=yes\">" . + "" . _("Select all") . "\n"; + echo "\n"; + echo (""); + + echo ("
"); + } + + /** + * Prints the create, delete and PDF buttons. + * + * @param boolean $createOnly true if only the create button should be displayed + */ + function listPrintButtons($createOnly) { + // show translate GID to group name box if there is a column with gidnumber + if (in_array("gidnumber", $this->attrArray)) { + echo "

\n"; + echo "" . _("Translate GID number to group name") . ": "; + if ($this->trans_primary == "on") { + echo ""; + } + else echo ""; + echo ("  "); + echo "

\n"; + } + + echo ("

 

\n"); + parent::listPrintButtons($createOnly); + } + +} + +?> \ No newline at end of file diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index 50e588c1..3f2ffd08 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -79,253 +79,8 @@ legend { color:#007a3b; } - -/** - * style for userlist.php - * - */ - -/* table preferences */ -table.userlist { - border-width:1px; - border-style:solid; - border-color:#9b8523; -} - -/* color of entry rows */ -tr.userlist { - background-color:#fffde2; -} - -/* color of head row */ -tr.userlist-head { - background-color:#fff2a3; - font-weight:bold; -} - -/* color of rows on mouseOver */ -tr.userlist-over { - background-color:#ccccff; -} - -/* color of checked rows */ -tr.userlist-checked { - background-color:#f27c71; -} - -/* color for active page digit */ -td.usernav-activepage { - color:red; -} - -/* style of navigation bar */ -td.usernav { - color:#AAAAAA; -} - -table.usernav { - background-color:#fff2a3; - border-width:1px; - border-style:solid; - border-color:#9b8523; -} - -td.usernav-text { - color:green; - font-family:Verdana,sans-serif; - font-size:12px; -} - -/* style of active column */ -th.userlist-sort { - background-color:#fffde2; -} - - -/** - * table style for grouplist.php - * - */ - -/* navigation bar */ -table.groupnav { - background-color:#a8c3ff; - border-width:1px; - border-style:solid; - border-color:#7167bf; -} - -/* text in navigation bar */ -td.groupnav-text { - color:green; - font-family:Verdana,sans-serif; - font-size:12px; -} - -/* color for active page digit */ -td.groupnav-activepage { - color:red; -} - -/* table preferences */ -table.grouplist { - border-width:1px; - border-style:solid; - border-color:#7167bf; -} - -/* color of entry rows */ -tr.grouplist { - background-color:#d6e3ff; -} - -/* color of head row */ -tr.grouplist-head { - background-color:#a8c3ff; -} - -/* color of sorted column in head row */ -th.grouplist-sort { - background-color:#d6e3ff; -} - -/* color of rows on mouseOver */ -tr.grouplist-over { - background-color:#C7E7C7; -} - -/* color of checked rows */ -tr.grouplist-checked { - background-color:#f27c71; -} - -/** - * table style for hostlist.php - * - */ - -/* */ -table.hostnav { - background-color:#ffc4ba; - border-width:1px; - border-style:solid; - border-color:#911a1a; -} - -/* text in navigation bar */ -td.hostnav-text { - color:green; - font-family:Verdana,sans-serif; - font-size:12px; -} - -/* color for active page digit */ -td.hostnav-activepage { - color:red; -} - -/* table preferences */ -table.hostlist { - border-width:1px; - border-style:solid; - border-color:#911a1a; -} - -/* color of entry rows */ -tr.hostlist { - background-color:#ffe2dd; -} - -/* color of head row */ -tr.hostlist-head { - background-color:#ffc4ba; -} - -/* color of sorted column in head row */ -th.hostlist-sort { - background-color:#ffe2dd; -} - -/* color of rows on mouseOver */ -tr.hostlist-over { - background-color:#ffe265; -} - -/* color of checked rows */ -tr.hostlist-checked { - background-color:#f27c71; -} - -/** - * table style for domainlist.php - * - */ - -/* */ -table.domainnav { - background-color:#a8ddbf; - border-width:1px; - border-style:solid; - border-color:#1d993e; -} - -/* text in navigation bar */ -td.domainnav-text { - color:green; - font-family:Verdana,sans-serif; - font-size:12px; -} - -/* color for active page digit */ -td.domainnav-activepage { - color:red; -} - -/* table preferences */ -table.domainlist { - border-width:1px; - border-style:solid; - border-color:#1d993e; -} - -/* color of entry rows */ -tr.domainlist { - background-color:#c9ddd2; -} - -/* color of head row */ -tr.domainlist-head { - background-color:#a8ddbf; -} - -/* color of sorted column in head row */ -th.domainlist-sort { - background-color:#c9ddd2; -} - -/* color of rows on mouseOver */ -tr.domainlist-over { - background-color:#ffe265; -} - -/* color of checked rows */ -tr.domainlist-checked { - background-color:#f27c71; -} - -/** - * style for domain.php - * - */ - -/* fieldset and legend */ - -fieldset.domedit { -background-color:#c9ddd2; -} - -legend.domedit { -color:blue; +fieldset fieldset legend { +color:black; } @@ -437,83 +192,6 @@ p.statusError { margin-right:35px; } -/** - * table style for groupedit.php - * - */ - -fieldset.groupedit { - background-color:#d6e3ff; -} - -fieldset.groupedit legend { - color:blue; -} - -fieldset.groupedit fieldset { - background-color:#d6e3ff; -} - -fieldset.groupedit fieldset fieldset { - background-color:#d6e3ff; -} - -fieldset.groupedit select { - background-color:#a8c3ff; -} - - -/** - * table style for hostedit.php - * - */ - -fieldset.hostedit { - background-color:#ffe2dd; -} - -fieldset.hostedit legend { - color:blue; -} - -fieldset.hostedit fieldset { - background-color:#ffe2dd; -} - -fieldset.hostedit fieldset fieldset { - background-color:#ffe2dd; -} - -fieldset.hostedit select { - background-color:#ffc4ba; -} - - -/** - * table style for useredit.php - * - */ - -fieldset.useredit { - background-color:#fff2a3; -} - -fieldset.useredit legend { - color:blue; -} - -fieldset.useredit fieldset { - background-color:#fff2a3; -} - -fieldset.useredit fieldset fieldset { - background-color:#fff2a3; -} - -fieldset.useredit select { - background-color:#fffde2; -} - /* schema browser */ diff --git a/lam/style/600_type_group.css b/lam/style/600_type_group.css new file mode 100644 index 00000000..01358ff6 --- /dev/null +++ b/lam/style/600_type_group.css @@ -0,0 +1,100 @@ +/* +$Id$ + + This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) + Copyright (C) 2005-2006 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more detaexils. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +/** + * style definition for group accounts + */ + + +/* navigation bar */ +table.groupnav { + background-color:#a8c3ff; + border-width:1px; + border-style:solid; + border-color:#7167bf; +} + +/* text in navigation bar */ +td.groupnav-text { + color:green; + font-family:Verdana,sans-serif; + font-size:12px; +} + +/* color for active page digit */ +td.groupnav-activepage { + color:red; +} + +/* table preferences */ +table.grouplist { + border-width:1px; + border-style:solid; + border-color:#7167bf; +} + +/* color of entry rows */ +tr.grouplist { + background-color:#d6e3ff; +} + +/* color of head row */ +tr.grouplist-head { + background-color:#a8c3ff; +} + +/* color of sorted column in head row */ +th.grouplist-sort { + background-color:#d6e3ff; +} + +/* color of rows on mouseOver */ +tr.grouplist-over { + background-color:#C7E7C7; +} + +/* color of checked rows */ +tr.grouplist-checked { + background-color:#f27c71; +} + +fieldset.groupedit { + background-color:#d6e3ff; +} + +fieldset.groupedit legend { + color:blue; +} + +fieldset.groupedit fieldset { + background-color:#d6e3ff; +} + +fieldset.groupedit fieldset fieldset { + background-color:#d6e3ff; +} + +fieldset.groupedit select { + background-color:#a8c3ff; +} + diff --git a/lam/style/600_type_host.css b/lam/style/600_type_host.css new file mode 100644 index 00000000..30870b4b --- /dev/null +++ b/lam/style/600_type_host.css @@ -0,0 +1,100 @@ +/* +$Id$ + + This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) + Copyright (C) 2005-2006 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more detaexils. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +/** + * style definition for host accounts + * + */ + +/* */ +table.hostnav { + background-color:#ffc4ba; + border-width:1px; + border-style:solid; + border-color:#911a1a; +} + +/* text in navigation bar */ +td.hostnav-text { + color:green; + font-family:Verdana,sans-serif; + font-size:12px; +} + +/* color for active page digit */ +td.hostnav-activepage { + color:red; +} + +/* table preferences */ +table.hostlist { + border-width:1px; + border-style:solid; + border-color:#911a1a; +} + +/* color of entry rows */ +tr.hostlist { + background-color:#ffe2dd; +} + +/* color of head row */ +tr.hostlist-head { + background-color:#ffc4ba; +} + +/* color of sorted column in head row */ +th.hostlist-sort { + background-color:#ffe2dd; +} + +/* color of rows on mouseOver */ +tr.hostlist-over { + background-color:#ffe265; +} + +/* color of checked rows */ +tr.hostlist-checked { + background-color:#f27c71; +} + +fieldset.hostedit { + background-color:#ffe2dd; +} + +fieldset.hostedit legend { + color:blue; +} + +fieldset.hostedit fieldset { + background-color:#ffe2dd; +} + +fieldset.hostedit fieldset fieldset { + background-color:#ffe2dd; +} + +fieldset.hostedit select { + background-color:#ffc4ba; +} + diff --git a/lam/style/600_type_mailAlias.css b/lam/style/600_type_mailAlias.css new file mode 100644 index 00000000..6395a3ec --- /dev/null +++ b/lam/style/600_type_mailAlias.css @@ -0,0 +1,100 @@ +/* +$Id$ + + This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) + Copyright (C) 2005-2006 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more detaexils. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +/** + * style definition for mailing list accounts + */ + + +/* navigation bar */ +table.mailAliasnav { + background-color:#ffe27f; + border-width:1px; + border-style:solid; + border-color:#af8800; +} + +/* text in navigation bar */ +td.mailAliasnav-text { + color:green; + font-family:Verdana,sans-serif; + font-size:12px; +} + +/* color for active page digit */ +td.mailAliasnav-activepage { + color:red; +} + +/* table preferences */ +table.mailAliaslist { + border-width:1px; + border-style:solid; + border-color:#af8800; +} + +/* color of entry rows */ +tr.mailAliaslist { + background-color:#fff3c8; +} + +/* color of head row */ +tr.mailAliaslist-head { + background-color:#ffe27f; +} + +/* color of sorted column in head row */ +th.mailAliaslist-sort { + background-color:#fff3c8; +} + +/* color of rows on mouseOver */ +tr.mailAliaslist-over { + background-color:#d6e3ff; +} + +/* color of checked rows */ +tr.mailAliaslist-checked { + background-color:#f27c71; +} + +fieldset.mailAliasedit { + background-color:#fff3c8; +} + +fieldset.mailAliasedit legend { + color:blue; +} + +fieldset.mailAliasedit fieldset { + background-color:#fff3c8; +} + +fieldset.mailAliasedit fieldset fieldset { + background-color:#fff3c8; +} + +fieldset.mailAliasedit select { + background-color:#ffe27f; +} + diff --git a/lam/style/600_type_smbDomain.css b/lam/style/600_type_smbDomain.css new file mode 100644 index 00000000..741f05cb --- /dev/null +++ b/lam/style/600_type_smbDomain.css @@ -0,0 +1,100 @@ +/* +$Id$ + + This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) + Copyright (C) 2005-2006 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more detaexils. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +/** + * style definition for smbDomain accounts + * + */ + +/* */ +table.smbDomainnav { + background-color:#a8ddbf; + border-width:1px; + border-style:solid; + border-color:#1d993e; +} + +/* text in navigation bar */ +td.smbDomainnav-text { + color:green; + font-family:Verdana,sans-serif; + font-size:12px; +} + +/* color for active page digit */ +td.smbDomainnav-activepage { + color:red; +} + +/* table preferences */ +table.smbDomainlist { + border-width:1px; + border-style:solid; + border-color:#1d993e; +} + +/* color of entry rows */ +tr.smbDomainlist { + background-color:#c9ddd2; +} + +/* color of head row */ +tr.smbDomainlist-head { + background-color:#a8ddbf; +} + +/* color of sorted column in head row */ +th.smbDomainlist-sort { + background-color:#c9ddd2; +} + +/* color of rows on mouseOver */ +tr.smbDomainlist-over { + background-color:#ffe265; +} + +/* color of checked rows */ +tr.smbDomainlist-checked { + background-color:#f27c71; +} + + +fieldset.smbDomainedit { + background-color:#c9ddd2; +} + +fieldset.smbDomainedit legend { + color:blue; +} + +fieldset.smbDomainedit fieldset { + background-color:#c9ddd2; +} + +fieldset.smbDomainedit fieldset fieldset { + background-color:#c9ddd2; +} + +fieldset.smbDomainedit select { + background-color:#a8ddbf; +} diff --git a/lam/style/600_type_user.css b/lam/style/600_type_user.css new file mode 100644 index 00000000..eb47ebac --- /dev/null +++ b/lam/style/600_type_user.css @@ -0,0 +1,119 @@ +/* +$Id$ + + This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) + Copyright (C) 2005-2006 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more detaexils. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +/** + * style definition for user accounts + */ + +/** +* Preferences for the list view and some other pages which have no own definitions (e.g. profile editor). +*/ + +/* main table of account list */ +table.userlist { + border-width:1px; + border-style:solid; + border-color:#9b8523; +} + +/* color of entry rows */ +tr.userlist { + background-color:#fffde2; +} + +/* color of head row */ +tr.userlist-head { + background-color:#fff2a3; + font-weight:bold; +} + +/* color of rows on mouseOver */ +tr.userlist-over { + background-color:#ccccff; +} + +/* color of checked rows */ +tr.userlist-checked { + background-color:#f27c71; +} + +/* color of sorted column */ +th.userlist-sort { + background-color:#fffde2; +} + + + + +/* style of navigation bar */ +table.usernav { + background-color:#fff2a3; + border-width:1px; + border-style:solid; + border-color:#9b8523; +} + +/* text area in the center, e.g. "100 object(s) found" */ +td.usernav-text { + color:green; + font-family:Verdana,sans-serif; + font-size:12px; +} + +/* color for active page number */ +td.usernav-activepage { + color:red; +} + + + + +/* account pages */ + +/* main fieldset */ +fieldset.useredit { + background-color:#fff2a3; +} + +/* legend of main fieldset */ +fieldset.useredit legend { + color:blue; +} + +/* subfieldset */ +fieldset.useredit fieldset { + background-color:#fff2a3; +} + +/* subsubfieldset */ +fieldset.useredit fieldset fieldset { + background-color:#fff2a3; +} + +/* select boxes */ +fieldset.useredit select { + background-color:#fffde2; +} + + + diff --git a/lam/templates/config/conflogin.php b/lam/templates/config/conflogin.php index 9435d5e1..1b07f1b6 100644 --- a/lam/templates/config/conflogin.php +++ b/lam/templates/config/conflogin.php @@ -42,22 +42,10 @@ session_save_path("../../sess"); setlanguage(); // remove settings from session -unset($_SESSION['conf_passwd']); -unset($_SESSION['conf_passwd1']); -unset($_SESSION['conf_passwd2']); -unset($_SESSION['conf_serverurl']); -unset($_SESSION['conf_admins']); -unset($_SESSION['conf_suffusers']); -unset($_SESSION['conf_suffgroups']); -unset($_SESSION['conf_suffhosts']); -unset($_SESSION['conf_usrlstattr']); -unset($_SESSION['conf_grplstattr']); -unset($_SESSION['conf_hstlstattr']); -unset($_SESSION['conf_maxlistentries']); -unset($_SESSION['conf_lang']); -unset($_SESSION['conf_scriptpath']); -unset($_SESSION['conf_scriptserver']); -unset($_SESSION['conf_filename']); +$sessionKeys = array_keys($_SESSION); +for ($i = 0; $i < sizeof($sessionKeys); $i++) { + if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]); +} echo $_SESSION['header']; diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 4b03e72b..f1f1df6d 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -43,9 +43,9 @@ session_save_path("../../sess"); setlanguage(); // check if button was pressed and if we have to save the setting or go back to login -if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmodules'])){ +if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmodules']) || isset($_POST['edittypes'])){ // save settings - if ($_POST['submitconf'] || $_POST['editmodules']){ + if ($_POST['submitconf'] || $_POST['editmodules'] || $_POST['edittypes']){ // save HTTP-POST variables in session $_SESSION['conf_passwd'] = $_POST['passwd']; $_SESSION['conf_passwd1'] = $_POST['passwd1']; @@ -53,21 +53,11 @@ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmo $_SESSION['conf_serverurl'] = $_POST['serverurl']; $_SESSION['conf_cachetimeout'] = $_POST['cachetimeout']; $_SESSION['conf_admins'] = $_POST['admins']; - $_SESSION['conf_suffusers'] = $_POST['suffusers']; - $_SESSION['conf_suffgroups'] = $_POST['suffgroups']; - $_SESSION['conf_suffhosts'] = $_POST['suffhosts']; - $_SESSION['conf_suffdomains'] = $_POST['suffdomains']; $_SESSION['conf_sufftree'] = $_POST['sufftree']; - $_SESSION['conf_usrlstattr'] = $_POST['usrlstattr']; - $_SESSION['conf_grplstattr'] = $_POST['grplstattr']; - $_SESSION['conf_hstlstattr'] = $_POST['hstlstattr']; $_SESSION['conf_maxlistentries'] = $_POST['maxlistentries']; $_SESSION['conf_lang'] = $_POST['lang']; $_SESSION['conf_scriptpath'] = $_POST['scriptpath']; $_SESSION['conf_scriptserver'] = $_POST['scriptserver']; - $_SESSION['conf_usermodules'] = explode(",", $_POST['usermodules']); - $_SESSION['conf_groupmodules'] = explode(",", $_POST['groupmodules']); - $_SESSION['conf_hostmodules'] = explode(",", $_POST['hostmodules']); $_SESSION['conf_filename'] = $_POST['filename']; $modSettings = array_keys($_SESSION['config_types']); for ($i = 0; $i < sizeof($modSettings); $i++) $_SESSION['config_moduleSettings'][$modSettings[$i]] = $_POST[$modSettings[$i]]; @@ -80,6 +70,10 @@ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmo elseif ($_POST['editmodules']){ metaRefresh("confmodules.php"); } + // go to types page + elseif ($_POST['edittypes']){ + metaRefresh("conftypes.php"); + } // back to login else if ($_POST['back']){ metaRefresh("../login.php"); @@ -89,7 +83,7 @@ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmo // get password if register_globals is off if (isset($_POST['passwd'])) $passwd = $_POST['passwd']; -if (isset($_GET["modulesback"])) $passwd = $_SESSION['conf_passwd']; +if (isset($_GET["modulesback"]) || isset($_GET["typesback"])) $passwd = $_SESSION['conf_passwd']; // check if password was entered // if not: load login page @@ -101,7 +95,7 @@ if (! $passwd) { } $filename = $_POST['filename']; -if (isset($_GET["modulesback"])) $filename = $_SESSION['conf_filename']; +if (isset($_GET["modulesback"]) || isset($_GET["typesback"])) $filename = $_SESSION['conf_filename']; $conf = new Config($filename); // check if password is valid @@ -119,26 +113,26 @@ if (isset($_GET["modulesback"])) { $conf->set_ServerURL($_SESSION['conf_serverurl']); $conf->set_cacheTimeout($_SESSION['conf_cachetimeout']); $conf->set_Adminstring($_SESSION['conf_admins']); - $conf->set_Suffix('user', $_SESSION['conf_suffusers']); - $conf->set_Suffix('group', $_SESSION['conf_suffgroups']); - $conf->set_Suffix('host', $_SESSION['conf_suffhosts']); - $conf->set_Suffix('domain', $_SESSION['conf_suffdomains']); $conf->set_Suffix('tree', $_SESSION['conf_sufftree']); - $conf->set_listAttributes($_SESSION['conf_usrlstattr'], 'user'); - $conf->set_listAttributes($_SESSION['conf_grplstattr'], 'group'); - $conf->set_listAttributes($_SESSION['conf_hstlstattr'], 'host'); $conf->set_MaxListEntries($_SESSION['conf_maxlistentries']); $conf->set_defaultLanguage($_SESSION['conf_lang']); $conf->set_scriptpath($_SESSION['conf_scriptpath']); $conf->set_scriptserver($_SESSION['conf_scriptserver']); - // check if modules were edited - if ($_GET["moduleschanged"] == "true") { - $conf->set_AccountModules($_SESSION['conf_usermodules'], 'user'); - $conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group'); - $conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host'); +} + +// check if user comes from types page +if (isset($_GET["typesback"])) { + // check if a new account type was added + if (isset($_GET["typeschanged"])) { + metaRefresh("confmodules.php"); + exit; } } +// type information +if (!isset($_SESSION['conf_accountTypes'])) $_SESSION['conf_accountTypes'] = $conf->get_ActiveTypes(); +if (!isset($_SESSION['conf_typeSettings'])) $_SESSION['conf_typeSettings'] = $conf->get_typeSettings(); + // index for tab order $tabindex = 1; $tabindexLink = 1000; @@ -172,49 +166,9 @@ $tabindex++; // new line echo (" "); -// user suffix -echo ("". - _("UserSuffix") . ": ". - "get_Suffix('user') . "\">\n"); -echo ""; -echo ""; -echo "\"""; -echo "\n"; -echo "\n"; -$tabindex++; -// group suffix -echo ("". - _("GroupSuffix") . ": ". - "get_Suffix('group') . "\">\n"); -echo ""; -echo ""; -echo "\"""; -echo "\n"; -echo "\n"; -$tabindex++; -// host suffix -echo ("". - _("HostSuffix") . ": ". - "get_Suffix('host') . "\">\n"); -echo ""; -echo ""; -echo "\"""; -echo "\n"; -echo "\n"; -$tabindex++; -// domain suffix -echo ("". - _("DomainSuffix") . " **: ". - "get_Suffix('domain') . "\">\n"); -echo ""; -echo ""; -echo "\"""; -echo "\n"; -echo "\n"; -$tabindex++; // tree suffix echo ("". - _("TreeSuffix") . ": ". + _("Tree suffix") . ":
". "get_Suffix('tree') . "\">\n"); echo ""; echo ""; @@ -249,22 +203,22 @@ echo ("
"); echo ("

"); -echo ("
" . _("Account modules") . ""); -echo (""); +echo ("
" . _("Account types and modules") . ""); // Account modules -echo "
\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; $tabindex++; -echo ("
" . _("User modules") . ": " . implode(", ", $conf->get_AccountModules('user')) . "
" . _("Group modules") . ": " . implode(", ", $conf->get_AccountModules('group')) . "
" . _("Host modules") . ": " . implode(", ", $conf->get_AccountModules('host')) . "
 
  "; +$types = $_SESSION['conf_accountTypes']; +for ($i = 0; $i < sizeof($types); $i++) { + echo "" . getTypeAlias($types[$i]) . ": " . implode(", ", $conf->get_AccountModules($types[$i])) . "
\n"; +} +echo "
\n"; +echo "  "; +$tabindex++; +echo "  "; echo ""; echo "\"""; echo "\n"; -echo "
"); echo ("
"); echo ("

"); @@ -274,12 +228,10 @@ echo ("

"); // get list of scopes of modules $scopes = array(); -$mods = $conf->get_AccountModules('user'); -for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'user'; -$mods = $conf->get_AccountModules('group'); -for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'group'; -$mods = $conf->get_AccountModules('host'); -for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'host'; +for ($m = 0; $m < sizeof($types); $m++) { + $mods = $conf->get_AccountModules($types[$m]); + for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; +} // get module options $options = getConfigOptions($scopes); @@ -305,42 +257,9 @@ for ($i = 0; $i < sizeof($modules); $i++) { } -echo ("
" . _("LDAP List settings") . "\n"); +echo ("
" . _("List settings") . "\n"); echo ("\n"); -// user list attributes -echo ("". - ""); -echo "\n"; -$tabindex++; -// group list attributes -echo ("". - ""); -echo "\n"; -$tabindex++; -// host list attributes -echo ("". - ""); -echo "\n"; -$tabindex++; - -echo ("\n"); - // maximum list entries echo ("". @@ -500,11 +419,6 @@ echo ("

\ // config file echo ("

\n"); -// modules -echo ("

get_AccountModules('user')) . "\">

\n"); -echo ("

get_AccountModules('group')) . "\">

\n"); -echo ("

get_AccountModules('host')) . "\">

\n"); - echo ("\n"); echo ("\n"); echo ("\n"); diff --git a/lam/templates/config/confmodules.php b/lam/templates/config/confmodules.php index 02f00bbc..ca529b8a 100644 --- a/lam/templates/config/confmodules.php +++ b/lam/templates/config/confmodules.php @@ -56,30 +56,36 @@ if ($passwd != $conf->get_Passwd()) { if ($_POST['submit']) { //selection ok, back to other settings metarefresh('confmain.php?modulesback=true&moduleschanged=true'); + exit; } elseif ($_POST['abort']) { // no changes metarefresh('confmain.php?modulesback=true'); + exit; } +$types = $_SESSION['conf_accountTypes']; + echo $_SESSION['header']; echo "" . _("LDAP Account Manager Configuration") . "\n"; echo "\n"; +for ($i = 0; $i < sizeof($types); $i++){ + echo "\n"; +} echo "\n"; echo ("

". "\"LDAP



\n"); echo ("\n"); -echo "

" . _("Module selection") . "

"; +echo "

" . _("Module selection") . "

"; -$account_list = array( - array('user', _('User modules')), - array('group', _('Group modules')), - array('host', _('Host modules')) -); +$account_list = array(); +for ($i = 0; $i < sizeof($types); $i++) { + $account_list[] = array($types[$i], getTypeAlias($types[$i])); +} $allDependenciesOk = true; @@ -126,7 +132,8 @@ echo "\n"; */ function config_showAccountModules($scope, $title) { // account modules - $selected_temp = $_SESSION['conf_' . $scope . 'modules']; + $selected_temp = $_SESSION['conf_typeSettings']['modules_' . $scope]; + if (isset($selected_temp)) $selected_temp = explode(',', $selected_temp); $available = array(); $available = getAvailableModules($scope); $selected = array(); @@ -145,7 +152,7 @@ function config_showAccountModules($scope, $title) { if (! in_array($selected[$i], $_POST[$scope . '_selected'])) $new_selected[] = $selected[$i]; } $selected = $new_selected; - $_SESSION['conf_' . $scope . 'modules'] = $selected; + $_SESSION['conf_typeSettings']['modules_' . $scope] = implode(',', $selected); } // add modules to selection @@ -155,7 +162,7 @@ function config_showAccountModules($scope, $title) { if (! in_array($_POST[$scope . '_available'][$i], $selected)) $new_selected[] = $_POST[$scope . '_available'][$i]; } $selected = $new_selected; - $_SESSION['conf_' . $scope . 'modules'] = $selected; + $_SESSION['conf_typeSettings']['modules_' . $scope] = implode(',', $selected); } // show account modules diff --git a/lam/templates/config/confsave.php b/lam/templates/config/confsave.php index 6ca7d3a2..55cb92fc 100644 --- a/lam/templates/config/confsave.php +++ b/lam/templates/config/confsave.php @@ -48,14 +48,7 @@ $passwd2 = $_SESSION['conf_passwd2']; $serverurl = $_SESSION['conf_serverurl']; $cachetimeout = $_SESSION['conf_cachetimeout']; $admins = $_SESSION['conf_admins']; -$suffusers = $_SESSION['conf_suffusers']; -$suffgroups = $_SESSION['conf_suffgroups']; -$suffhosts = $_SESSION['conf_suffhosts']; -$suffdomains = $_SESSION['conf_suffdomains']; $sufftree = $_SESSION['conf_sufftree']; -$usrlstattr = $_SESSION['conf_usrlstattr']; -$grplstattr = $_SESSION['conf_grplstattr']; -$hstlstattr = $_SESSION['conf_hstlstattr']; $maxlistentries = $_SESSION['conf_maxlistentries']; $lang = $_SESSION['conf_lang']; $scriptpath = $_SESSION['conf_scriptpath']; @@ -81,10 +74,7 @@ echo ("

set_Adminstring($admins)) { echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$conf->set_Suffix('user', $suffusers)) { - echo ("" . _("UserSuffix is invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (!$conf->set_Suffix('group', $suffgroups)) { - echo ("" . _("GroupSuffix is invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (!$conf->set_Suffix('host', $suffhosts)) { - echo ("" . _("HostSuffix is invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (!$conf->set_Suffix('domain', $suffdomains)) { - echo ("" . _("DomainSuffix is invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} if (!$conf->set_Suffix("tree", $sufftree)) { echo ("" . _("TreeSuffix is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$conf->set_listAttributes($usrlstattr, 'user')) { - echo ("" . _("User list attributes are invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (!$conf->set_listAttributes($grplstattr, 'group')) { - echo ("" . _("Group list attributes are invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (!$conf->set_listAttributes($hstlstattr, 'host')) { - echo ("" . _("Host list attributes are invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} if (!$conf->set_MaxListEntries($maxlistentries)) { echo ("" . _("Max list entries is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); @@ -167,23 +122,8 @@ if (!$conf->set_scriptserver($scriptserver)) { exit; } -if (! $conf->set_AccountModules($_SESSION['conf_usermodules'], 'user')) { - echo ("" . _("Saving user modules failed!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} - -if (! $conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group')) { - echo ("" . _("Saving group modules failed!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} - -if (! $conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host')) { - echo ("" . _("Saving host modules failed!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} +$conf->set_typeSettings($_SESSION['conf_typeSettings']); +$conf->set_ActiveTypes($_SESSION['conf_accountTypes']); // check module options // create option array to check and save @@ -249,34 +189,14 @@ if ($passwd1) { // save settings and display new settings $conf->save(); -echo ("" . _("The following settings were saved to profile:") . " " . $filename . "

"); -$conf->printconf(); echo ("




" . _("Back to Login") . ""); echo(""); // remove settings from session -unset($_SESSION['conf_passwd']); -unset($_SESSION['conf_passwd1']); -unset($_SESSION['conf_passwd2']); -unset($_SESSION['conf_serverurl']); -unset($_SESSION['conf_cachetimeout']); -unset($_SESSION['conf_admins']); -unset($_SESSION['conf_suffusers']); -unset($_SESSION['conf_suffgroups']); -unset($_SESSION['conf_suffhosts']); -unset($_SESSION['conf_suffdomains']); -unset($_SESSION['conf_sufftree']); -unset($_SESSION['conf_usrlstattr']); -unset($_SESSION['conf_grplstattr']); -unset($_SESSION['conf_hstlstattr']); -unset($_SESSION['conf_maxlistentries']); -unset($_SESSION['conf_lang']); -unset($_SESSION['conf_scriptpath']); -unset($_SESSION['conf_scriptserver']); -unset($_SESSION['conf_filename']); -unset($_SESSION['conf_usermodules']); -unset($_SESSION['conf_groupmodules']); -unset($_SESSION['conf_hostmodules']); +$sessionKeys = array_keys($_SESSION); +for ($i = 0; $i < sizeof($sessionKeys); $i++) { + if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]); +} ?> diff --git a/lam/templates/config/conftypes.php b/lam/templates/config/conftypes.php new file mode 100644 index 00000000..7b413630 --- /dev/null +++ b/lam/templates/config/conftypes.php @@ -0,0 +1,224 @@ +get_Passwd()) { + /** go back to login if password is invalid */ + require('conflogin.php'); + exit; +} + +// update type settings +if (isset($_POST['postAvailable'])) { + $postKeys = array_keys($_POST); + for ($i = 0; $i < sizeof($postKeys); $i++) { + $key = $postKeys[$i]; + if (substr($key, 0, 7) == "suffix_") { + $_SESSION['conf_typeSettings'][$key] = $_POST[$key]; + } + elseif (substr($key, 0, 5) == "attr_") { + $_SESSION['conf_typeSettings'][$key] = $_POST[$key]; + } + } +} + +$errors = array(); +// user pressed submit/abort button +if ($_POST['submit']) { + // check settings + $allOK = true; + $postKeys = array_keys($_POST); + for ($i = 0; $i < sizeof($postKeys); $i++) { + $key = $postKeys[$i]; + if (substr($key, 0, 7) == "suffix_") { + $type = substr($postKeys[$i], 7); + if (strlen($_POST[$key]) < 1) { + $errors[] = array("ERROR", _("LDAP Suffix is invalid!"), getTypeAlias($type)); + $allOK = false; + } + } + elseif (substr($key, 0, 5) == "attr_") { + $type = substr($postKeys[$i], 5); + if (!is_string($_POST[$key]) || !eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $_POST[$key])) { + $errors[] = array("ERROR", _("List attributes are invalid!"), getTypeAlias($type)); + $allOK = false; + } + } + } + if ($allOK) { + //selection ok, back to other settings + metarefresh('confmain.php?typesback=true&typeschanged=true'); + exit; + } +} +elseif ($_POST['abort']) { + // no changes + metarefresh('confmain.php?typesback=true'); + exit; +} + +// check if remove button was pressed +$postKeys = array_keys($_POST); +for ($i = 0; $i < sizeof($postKeys); $i++) { + $key = $postKeys[$i]; + if (substr($key, 0, 4) == "rem_") { + $type = substr($key, 4); + $_SESSION['conf_accountTypes'] = array_flip($_SESSION['conf_accountTypes']); + unset($_SESSION['conf_accountTypes'][$type]); + $_SESSION['conf_accountTypes'] = array_flip($_SESSION['conf_accountTypes']); + $_SESSION['conf_accountTypes'] = array_values($_SESSION['conf_accountTypes']); + } +} + +// check if add button was pressed +$postKeys = array_keys($_POST); +for ($i = 0; $i < sizeof($postKeys); $i++) { + $key = $postKeys[$i]; + if (substr($key, 0, 4) == "add_") { + $type = substr($key, 4); + $_SESSION['conf_accountTypes'][] = $type; + } +} + + +// get active and available types +$allTypes = getTypes(); +$activeTypes = $_SESSION['conf_accountTypes']; +$availableTypes = array(); +for ($i = 0; $i < sizeof($allTypes); $i++) { + if (!in_array($allTypes[$i], $activeTypes)) $availableTypes[] = $allTypes[$i]; +} + +echo $_SESSION['header']; + +echo "" . _("LDAP Account Manager Configuration") . "\n"; +echo "\n"; +for ($i = 0; $i < sizeof($allTypes); $i++){ + echo "\n"; +} +echo "\n"; + +echo ("

". + "\"LDAP



\n"); + +// print error messages +for ($i = 0; $i < sizeof($errors); $i++) call_user_func_array('StatusMessage', $errors[$i]); + +echo ("\n"); +echo "

" . _("Account type selection") . "

"; + +// show available types +echo "
" . _("Available account types") . "\n"; +echo "
". - _("Attributes in User List") . " *:get_listAttributes('user') . "\">"; -echo ""; -echo "\"""; -echo "\n"; -echo "
". - _("Attributes in Group List") . " *:get_listAttributes('group') . "\">"; -echo ""; -echo "\"""; -echo "\n"; -echo "
". - _("Attributes in Host List") . " **:get_listAttributes('host') . "\">"; -echo ""; -echo "\"""; -echo "\n"; -echo "
 
". _("Maximum list entries") . " :
\n"; +for ($i = 0; $i < sizeof($availableTypes); $i++) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +} +echo "
" . getTypeAlias($availableTypes[$i]) . ": " . getTypeDescription($availableTypes[$i]) . "
\n"; +echo "
\n"; + +echo "



"; + +// show active types +echo "
" . _("Active account types") . "
\n"; +for ($i = 0; $i < sizeof($activeTypes); $i++) { + echo "
\n"; + echo "" . "" . getTypeAlias($activeTypes[$i]) . ": " . getTypeDescription($activeTypes[$i]) . ""; + echo "
\n"; + echo "\n"; + // LDAP suffix + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + // list attributes + if (isset($_SESSION['conf_typeSettings']['attr_' . $activeTypes[$i]])) { + $attributes = $_SESSION['conf_typeSettings']['attr_' . $activeTypes[$i]]; + } + else { + $attributes = getDefaultListAttributes($activeTypes[$i]); + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + // remove button + echo "\n"; + echo "\n"; + echo "\n"; + echo "
" . _("LDAP suffix") . "
" . _("List attributes") . "
 
\n"; + echo "

\n"; +} +echo "
\n"; + + +echo "



\n"; + +// submit and abort button +echo "

"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

"; + +echo "



\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + + + +?> + + + + diff --git a/lam/templates/domain.php b/lam/templates/domain.php deleted file mode 100644 index 2e217d9a..00000000 --- a/lam/templates/domain.php +++ /dev/null @@ -1,357 +0,0 @@ -get_Suffix('domain')); - // get possible suffixes - $domsuff = $_SESSION['ldap']->search_units($_SESSION['config']->get_Suffix('domain')); - if ($_GET['action'] == "edit") { - // remove "\'" - $_GET['DN'] = str_replace("\\", "", $_GET['DN']); - $_GET['DN'] = str_replace("'", "", $_GET['DN']); - // load attributes from domain - for ($i = 0; $i < sizeof($domlist); $i++) { - if ($domlist[$i]->dn == $_GET['DN']) { - $domain = $domlist[$i]; - break; - } - } - // get suffix - $tmp_arr = explode(",", $domain->dn); - array_shift($tmp_arr); - $domain_suffix = implode(",", $tmp_arr); - } - else { - $domain = new samba3domain(); - $domain_suffix = $_SESSION['config']->get_Suffix('domain'); - } - // display page - echo $_SESSION['header']; - echo "Domain Management\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // print message, if needed - if ($_SESSION['domain_message']) StatusMessage("INFO", $_SESSION['domain_message'], ""); - // print fieldset - echo "
\n"; - echo "

 

\n"; - echo "
\n"; - echo "" . _("Domain Settings") . "\n"; - echo "\n"; - // domain name - echo "\n"; - echo "\n"; - echo "\n"; - echo ("\n"); - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // domain SID - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // next RID - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // next user RID - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // next group RID - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // algorithmic RID base - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // domain suffix - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "" . _("Domain name") . ":\n"; - echo "\n"; - if ($_GET['action'] == "edit") { - echo $domain->name . "\n"; - } - else echo "\n"; - echo ""); - // help link - echo ""; - echo "\"""; - echo "\n"; - echo ("
  
\n"; - echo "" . _("Domain SID") . ": \n"; - echo "\n"; - if ($_GET['action'] == "edit") { - echo $domain->SID . "\n"; - } - else echo "\n"; - echo ""; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo "
  
" . _("Next RID") . ": \n"; - echo "nextRID . "\">\n"; - echo ""; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo "
" . _("Next User RID") . ": \n"; - echo "nextUserRID . "\">\n"; - echo ""; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo "
" . _("Next Group RID") . ": \n"; - echo "nextGroupRID . "\">\n"; - echo ""; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo "
  
" . _("Algorithmic RID Base") . ": \n"; - if ($_GET['action'] == "edit") echo $domain->RIDbase . "\n"; - else echo "RIDbase . "\">\n"; - echo ""; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo "
  
\n"; - echo "" . _("Suffix") . ": \n"; - echo "\n"; - echo ""; - echo ""; - // help link - echo ""; - echo "\"""; - echo "\n"; - echo "
  
\n"; - echo "
\n"; - // post DN and old RID values - echo "dn . "\">"; - echo "nextRID . "\">"; - echo "nextUserRID . "\">"; - echo "nextGroupRID . "\">"; - // edit or add operation - if ($_GET['action'] == "edit") echo ""; - else echo ""; - echo "

 

\n"; - echo "

\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "

\n"; - echo "
\n"; - echo "\n"; - echo "\n"; -} - - -// delete domain, ask if sure -elseif ($_GET['action'] == "delete") { - // remove "\'" and make array - $DNs = str_replace("\\", "", $_GET['DN']); - $DNs = str_replace("'", "", $DNs); - $DNs = explode(";", $DNs); - // display page - echo $_SESSION['header']; - echo "Domain Management\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "

 

\n"; - echo "
" . _("Delete domain(s)") . "\n"; - echo "

" . _("Do you really want to delete domain(s):") . "

\n"; - echo "

 

\n"; - for ($i = 0; $i < sizeof($DNs); $i++) { - echo "

" . $DNs[$i] . "

\n"; - } - echo "

 

\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "
\n"; - echo "\n"; - echo "\n"; -} - - -// save domain -elseif ($_POST['sub_save']) { - echo $_SESSION['header']; - echo "Domain Management\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // check input - if ($_POST['add']) { // check for existing domains - $suffix = $_SESSION['config']->get_Suffix('domain'); - $server = $_SESSION['ldap']->server; - $filter = "(|(sambasid=" . $_POST['dom_SID'] . ")(sambadomainname=" . $_POST['dom_name'] . "))"; - $sr = @ldap_search($server, $suffix, $filter, array()); - $info = @ldap_get_entries($_SESSION["ldap"]->server, $sr); - } - if ($_POST['add'] && !eregi("^[a-z0-9_\\-]+$", $_POST['dom_name'])) StatusMessage("ERROR", "", _("Domain name is invalid!")); - elseif ($_POST['add'] && !eregi("^S-[0-9]-[0-9]-[0-9]{2,2}-[0-9]*-[0-9]*-[0-9]*$", $_POST['dom_SID'])) { - StatusMessage("ERROR", "", _("Samba 3 domain SID is invalid!")); - } - elseif ($_POST['add'] && ($info["count"] > 0)) { - StatusMessage("ERROR", "", _("This Samba 3 domain is already present!")); - } - elseif ($_POST['dom_nextRID'] && !is_numeric($_POST['dom_nextRID'])) StatusMessage("ERROR", "", _("Next RID is not a number!")); - elseif ($_POST['dom_nextUserRID'] && !is_numeric($_POST['dom_nextUserRID'])) StatusMessage("ERROR", "", _("Next user RID is not a number!")); - elseif ($_POST['dom_nextGroupRID'] && !is_numeric($_POST['dom_nextGroupRID'])) StatusMessage("ERROR", "", _("Next group RID is not a number!")); - elseif ($_POST['add'] && !is_numeric($_POST['dom_RIDbase'])) StatusMessage("ERROR", "", _("Algorithmic RID base is not a number!")); - // edit entry - elseif ($_POST['edit'] == "yes") { - $success = true; - // change attributes - $attr = array(); - if ($_POST['dom_nextRID'] != $_POST['dom_oldnextRID']) $attr['sambaNextRid'] = $_POST['dom_nextRID']; - if ($_POST['dom_nextUserRID'] != $_POST['dom_oldnextUserRID']) $attr['sambaNextUserRid'] = $_POST['dom_nextUserRID']; - if ($_POST['dom_nextGroupRID'] != $_POST['dom_oldnextGroupRID']) $attr['sambaNextGroupRid'] = $_POST['dom_nextGroupRID']; - if (sizeof($attr) > 0) $success = ldap_modify($_SESSION['ldap']->server(), $_POST['dom_DN'], $attr); - // change suffix - $RDN = explode(",", $_POST['dom_DN']); - $RDN = $RDN[0]; - $newDN = $RDN . "," . $_POST['dom_suffix']; - if ($_POST['dom_DN'] != $newDN) { - $success = ldap_rename($_SESSION['ldap']->server(), $_POST['dom_DN'], $RDN, $_POST['dom_suffix'], true); - } - if ($success) StatusMessage("INFO", _("Domain has been modified."), $_POST['dom_DN']); - else StatusMessage("ERROR", "", _("Failed to modify domain!")); - } - // add entry - else { - $DN = "sambaDomainName" . "=" . $_POST['dom_name'] . "," . $_POST['dom_suffix']; - $attr = array(); - $attr['objectclass'] = "sambaDomain"; - $attr['sambaDomainName'] = $_POST['dom_name']; - $attr['sambaSID'] = $_POST['dom_SID']; - if ($_POST['dom_nextRID']) $attr['sambaNextRid'] = $_POST['dom_nextRID']; - if ($_POST['dom_nextGroupRID']) $attr['sambaNextGroupRid'] = $_POST['dom_nextGroupRID']; - if ($_POST['dom_nextUserRID']) $attr['sambaNextUserRid'] = $_POST['dom_nextUserRID']; - $attr['sambaAlgorithmicRidBase'] = $_POST['dom_RIDbase']; - // write to LDAP - if (@ldap_add($_SESSION['ldap']->server(), $DN, $attr)) { - StatusMessage("INFO", "Domain has been created.", $DN); - } - else StatusMessage("ERROR", "", _("Failed to add domain!") . "\n
" . ldap_error($_SESSION['ldap']->server())); - } - echo "

 

\n"; - echo "

" . _("Back to domain list") . "

\n"; - echo "\n"; - echo "\n"; -} - - -// back to list -elseif ($_POST['sub_back']) { - metaRefresh("lists/listdomains.php"); -} - - -// delete domain, user was sure -elseif ($_POST['sub_delete']) { - $DNs = explode(";", $_POST['delDN']); - // display page - echo $_SESSION['header']; - echo "Domain Management\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // delete DNs - for ($i = 0; $i < sizeof($DNs); $i++) { - if (ldap_delete($_SESSION['ldap']->server(), $DNs[$i])) StatusMessage("INFO", _("Domain deleted successfully."), $DNs[$i]); - else StatusMessage("ERROR", _("Unable to delete domain!"), $DNs[$i]); - } - echo "

 

\n"; - echo "

" . _("Back to domain list") . "

\n"; - echo "\n"; - echo "\n"; -} - -?> diff --git a/lam/templates/lists/list.php b/lam/templates/lists/list.php new file mode 100644 index 00000000..1d23db00 --- /dev/null +++ b/lam/templates/lists/list.php @@ -0,0 +1,55 @@ +showPage(); + +?> \ No newline at end of file diff --git a/lam/templates/lists/listdomains.php b/lam/templates/lists/listdomains.php deleted file mode 100644 index 1b3f9cad..00000000 --- a/lam/templates/lists/listdomains.php +++ /dev/null @@ -1,222 +0,0 @@ -listdomains\n"; -echo "\n"; -echo "\n"; - -listPrintJavaScript(); - -// get current page -if (isset($_GET["page"])) $page = $_GET["page"]; -else $page = 1; - -// take maximum count of domain entries shown on one page out of session -if ($_SESSION["config"]->get_MaxListEntries() <= 0) - $max_page_entries = 10; // default setting, if not yet set -else - $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); - - -// generate attribute and description tables -$attr_array = array(); // list of LDAP attributes to show -$desc_array = array(); // list of descriptions for the attributes -$attr_array[] = "sambaDomainName"; -$attr_array[] = "sambaSID"; -$attr_array[] = "dn"; -$desc_array[] = strtoupper(_("Domain name")); -$desc_array[] = strtoupper(_("Domain SID")); -$desc_array[] = "DN"; - -if (isset($_GET["sort"])) $sort = $_GET["sort"]; -else $sort = strtolower($attr_array[0]); - -// check search suffix -if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox -elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix - -$refresh = true; -if (isset($_GET['norefresh'])) $refresh = false; -if (isset($_POST['refresh'])) $refresh = true; - -if ($refresh) { - // configure search filter - $filter = "(objectClass=sambaDomain)"; - $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); - if (ldap_errno($_SESSION["ldap"]->server()) == 4) { - StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); - } - if ($sr) { - $info = ldap_get_entries($_SESSION["ldap"]->server, $sr); - ldap_free_result($sr); - if ($info["count"] == 0) StatusMessage("WARN", "", _("No Samba domains found!")); - // delete first array entry which is "count" - unset($info['count']); - // sort rows by sort column ($sort) - $info = listSort($sort, $attr_array, $info); - } - else StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Samba domains found!")); -} -// use search result from session -else { - if (sizeof($info) == 0) StatusMessage("WARN", "", _("No Samba domains found!")); - // sort rows by sort column ($sort) - if ($info) $info = listSort($sort, $attr_array, $info); -} - -echo ("
\n"); - -// draw navigation bar if domain accounts were found -if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found")); -echo ("
\n"); -} - -// print domain table header -echo "\n"; -echo ""; -// table header -for ($k = 0; $k < sizeof($desc_array); $k++) { - if (strtolower($attr_array[$k]) == $sort) { - echo ""; - } - else echo ""; -} -echo "\n"; - -// calculate which rows to show -$table_begin = ($page - 1) * $max_page_entries; -if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info); -else $table_end = ($page * $max_page_entries); - -// print domain list -for ($i = $table_begin; $i < $table_end; $i++) { - echo("" . - " " . - " "); - for ($k = 0; $k < sizeof($attr_array); $k++) { - echo (""); - } - echo("\n"); -} -echo ("
" . $desc_array[$k] . "" . $desc_array[$k] . "
" . _("Edit") . ""); - // print all attribute entries seperated by "; " - if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) { - // delete first array entry which is "count" - if (is_array($info[$i][strtolower($attr_array[$k])])) unset($info[$i][strtolower($attr_array[$k])]['count']); - if (is_array($info[$i][strtolower($attr_array[$k])])) echo implode("; ", $info[$i][strtolower($attr_array[$k])]); - else echo $info[$i][strtolower($attr_array[$k])]; - } - echo ("
"); - -echo ("
"); - -// draw navigation bar if domain accounts were found -if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found")); -echo ("
\n"); -} - -if ($refresh) { - // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); -} - -// print combobox with possible sub-DNs -listShowOUSelection($units, $suffix); - -echo ("

\n"); -echo ("\n"); -if (sizeof($info) > 0) echo ("\n"); -echo ("

\n"); - -echo ("
\n"); -echo "\n"; - - - -// save variables to session -$_SESSION[$scope . 'info'] = $info; -$_SESSION[$scope . '_units'] = $units; -$_SESSION[$scope . '_suffix'] = $suffix; - -?> diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php deleted file mode 100644 index 2aca8315..00000000 --- a/lam/templates/lists/listgroups.php +++ /dev/null @@ -1,261 +0,0 @@ -listgroups\n"; -echo "\n"; -echo "\n"; - -listPrintJavaScript(); - -// generate attribute-description table -$temp_array = listGetAttributeDescriptionList($scope); -$attr_array = array_keys($temp_array); // list of LDAP attributes to show -$desc_array = array_values($temp_array); // list of descriptions for the attributes - -// get current page -if (isset($_GET["page"])) $page = $_GET["page"]; -else $page = 1; - -// take maximum count of group entries shown on one page out of session -if ($_SESSION["config"]->get_MaxListEntries() <= 0) - $max_page_entries = 10; // default setting, if not yet set -else - $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); - -// get sorting column -if (isset($_GET["sort"])) $sort = $_GET["sort"]; -else $sort = strtolower($attr_array[0]); - -// check search suffix -if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox -elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix - -$refresh = true; -if (isset($_GET['norefresh'])) $refresh = false; -if (isset($_POST['refresh'])) $refresh = true; - -if ($refresh) { - // configure search filter - $module_filter = get_ldap_filter($scope); // basic filter is provided by modules - $filter = "(&" . $module_filter . ")"; - $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); - if (ldap_errno($_SESSION["ldap"]->server()) == 4) { - StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); - } - if ($sr) { - $info = ldap_get_entries($_SESSION["ldap"]->server, $sr); - ldap_free_result($sr); - // delete first array entry which is "count" - unset($info['count']); - // save position in original $info - for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i; - // save results - $_SESSION[$scope . 'info'] = $info; - } - else { - $info = array(); - $_SESSION[$scope . 'info'] = array(); - StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No groups found!")); - } -} - -$filter = listBuildFilter($attr_array); -$info = listFilterAccounts($info, $filter); -if (sizeof($info) == 0) StatusMessage("WARN", "", _("No groups found!")); -// sort rows by sort column ($sort) -if ($info) { - $info = listSort($sort, $attr_array, $info); -} - -// build filter URL -$searchFilter = array(); -$filterAttributes = array_keys($filter); -for ($i = 0; $i < sizeof($filterAttributes); $i++) { - $searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original']; -} -if (sizeof($searchFilter) > 0) { - $searchFilter = "&" . implode("&", $searchFilter); -} -else { - $searchFilter = ""; -} - -echo ("
\n"); - -// draw navigation bar if group accounts were found -if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, $scope, _("%s group(s) found")); -echo ("
"); -} - -// account table head -listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $_POST, $sort); - -// calculate which rows to show -$table_begin = ($page - 1) * $max_page_entries; -if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info); -else $table_end = ($page * $max_page_entries); - -if (sizeof($info) > 0) { - // print group list - for ($i = $table_begin; $i < $table_end; $i++) { - echo("\n"); - if (isset($_GET['selectall'])) { - echo " \n"; - } - else { - echo " \n"; - } - echo (" " . _("Edit") . "\n"); - for ($k = 0; $k < sizeof($attr_array); $k++) { - echo (""); - // print all attribute entries seperated by "; " - $attrName = strtolower($attr_array[$k]); - if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) { - // delete first array entry which is "count" - if (is_array($info[$i][$attrName])) unset($info[$i][$attrName]['count']); - // generate links for group members - if ($attrName == "memberuid") { - // sort array - sort($info[$i][$attrName]); - // make a link for each member of the group - $linklist = array(); - for ($d = 0; $d < sizeof($info[$i][$attrName]); $d++) { - $user = $info[$i][$attrName][$d]; // user name - $linklist[$d] = "" . $user . ""; - } - echo implode("; ", $linklist); - } - // print all other attributes - else { - if (is_array($info[$i][$attrName])) { - // delete "count" entry - unset($info[$i][$attrName]['count']); - // sort array - sort($info[$i][$attrName]); - echo implode("; ", $info[$i][$attrName]); - } - else echo $info[$i][$attrName]; - } - } - echo ("\n"); - } - echo("\n"); - } - // display select all link - $colspan = sizeof($attr_array) + 1; - echo "\n"; - echo "\"select\n"; - echo " " . - "" . _("Select all") . "\n"; - echo "\n"; -} -echo (""); -echo ("
"); - -// draw navigation bar if group accounts were found -if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, $scope, _("%s group(s) found")); -echo ("
\n"); -} - -if ($refresh) { - // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); -} - -// print combobox with possible sub-DNs -listShowOUSelection($units, $suffix); - -echo ("\n"); -if (sizeof($info) > 0) { - echo ("\n"); - echo ("


\n"); - echo "
PDF\n"; - echo ("" . _('PDF structure') . ":      \n"; - echo ("\n"); - echo " "; - echo ("\n"); - echo "
"; -} - -echo ("
\n"); -echo "\n"; - -// save variables to session -$_SESSION[$scope . '_units'] = $units; -$_SESSION[$scope . '_suffix'] = $suffix; - -?> diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php deleted file mode 100644 index ba3284ed..00000000 --- a/lam/templates/lists/listhosts.php +++ /dev/null @@ -1,246 +0,0 @@ -listhosts\n"; -echo "\n"; -echo "\n"; - -listPrintJavaScript(); - -// generate attribute-description table -$temp_array = listGetAttributeDescriptionList($scope); -$attr_array = array_keys($temp_array); // list of LDAP attributes to show -$desc_array = array_values($temp_array); // list of descriptions for the attributes - -// get current page -if (isset($_GET["page"])) $page = $_GET["page"]; -else $page = 1; - -// take maximum count of host entries shown on one page out of session -if ($_SESSION["config"]->get_MaxListEntries() <= 0) - $max_page_entries = 10; // default setting, if not yet set -else - $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); - -// get sorting column -if (isset($_GET["sort"])) $sort = $_GET["sort"]; -else $sort = strtolower($attr_array[0]); - -// check search suffix -if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox -elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix - -$refresh = true; -if (isset($_GET['norefresh'])) $refresh = false; -if (isset($_POST['refresh'])) $refresh = true; - -if ($refresh) { - // configure search filter - $module_filter = get_ldap_filter("host"); // basic filter is provided by modules - $filter = "(&" . $module_filter . ")"; - $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); - if (ldap_errno($_SESSION["ldap"]->server()) == 4) { - StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); - } - if ($sr) { - $info = ldap_get_entries($_SESSION["ldap"]->server, $sr); - ldap_free_result($sr); - // delete first array entry which is "count" - unset($info['count']); - // save position in original $info - for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i; - // save results - $_SESSION[$scope . 'info'] = $info; - } - else { - $info = array(); - $_SESSION[$scope . 'info'] = array(); - StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No hosts found!")); - } -} - -$filter = listBuildFilter($attr_array); -$info = listFilterAccounts($info, $filter); -if (sizeof($info) == 0) StatusMessage("WARN", "", _("No hosts found!")); -// sort rows by sort column ($sort) -if ($info) { - $info = listSort($sort, $attr_array, $info); -} - -// build filter URL -$searchFilter = array(); -$filterAttributes = array_keys($filter); -for ($i = 0; $i < sizeof($filterAttributes); $i++) { - $searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original']; -} -if (sizeof($searchFilter) > 0) { - $searchFilter = "&" . implode("&", $searchFilter); -} -else { - $searchFilter = ""; -} - -echo ("
\n"); - -// draw navigation bar if host accounts were found -if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found")); -echo ("
\n"); -} - -// account table head -listPrintTableHeader("host", $searchFilter, $desc_array, $attr_array, $_POST, $sort); - -// calculate which rows to show -$table_begin = ($page - 1) * $max_page_entries; -if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info); -else $table_end = ($page * $max_page_entries); - -if (sizeof($info) > 0) { - // print host list - for ($i = $table_begin; $i < $table_end; $i++) { - echo("\n"); - if (isset($_GET['selectall'])) { - echo " \n"; - } - else { - echo " \n"; - } - echo (" " . _("Edit") . "\n"); - for ($k = 0; $k < sizeof($attr_array); $k++) { - echo (""); - // print all attribute entries seperated by "; " - $attrName = strtolower($attr_array[$k]); - if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) { - // delete "count" entry - unset($info[$i][$attrName]['count']); - if (is_array($info[$i][$attrName])) { - // sort array - sort($info[$i][$attrName]); - echo implode("; ", $info[$i][$attrName]); - } - else echo $info[$i][$attrName]; - } - echo ("\n"); - } - echo("\n"); - } - // display select all link - $colspan = sizeof($attr_array) + 1; - echo "\n"; - echo "\"select\n"; - echo " " . - "" . _("Select all") . "\n"; - echo "\n"; -} -echo (""); - -echo ("
"); - -// draw navigation bar if host accounts were found -if (sizeof($info) > 0) { -listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found")); -echo ("
\n"); -} - -if ($refresh) { - // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); -} - -// print combobox with possible sub-DNs -listShowOUSelection($units, $suffix); - -// add/delete/PDF buttons -echo ("\n"); -if (sizeof($info) > 0) { - echo ("\n"); - echo ("


\n"); - echo "
PDF\n"; - echo ("" . _('PDF structure') . ":      \n"; - echo ("\n"); - echo " "; - echo ("\n"); - echo "
"; -} - -echo ("
\n"); -echo "\n"; - -// save variables to session -$_SESSION[$scope . '_units'] = $units; -$_SESSION[$scope . '_suffix'] = $suffix; - -?> diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php deleted file mode 100644 index 650176f9..00000000 --- a/lam/templates/lists/listusers.php +++ /dev/null @@ -1,309 +0,0 @@ -get_Suffix('group'); - $filter = "objectClass=posixGroup"; - $attrs = array("cn", "gidNumber"); - $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); - if ($sr) { - $info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr); - unset($info['count']); // delete count entry - for ($i = 0; $i < sizeof($info); $i++) { - $trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0]; - } - $_SESSION['trans_primary_hash'] = $trans_primary_hash; - } -} - - -if (isset($_SESSION[$scope . 'info'])) $info = $_SESSION[$scope . 'info']; -if (isset($_SESSION[$scope . '_units'])) $units = $_SESSION[$scope . '_units']; - -listDoPost($scope); - -echo $_SESSION['header']; - -echo "listusers\n"; -echo "\n"; -echo "\n"; - -listPrintJavaScript(); - -// get current page -if (isset($_GET["page"])) $page = $_GET["page"]; -else $page = 1; - -// take maximum count of user entries shown on one page out of session -if ($_SESSION["config"]->get_MaxListEntries() <= 0) { - $max_page_entries = 10; // default setting, if not yet set -} -else $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); - -// generate attribute-description table -$temp_array = listGetAttributeDescriptionList($scope); -$attr_array = array_keys($temp_array); // list of LDAP attributes to show -$desc_array = array_values($temp_array); // list of descriptions for the attributes - -if (isset($_GET["sort"])) $sort = $_GET["sort"]; -else $sort = strtolower($attr_array[0]); - -// check search suffix -if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox -elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix - - -// configure search filter for LDAP -$module_filter = get_ldap_filter($scope); // basic filter is provided by modules -$filter = "(&" . $module_filter . ")"; - -if ($refresh) { - $attrs = $attr_array; - $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); - if (ldap_errno($_SESSION["ldap"]->server()) == 4) { - StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem.")); - } - if ($sr) { - $info = ldap_get_entries ($_SESSION["ldap"]->server, $sr); - ldap_free_result ($sr); - // delete first array entry which is "count" - unset($info['count']); - // save position in original $info - for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i; - // save results - $_SESSION[$scope . 'info'] = $info; - } - else { - $_SESSION[$scope . 'info'] = array(); - $info = array(); - StatusMessage("ERROR", - _("LDAP Search failed! Please check your preferences."), - _("No users found!")); - } -} - -$filter = listBuildFilter($attr_array); -$info = listFilterAccounts($info, $filter); -if (sizeof($info) == 0) StatusMessage("WARN", "", _("No users found!")); -// sort rows by sort column ($sort) -if ($info) { - $info = listSort($sort, $attr_array, $info); -} - -// build filter URL -$searchFilter = array(); -$filterAttributes = array_keys($filter); -for ($i = 0; $i < sizeof($filterAttributes); $i++) { - $searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original']; -} -if (sizeof($searchFilter) > 0) { - $searchFilter = "&" . implode("&", $searchFilter); -} -else { - $searchFilter = ""; -} - -echo ("
\n"); - -// display table only if users exist in LDAP -if (sizeof($info) != 0) { - // create navigation bar on top of user table - listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, - $searchFilter . "&trans_primary=" . $trans_primary, $scope, _("%s user(s) found")); - echo ("
"); -} - -// account table head -listPrintTableHeader($scope, $searchFilter . "&trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort); - -// calculate which rows to show -$table_begin = ($page - 1) * $max_page_entries; -if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info); -else $table_end = ($page * $max_page_entries); - -if (sizeof($info) != 0) { - // translate GIDs and resort array if selected - if ($trans_primary == "on") { - // translate GIDs - for ($i = 0; $i < sizeof($info); $i++) { - if (isset($trans_primary_hash[$info[$i]['gidnumber'][0]])) { - $info[$i]['gidnumber'][0] = $trans_primary_hash[$info[$i]['gidnumber'][0]]; - } - } - // resort if needed - if ($sort == "gidnumber") { - $info = listSort($sort, $attr_array, $info); - } - } - // print user list - for ($i = $table_begin; $i < $table_end; $i++) { - echo("\n"); - // checkboxes if selectall = "yes" - if (isset($_GET['selectall'])) { - echo "\n\n\n"; - } - else { - echo "\n\n\n"; - } - echo ("\n" . - _("Edit") . "\n\n"); - for ($k = 0; $k < sizeof($attr_array); $k++) { - echo ("\n"); - // print attribute values - $attrName = strtolower($attr_array[$k]); - if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) { - if (is_array($info[$i][$attrName])) { - // delete first array entry which is "count" - unset($info[$i][$attrName]['count']); - // sort array - sort($info[$i][$attrName]); - // print all attribute entries seperated by "; " - echo implode("; ", $info[$i][$attrName]) . "\n"; - } - else echo $info[$i][$attrName] . "\n"; - } - echo ("\n"); - } - echo("\n"); - } - // display select all link - $colspan = sizeof($attr_array) + 1; - echo "\n"; - echo "\"select\n"; - echo " " . - "" . _("Select all") . "\n"; - echo "\n"; -} -echo ("\n"); - -echo ("
"); -if (sizeof($info) != 0) { - listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, - $searchFilter . "&trans_primary=" . $trans_primary, $scope, _("%s user(s) found")); - echo ("
"); -} - -if ($refresh) { - // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); -} - -// print combobox with possible sub-DNs -listShowOUSelection($units, $suffix); - -// show translate GID to group name box if there is a column with gidnumber -if (in_array("gidnumber", $attr_array)) { - echo "

\n"; - echo "" . _("Translate GID number to group name") . ": "; - if ($trans_primary == "on") { - echo ""; - } - else echo ""; - echo ("  "); - echo "

\n"; -} - -echo ("

 

\n"); - -// new/delete/PDF buttons -echo ("\n"); -if (sizeof($info) != 0) { - echo ("\n"); - echo ("


\n"); - echo "
PDF\n"; - echo ("" . _('PDF structure') . ":      \n"; - echo ("\n"); - echo " "; - echo ("\n"); - echo "
"; -} - -echo ("

 

\n"); - -echo ("
\n"); -echo "\n"; - - -// save variables to session -$_SESSION[$scope . '_units'] = $units; -$_SESSION[$scope . '_suffix'] = $suffix; - -?> diff --git a/lam/templates/lists/userlink.php b/lam/templates/lists/userlink.php index 0f9bd681..4c94efd6 100644 --- a/lam/templates/lists/userlink.php +++ b/lam/templates/lists/userlink.php @@ -62,7 +62,7 @@ else { echo "\n"; StatusMessage("ERROR", "", _("This user was not found!") . " (" . $user . ")"); echo "

 

"; - echo "

" . _("Back to group list") . "

"; + echo "

" . _("Back to group list") . "

"; echo ("\n"); } diff --git a/lam/templates/main.php b/lam/templates/main.php index 87694ce6..5ea1c720 100644 --- a/lam/templates/main.php +++ b/lam/templates/main.php @@ -36,37 +36,15 @@ if (!isset($_SESSION['cache'])) { $_SESSION['cache'] = new cache(); } -$startPage = ""; - // check if all suffixes in conf-file exist $conf = $_SESSION['config']; $new_suffs = array(); -if ($conf->get_Suffix('user') && ($conf->get_Suffix('user') != "")) { - $startPage = "./lists/listusers.php"; - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('user'), "", array()); +// get list of active types +$types = $_SESSION['config']->get_ActiveTypes(); +for ($i = 0; $i < sizeof($types); $i++) { + $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix($types[$i]), "(objectClass=*)", array()); $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_Suffix('user'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('user'); -} -if ($conf->get_Suffix('group') && ($conf->get_Suffix('group') != "")) { - if ($startPage == "") { - $startPage = "./lists/listgroups.php"; - } - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('group'), "", array()); - $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_Suffix('group'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('group'); -} -if ($conf->get_Suffix('host') && ($conf->get_Suffix('host') != "")) { - if ($startPage == "") { - $startPage = "./lists/listhosts.php"; - } - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('host'), "", array()); - $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_Suffix('host'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('host'); -} -if ($conf->get_Suffix('domain') && ($conf->get_Suffix('domain') != "")) { - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('domain'), "", array()); - $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_Suffix('domain'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('domain'); + if (!$res && !in_array($conf->get_Suffix($types[$i]), $new_suffs)) $new_suffs[] = $conf->get_Suffix($types[$i]); } // get encoding @@ -88,7 +66,14 @@ echo (" 0) echo ("\n"); -else echo ("\n"); +else { + if (sizeof($types) > 0) { + echo ("\n"); + } + else { + echo ("\n"); + } +} echo ("\n"); echo ("This page requires a browser that can show frames!\n"); echo ("\n"); diff --git a/lam/templates/main_header.php b/lam/templates/main_header.php index 9cfbaaa8..49b5fe8a 100644 --- a/lam/templates/main_header.php +++ b/lam/templates/main_header.php @@ -40,10 +40,8 @@ setlanguage(); echo $_SESSION['header']; // number of list views (users, groups, ...) -$lists = 0; -if ($_SESSION['config']->get_Suffix('user') != "") $lists++; -if ($_SESSION['config']->get_Suffix('group') != "") $lists++; -if ($_SESSION['config']->get_Suffix('host') != "") $lists++; +$types = $_SESSION['config']->get_ActiveTypes(); +$lists = sizeof($types); if ($_SESSION['config']->get_Suffix('tree') != "") $lists++; ?> @@ -63,7 +61,7 @@ if ($_SESSION['config']->get_Suffix('tree') != "") $lists++; \n"; ?> - LDAP Account Manager + LDAP Account Manager   @@ -79,14 +77,11 @@ if ($_SESSION['config']->get_Suffix('tree') != "") $lists++; if ($_SESSION['config']->get_Suffix('tree') != "") { echo ' ' . _("Tree view") . '' . "\n"; } - if ($_SESSION['config']->get_Suffix('user') != "") { - echo ' ' . _("Users") . '' . "\n"; - } - if ($_SESSION['config']->get_Suffix('group') != "") { - echo ' ' . _("Groups") . '' . "\n"; - } - if ($_SESSION['config']->get_Suffix('host') != "") { - echo ' ' . _("Hosts") . '' . "\n"; + for ($i = 0; $i < sizeof($types); $i++) { + echo ''; + echo ' '; + echo '' . getTypeAlias($types[$i]) . ''; + echo '' . "\n"; } ?> diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index 1a557c20..216f854b 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -63,16 +63,20 @@ if (isset($_GET['getCSV'])) { exit; } +$types = $_SESSION['config']->get_ActiveTypes(); + echo $_SESSION['header']; echo "account upload\n"; echo "\n"; +for ($i = 0; $i < sizeof($types); $i++) { + echo "\n"; +} echo "\n"; echo "\n"; // check if account specific page should be shown -if (isset($_POST['user'])) showMainPage('user'); -elseif (isset($_POST['group'])) showMainPage('group'); -elseif (isset($_POST['host'])) showMainPage('host'); +if (isset($_POST['type'])) showMainPage($_POST['type']); + // show start page else { echo "

" . _("Account creation via file upload") . "

\n"; @@ -91,18 +95,15 @@ else { echo "
\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + for ($i = 0; $i < sizeof($types); $i++) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
" . getTypeAlias($types[$i]) . "
\n"; + echo "

\n"; + echo "\n"; echo "
\n"; echo "\n"; @@ -161,7 +162,6 @@ function showMainPage($scope) { echo "
    \n"; echo "
  • " . _("Identifier") . ": " . "dn_rdn
  • \n"; echo "
  • " . _("Possible values") . ": " . implode(", ", getRDNAttributes($scope)) . "
  • \n"; - echo "
  • " . _("Example value") . ": " . "uid
  • \n"; echo "
\n"; echo "\n"; echo "\n"; diff --git a/lam/templates/ou_edit.php b/lam/templates/ou_edit.php index 549ba761..f1d9ed9c 100644 --- a/lam/templates/ou_edit.php +++ b/lam/templates/ou_edit.php @@ -41,268 +41,78 @@ session_save_path("../sess"); setlanguage(); +$types = $_SESSION['config']->get_ActiveTypes(); + // check if submit button was pressed if ($_POST['submit']) { - // user operations - // new user ou - if ($_POST['type'] == "new_usr") { - // create ou if valid - if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_u'])) { - // check if ou already exists - $new_dn = "ou=" . $_POST['newsuff_u'] . "," . $_POST['usersuff_n']; - if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['usersuff_n']))) { - // add new ou - $ou = array(); - $ou['objectClass'] = "organizationalunit"; - $ou['ou'] = $_POST['newsuff_u']; - $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); - if ($ret) { - $message = _("New OU created successfully."); - } - else { - $error = _("Unable to create new OU!"); + // check user input + for ($i = 0; $i < sizeof($types); $i++) { + // new ou + if ($_POST['type'] == "new_" . $types[$i]) { + // create ou if valid + if (eregi("^[a-z0-9 _\\-]+$", $_POST['newname_' . $types[$i]])) { + // check if ou already exists + $new_dn = "ou=" . $_POST['newname_' . $types[$i]] . "," . $_POST['parentsuff_' . $types[$i]]; + if (!in_array($new_dn, $_SESSION['ldap']->search_units($_POST['parentsuff_' . $types[$i]]))) { + // add new ou + $ou = array(); + $ou['objectClass'] = "organizationalunit"; + $ou['ou'] = $_POST['newname_' . $types[$i]]; + $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); + if ($ret) { + $message = _("New OU created successfully."); + } + else { + $error = _("Unable to create new OU!"); + } } + else $error = _("OU already exists!"); } - else $error = _("OU already exists!"); - } - // show errormessage if ou is invalid - else { - $error = _("OU is invalid!") . " " . $_POST['newsuff_u']; - } - } - // delete ou, user was sure - elseif (($_POST['type'] == "del_usr") && ($_POST['sure'])) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } - } - // do not delete ou - elseif (($_POST['type'] == "del_usr") && ($_POST['abort'])) { - display_main(); - exit; - } - // ask if user is sure to delete - elseif ($_POST['type'] == "del_usr") { - // check for sub entries - $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array("")); - $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($sr && $info['count'] == 0) { - $text = "
\n" . - "

" . _("Do you really want to delete this OU?") . " " . "\n" . - "
\n

" . $_POST['usersuff_d'] . "

\n" . - "
\n" . - "
\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "
"; - } - else { - $error = _("OU is not empty or invalid!"); - } - } - - // group operations - // new group ou - if ($_POST['type'] == "new_grp") { - // create ou if valid - if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_g'])) { - // check if ou already exists - $new_dn = "ou=" . $_POST['newsuff_g'] . "," . $_POST['groupsuff_n']; - if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['groupsuff_n']))) { - // add new ou - $ou = array(); - $ou['objectClass'] = "organizationalunit"; - $ou['ou'] = $_POST['newsuff_g']; - $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); - if ($ret) { - $message = _("New OU created successfully."); - } - else { - $error = _("Unable to create new OU!"); - } + // show errormessage if ou is invalid + else { + $error = _("OU is invalid!") . " " . $_POST['newname_' . $types[$i]]; } - else $error = _("OU already exists!"); } - // show errormessage if ou is invalid - else { - $error = _("OU is invalid!") . " " . $_POST['newsuff_g']; - } - } - // delete ou, user was sure - elseif (($_POST['type'] == "del_grp") && ($_POST['sure'])) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } - } - // do not delete ou - elseif (($_POST['type'] == "del_grp") && ($_POST['abort'])) { - display_main(); - exit; - } - // ask if user is sure to delete - elseif ($_POST['type'] == "del_grp") { - // check for sub entries - $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array("")); - $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($sr && $info['count'] == 0) { - $text = "
\n" . - "

" . _("Do you really want to delete this OU?") . " " . "\n" . - "
\n

" . $_POST['groupsuff_d'] . "

\n" . - "
\n" . - "
\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "
"; - } - else { - $error = _("OU is not empty or invalid!"); - } - } - - // host operations - // new host ou - if ($_POST['type'] == "new_hst") { - // create ou if valid - if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_h'])) { - // check if ou already exists - $new_dn = "ou=" . $_POST['newsuff_h'] . "," . $_POST['hostsuff_n']; - if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['hostsuff_n']))) { - // add new ou - $ou = array(); - $ou['objectClass'] = "organizationalunit"; - $ou['ou'] = $_POST['newsuff_h']; - $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); - if ($ret) { - $message = _("New OU created successfully."); - } - else { - $error = _("Unable to create new OU!"); - } + // delete ou, user was sure + elseif (($_POST['type'] == "del_" . $types[$i]) && ($_POST['sure'])) { + $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['deletename_' . $types[$i]]); + if ($ret) { + $message = _("OU deleted successfully."); } - else $error = _("OU already exists!"); - } - // show errormessage if ou is invalid - else { - $error = _("OU is invalid!") . " " . $_POST['newsuff_h']; - } - } - // delete ou, user was sure - elseif (($_POST['type'] == "del_hst") && ($_POST['sure'])) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } - } - // do not delete ou - elseif (($_POST['type'] == "del_hst") && ($_POST['abort'])) { - display_main(); - exit; - } - // ask if user is sure to delete - elseif ($_POST['type'] == "del_hst") { - // check for sub entries - $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array("")); - $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($sr && $info['count'] == 0) { - $text = "
\n" . - "

" . _("Do you really want to delete this OU?") . " " . "\n" . - "
\n

" . $_POST['hostsuff_d'] . "

\n" . - "
\n" . - "
\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "
"; - } - else { - $error = _("OU is not empty or invalid!"); - } - } - - // domain operations - // new domain ou - if ($_POST['type'] == "new_dom") { - // create ou if valid - if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_d'])) { - // check if ou already exists - $new_dn = "ou=" . $_POST['newsuff_d'] . "," . $_POST['domsuff_n']; - if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['domsuff_n']))) { - // add new ou - $ou = array(); - $ou['objectClass'] = "organizationalunit"; - $ou['ou'] = $_POST['newsuff_d']; - $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); - if ($ret) { - $message = _("New OU created successfully."); - } - else { - $error = _("Unable to create new OU!"); - } + else { + $error = _("Unable to delete OU!"); } - else $error = _("OU already exists!"); } - // show errormessage if ou is invalid - else { - $error = _("OU is invalid!") . " " . $_POST['newsuff_d']; + // do not delete ou + elseif (($_POST['type'] == "del_" . $types[$i]) && ($_POST['abort'])) { + display_main(); + exit; + } + // ask if user is sure to delete + elseif ($_POST['type'] == "del_" . $types[$i]) { + // check for sub entries + $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deletename_' . $types[$i]], "ObjectClass=*", array("")); + $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); + if ($sr && $info['count'] == 0) { + $text = "
\n" . + "

" . _("Do you really want to delete this OU?") . " " . "\n" . + "
\n

" . $_POST['deletename_' . $types[$i]] . "

\n" . + "
\n" . + "
\n" . + "\n" . + "\n" . + "\n" . + "\n" . + "\n" . + "
"; + } + else { + $error = _("OU is not empty or invalid!"); + } } } - // delete ou, user was sure - elseif (($_POST['type'] == "del_dom") && ($_POST['sure'])) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['domsuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } - } - // do not delete ou - elseif (($_POST['type'] == "del_dom") && ($_POST['abort'])) { - display_main(); - exit; - } - // ask if user is sure to delete - elseif ($_POST['type'] == "del_dom") { - // check for sub entries - $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['domsuff_d'], "ObjectClass=*", array("")); - $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($sr && $info['count'] == 0) { - $text = "
\n" . - "

" . _("Do you really want to delete this OU?") . " " . "\n" . - "
\n

" . $_POST['domsuff_d'] . "

\n" . - "
\n" . - "
\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "\n" . - "
"; - } - else { - $error = _("OU is not empty or invalid!"); - } - } - + + // print header echo $_SESSION['header']; echo ("OU-Editor\n"); @@ -328,153 +138,47 @@ exit; else display_main(); function display_main() { + $types = $_SESSION['config']->get_ActiveTypes(); // display main page echo $_SESSION['header']; echo ("OU-Editor\n"); echo ("\n"); + for ($i = 0; $i < sizeof($types); $i++) { + echo ("\n"); + } echo ("\n"); echo ("\n"); + echo "

" . _("OU editor") . "

"; echo ("
\n"); - echo ("
\n"); + echo ("\n"); - // user OUs - if ($_SESSION["config"]->get_Suffix('user') != "") { + // display fieldsets + for ($i = 0; $i < sizeof($types); $i++) { // generate lists of possible suffixes - $usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('user')); - echo ("
" . _("Users") . "\n"); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($types[$i])); + echo ("
" . getTypeAlias($types[$i]) . "\n"); echo ("\n"); // new OU echo ("\n"); - echo ("\n"); + echo ("\n"); echo ("\n"); echo ("\n"); - echo ("\n"); + echo ("\n"); echo ("\n"); echo ("\n"); // delete OU echo ("\n"); - echo ("\n"); + echo ("\n"); echo ("\n"); echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("
" . _("New organizational unit") . ": \n"); - echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); - echo (" ". _("Help") ."
\n"); - echo ("
\n"); - echo ("
\n"); - } - - // group OUs - if ($_SESSION["config"]->get_Suffix('group') != "") { - // generate lists of possible suffixes - $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('group')); - echo ("
" . _("Groups") . "\n"); - echo ("\n"); - // new OU - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - // delete OU - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("
" . _("New organizational unit") . ": \n"); - echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); - echo (" ". _("Help") ."
\n"); - echo ("
\n"); - echo ("
\n"); - } - - // host OUs - if ($_SESSION["config"]->get_Suffix('host') != "") { - // generate lists of possible suffixes - $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('host')); - echo ("
" . _("Samba Hosts") . "\n"); - echo ("\n"); - // new OU - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - // delete OU - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("
" . _("New organizational unit") . ": \n"); - echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); - echo (" ". _("Help") ."
\n"); - echo ("
\n"); - echo ("
\n"); - } - - // domain OUs - if ($_SESSION["config"]->get_Suffix('domain') != "") { - // generate lists of possible suffixes - $dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('domain')); - echo ("
" . _("Domains") . "\n"); - echo ("\n"); - // new OU - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - // delete OU - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); - echo ("\n"); diff --git a/lam/templates/pdfedit/pdfdelete.php b/lam/templates/pdfedit/pdfdelete.php index 7f544592..cc9baab4 100644 --- a/lam/templates/pdfedit/pdfdelete.php +++ b/lam/templates/pdfedit/pdfdelete.php @@ -73,19 +73,22 @@ if ($_POST['abort']) { // check if right type was given $type = $_GET['type']; -if (($type == "user") || ($type == "host") || ($type == "group")) { - echo ("

" . _("Do you really want to delete this PDF structure?") . " "); - echo (_('Scope') . ': ' . $_GET['type'] . ' ' . _('Name') . ': ' . $_GET['delete'] . "

\n"); - echo ("\n"); - echo ("

\n"); - echo ("\n"); - echo ("\n"); - echo (""); - echo (""); - echo ("

\n"); -} -else{ - // no valid pdf type - StatusMessage("ERROR", "", _("Wrong or missing type!") . " " . $type); - echo ("" . _("Back to PDF Editor") . ""); -} +echo ("

" . _("Do you really want to delete this PDF structure?") . ""); +echo "
\n"; +echo "

\n"; +echo "
" . _("New organizational unit") . ": \n"); - echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); echo (" 
\n"; + echo "\n"; + echo "\n"; +echo "
\n"; + echo "" . _('Account type') . ': ' . $_GET['type']; + echo "
\n"; + echo "" . _('Name') . ': ' . $_GET['delete'] . "
\n"; + echo "
\n"; +echo "
\n"; +echo ("
\n"); +echo ("

\n"); +echo ("\n"); +echo ("\n"); +echo (""); +echo (""); +echo ("

\n"); diff --git a/lam/templates/pdfedit/pdfmain.php b/lam/templates/pdfedit/pdfmain.php index 86d9244f..197bcce0 100644 --- a/lam/templates/pdfedit/pdfmain.php +++ b/lam/templates/pdfedit/pdfmain.php @@ -82,7 +82,7 @@ if ($_POST['forward'] == "yes") { exit; } -$scopes = getAvailableScopes(); +$scopes = $_SESSION['config']->get_ActiveTypes(); $availableStructureDefinitions = ''; $availableScopes = ''; diff --git a/lam/templates/profedit/profiledelete.php b/lam/templates/profedit/profiledelete.php index 18d14c54..792c6f75 100644 --- a/lam/templates/profedit/profiledelete.php +++ b/lam/templates/profedit/profiledelete.php @@ -73,22 +73,13 @@ if ($_POST['abort']) { exit; } -// check if right type was given $type = $_GET['type']; -if (($type == "user") || ($type == "host") || ($type == "group")) { - // user profile - echo ("

" . _("Do you really want to delete this profile?") . " "); - echo ($_GET['del'] . "

\n"); - echo ("
\n"); - echo ("

\n"); - echo ("\n"); - echo ("\n"); - echo (""); - echo (""); - echo ("

\n"); -} -else{ - // no valid profile type - StatusMessage("ERROR", "", _("Wrong or missing type!") . " " . $type); - echo ("" . _("Back to profile editor") . ""); -} +echo ("

" . _("Do you really want to delete this profile?") . " "); +echo ($_GET['del'] . "

\n"); +echo ("
\n"); +echo ("

\n"); +echo ("\n"); +echo ("\n"); +echo (""); +echo (""); +echo ("

\n"); diff --git a/lam/templates/profedit/profilemain.php b/lam/templates/profedit/profilemain.php index 696b0d7b..73158abf 100644 --- a/lam/templates/profedit/profilemain.php +++ b/lam/templates/profedit/profilemain.php @@ -41,11 +41,15 @@ session_save_path("../../sess"); setlanguage(); -$profileClasses = array( - array('scope' => 'user', 'title' => _('User profiles'), 'profiles' => ""), - array('scope' => 'group', 'title' => _('Group profiles'), 'profiles' => ""), - array('scope' => 'host', 'title' => _('Host profiles'), 'profiles' => "") -); +$types = $_SESSION['config']->get_ActiveTypes(); +$profileClasses = array(); +for ($i = 0; $i < sizeof($types); $i++) { + $profileClasses[] = array( + 'scope' => $types[$i], + 'title' => getTypeAlias($types[$i]), + 'profiles' => ""); +} + // check if user is logged in, if not go to login if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) { @@ -97,6 +101,9 @@ echo $_SESSION['header']; echo "LDAP Account Manager\n"; echo "\n"; +for ($i = 0; $i < sizeof($profileClasses); $i++) { + echo "\n"; +} echo "\n"; echo "\n"; @@ -106,7 +113,7 @@ echo "
\n"; for ($i = 0; $i < sizeof($profileClasses); $i++) { - echo "
\n"; + echo "
\n"; echo "\n"; echo "" . $profileClasses[$i]['title'] . "\n"; echo "\n"; diff --git a/lam/templates/profedit/profilepage.php b/lam/templates/profedit/profilepage.php index 657fec78..f82d8d9a 100644 --- a/lam/templates/profedit/profilepage.php +++ b/lam/templates/profedit/profilepage.php @@ -65,6 +65,7 @@ if ($_POST['abort']) { // print header echo $_SESSION['header']; echo "\n\n"; +echo "\n\n"; echo "
\n"; // save button was presed @@ -130,7 +131,6 @@ $_SESSION['profile_types'] = array(); // check if account type is valid $type = $_GET['type']; -if (!(($type == 'user') || ($type == 'group') || ($type == 'host'))) meta_refresh('profilemain.php'); // get module options $options = getProfileOptions($type); diff --git a/lam/templates/tools.php b/lam/templates/tools.php index 6a9338ef..78be7995 100644 --- a/lam/templates/tools.php +++ b/lam/templates/tools.php @@ -42,6 +42,7 @@ echo $_SESSION['header']; echo "\n"; echo "\n"; +echo "\n"; echo ""; echo "\n"; @@ -55,15 +56,6 @@ $tools[] = array( "link" => "profedit/profilemain.php" ); -// Samba 3 domains -if ($_SESSION['config']->get_Suffix('domain') && ($_SESSION['config']->get_Suffix('domain') != "")) { -$tools[] = array( - "name" => _("Samba 3 domains"), - "description" => _("Manages Samba 3 domain accounts."), - "link" => "lists/listdomains.php" - ); -} - // file upload $tools[] = array( "name" => _("File upload"), diff --git a/lam/tests/conf-test.php b/lam/tests/conf-test.php index b3ddea78..3d7a9226 100644 --- a/lam/tests/conf-test.php +++ b/lam/tests/conf-test.php @@ -34,8 +34,6 @@ include ("../lib/config.inc"); $conf = new Config('test'); echo ""; -echo (" Current Config

"); -$conf->printconf(); echo ("

Starting Test...

"); // now all preferences are loaded echo ("Loading preferences..."); @@ -46,7 +44,7 @@ $Adminstring = $conf->get_Adminstring(); $Suff_users = $conf->get_Suffix('user'); $Suff_groups = $conf->get_Suffix('group'); $Suff_hosts = $conf->get_Suffix('host'); -$Suff_domains = $conf->get_Suffix('domain'); +$Suff_domains = $conf->get_Suffix('smbDomain'); $userlistAttributes = $conf->get_listAttributes('user'); $grouplistAttributes = $conf->get_listAttributes('group'); $hostlistAttributes = $conf->get_listAttributes('host'); @@ -65,7 +63,7 @@ $conf->set_Adminstring("uid=test,o=test,dc=org;uid=root,o=test2,c=de"); $conf->set_Suffix('user', "ou=test,o=test,c=de"); $conf->set_Suffix('group', "ou=testgrp,o=test,c=de"); $conf->set_Suffix('host', "ou=testhst,o=test,c=de"); -$conf->set_Suffix('domain', "ou=testdom,o=test,c=de"); +$conf->set_Suffix('smbDomain', "ou=testdom,o=test,c=de"); $conf->set_listAttributes("#uid;#cn", 'user'); $conf->set_listAttributes("#gidNumber;#cn;#memberUID", 'group'); $conf->set_listAttributes("#cn;#uid;#description", 'host'); @@ -86,7 +84,7 @@ if ($conf2->get_Adminstring() != "uid=test,o=test,dc=org;uid=root,o=test2,c=de") if ($conf2->get_Suffix('user') != "ou=test,o=test,c=de") echo ("
Saving user suffix failed!
"); if ($conf2->get_Suffix('group') != "ou=testgrp,o=test,c=de") echo ("
Saving group suffix failed!
"); if ($conf2->get_Suffix('host') != "ou=testhst,o=test,c=de") echo ("
Saving host suffix failed!
"); -if ($conf2->get_Suffix('domain') != "ou=testdom,o=test,c=de") echo ("
Saving domain suffix failed!
"); +if ($conf2->get_Suffix('smbDomain') != "ou=testdom,o=test,c=de") echo ("
Saving domain suffix failed!
"); if ($conf2->get_listAttributes('user') != "#uid;#cn") echo ("
Saving userlistAttributes failed!
"); if ($conf2->get_listAttributes('group') != "#gidNumber;#cn;#memberUID") echo ("
Saving grouplistAttributes failed!
"); if ($conf2->get_listAttributes('host') != "#cn;#uid;#description") echo ("
Saving hostlistAttributes failed!
"); @@ -106,7 +104,7 @@ $conf2->set_Adminstring($Adminstring); $conf2->set_Suffix('user', $Suff_users); $conf2->set_Suffix('group', $Suff_groups); $conf2->set_Suffix('host', $Suff_hosts); -$conf2->set_Suffix('domain', $Suff_domains); +$conf2->set_Suffix('smbDomain', $Suff_domains); $conf2->set_listAttributes($userlistAttributes, 'user'); $conf2->set_listAttributes($grouplistAttributes, 'group'); $conf2->set_listAttributes($hostlistAttributes, 'host'); @@ -119,7 +117,5 @@ $conf2->save(); echo ("done
"); // finished echo ("
Test is complete."); -echo ("

Current Config

"); -$conf2->printconf(); ?>