allow to selected modules for file upload

This commit is contained in:
Roland Gruber 2010-02-15 20:21:44 +00:00
parent efc47ad218
commit 4f84924055
29 changed files with 299 additions and 143 deletions

View File

@ -1,5 +1,6 @@
March 2010 3.0.0 March 2010 3.0.0
- support to remove extension from an existing account: shadowAccount, sambaSamAccount, eduPerson - support to remove extension from an existing account: shadowAccount, sambaSamAccount, eduPerson
- file upload: allow to select account modules for upload
- removed frames - removed frames
- Unix: automatic user name generation from first and last name (2492675) - Unix: automatic user name generation from first and last name (2492675)
- fixed bugs: - fixed bugs:

View File

@ -105,12 +105,13 @@ objectClass which is added to all accounts.<br>
&nbsp;&nbsp;&nbsp; * @param array $partialAccounts list of hash arrays &nbsp;&nbsp;&nbsp; * @param array $partialAccounts list of hash arrays
(name =&gt; value) which are later added to LDAP<br> (name =&gt; value) which are later added to LDAP<br>
&nbsp;&nbsp;&nbsp; * @param array $ids list of IDs for column position &nbsp;&nbsp;&nbsp; * @param array $ids list of IDs for column position
(e.g. "posixAccount_uid" =&gt; 5)<br> (e.g. "posixAccount_uid" =&gt; 5)<br> 
  * @param array $selectedModules list of selected account modules<br>
