fixed smaller bugs realted to new design f groupedit.php

This commit is contained in:
katagia 2003-09-12 07:16:23 +00:00
parent 2cb8eb5487
commit fd6f511e7a
2 changed files with 27 additions and 11 deletions

View File

@ -181,6 +181,7 @@ function array_delete($values, $array) { // This function will return all values
function checkglobal($values, $type, $values_old=false) { // This functions checks all global account parameters $values is class account(), $type=user|host|group function checkglobal($values, $type, $values_old=false) { // This functions checks all global account parameters $values is class account(), $type=user|host|group
// If all values are OK an array of class account is returned. Else an error-string is returned // If all values are OK an array of class account is returned. Else an error-string is returned
$return = new account(); $return = new account();
$return->general_dn = $values->general_dn;
switch ($type) { switch ($type) {
case 'user' : case 'user' :
// Check if Homedir is valid // Check if Homedir is valid
@ -662,12 +663,13 @@ function ldapexists($values, $type, $values_old=false) { // This function will s
$keys = array_keys($_SESSION['groupDN']); $keys = array_keys($_SESSION['groupDN']);
unset ($keys[0]); unset ($keys[0]);
$keys = array_values($keys); $keys = array_values($keys);
if ( ($values_old->general_username != $values->general_username) && if (in_array($search , $keys)) print "hit";
if ( ($values_old->general_username != $values->general_username) &&
($_SESSION['groupDN'][0] != $values->general_username) && ($_SESSION['groupDN'][0] != $values->general_username) &&
(in_array($search , $keys)) ) return sprintf (_('%s already exists!'), $type); (in_array($search , $keys)) ) return sprintf (_('%s already exists!'), $type);
if ((!$values_old) && if ((!$values_old) &&
($_SESSION['groupDN'][0] != $values->general_username) && ($_SESSION['groupDN'][0] != $values->general_username) &&
(in_array($search , $keys))) return sprintf (_('%s already exists!'), $type); (in_array($search , $keys)) ) return sprintf (_('%s already exists!'), $type);
break; break;
case 'host': case 'host':
ldapreload('host'); ldapreload('host');
@ -715,6 +717,7 @@ function getgid($groupname) { // Will return the the gid to an existing Groupnam
function checkid($values, $type, $values_old=false) { // if value is empty will return an unused id from all ids found in LDAP else check existing value function checkid($values, $type, $values_old=false) { // if value is empty will return an unused id from all ids found in LDAP else check existing value
switch ($type) { switch ($type) {
case 'user': case 'user':
ldapreload('user');
$minID = intval($_SESSION['config']->get_minUID()); $minID = intval($_SESSION['config']->get_minUID());
$maxID = intval($_SESSION['config']->get_maxUID()); $maxID = intval($_SESSION['config']->get_maxUID());
$suffix = $_SESSION['config']->get_UserSuffix(); $suffix = $_SESSION['config']->get_UserSuffix();
@ -725,6 +728,7 @@ function checkid($values, $type, $values_old=false) { // if value is empty will
// $ids[] = $_SESSION['userDN'][$key]['uidNumber']; // $ids[] = $_SESSION['userDN'][$key]['uidNumber'];
break; break;
case 'group': case 'group':
ldapreload('group');
$minID = intval($_SESSION['config']->get_MinGID()); $minID = intval($_SESSION['config']->get_MinGID());
$maxID = intval($_SESSION['config']->get_MaxGID()); $maxID = intval($_SESSION['config']->get_MaxGID());
$suffix = $_SESSION['config']->get_GroupSuffix(); $suffix = $_SESSION['config']->get_GroupSuffix();
@ -735,6 +739,7 @@ function checkid($values, $type, $values_old=false) { // if value is empty will
// $ids[] = $_SESSION['groupDN'][$key]['gidNumber']; // $ids[] = $_SESSION['groupDN'][$key]['gidNumber'];
break; break;
case 'host': case 'host':
ldapreload('host');
$minID = intval($_SESSION['config']->get_MinMachine()); $minID = intval($_SESSION['config']->get_MinMachine());
$maxID = intval($_SESSION['config']->get_MaxMachine()); $maxID = intval($_SESSION['config']->get_MaxMachine());
$suffix = $_SESSION['config']->get_HostSuffix(); $suffix = $_SESSION['config']->get_HostSuffix();
@ -746,7 +751,7 @@ function checkid($values, $type, $values_old=false) { // if value is empty will
break; break;
} }
if ($values->general_uidNumber=='') { if ($values->general_uidNumber=='') {
if (!isset($values_old)) { if (!isset($values_old->general_uidNumber)) {
if ($keys) { if ($keys) {
$id = 0; $id = 0;
foreach ($keys as $key) foreach ($keys as $key)

View File

@ -42,8 +42,11 @@ if (isset($_GET['DN'])) {
$_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1); $_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1);
$_SESSION['final_changegids'] = ''; $_SESSION['final_changegids'] = '';
} }
else $_SESSION['account'] = loadGroupProfile('default'); else {
$_SESSION['account'] = loadGroupProfile('default');
if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']);
}
$_SESSION['account'] ->type = 'group';
$values = getquotas($type); $values = getquotas($type);
if (is_object($values)) { if (is_object($values)) {
while (list($key, $val) = each($values)) // Set only defined values while (list($key, $val) = each($values)) // Set only defined values
@ -91,10 +94,9 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch
$_SESSION['account']->general_username = $_POST['f_general_username']; $_SESSION['account']->general_username = $_POST['f_general_username'];
$_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber']; $_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber'];
$_SESSION['account']->general_gecos = $_POST['f_general_gecos']; $_SESSION['account']->general_gecos = $_POST['f_general_gecos'];
// Check if values are OK and set automatic values. if not error-variable will be set // 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'], $_SESSION['account']->type, $_SESSION['account_old']); // account.inc if (isset($_SESSION['account_old'])) list($values, $errors) = checkglobal($_SESSION['account'], 'group', $_SESSION['account_old']); // account.inc
else list($values, $errors) = checkglobal($_SESSION['account'], $_SESSION['account']->type); // account.inc else list($values, $errors) = checkglobal($_SESSION['account'], 'group'); // account.inc
if (is_object($values)) { // Set only defined values if (is_object($values)) { // Set only defined values
while (list($key, $val) = each($values)) while (list($key, $val) = each($values))
if (isset($val)) $_SESSION['account']->$key = $val; if (isset($val)) $_SESSION['account']->$key = $val;
@ -227,6 +229,7 @@ do { // X-Or, only one if() can be true
echo "</head><body>\n"; echo "</head><body>\n";
echo "<form action=\"groupedit.php\" method=\"post\">\n"; echo "<form action=\"groupedit.php\" method=\"post\">\n";
if (is_array($errors)) { if (is_array($errors)) {
echo "<table class=\"account\" width=\"100%\">\n"; echo "<table class=\"account\" width=\"100%\">\n";
for ($i=0; $i<sizeof($errors); $i++) StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]); for ($i=0; $i<sizeof($errors); $i++) StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
@ -259,7 +262,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo "\"></fieldset></td>\n<td>"; echo "\"></fieldset></td>\n<td>";
echo "<fieldset><legend><b>". _('Additional group members') . "</b></legend>\n"; echo "<fieldset><legend><b>". _('Additional group members') . "</b></legend>\n";
echo "<table border=0 width=\"100%\">\n"; echo "<table border=0 width=\"100%\">\n";
echo "<tr><td><fieldset><legend>"; echo "<tr><td valign=\"top\"><fieldset><legend>";
echo _('Group members'); echo _('Group members');
echo "</legend><select name=\"members[]\" size=15 multiple>\n"; echo "</legend><select name=\"members[]\" size=15 multiple>\n";
for ($i=0; $i<count($_SESSION['account']->unix_memberUid); $i++) for ($i=0; $i<count($_SESSION['account']->unix_memberUid); $i++)
@ -269,7 +272,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo " "; echo " ";
echo "<input type=\"submit\" name=\"remove\" value=\"=>\"><br><br>"; echo "<input type=\"submit\" name=\"remove\" value=\"=>\"><br><br>";
echo "<a href=\"help.php?HelpNumber=XXX\" target=\"lamhelp\">"._('Help-XX')."</a></td>\n"; echo "<a href=\"help.php?HelpNumber=XXX\" target=\"lamhelp\">"._('Help-XX')."</a></td>\n";
echo "<td><fieldset><legend>"; echo "<td valign=\"top\"><fieldset><legend>";
echo _('Available users'); echo _('Available users');
echo "</legend><select name=\"users[]\" size=15 multiple>\n"; echo "</legend><select name=\"users[]\" size=15 multiple>\n";
foreach ($_SESSION['userDN'] as $temp) foreach ($_SESSION['userDN'] as $temp)
@ -284,6 +287,7 @@ switch ($select_local) { // Select which part of page will be loaded
// load list of profiles // load list of profiles
$profilelist = getGroupProfiles(); $profilelist = getGroupProfiles();
// Show page info // Show page info
echo "<input name=\"select\" type=\"hidden\" value=\"general\">\n";
echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >"; echo "<table border=0 width=\"100%\">\n<tr><td valign=\"top\" width=\"15%\" >";
echo "<br><fieldset><legend>"; echo "<br><fieldset><legend>";
echo _('Please select page:'); echo _('Please select page:');
@ -481,6 +485,13 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Change GID-Number of all users in group to new value'); echo _('Change GID-Number of all users in group to new value');
echo '</td></tr>'."\n"; echo '</td></tr>'."\n";
} }
$disabled = "";
if (!isset($_SESSION['account']->smb_mapgroup)) { // Samba page nit viewd; can not create group because if missing options
$disabled = "disabled";
echo "<tr>";
StatusMessage("ERROR", _("Samba Options not set!"), _("Please check settings on samba page."));
echo "</tr>";
}
if (isset($_SESSION['account_old']->general_objectClass)) { if (isset($_SESSION['account_old']->general_objectClass)) {
if (($_SESSION['config']->samba3 == 'yes') && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) { if (($_SESSION['config']->samba3 == 'yes') && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) {
echo '<tr>'; echo '<tr>';
@ -501,7 +512,7 @@ switch ($select_local) { // Select which part of page will be loaded
echo _('Save profile'); echo _('Save profile');
echo '"><a href="help.php?HelpNumber=457" target="lamhelp">'._('Help').'</a>'. echo '"><a href="help.php?HelpNumber=457" target="lamhelp">'._('Help').'</a>'.
'</td>'."\n".'<td>'. '</td>'."\n".'<td>'.
'<input name="create" type="submit" value="'; "<input name=\"create\" type=\"submit\" $disabled value=\"";
if ($_SESSION['account_old']) echo _('Modify Account'); if ($_SESSION['account_old']) echo _('Modify Account');
else echo _('Create Account'); else echo _('Create Account');
echo '">'. echo '">'.