From 6b9aa444de2de2681106dad1173d67676c60877e Mon Sep 17 00:00:00 2001 From: katagia Date: Wed, 17 Sep 2003 12:20:38 +0000 Subject: [PATCH] Fixed some issues when converting nonsamba group. Added missing help entries. Checked compatbility with samba 2.2 schemas. --- lam/help/help.inc | 4 + lam/templates/account/groupedit.php | 130 ++++++++++++++++++++-------- 2 files changed, 97 insertions(+), 37 deletions(-) diff --git a/lam/help/help.inc b/lam/help/help.inc index 208b63b3..20a83785 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -166,6 +166,10 @@ $helpArray = array ( "Text" => _("Number of days a user has to wait until he\'s allowed to change his password again. If set value must be 0<."). ' '. _("Can be left empty.")), "418" => array ("ext" => "FALSE", "Headline" => _("Expire date"), "Text" => _("Account expire date. If an account is expired login is only possible if password expire is set. Format: DD-MM-YYYY")), + "419" => array ("ext" => "FALSE", "Headline" => _("Group members"), + "Text" => _("Users wich are also members of group.")), + "420" => array ("ext" => "FALSE", "Headline" => _("Display name"), + "Text" => _("Groupname Windows clients will show.")), "424" => array ("ext" => "FALSE", "Headline" => _("Surname"), "Text" => _("Surname of user. Only letters, - and spaces are allowed.")), "425" => array ("ext" => "FALSE", "Headline" => _("Given name"), diff --git a/lam/templates/account/groupedit.php b/lam/templates/account/groupedit.php index 4725a195..f54e14c6 100644 --- a/lam/templates/account/groupedit.php +++ b/lam/templates/account/groupedit.php @@ -46,6 +46,7 @@ if (isset($_GET['DN'])) { $_SESSION['account'] = loadGroupProfile('default'); $_SESSION['account'] ->type = 'group'; if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); + $_SESSION['account_old'] = false; } $values = getquotas($type); if (is_object($values)) { @@ -57,6 +58,7 @@ else if (count($_POST)==0) { // Startcondition. groupedit.php was called from ou $_SESSION['account'] = loadGroupProfile('default'); $_SESSION['account'] ->type = 'group'; if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); + $_SESSION['account_old'] = false; } switch ($_POST['select']) { // Select which part of page should be loaded and check values @@ -87,7 +89,6 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch $select_local = 'groupmembers'; break; } - $select_local = 'groupmembers'; } while(0); break; @@ -105,20 +106,58 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch (2 * $_POST['f_general_uidNumber'] + $_SESSION['account']->smb_domain->RIDbase +1); } } - $_SESSION['account']->general_dn = $_POST['f_general_suffix']; $_SESSION['account']->general_username = $_POST['f_general_username']; $_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber']; $_SESSION['account']->general_gecos = $_POST['f_general_gecos']; + // Check if values are OK and set automatic values. if not error-variable will be set - if (isset($_SESSION['account_old'])) list($values, $errors) = checkglobal($_SESSION['account'], 'group', $_SESSION['account_old']); // account.inc - else list($values, $errors) = checkglobal($_SESSION['account'], 'group'); // account.inc - if (is_object($values)) { // Set only defined values - while (list($key, $val) = each($values)) - if (isset($val)) $_SESSION['account']->$key = $val; + + // Check if Groupname contains only valid characters + if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_SESSION['account']->general_username)) + $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); + if ($_SESSION['account']->general_gecos=='') { + $_SESSION['account']->general_gecos = $_SESSION['account']->general_username ; + $errors[] = array('INFO', _('Gecos'), _('Inserted groupname in gecos-field.')); } - // Check which part Site should be displayed next - $select_local = 'general'; + // Create automatic groupaccount with number if original user already exists + // Reset name to original name if new name is in use + if (ldapexists($_SESSION['account'], 'group', $_SESSION['account_old']) && is_object($_SESSION['account_old'])) + $_SESSION['account']->general_username = $_SESSION['account_old']->general_username; + while ($temp = ldapexists($_SESSION['account'], 'group', $_SESSION['account_old'])) { + // get last character of username + $lastchar = substr($_SESSION['account']->general_username, strlen($_SESSION['account']->general_username)-1, 1); + // Last character is no number + if ( !ereg('^([0-9])+$', $lastchar)) + $_SESSION['account']->general_username = $_SESSION['account']->general_username . '2'; + else { + $i=strlen($_SESSION['account']->general_username)-1; + $mark = false; + while (!$mark) { + if (ereg('^([0-9])+$',substr($_SESSION['account']->general_username, $i, strlen($_SESSION['account']->general_username)-$i))) $i--; + else $mark=true; + } + // increase last number with one + $firstchars = substr($_SESSION['account']->general_username, 0, $i+1); + $lastchars = substr($_SESSION['account']->general_username, $i+1, strlen($_SESSION['account']->general_username)-$i); + $_SESSION['account']->general_username = $firstchars . (intval($lastchars)+1); + } + } + if ($_SESSION['account']->general_username != $_POST['f_general_username']) $errors[] = array('WARN', _('Groupname'), _('Groupname already in use. Selected next free groupname.')); + + // Check if UID is valid. If none value was entered, the next useable value will be inserted + $_SESSION['account']->general_uidNumber = checkid($_SESSION['account'], 'group', $_SESSION['account_old']); + if (is_string($_SESSION['account']->general_uidNumber)) { // true if checkid has returned an error + $errors[] = array('ERROR', _('ID-Number'), $_SESSION['account']->general_uidNumber); + unset($return->general_uidNumber); + } + + // Check if Name-length is OK. minLength=3, maxLength=20 + if ( !ereg('.{3,20}', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.')); + // Check if Name starts with letter + if ( !ereg('^([a-z]|[A-Z]).*$', $_SESSION['account']->general_username)) + $errors[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter')); + } break; @@ -137,12 +176,12 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch (2 * getgid($_SESSION['account']->general_username) + $_SESSION['account']->smb_domain->RIDbase +1); break; } - if (isset($_SESSION['account_old'])) list($values, $errors) = checksamba($_SESSION['account'], 'group', $_SESSION['account_old']); // account.inc - else list($values, $errors) = checksamba($_SESSION['account'], 'group'); // account.inc - if (is_object($values)) { // Set only defined values - while (list($key, $val) = each($values)) - if (isset($val)) $_SESSION['account']->$key = $val; + // Check if value is set + if (($_SESSION['account']->smb_displayName=='') && isset($_SESSION['account']->general_gecos)) { + $_SESSION['account']->smb_displayName = $_SESSION['account']->general_gecos; + $errors[] = array('INFO', _('Display name'), _('Inserted gecos-field as display name.')); } + break; case 'quota': @@ -157,19 +196,24 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch } // Check if values are OK and set automatic values. if not error-variable will be set - list($values, $errors) = checkquota($_SESSION['account'], $_SESSION['account']->type); // account.inc - if (is_object($values)) { - while (list($key, $val) = each($values)) // Set only defined values - if (isset($val)) $_SESSION['account']->$key = $val; + $i=0; + while ($_SESSION['account']->quota[$i][0]) { + if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][2])) + $errors[] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed')); + if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][3])) + $errors[] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed')); + if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][6])) + $errors[] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed')); + if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][7])) + $errors[] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed')); + $i++; } - // Check which part Site should be displayed next break; case 'final': // Write all general values into $_SESSION['account'] if ($_POST['f_final_changegids']) $_SESSION['final_changegids'] = $_POST['f_final_changegids'] ; - // Check which part Site should be displayed next break; } @@ -284,8 +328,9 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->samba3 == 'yes') + if ($_SESSION['config']->samba3 == 'yes') { echo "\n
"; + } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n"; echo "
"; echo _('Group members'); - echo "
\n"; + echo ""; + if (count($_SESSION['account']->unix_memberUid)!=0) { + echo "\n"; + } + echo "\n"; echo ""; echo " "; echo "\">

"; - echo ""._('Help-XX')."\n"; + echo ""._('Help')."\n"; echo "
"; echo _('Available users'); - echo "
\n\n\n\n\n\n"; + echo "\n"; + if (count($_SESSION['userDN'])!=0) { + echo "\n"; + } + echo "\n\n\n\n\n\n"; break; case 'general': @@ -324,8 +377,9 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->samba3 == 'yes') + if ($_SESSION['config']->samba3 == 'yes') { echo "\n
"; + } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "\n". "smb_displayName."\">". - "\n"._('Help-XX')."\n\n\n"; + "\n"._('Help')."\n\n\n"; echo _('Windows groupname'); echo "\n\n
"; echo "\n
"; - if ($_SESSION['config']->samba3 == 'yes') + if ($_SESSION['config']->samba3 == 'yes') { echo "\n
"; + } echo "\n
"; echo "\n"; @@ -500,8 +555,9 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n"; echo "\n
"; echo "\n
"; - if ($_SESSION['config']->samba3 == 'yes') + if ($_SESSION['config']->samba3 == 'yes') { echo "\n
"; + } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo "'."\n"; } $disabled = ""; - if (!isset($_SESSION['account']->smb_domain)) { // Samba page nit viewd; can not create group because if missing options + if ((!isset($_SESSION['account']->smb_domain)) && ($_SESSION['config']->samba3 == 'yes')) { // Samba page nit viewd; can not create group because if missing options $disabled = "disabled"; echo ""; StatusMessage("ERROR", _("Samba Options not set!"), _("Please check settings on samba page."));