From 248737d10da26796322c66dfc3285f89aebd8666 Mon Sep 17 00:00:00 2001 From: katagia Date: Sun, 28 Sep 2003 16:00:13 +0000 Subject: [PATCH] upload should now work. Added some help Fixed wrong Warn-message when creating new hosts --- lam/help/help.inc | 6 +++ lam/templates/account/hostedit.php | 12 +---- lam/templates/masscreate.php | 84 +++++++++++++++++++++++++----- 3 files changed, 80 insertions(+), 22 deletions(-) diff --git a/lam/help/help.inc b/lam/help/help.inc index c6edd7a0..9b9fa3c1 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -184,6 +184,10 @@ $helpArray = array ( "Text" => _("Groupname Windows clients will show.")), "421" => array ("ext" => "FALSE", "Headline" => _("Load profile"), "Text" => _("You can select a previous defined profile here. All values which make senso to store in profile are overwritten with the stored values.")), + "422" => array ("ext" => "FALSE", "Headline" => _("Expand suffix with primary groupname"), + "Text" => _("If select users will be added with OUs expanded with their primary group. E.G a user is in group admin, user suffix will be ou=admin,+user suffix.")), + "423" => array ("ext" => "FALSE", "Headline" => _("Group suffix"), + "Text" => _("If a not yet existing group is defined in csv-file, a new group in the selected group suffix will be created.")), "424" => array ("ext" => "FALSE", "Headline" => _("Surname"), "Text" => _("Surname of user. Only letters, - and spaces are allowed.")), "425" => array ("ext" => "FALSE", "Headline" => _("Given name"), @@ -258,6 +262,8 @@ $helpArray = array ( "Text" => _("eMail address")), "457" => array ("ext" => "FALSE", "Headline" => _("Save profile"), "Text" => _("Save profile")), + "458" => array ("ext" => "FALSE", "Headline" => _("Select group profile"), + "Text" => _("If a not yet existing group is defined in csv-file, a new group with the selected group profile will be created.")), "460" => array ("ext" => "FALSE", "Headline" => _("Windows domain"), "Text" => _("Windows domain of host."). ' '. _("Can be left empty.")), "461" => array ("ext" => "FALSE", "Headline" => _("Suffix"), diff --git a/lam/templates/account/hostedit.php b/lam/templates/account/hostedit.php index aa66d61e..6b9a44f8 100644 --- a/lam/templates/account/hostedit.php +++ b/lam/templates/account/hostedit.php @@ -45,15 +45,6 @@ if (isset($_GET['DN'])) { $_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1); $_SESSION['final_changegids'] = ''; } - else { - $_SESSION['account'] = loadHostProfile('default'); - $_SESSION['account'] ->type = 'host'; - $_SESSION['account']->smb_flagsW = 1; - $_SESSION['account']->smb_flagsX = 1; - $_SESSION['account']->general_homedir = '/dev/null'; - $_SESSION['account']->general_shell = '/bin/false'; - if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); - } } else if (count($_POST)==0) { // Startcondition. hostedit.php was called from outside $_SESSION['account'] = loadHostProfile('default'); @@ -88,6 +79,7 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch $_SESSION['account']->general_username = $_SESSION['account']->general_username . '$'; $errors[] = array('WARN', _('Host name'), _('Added $ to hostname.')); } + $tempname = $_SESSION['account']->general_username; // Check if Hostname contains only valid characters if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[$])*$', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Host name'), _('Hostname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); @@ -121,7 +113,7 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch } $_SESSION['account']->general_username = $_SESSION['account']->general_username . "$"; } - if ($_SESSION['account']->general_username != $_POST['f_general_username']) + if ($_SESSION['account']->general_username != $tempname) $errors[] = array('WARN', _('Host name'), _('Hostname already in use. Selected next free hostname.')); // Check if UID is valid. If none value was entered, the next useable value will be inserted diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index 8957e5ef..4f51b766 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -66,6 +66,8 @@ if ($select!='pdf') { if ( isset($_SESSION['accounts'])) unset($_SESSION['accounts']); if ( isset($_SESSION['pointer'])) unset($_SESSION['pointer']); if ( isset($_SESSION['errors'])) unset($_SESSION['errors']); + if ( isset($_SESSION['group_suffix'])) unset($_SESSION['group_suffix']); + if ( isset($_SESSION['group_selectprofile'])) unset($_SESSION['group_selectprofile']); echo ''."\n". ''."\n". '
'."\n". @@ -106,13 +108,53 @@ if ($select!='pdf') { if (getgid($_SESSION['accounts'][$_SESSION['pointer']]->general_group)==-1) { - $group = new account(); + $group = LoadGroupProfile($_SESSION['group_selectprofile']); + + $group->type = 'group'; + // load quotas from profile and check if they are valid + $values = getquotas('group'); + if (isset($group->quota[0])) { // check quotas from profile + $i=0; + // check quota settings + while (isset($group->quota[$i])) { + $found = (-1); + for ($j=0; $jquota); $j++) + if ($values->quota[$j][0]==$group->quota[$i][0]) $found = $j; + if ($found==-1) unset($group->quota[$i]); + else { + $group->quota[$i][1] = $values->quota[$found][1]; + $group->quota[$i][5] = $values->quota[$found][5]; + $group->quota[$i][4] = $values->quota[$found][4]; + $group->quota[$i][8] = $values->quota[$found][8]; + $i++; + } + } + $group->quota = array_values($group->quota); + } + else { // No quotas saved in profile + if (is_object($values)) { + while (list($key, $val) = each($values)) // Set only defined values + if (isset($val)) $group->$key = $val; + } + } + $group->general_username=$_SESSION['accounts'][$_SESSION['pointer']]->general_group; $group->general_uidNumber=checkid($_SESSION['accounts'][$_SESSION['pointer']], 'group'); $group->general_gecos=$_SESSION['accounts'][$_SESSION['pointer']]->general_group; - $group->general_dn=$_SESSION['config']->get_GroupSuffix(); - creategroup($group); + $group->general_dn=$_SESSION['group_suffix']; + $error = creategroup($group); + if ($error==1) { + $_SESSION['pointer']++; + echo ''; + sprintf (_('Created group %s.'), $_SESSION['accounts'][$_SESSION['pointer']]->general_group); + echo ''."\n"; + } + else { + $stay = false; + StatusMessage('ERROR', _('Could not create group!'), sprintf (_('Was unable to create %s.'), $_SESSION['accounts'][$row]->general_group)); + } } + $_SESSION['accounts'][$_SESSION['pointer']]->general_uidNumber = checkid($_SESSION['accounts'][$_SESSION['pointer']], 'user'); $iv = base64_decode($_COOKIE["IV"]); $key = base64_decode($_COOKIE["Key"]); @@ -153,6 +195,8 @@ if ($select!='pdf') { echo ''."\n\n"; if ( isset($_SESSION['pointer'])) unset($_SESSION['pointer']); if ( isset($_SESSION['errors'])) unset($_SESSION['errors']); + if ( isset($_SESSION['group_suffix'])) unset($_SESSION['group_suffix']); + if ( isset($_SESSION['group_selectprofile'])) unset($_SESSION['group_selectprofile']); } break; case 'list': @@ -165,8 +209,8 @@ if ($select!='pdf') { ''; echo _('Please press here if meta-refresh didn\'t work.'); echo "\n"; - echo ''; - echo ''; + $_SESSION['group_suffix'] = $_POST['f_group_suffix']; + $_SESSION['group_selectprofile'] = $_POST['f_selectgroupprofile']; } else { @@ -193,7 +237,6 @@ if ($select!='pdf') { StatusMessage('INFO', _('Group').' '. $_SESSION['accounts'][$i]->general_group.' '._('not found!'), _('It will be created.')); echo "\n"; - //print_r($_SESSION['accounts']); echo "
"; echo _('Confirm List'); echo "\n\n"; @@ -251,6 +294,8 @@ if ($select!='pdf') { if ( isset($_SESSION['accounts'])) unset($_SESSION['accounts']); if ( isset($_SESSION['pointer'])) unset($_SESSION['pointer']); if ( isset($_SESSION['errors'])) unset($_SESSION['errors']); + if ( isset($_SESSION['group_suffix'])) unset($_SESSION['group_suffix']); + if ( isset($_SESSION['group_selectprofile'])) unset($_SESSION['group_selectprofile']); $_SESSION['pointer']=0; echo ''."\n". ''."\n". @@ -310,19 +355,19 @@ if ($select!='pdf') { ''."\n".'\n\n\n\n\n\n'."\n".''."\n".'\n\n\n\n\n\n'."\n". @@ -340,6 +385,8 @@ function loadfile() { $OUs = array(); $handle = fopen($_FILES['userfile']['tmp_name'], 'r'); $profile = loadUserProfile($_POST['f_selectprofile']) ; + $profile->type = 'user'; + $profile->smb_flagsW = 0; // load quotas from profile and check if they are valid $values = getquotas('user'); @@ -367,7 +414,6 @@ function loadfile() { if (isset($val)) $profile->$key = $val; } } - print_r($profile); for ($row=0; $line_array=fgetcsv($handle,2048); $row++) { // loops for every row $iv = base64_decode($_COOKIE["IV"]); @@ -406,6 +452,20 @@ function loadfile() { } } + // check if account allready exists + for ($i=0; $i hello + 456 + $start = strlen($_SESSION['accounts'][$i]->general_username)-1; + while (is_numeric(substr($_SESSION['accounts'][$i]->general_username, $start))) $start--; + // Increse rusultung number + $first = substr($_SESSION['accounts'][$i]->general_username, 0, $start+1); + $second = intval(substr($_SESSION['accounts'][$i]->general_username, $start+1))+1; + $_SESSION['accounts'][$i]->general_username = $first . $second; + } + } + + for ($row2=0; $row2
'."\n"; echo _("Expand suffix with primary groupname"); echo ''; - echo ""; - echo _('Help-XX')."
"; + echo ""; + echo _('Help')."
"; echo _('Group suffix'); echo ''._('Help-XX').''. + echo ''._('Help').''. '
'."\n"; echo _('Select group profile:'); echo ''; - echo ""; - echo _('Help-XX')."
"; + echo ""; + echo _('Help')."
"; echo ''; echo _('Select file:'); echo '