diff --git a/lam/HISTORY b/lam/HISTORY
index 46e2fd1c..bbf968e3 100644
--- a/lam/HISTORY
+++ b/lam/HISTORY
@@ -1,5 +1,6 @@
March 2010 3.0.0
- support to remove extension from an existing account: shadowAccount, sambaSamAccount, eduPerson
+ - file upload: allow to select account modules for upload
- removed frames
- Unix: automatic user name generation from first and last name (2492675)
- fixed bugs:
diff --git a/lam/docs/devel/mod_upload.htm b/lam/docs/devel/mod_upload.htm
index 4c03252f..1877fdf3 100644
--- a/lam/docs/devel/mod_upload.htm
+++ b/lam/docs/devel/mod_upload.htm
@@ -105,12 +105,13 @@ objectClass which is added to all accounts.
* @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)
+(e.g. "posixAccount_uid" => 5)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
function build_uploadAccounts($rawAccounts,
-$ids, &$partialAccounts) {
+$ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i <
sizeof($rawAccounts); $i++) {
diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm
index 10a53a5b..5ccde682 100644
--- a/lam/docs/devel/upgrade.htm
+++ b/lam/docs/devel/upgrade.htm
@@ -23,7 +23,14 @@ This is a list of API changes for all LAM releases.
You can now integrate JavaScript libraries by simply putting the files
into templates/lib. All files with the name *.js are automatically
included on all pages.
-There is a new log level LOG_DEBUG available for logNewMessage().
+There is a new log level LOG_DEBUG available for logNewMessage().
+
+
Module interface:
+The function
+build_uploadAccounts()
+has a new parameter
+$selectedModules
+.
diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc
index 48be0a83..4c774530 100644
--- a/lam/lib/baseModule.inc
+++ b/lam/lib/baseModule.inc
@@ -824,11 +824,12 @@ abstract class baseModule {
*
boolean: unique // true if all values of this column must be different values (optional, default: "false")
*
)
*
+ * @param array $selectedModules list of selected account modules
* @return array column list
*
* @see baseModule::get_metaData()
*/
- public function get_uploadColumns() {
+ public function get_uploadColumns($selectedModules) {
if (isset($this->meta['upload_columns'])) return $this->meta['upload_columns'];
else return array();
}
@@ -859,9 +860,10 @@ abstract class baseModule {
* @param array $rawAccounts the user input data, contains one subarray for each account.
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- public function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ public function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
// must be implemented in sub modules
return array();
}
diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc
index 1e98adfa..7ee89b5c 100644
--- a/lam/lib/modules.inc
+++ b/lam/lib/modules.inc
@@ -115,10 +115,14 @@ function get_ldap_filter($scope) {
* The list is already sorted by the priority given by the nodules.
*
* @param string $scope account type (user, group, host)
+* @param array $selectedModules return only RDN attributes of these modules
* @return array list of LDAP attributes
*/
-function getRDNAttributes($scope) {
+function getRDNAttributes($scope, $selectedModules=null) {
$mods = $_SESSION['config']->get_AccountModules($scope);
+ if ($selectedModules != null) {
+ $mods = $selectedModules;
+ }
$return = array();
$attrs_low = array();
$attrs_normal = array();
@@ -380,14 +384,14 @@ function getAvailablePDFFields($scope) {
*
)
*
* @param string $scope account type
+* @param array $selectedModules selected account modules
* @return array column list
*/
-function getUploadColumns($scope) {
- $mods = $_SESSION['config']->get_AccountModules($scope);
+function getUploadColumns($scope, $selectedModules) {
$return = array();
- for ($i = 0; $i < sizeof($mods); $i++) {
- $module = new $mods[$i]($scope);
- $return[$mods[$i]] = $module->get_uploadColumns();
+ for ($i = 0; $i < sizeof($selectedModules); $i++) {
+ $module = new $selectedModules[$i]($scope);
+ $return[$selectedModules[$i]] = $module->get_uploadColumns($selectedModules);
}
return $return;
}
@@ -400,11 +404,12 @@ function getUploadColumns($scope) {
* @param string $scope account type
* @param array $data array containing one account in each element
* @param array $ids array( => )
+* @param array $selectedModules selected account modules
* @return mixed array including accounts or false if there were errors
*/
-function buildUploadAccounts($scope, $data, $ids) {
+function buildUploadAccounts($scope, $data, $ids, $selectedModules) {
// build module order
- $unOrdered = $_SESSION['config']->get_AccountModules($scope);
+ $unOrdered = $selectedModules;
$ordered = array();
$predepends = array();
// get dependencies
@@ -453,7 +458,7 @@ function buildUploadAccounts($scope, $data, $ids) {
for ($i = 0; $i < sizeof($data); $i++) $partialAccounts[$i]['objectClass'] = array();
for ($i = 0; $i < sizeof($ordered); $i++) {
$module = new $ordered[$i]($scope);
- $errors = $module->build_uploadAccounts($data, $ids, $partialAccounts);
+ $errors = $module->build_uploadAccounts($data, $ids, $partialAccounts, $selectedModules);
if (sizeof($errors) > 0) {
array_unshift($errors, array("INFO", _("Displayed account numbers start at \"0\". Add 2 to get the row in your spreadsheet."), ""));
$errors[] = array("ERROR", _("Upload was stopped after errors in %s module!"), "", array($module->get_alias()));
diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc
index af6817c1..1047c1bf 100644
--- a/lam/lib/modules/account.inc
+++ b/lam/lib/modules/account.inc
@@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz
- 2005 - 2007 Roland Gruber
+ 2005 - 2010 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -101,30 +101,18 @@ class account extends baseModule {
)
);
// upload columns
- if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
- if ($this->get_scope() == 'user') {
- $return['upload_columns'][] = array(
- 'name' => 'account_hosts',
- 'description' => _('Host list'),
- 'help' => 'host'
- );
- }
- if (!in_array('posixAccount', $modules)) {
- $return['upload_columns'][] = array(
- 'name' => 'account_uid',
- 'description' => _('User name'),
- 'help' => 'uid',
- 'required' => true
- );
- $return['upload_columns'] = array(
- array(
- 'name' => 'account_description',
- 'description' => _('Description'),
- 'help' => 'description'
- )
- );
- }
+ if ($this->get_scope() == 'user') {
+ $return['upload_columns'][] = array(
+ 'name' => 'account_hosts',
+ 'description' => _('Host list'),
+ 'help' => 'host'
+ );
}
+ $return['upload_columns'][] = array(
+ 'name' => 'account_description',
+ 'description' => _('Description'),
+ 'help' => 'description'
+ );
return $return;
}
@@ -217,16 +205,17 @@ class account extends baseModule {
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if (!in_array('posixAccount', $modules)) {
$return[] = array (
- 0 => array('kind' => 'text', 'text' => _("User name").'*'),
- 1 => array('kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '30', 'maxlength' => '20',
+ array('kind' => 'text', 'text' => _("User name").'*'),
+ array('kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '30', 'maxlength' => '20',
'value' => $this->attributes['uid'][0]),
- 2 => array('kind' => 'help', 'value' => 'uid'));
+ array('kind' => 'help', 'value' => 'uid'));
}
// description
- $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
- 1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
- 'maxlength' => '255', 'value' => $this->attributes['description'][0] ),
- 2 => array ('kind' => 'help', 'value' => 'description'));
+ $return[] = array(
+ array('kind' => 'text', 'text' => _('Description')),
+ array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
+ 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
+ array('kind' => 'help', 'value' => 'description'));
return $return;
}
@@ -242,28 +231,59 @@ class account extends baseModule {
return $return;
}
+ /**
+ * Returns an array containing all input columns for the file upload.
+ *
+ * Syntax:
+ *
array(
+ *
string: name, // fixed non-translated name which is used as column name (should be of format: _)
+ *
string: description, // short descriptive name
+ *
string: help, // help ID
+ *
string: example, // example value
+ *
boolean: required // true, if user must set a value for this column
+ *
)
+ *
+ * @param array $selectedModules list of selected account modules
+ * @return array column list
+ */
+ function get_uploadColumns($selectedModules) {
+ $return = parent::get_uploadColumns($selectedModules);
+ if (!in_array('posixAccount', $selectedModules)) {
+ $return[] = array(
+ 'name' => 'account_uid',
+ 'description' => _('User name'),
+ 'help' => 'uid',
+ 'required' => true
+ );
+ }
+ return $return;
+ }
+
/**
* 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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("account", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "account";
- $modules = $_SESSION['config']->get_AccountModules($this->get_scope());
- if (!in_array('posixAccount', $modules)) {
- // description
- if ($rawAccounts[$i][$ids['account_description']] && ($rawAccounts[$i][$ids['account_description']] != '')) {
- $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['account_description']];
- }
- else {
- $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['account_uid']];
- }
+ // description
+ if ($rawAccounts[$i][$ids['account_description']] && ($rawAccounts[$i][$ids['account_description']] != '')) {
+ $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['account_description']];
+ }
+ elseif (isset($rawAccounts[$i][$ids['account_uid']])) {
+ $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['account_uid']];
+ }
+ elseif (isset($partialAccounts[$i]['uid'])) {
+ $partialAccounts[$i]['description'] = $partialAccounts[$i]['uid'];
+ }
+ if (!in_array('posixAccount', $selectedModules)) {
// user name
if (get_preg($rawAccounts[$i][$ids['account_uid']], 'username')) {
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['account_uid']];
diff --git a/lam/lib/modules/asteriskAccount.inc b/lam/lib/modules/asteriskAccount.inc
index 88e5ab30..6acc9562 100644
--- a/lam/lib/modules/asteriskAccount.inc
+++ b/lam/lib/modules/asteriskAccount.inc
@@ -280,9 +280,10 @@ class asteriskAccount extends baseModule implements passwordService {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/asteriskExtension.inc b/lam/lib/modules/asteriskExtension.inc
index 9cbe02fd..2f0c8d31 100644
--- a/lam/lib/modules/asteriskExtension.inc
+++ b/lam/lib/modules/asteriskExtension.inc
@@ -421,9 +421,10 @@ class asteriskExtension extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc
index a3216fb1..fe9e7271 100644
--- a/lam/lib/modules/ddns.inc
+++ b/lam/lib/modules/ddns.inc
@@ -620,9 +620,10 @@ class ddns extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
if (!$this->check_if_ddns_is_enable()) {
return $messages;
diff --git a/lam/lib/modules/dhcp_settings.inc b/lam/lib/modules/dhcp_settings.inc
index 2d777888..c1fa4e83 100644
--- a/lam/lib/modules/dhcp_settings.inc
+++ b/lam/lib/modules/dhcp_settings.inc
@@ -801,9 +801,10 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/eduPerson.inc b/lam/lib/modules/eduPerson.inc
index 4bde854b..df9f906f 100644
--- a/lam/lib/modules/eduPerson.inc
+++ b/lam/lib/modules/eduPerson.inc
@@ -542,9 +542,10 @@ class eduPerson extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/ieee802device.inc b/lam/lib/modules/ieee802device.inc
index 5766494f..7ffec478 100644
--- a/lam/lib/modules/ieee802device.inc
+++ b/lam/lib/modules/ieee802device.inc
@@ -160,9 +160,10 @@ class ieee802Device extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/inetLocalMailRecipient.inc b/lam/lib/modules/inetLocalMailRecipient.inc
index be6ff1e4..2adba23c 100644
--- a/lam/lib/modules/inetLocalMailRecipient.inc
+++ b/lam/lib/modules/inetLocalMailRecipient.inc
@@ -252,9 +252,10 @@ class inetLocalMailRecipient extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc
index 9759b4f4..35cd7910 100644
--- a/lam/lib/modules/inetOrgPerson.inc
+++ b/lam/lib/modules/inetOrgPerson.inc
@@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz
- 2005 - 2009 Roland Gruber
+ 2005 - 2010 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -472,27 +472,6 @@ class inetOrgPerson extends baseModule implements passwordService {
'example' => _('YourCompany, Human Resources')
);
}
- // cn and uid for upload (only if posixAccount is not loaded)
- if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
- $modules = $_SESSION['config']->get_AccountModules($this->get_scope());
- if (!in_array('posixAccount', $modules)) {
- $return['upload_columns'][] = array(
- 'name' => 'inetOrgPerson_cn',
- 'description' => _('Common name'),
- 'help' => 'cn',
- 'example' => _('Steve Miller'),
- 'default' => '<inetOrgPerson_firstName> <inetOrgPerson_lastName>'
- );
- $return['upload_columns'][] = array(
- 'name' => 'inetOrgPerson_userName',
- 'description' => _('User name'),
- 'help' => 'uid',
- 'example' => _('smiller'),
- 'unique' => true,
- 'required' => true
- );
- }
- }
// Unix workstations for upload
if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
if ($this->supportUnixHosts()) {
@@ -1287,15 +1266,54 @@ class inetOrgPerson extends baseModule implements passwordService {
}
}
+ /**
+ * Returns an array containing all input columns for the file upload.
+ *
+ * Syntax:
+ *
array(
+ *
string: name, // fixed non-translated name which is used as column name (should be of format: _)
+ *
string: description, // short descriptive name
+ *
string: help, // help ID
+ *
string: example, // example value
+ *
boolean: required // true, if user must set a value for this column
+ *
)
+ *
+ * @param array $selectedModules list of selected account modules
+ * @return array column list
+ */
+ function get_uploadColumns($selectedModules) {
+ $return = parent::get_uploadColumns($selectedModules);
+ // cn and uid for upload (only if posixAccount is not selected)
+ if (!in_array('posixAccount', $selectedModules)) {
+ $return[] = array(
+ 'name' => 'inetOrgPerson_cn',
+ 'description' => _('Common name'),
+ 'help' => 'cn',
+ 'example' => _('Steve Miller'),
+ 'default' => '<inetOrgPerson_firstName> <inetOrgPerson_lastName>'
+ );
+ $return[] = array(
+ 'name' => 'inetOrgPerson_userName',
+ 'description' => _('User name'),
+ 'help' => 'uid',
+ 'example' => _('smiller'),
+ 'unique' => true,
+ 'required' => true
+ );
+ }
+ return $return;
+ }
+
/**
* 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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$errors = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
@@ -1504,8 +1522,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$errors[] = $errMsg;
}
}
- $modules = $_SESSION['config']->get_AccountModules($this->get_scope());
- if (!in_array('posixAccount', $modules)) {
+ if (!in_array('posixAccount', $selectedModules)) {
// cn
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") {
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_cn']], 'cn')) {
diff --git a/lam/lib/modules/kolabUser.inc b/lam/lib/modules/kolabUser.inc
index d51827c3..e2df68d6 100644
--- a/lam/lib/modules/kolabUser.inc
+++ b/lam/lib/modules/kolabUser.inc
@@ -609,9 +609,10 @@ class kolabUser extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/ldapPublicKey.inc b/lam/lib/modules/ldapPublicKey.inc
index 02a85417..fae71500 100644
--- a/lam/lib/modules/ldapPublicKey.inc
+++ b/lam/lib/modules/ldapPublicKey.inc
@@ -139,9 +139,10 @@ class ldapPublicKey extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/nisMailAlias.inc b/lam/lib/modules/nisMailAlias.inc
index db29e93b..2169704e 100644
--- a/lam/lib/modules/nisMailAlias.inc
+++ b/lam/lib/modules/nisMailAlias.inc
@@ -230,9 +230,10 @@ class nisMailAlias extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/nisnetgroup.inc b/lam/lib/modules/nisnetgroup.inc
index b6d2dede..c4038b99 100644
--- a/lam/lib/modules/nisnetgroup.inc
+++ b/lam/lib/modules/nisnetgroup.inc
@@ -497,9 +497,10 @@ class nisnetgroup extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
// get list of existing groups
$dnGroups = $_SESSION['cache']->get_cache('cn', 'nisNetgroup', 'netgroup');
diff --git a/lam/lib/modules/phpGroupwareGroup.inc b/lam/lib/modules/phpGroupwareGroup.inc
index cdc069f6..ea788eab 100644
--- a/lam/lib/modules/phpGroupwareGroup.inc
+++ b/lam/lib/modules/phpGroupwareGroup.inc
@@ -171,9 +171,10 @@ class phpGroupwareGroup extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (isset($rawAccounts[$i][$ids['phpGroupwareGroup_extension']])
&& (strtolower($rawAccounts[$i][$ids['phpGroupwareGroup_extension']]) == "true")) {
diff --git a/lam/lib/modules/phpGroupwareUser.inc b/lam/lib/modules/phpGroupwareUser.inc
index b3b56cb0..54a793f5 100644
--- a/lam/lib/modules/phpGroupwareUser.inc
+++ b/lam/lib/modules/phpGroupwareUser.inc
@@ -373,9 +373,10 @@ class phpGroupwareUser extends baseModule implements passwordService {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!isset($rawAccounts[$i][$ids['phpGroupwareUser_extension']])
diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc
index 7dba38e3..f32dd2b4 100644
--- a/lam/lib/modules/posixAccount.inc
+++ b/lam/lib/modules/posixAccount.inc
@@ -1250,9 +1250,10 @@ class posixAccount extends baseModule implements passwordService {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$errors = array();
$needAutoUID = array();
// get list of existing users
diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc
index 3d5873ed..bb7f01d9 100644
--- a/lam/lib/modules/posixGroup.inc
+++ b/lam/lib/modules/posixGroup.inc
@@ -54,9 +54,10 @@ class posixGroup extends baseModule implements passwordService {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$error_messages = array();
$needAutoGID = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc
index aeb63600..df49814d 100644
--- a/lam/lib/modules/quota.inc
+++ b/lam/lib/modules/quota.inc
@@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz
- 2007 - 2009 Roland Gruber
+ 2007 - 2010 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -611,9 +611,10 @@ class quota extends baseModule {
*
boolean: required // true, if user must set a value for this column
*
)
*
+ * @param array $selectedModules list of selected account modules
* @return array column list
*/
- function get_uploadColumns() {
+ function get_uploadColumns($selectedModules) {
$this->initQuotas();
if (!isset($this->quota) || !is_array($this->quota)) return array();
$return = array();
diff --git a/lam/lib/modules/sambaDomain.inc b/lam/lib/modules/sambaDomain.inc
index f0893e9d..1dc7ea72 100644
--- a/lam/lib/modules/sambaDomain.inc
+++ b/lam/lib/modules/sambaDomain.inc
@@ -546,9 +546,10 @@ class sambaDomain extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc
index 1f27a3f2..89afd269 100644
--- a/lam/lib/modules/sambaGroupMapping.inc
+++ b/lam/lib/modules/sambaGroupMapping.inc
@@ -134,9 +134,10 @@ class sambaGroupMapping extends baseModule {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
// search existing Samba 3 domains
$domains = search_domains();
$nameToSID = array();
diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc
index d8674729..00ee8ba2 100644
--- a/lam/lib/modules/sambaSamAccount.inc
+++ b/lam/lib/modules/sambaSamAccount.inc
@@ -1855,9 +1855,10 @@ class sambaSamAccount extends baseModule implements passwordService {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$errors = array();
// get list of Samba 3 domains
$domains = search_domains();
diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc
index 22bf5d55..827140cb 100644
--- a/lam/lib/modules/shadowAccount.inc
+++ b/lam/lib/modules/shadowAccount.inc
@@ -425,9 +425,10 @@ class shadowAccount extends baseModule implements passwordService {
* @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)
+ * @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
- function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
+ function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
diff --git a/lam/templates/massBuildAccounts.php b/lam/templates/massBuildAccounts.php
index b15f13ab..53ff9617 100644
--- a/lam/templates/massBuildAccounts.php
+++ b/lam/templates/massBuildAccounts.php
@@ -86,11 +86,12 @@ if (isset($_GET['showldif'])) {
include 'main_header.php';
if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
+ $selectedModules = explode(',', $_POST['selectedModules']);
// check if input file is well formated
$data = array(); // input values without first row
$ids = array(); // =>
// get input fields from modules
- $columns = getUploadColumns($_POST['scope']);
+ $columns = getUploadColumns($_POST['scope'], $selectedModules);
// read input file
$handle = fopen ($_FILES['inputfile']['tmp_name'], "r");
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
@@ -157,9 +158,9 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
// let modules build accounts
else {
- $accounts = buildUploadAccounts($_POST['scope'], $data, $ids);
+ $accounts = buildUploadAccounts($_POST['scope'], $data, $ids, $selectedModules);
if ($accounts != false) {
- $rdnList = getRDNAttributes($_POST['scope']);
+ $rdnList = getRDNAttributes($_POST['scope'], $selectedModules);
$suffix = $_SESSION['config']->get_Suffix($_POST['scope']);
// set DN
for ($i = 0; $i < sizeof($accounts); $i++) {
diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php
index aed10318..666f19b6 100644
--- a/lam/templates/masscreate.php
+++ b/lam/templates/masscreate.php
@@ -72,51 +72,129 @@ $types = $_SESSION['config']->get_ActiveTypes();
include 'main_header.php';
// check if account specific page should be shown
-if (isset($_POST['type'])) showMainPage($_POST['type']);
+if (isset($_POST['type'])) {
+ // get selected type
+ $scope = $_POST['type'];
+ // get selected modules
+ $selectedModules = array();
+ $checkedBoxes = array_keys($_POST, 'on');
+ for ($i = 0; $i < sizeof($checkedBoxes); $i++) {
+ if (strpos($checkedBoxes[$i], $scope . '_') === 0) {
+ $selectedModules[] = substr($checkedBoxes[$i], strlen($scope) + 1);
+ }
+ }
+ $deps = getModulesDependencies($scope);
+ $depErrors = check_module_depends($selectedModules, $deps);
+ if (is_array($depErrors) && (sizeof($depErrors) > 0)) {
+ for ($i = 0; $i < sizeof($depErrors); $i++) {
+ StatusMessage('ERROR', _("Unsolved dependency:") . ' ' .
+ getModuleAlias($depErrors[$i][0], $scope) . " (" .
+ getModuleAlias($depErrors[$i][1], $scope) . ")");
+ }
+ }
+ else {
+ showMainPage($scope, $selectedModules);
+ exit;
+ }
+}
// show start page
-else {
- echo "" . _("Account creation via file upload") . "
\n";
- echo "
\n";
-
- echo "\n";
- echo _("Here you can create multiple accounts by providing a CSV file.");
- echo "
\n";
-
- echo "
\n";
-
- echo "\n";
- echo _("Please select your account type:");
- echo "
\n";
-
- echo "