0)) $select = 'list'; if ($_POST['back']) $select = 'main'; if ($_POST['cancel']) $select = 'cancel'; if ($_POST['create']) $select = 'create'; if ($_POST['pdf']) createpdf($_SESSION['accounts']); if (!$select) $select='main'; // Write HTML-Header and part of Table echo ''; echo _('Create new Accounts'); echo '
'; echo ''; switch ($select) { case 'main': if ( session_is_registered("accounts")) session_unregister("accounts"); session_register("accounts"); $profilelist = getUserProfiles(); echo ''; echo ''; break; case 'list': if (!is_array($accounts)) $accounts = array(); $handle = fopen($_FILES['userfile']['tmp_name'], 'r'); $error=false; $groups = array(); echo ''; for ($row=0; $line_array=fgetcsv($handle,2048); $row++) { // loops for every row $_SESSION['accounts'][$row] = loadUserProfile($_POST['f_selectprofile']) ; if ($line_array[0]) $_SESSION['accounts'][$row]->general_surname = $line_array[0]; if ($line_array[1]) $_SESSION['accounts'][$row]->general_givenname = $line_array[1]; if ($line_array[2]) $_SESSION['accounts'][$row]->general_username = $line_array[2]; if ($line_array[3]) $_SESSION['accounts'][$row]->general_group = $line_array[3]; if ($line_array[4]) $_SESSION['accounts'][$row]->personal_title = $line_array[4]; if ($line_array[5]) $_SESSION['accounts'][$row]->personal_mail = $line_array[5]; if ($line_array[6]) $_SESSION['accounts'][$row]->personal_telephoneNumber = $line_array[6]; if ($line_array[7]) $_SESSION['accounts'][$row]->personal_mobileTelephoneNumber = $line_array[7]; if ($line_array[8]) $_SESSION['accounts'][$row]->personal_facsimileTelephoneNumber = $line_array[8]; if ($line_array[9]) $_SESSION['accounts'][$row]->personal_street = $line_array[9]; if ($line_array[10]) $_SESSION['accounts'][$row]->personal_postalCode = $line_array[10]; if ($line_array[11]) $_SESSION['accounts'][$row]->personal_postalAddress = $line_array[11]; if ($line_array[12]) $_SESSION['accounts'][$row]->personal_employeeType = $line_array[12]; $_SESSION['accounts'][$row]->unix_password=genpasswd(); $_SESSION['accounts'][$row]->smb_password=genpasswd(); $values = checkglobal($_SESSION['accounts'][$row], 'user'); // account.inc if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['accounts'][$row]->$key = $val; } else $error = $values; if (!$error) { $values = checkpersonal($_SESSION['accounts'][$row], 'user'); // account.inc if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['accounts'][$row]->$key = $val; } else $error = $values; } if (!$error) { $values = checksamba($_SESSION['accounts'][$row], 'user'); // account.inc if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['accounts'][$row]->$key = $val; } else $error = $values; $values = checkquota($_SESSION['accounts'][$row], 'user'); // account.inc } if (!$error) { if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['accounts'][$row]->$key = $val; } else $error = $values; } if ($error) StatusMessage('ERROR', _('Invalid Value in row ').$row.'!', $error); if ((getgid($_SESSION['accounts'][$row]->general_group)==-1) && (!in_array($_SESSION['accounts'][$row]->general_group, $groups))) $groups[] = $_SESSION['accounts'][$row]->general_group; } for ($i=0; $igeneral_group._(' not found!'), _('It will be created.')); fclose($handle); unlink($_FILES['userfile']['tmp_name']); echo ''; for ($row=0; $row'; } echo '
'; echo _('Mass Creation'); echo '
'; echo _('Please provide a csv-file with the following syntax. Values with * are required:'); echo '
'; echo _('Surname*,Givenname*,Username*,PrimaryGroup,Title,Mail,telephonenumber,'); echo '
'; echo _('mobileTelephoneNumber,facsimileNumber,street,postalCode,postalAddress,'); echo '
'; echo _('employeeType. If PrimaryGroup is not given it\'ll used from profile.'); echo '
'; echo _('If PrimaryGroup doesn\'t exist it will be created.'); echo '
'; echo _('Select Profile:'); echo ''; echo '
'; echo _('Select file:'); echo '
'; echo '
'; echo _('Confirm List'); echo '
'._('row').''. _('Surname'). ''. _('Givenname'). ''. _('Username'). ''. _('Primary Group'). ''. _('Title'). ''. _('Mail Address'). ''. _('Telephonenumber'). ''. _('Mobiletelephonenumber') . ''. _('Facsimiletelephonenumber'). ''. _('Street'). ''. _('Postal Code') . ''. _('Postal Address'). ''. _('Employee Type') .'
'.$row.''. $_SESSION['accounts'][$row]->general_surname.''. $_SESSION['accounts'][$row]->general_givenname.''. $_SESSION['accounts'][$row]->general_username.''. $_SESSION['accounts'][$row]->general_group.''. $_SESSION['accounts'][$row]->personal_title.''. $_SESSION['accounts'][$row]->personal_mail.''. $_SESSION['accounts'][$row]->personal_telephoneNumber.''. $_SESSION['accounts'][$row]->personal_mobileTelephoneNumber.''. $_SESSION['accounts'][$row]->personal_facsimileTelephoneNumber.''. $_SESSION['accounts'][$row]->personal_street.''. $_SESSION['accounts'][$row]->personal_postalCode.''. $_SESSION['accounts'][$row]->personal_postalAddress.''. $_SESSION['accounts'][$row]->personal_employeeType.'
'; echo ''; echo ''; break; case 'cancel': if ( session_is_registered("accounts")) session_unregister("accounts"); echo ''; break; case 'create': $row=0; $stay=true; while (($row < sizeof($_SESSION['accounts'])) && $stay) { if (getgid($_SESSION['accounts'][$row]->general_group)==-1) { $group = new account(); $group->general_username=$_SESSION['accounts'][$row]->general_group; $group->general_uidNumber=checkid($_SESSION['accounts'][$row], 'group'); $group->general_gecos=$_SESSION['accounts'][$row]->general_group; creategroup($group); } $error = createuser($_SESSION['accounts'][$row]); if ($error==1) $row++; else { $stay = false; StatusMessage('ERROR', _('Could not create user'), _('Was unable to create ').$_SESSION['accounts'][$row]->general_username); } } if (!$stay) { echo '
'; } else { echo '
'; echo _('All Users have been created'); echo '
'; echo '
'; echo ''; } break; } echo ''; ?>