added more upload columns

This commit is contained in:
Roland Gruber 2004-11-05 16:53:38 +00:00
parent d73da87f8c
commit b7dd7e9a35
2 changed files with 93 additions and 0 deletions

View File

@ -48,6 +48,32 @@ class account extends baseModule {
) )
) )
); );
// upload columns
if ($_SESSION['loggedIn']) {
if ($this->get_scope() == 'user') {
$return['upload_columns'][] = array(
'name' => 'account_hosts',
'description' => _('Host list'),
'help' => 'host'
);
}
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
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'
)
);
}
}
return $return; return $return;
} }
@ -146,6 +172,44 @@ class account extends baseModule {
return array('account_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>')); return array('account_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>'));
} }
/**
* 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("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']];
}
// user name
if (get_preg($rawAccounts[$i][$ids['account_uid']], 'username')) {
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['account_uid']];
}
else {
$errMsg = $this->messages['uid'][7];
array_push($errMsg, array($i));
$triggered_messages[] = $errMsg;
}
}
if ($this->get_scope() == 'user') {
}
}
return $messages;
}
} }
?> ?>

View File

@ -258,6 +258,17 @@ class posixAccount extends baseModule {
) )
); );
} }
if ($_SESSION['loggedIn']) {
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if (!in_array('inetOrgPerson', $modules)) {
$return['upload_columns'][] =
array(
'name' => 'posixAccount_description',
'description' => _('Description'),
'help' => 'description'
);
}
}
// available PDF fields // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'uid', 'uid',
@ -1139,18 +1150,36 @@ class posixAccount extends baseModule {
array_push($errMsg, array($i)); array_push($errMsg, array($i));
$triggered_messages[] = $errMsg; $triggered_messages[] = $errMsg;
} }
// description
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if (!in_array('inetOrgPerson', $modules)) {
if ($rawAccounts[$i][$ids['posixAccount_description']] && ($rawAccounts[$i][$ids['posixAccount_description']] != '')) {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixAccount_description']];
}
else {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
}
}
} }
// host specific attributes // host specific attributes
elseif ($this->scope == 'host') { elseif ($this->scope == 'host') {
// host name // host name
if (get_preg($rawAccounts[$i][$ids['posixAccount_hostName']], 'hostname')) { if (get_preg($rawAccounts[$i][$ids['posixAccount_hostName']], 'hostname')) {
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_hostName']]; $partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
} }
else { else {
$errMsg = $this->messages['uid'][8]; $errMsg = $this->messages['uid'][8];
array_push($errMsg, array($i)); array_push($errMsg, array($i));
$triggered_messages[] = $errMsg; $triggered_messages[] = $errMsg;
} }
// description
if ($rawAccounts[$i][$ids['posixAccount_description']] && ($rawAccounts[$i][$ids['posixAccount_description']] != '')) {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixAccount_description']];
}
else {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
}
$partialAccounts[$i]['homeDirectory'] = '/dev/null'; $partialAccounts[$i]['homeDirectory'] = '/dev/null';
$partialAccounts[$i]['loginShell'] = '/bin/false'; $partialAccounts[$i]['loginShell'] = '/bin/false';
} }