&nbsp;&nbsp;&nbsp; * @return array list of error messages if any<br> &nbsp;&nbsp;&nbsp; * @return array list of error messages if any<br>
&nbsp;&nbsp;&nbsp; */<br> &nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span &nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span
style="color: rgb(255, 0, 0);">build_uploadAccounts</span>($rawAccounts, style="color: rgb(255, 0, 0);">build_uploadAccounts</span>($rawAccounts,
$ids, &amp;$partialAccounts) {<br> $ids, &amp;$partialAccounts, $selectedModules) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $messages = array();<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $messages = array();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for ($i = 0; $i &lt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for ($i = 0; $i &lt;
sizeof($rawAccounts); $i++) {<br> sizeof($rawAccounts); $i++) {<br>

View File

@ -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 You can now integrate JavaScript libraries by simply putting the files
into templates/lib. All files with the name *.js are automatically into templates/lib. All files with the name *.js are automatically
included on all pages.<br> included on all pages.<br>
There is a new log level LOG_DEBUG available for logNewMessage().<br> There is a new log level LOG_DEBUG available for logNewMessage().
<br>
<h3>Module interface:</h3>
The function
<span style="font-weight: bold;">build_uploadAccounts()</span>
has a new parameter
<span style="font-weight: bold;">$selectedModules</span>
.<br>
<br> <br>
<br> <br>

View File

@ -824,11 +824,12 @@ abstract class baseModule {
* <br> boolean: unique // true if all values of this column must be different values (optional, default: "false") * <br> boolean: unique // true if all values of this column must be different values (optional, default: "false")
* <br> ) * <br> )
* *
* @param array $selectedModules list of selected account modules
* @return array column list * @return array column list
* *
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
public function get_uploadColumns() { public function get_uploadColumns($selectedModules) {
if (isset($this->meta['upload_columns'])) return $this->meta['upload_columns']; if (isset($this->meta['upload_columns'])) return $this->meta['upload_columns'];
else return array(); 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 $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 $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 $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 * @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 // must be implemented in sub modules
return array(); return array();
} }

View File

@ -115,10 +115,14 @@ function get_ldap_filter($scope) {
* The list is already sorted by the priority given by the nodules. * The list is already sorted by the priority given by the nodules.
* *
* @param string $scope account type (user, group, host) * @param string $scope account type (user, group, host)
* @param array $selectedModules return only RDN attributes of these modules
* @return array list of LDAP attributes * @return array list of LDAP attributes
*/ */
function getRDNAttributes($scope) { function getRDNAttributes($scope, $selectedModules=null) {
$mods = $_SESSION['config']->get_AccountModules($scope); $mods = $_SESSION['config']->get_AccountModules($scope);
if ($selectedModules != null) {
$mods = $selectedModules;
}
$return = array(); $return = array();
$attrs_low = array(); $attrs_low = array();
$attrs_normal = array(); $attrs_normal = array();
@ -380,14 +384,14 @@ function getAvailablePDFFields($scope) {
* <br> ) * <br> )
* *
* @param string $scope account type * @param string $scope account type
* @param array $selectedModules selected account modules
* @return array column list * @return array column list
*/ */
function getUploadColumns($scope) { function getUploadColumns($scope, $selectedModules) {
$mods = $_SESSION['config']->get_AccountModules($scope);
$return = array(); $return = array();
for ($i = 0; $i < sizeof($mods); $i++) { for ($i = 0; $i < sizeof($selectedModules); $i++) {
$module = new $mods[$i]($scope); $module = new $selectedModules[$i]($scope);
$return[$mods[$i]] = $module->get_uploadColumns(); $return[$selectedModules[$i]] = $module->get_uploadColumns($selectedModules);
} }
return $return; return $return;
} }
@ -400,11 +404,12 @@ function getUploadColumns($scope) {
* @param string $scope account type * @param string $scope account type
* @param array $data array containing one account in each element * @param array $data array containing one account in each element
* @param array $ids array(<column_name> => <column number>) * @param array $ids array(<column_name> => <column number>)
* @param array $selectedModules selected account modules
* @return mixed array including accounts or false if there were errors * @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 // build module order
$unOrdered = $_SESSION['config']->get_AccountModules($scope); $unOrdered = $selectedModules;
$ordered = array(); $ordered = array();
$predepends = array(); $predepends = array();
// get dependencies // 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($data); $i++) $partialAccounts[$i]['objectClass'] = array();
for ($i = 0; $i < sizeof($ordered); $i++) { for ($i = 0; $i < sizeof($ordered); $i++) {
$module = new $ordered[$i]($scope); $module = new $ordered[$i]($scope);
$errors = $module->build_uploadAccounts($data, $ids, $partialAccounts); $errors = $module->build_uploadAccounts($data, $ids, $partialAccounts, $selectedModules);
if (sizeof($errors) > 0) { if (sizeof($errors) > 0) {
array_unshift($errors, array("INFO", _("Displayed account numbers start at \"0\". Add 2 to get the row in your spreadsheet."), "")); 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())); $errors[] = array("ERROR", _("Upload was stopped after errors in %s module!"), "", array($module->get_alias()));

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz 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 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 it under the terms of the GNU General Public License as published by
@ -101,7 +101,6 @@ class account extends baseModule {
) )
); );
// upload columns // upload columns
if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
if ($this->get_scope() == 'user') { if ($this->get_scope() == 'user') {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'account_hosts', 'name' => 'account_hosts',
@ -109,22 +108,11 @@ class account extends baseModule {
'help' => 'host' 'help' => 'host'
); );
} }
if (!in_array('posixAccount', $modules)) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'account_uid',
'description' => _('User name'),
'help' => 'uid',
'required' => true
);
$return['upload_columns'] = array(
array(
'name' => 'account_description', 'name' => 'account_description',
'description' => _('Description'), 'description' => _('Description'),
'help' => 'description' 'help' => 'description'
)
); );
}
}
return $return; return $return;
} }
@ -217,16 +205,17 @@ class account extends baseModule {
$modules = $_SESSION['config']->get_AccountModules($this->get_scope()); $modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if (!in_array('posixAccount', $modules)) { if (!in_array('posixAccount', $modules)) {
$return[] = array ( $return[] = array (
0 => array('kind' => 'text', 'text' => _("User name").'*'), array('kind' => 'text', 'text' => _("User name").'*'),
1 => array('kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '30', 'maxlength' => '20', array('kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '30', 'maxlength' => '20',
'value' => $this->attributes['uid'][0]), 'value' => $this->attributes['uid'][0]),
2 => array('kind' => 'help', 'value' => 'uid')); array('kind' => 'help', 'value' => 'uid'));
} }
// description // description
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ), $return[] = array(
1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', array('kind' => 'text', 'text' => _('Description')),
'maxlength' => '255', 'value' => $this->attributes['description'][0] ), array('kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30',
2 => array ('kind' => 'help', 'value' => 'description')); 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
array('kind' => 'help', 'value' => 'description'));
return $return; return $return;
} }
@ -242,28 +231,59 @@ class account extends baseModule {
return $return; return $return;
} }
/**
* Returns an array containing all input columns for the file upload.
*
* Syntax:
* <br> array(
* <br> string: name, // fixed non-translated name which is used as column name (should be of format: <module name>_<column name>)
* <br> string: description, // short descriptive name
* <br> string: help, // help ID
* <br> string: example, // example value
* <br> boolean: required // true, if user must set a value for this column
* <br> )
*
* @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. * In this function the LDAP account is built up.
* *
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class
if (!in_array("account", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "account"; 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 // description
if ($rawAccounts[$i][$ids['account_description']] && ($rawAccounts[$i][$ids['account_description']] != '')) { if ($rawAccounts[$i][$ids['account_description']] && ($rawAccounts[$i][$ids['account_description']] != '')) {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['account_description']]; $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['account_description']];
} }
else { elseif (isset($rawAccounts[$i][$ids['account_uid']])) {
$partialAccounts[$i]['description'] = $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 // user name
if (get_preg($rawAccounts[$i][$ids['account_uid']], 'username')) { if (get_preg($rawAccounts[$i][$ids['account_uid']], 'username')) {
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['account_uid']]; $partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['account_uid']];

View File

@ -280,9 +280,10 @@ class asteriskAccount extends baseModule implements passwordService {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -421,9 +421,10 @@ class asteriskExtension extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -620,9 +620,10 @@ class ddns extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
if (!$this->check_if_ddns_is_enable()) { if (!$this->check_if_ddns_is_enable()) {
return $messages; return $messages;

View File

@ -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 $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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -542,9 +542,10 @@ class eduPerson extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -160,9 +160,10 @@ class ieee802Device extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -252,9 +252,10 @@ class inetLocalMailRecipient extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz 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 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 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') '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' => '<i>&lt;inetOrgPerson_firstName&gt; &lt;inetOrgPerson_lastName&gt;</i>'
);
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_userName',
'description' => _('User name'),
'help' => 'uid',
'example' => _('smiller'),
'unique' => true,
'required' => true
);
}
}
// Unix workstations for upload // Unix workstations for upload
if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) { if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
if ($this->supportUnixHosts()) { 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:
* <br> array(
* <br> string: name, // fixed non-translated name which is used as column name (should be of format: <module name>_<column name>)
* <br> string: description, // short descriptive name
* <br> string: help, // help ID
* <br> string: example, // example value
* <br> boolean: required // true, if user must set a value for this column
* <br> )
*
* @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' => '<i>&lt;inetOrgPerson_firstName&gt; &lt;inetOrgPerson_lastName&gt;</i>'
);
$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. * In this function the LDAP account is built up.
* *
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$errors = array(); $errors = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson"; if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
@ -1504,8 +1522,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$errors[] = $errMsg; $errors[] = $errMsg;
} }
} }
$modules = $_SESSION['config']->get_AccountModules($this->get_scope()); if (!in_array('posixAccount', $selectedModules)) {
if (!in_array('posixAccount', $modules)) {
// cn // cn
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") { if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") {
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_cn']], 'cn')) { if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_cn']], 'cn')) {

View File

@ -609,9 +609,10 @@ class kolabUser extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -139,9 +139,10 @@ class ldapPublicKey extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -230,9 +230,10 @@ class nisMailAlias extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -497,9 +497,10 @@ class nisnetgroup extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
// get list of existing groups // get list of existing groups
$dnGroups = $_SESSION['cache']->get_cache('cn', 'nisNetgroup', 'netgroup'); $dnGroups = $_SESSION['cache']->get_cache('cn', 'nisNetgroup', 'netgroup');

View File

@ -171,9 +171,10 @@ class phpGroupwareGroup extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @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++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (isset($rawAccounts[$i][$ids['phpGroupwareGroup_extension']]) if (isset($rawAccounts[$i][$ids['phpGroupwareGroup_extension']])
&& (strtolower($rawAccounts[$i][$ids['phpGroupwareGroup_extension']]) == "true")) { && (strtolower($rawAccounts[$i][$ids['phpGroupwareGroup_extension']]) == "true")) {

View File

@ -373,9 +373,10 @@ class phpGroupwareUser extends baseModule implements passwordService {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!isset($rawAccounts[$i][$ids['phpGroupwareUser_extension']]) if (!isset($rawAccounts[$i][$ids['phpGroupwareUser_extension']])

View File

@ -1250,9 +1250,10 @@ class posixAccount extends baseModule implements passwordService {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$errors = array(); $errors = array();
$needAutoUID = array(); $needAutoUID = array();
// get list of existing users // get list of existing users

View File

@ -54,9 +54,10 @@ class posixGroup extends baseModule implements passwordService {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$error_messages = array(); $error_messages = array();
$needAutoGID = array(); $needAutoGID = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz 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 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 it under the terms of the GNU General Public License as published by
@ -611,9 +611,10 @@ class quota extends baseModule {
* <br> boolean: required // true, if user must set a value for this column * <br> boolean: required // true, if user must set a value for this column
* <br> ) * <br> )
* *
* @param array $selectedModules list of selected account modules
* @return array column list * @return array column list
*/ */
function get_uploadColumns() { function get_uploadColumns($selectedModules) {
$this->initQuotas(); $this->initQuotas();
if (!isset($this->quota) || !is_array($this->quota)) return array(); if (!isset($this->quota) || !is_array($this->quota)) return array();
$return = array(); $return = array();

View File

@ -546,9 +546,10 @@ class sambaDomain extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -134,9 +134,10 @@ class sambaGroupMapping extends baseModule {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @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 // search existing Samba 3 domains
$domains = search_domains(); $domains = search_domains();
$nameToSID = array(); $nameToSID = array();

View File

@ -1855,9 +1855,10 @@ class sambaSamAccount extends baseModule implements passwordService {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$errors = array(); $errors = array();
// get list of Samba 3 domains // get list of Samba 3 domains
$domains = search_domains(); $domains = search_domains();

View File

@ -425,9 +425,10 @@ class shadowAccount extends baseModule implements passwordService {
* @param array $rawAccounts list of hash arrays (name => value) from user input * @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 $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 $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 * @return array list of error messages if any
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array(); $messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class

View File

@ -86,11 +86,12 @@ if (isset($_GET['showldif'])) {
include 'main_header.php'; include 'main_header.php';
if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
$selectedModules = explode(',', $_POST['selectedModules']);
// check if input file is well formated // check if input file is well formated
$data = array(); // input values without first row $data = array(); // input values without first row
$ids = array(); // <column name> => <column number for $data> $ids = array(); // <column name> => <column number for $data>
// get input fields from modules // get input fields from modules
$columns = getUploadColumns($_POST['scope']); $columns = getUploadColumns($_POST['scope'], $selectedModules);
// read input file // read input file
$handle = fopen ($_FILES['inputfile']['tmp_name'], "r"); $handle = fopen ($_FILES['inputfile']['tmp_name'], "r");
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
@ -157,9 +158,9 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
// let modules build accounts // let modules build accounts
else { else {
$accounts = buildUploadAccounts($_POST['scope'], $data, $ids); $accounts = buildUploadAccounts($_POST['scope'], $data, $ids, $selectedModules);
if ($accounts != false) { if ($accounts != false) {
$rdnList = getRDNAttributes($_POST['scope']); $rdnList = getRDNAttributes($_POST['scope'], $selectedModules);
$suffix = $_SESSION['config']->get_Suffix($_POST['scope']); $suffix = $_SESSION['config']->get_Suffix($_POST['scope']);
// set DN // set DN
for ($i = 0; $i < sizeof($accounts); $i++) { for ($i = 0; $i < sizeof($accounts); $i++) {

View File

@ -72,51 +72,129 @@ $types = $_SESSION['config']->get_ActiveTypes();
include 'main_header.php'; include 'main_header.php';
// check if account specific page should be shown // 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 // show start page
else { echo "<h1>" . _("Account creation via file upload") . "</h1>\n";
echo "<h1>" . _("Account creation via file upload") . "</h1>\n"; echo "<p>&nbsp;</p>\n";
echo "<p>&nbsp;</p>\n";
echo "<p>\n"; echo "<p>\n";
echo _("Here you can create multiple accounts by providing a CSV file."); echo _("Here you can create multiple accounts by providing a CSV file.");
echo "</p>\n"; echo "</p>\n";
echo "<p>&nbsp;</p>\n"; echo "<p>&nbsp;</p>\n";
echo "<p><b>\n"; echo '<script type="text/javascript">';
echo _("Please select your account type:"); echo 'function changeVisibleModules(element) {';
echo "</b></p>\n"; echo 'jQuery(\'div.typeOptions\').toggle(false);';
echo 'jQuery(\'div#\' + element.options[element.selectedIndex].value).toggle();';
echo '}';
echo '</script>';
echo "<form enctype=\"multipart/form-data\" action=\"masscreate.php\" method=\"post\">\n"; echo "<form enctype=\"multipart/form-data\" action=\"masscreate.php\" method=\"post\">\n";
echo "<table style=\"border-color: grey\" cellpadding=\"10\" border=\"0\" cellspacing=\"0\">\n";
echo "<table style=\"border-color: grey\" cellpadding=\"10\" border=\"0\" cellspacing=\"0\">\n";
echo "<tr><td>\n"; echo "<tr><td>\n";
echo "<select class=\"user\" name=\"type\">\n"; echo '<b>' . _("Account type") . ':</b>';
echo "</td>\n";
echo "<td>\n";
echo "<select class=\"user\" name=\"type\" onChange=\"changeVisibleModules(this);\">\n";
for ($i = 0; $i < sizeof($types); $i++) { for ($i = 0; $i < sizeof($types); $i++) {
echo "<option value=\"" . $types[$i] . "\">\n"; $selected = '';
if (isset($_POST['type']) && ($_POST['type'] == $types[$i])) {
$selected = 'selected';
}
echo "<option value=\"" . $types[$i] . "\" $selected>\n";
echo getTypeAlias($types[$i]); echo getTypeAlias($types[$i]);
echo "</option>\n"; echo "</option>\n";
} }
echo "</select>\n"; echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><td valign=\"top\">\n";
echo '<b>' . _('Selected modules') . ':</b>';
echo "</td>\n"; echo "</td>\n";
echo "<td>\n"; echo "<td>\n";
// generate one DIV for each account type
for ($i = 0; $i < sizeof($types); $i++) {
$style = 'style="display:none;"';
if ((!isset($_POST['type']) && ($i == 0)) || ($_POST['type'] == $types[$i])) {
// show first account type or last selected one
$style = '';
}
echo "<div $style id=\"" . $types[$i] . "\" class=\"typeOptions\">\n";
echo "<table border=0>";
$modules = $_SESSION['config']->get_AccountModules($types[$i]);
for ($m = 0; $m < sizeof($modules); $m++) {
if ($m%3 == 0) {
echo "<tr>\n";
}
echo "<td>";
$module = new $modules[$m]($types[$i]);
$iconImage = $module->getIcon();
echo '<img align="middle" src="../graphics/' . $iconImage . '" alt="' . $iconImage . '">';
echo "</td><td>\n";
if (is_base_module($modules[$m], $types[$i])) {
echo "<input type=\"hidden\" name=\"" . $types[$i] . '_' . $modules[$m] . "\" value=\"on\"><input type=\"checkbox\" checked disabled>";
}
else {
$checked = 'checked';
if (isset($_POST['submit']) && !isset($_POST[$types[$i] . '_' . $modules[$m]])) {
$checked = '';
}
echo "<input type=\"checkbox\" name=\"" . $types[$i] . '_' . $modules[$m] . "\" $checked>";
}
echo getModuleAlias($modules[$m], $types[$i]);
echo "</td>";
if (($m%3 == 2) && ($m != (sizeof($modules) - 1))) {
echo "</tr>\n";
}
}
echo "</tr>";
echo "</table>\n";
echo "</div>\n";
}
echo "</td></tr>\n";
echo "<tr><td>\n";
echo "<input class=\"user\" type=\"submit\" name=\"submit\" value=\"". _("Ok") . "\">\n"; echo "<input class=\"user\" type=\"submit\" name=\"submit\" value=\"". _("Ok") . "\">\n";
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "</form>\n"; echo "</form>\n";
echo "</body>\n"; echo "</body>\n";
echo "</html>\n"; echo "</html>\n";
}
/** /**
* Displays the acount type specific main page of the upload. * Displays the acount type specific main page of the upload.
* *
* @param string $scope account type * @param string $scope account type
* @param array $selectedModules list of selected account modules
*/ */
function showMainPage($scope) { function showMainPage($scope, $selectedModules) {
echo "<h1>" . _("File upload") . "</h1>"; echo "<h1>" . _("File upload") . "</h1>";
echo "<p>\n"; echo "<p>\n";
echo _("Please provide a CSV formated file with your account data. The cells in the first row must be filled with the column identifiers. The following rows represent one account for each row."); echo _("Please provide a CSV formated file with your account data. The cells in the first row must be filled with the column identifiers. The following rows represent one account for each row.");
@ -133,6 +211,7 @@ function showMainPage($scope) {
echo "<b>" . _("CSV file:") . "</b> <input class=\"$scope\" name=\"inputfile\" type=\"file\">&nbsp;&nbsp;"; echo "<b>" . _("CSV file:") . "</b> <input class=\"$scope\" name=\"inputfile\" type=\"file\">&nbsp;&nbsp;";
echo "<input class=\"$scope\" name=\"submitfile\" type=\"submit\" value=\"" . _('Upload file and create accounts') . "\">\n"; echo "<input class=\"$scope\" name=\"submitfile\" type=\"submit\" value=\"" . _('Upload file and create accounts') . "\">\n";
echo "<input type=\"hidden\" name=\"scope\" value=\"$scope\">\n"; echo "<input type=\"hidden\" name=\"scope\" value=\"$scope\">\n";
echo "<input type=\"hidden\" name=\"selectedModules\" value=\"" . implode(',', $selectedModules) . "\">\n";
echo "</p>\n"; echo "</p>\n";
echo "</form>\n"; echo "</form>\n";
@ -166,7 +245,7 @@ function showMainPage($scope) {
echo "<br>\n"; echo "<br>\n";
echo "<ul>\n"; echo "<ul>\n";
echo "<li><b>" . _("Identifier") . ":</b> " . "dn_rdn</li>\n"; echo "<li><b>" . _("Identifier") . ":</b> " . "dn_rdn</li>\n";
echo "<li><b>" . _("Possible values") . ":</b> " . implode(", ", getRDNAttributes($scope)) . "</li>\n"; echo "<li><b>" . _("Possible values") . ":</b> " . implode(", ", getRDNAttributes($scope, $selectedModules)) . "</li>\n";
echo "</ul>\n"; echo "</ul>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
@ -174,12 +253,15 @@ function showMainPage($scope) {
echo "</fieldset><br>\n"; echo "</fieldset><br>\n";
// get input fields from modules // get input fields from modules
$columns = getUploadColumns($scope); $columns = getUploadColumns($scope, $selectedModules);
// print input fields // print input fields
$modules = array_keys($columns); $modules = array_keys($columns);
for ($m = 0; $m < sizeof($modules); $m++) { for ($m = 0; $m < sizeof($modules); $m++) {
if (sizeof($columns[$modules[$m]]) < 1) continue; // skip modules without upload columns
if (sizeof($columns[$modules[$m]]) < 1) {
continue;
}
$icon = ''; $icon = '';
$module = new $modules[$m]($scope); $module = new $modules[$m]($scope);
$iconImage = $module->getIcon(); $iconImage = $module->getIcon();
@ -243,7 +325,7 @@ function showMainPage($scope) {
} }
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
$RDNs = getRDNAttributes($scope); $RDNs = getRDNAttributes($scope, $selectedModules);
// DN attributes // DN attributes
$sampleCSV_row[] = "\"" . $_SESSION['config']->get_Suffix($scope) . "\""; $sampleCSV_row[] = "\"" . $_SESSION['config']->get_Suffix($scope) . "\"";
$sampleCSV_row[] = "\"" . $RDNs[0] . "\""; $sampleCSV_row[] = "\"" . $RDNs[0] . "\"";