general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1); $_SESSION['final_changegids'] = ''; } } else if (count($_POST)==0) { // Startcondition. groupedit.php was called from outside $_SESSION['account'] = loadGroupProfile('default'); $_SESSION['account'] ->type = 'group'; // load quotas from profile and check if they are valid $values = getquotas('group'); if (isset($_SESSION['account']->quota[0])) { // check quotas from profile $i=0; // check quota settings while (isset($_SESSION['account']->quota[$i])) { $found = (-1); for ($j=0; $jquota); $j++) if ($values->quota[$j][0]==$_SESSION['account']->quota[$i][0]) $found = $j; if ($found==-1) unset($_SESSION['account']->quota[$i]); else { $_SESSION['account']->quota[$i][1] = $values->quota[$found][1]; $_SESSION['account']->quota[$i][5] = $values->quota[$found][5]; $_SESSION['account']->quota[$i][4] = $values->quota[$found][4]; $_SESSION['account']->quota[$i][8] = $values->quota[$found][8]; $i++; } } $_SESSION['account']->quota = array_values($_SESSION['account']->quota); } else { // No quotas saved in profile if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $_SESSION['account']->$key = $val; } } if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); } switch ($_POST['select']) { // Select which part of page should be loaded and check values // general = startpage, general account paramters // samba = page with all samba-related parameters e.g. smbpassword // quota = page with all quota-related parameters e.g. hard file quota // personal = page with all personal-related parametergs, e.g. phone number // final = last page shown before account is created/modified // if account is modified commands might be ran are shown // finish = page shown after account has been created/modified case 'groupmembers': do { // X-Or, only one if() can be true if (isset($_POST['users']) && isset($_POST['add'])) { // Add users to list // Add new user $_SESSION['account']->unix_memberUid = array_merge($_SESSION['account']->unix_memberUid, $_POST['users']); // remove doubles $_SESSION['account']->unix_memberUid = array_flip($_SESSION['account']->unix_memberUid); array_unique($_SESSION['account']->unix_memberUid); $_SESSION['account']->unix_memberUid = array_flip($_SESSION['account']->unix_memberUid); // sort user sort($_SESSION['account']->unix_memberUid); // display groupmembers page break; } if (isset($_POST['members']) && isset($_POST['remove'])) { // remove users fromlist $_SESSION['account']->unix_memberUid = array_delete($_POST['members'], $_SESSION['account']->unix_memberUid); break; } } while(0); $select_local = 'groupmembers'; break; case 'general': // Write all general values into $_SESSION['account'] if no profile should be loaded if (!$_POST['load']) { $_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 // 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.')); } // Create automatic groupaccount with number if original group 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; case 'samba': $samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix()); foreach ($samba3domains as $domain) if ($_POST['f_smb_domain'] == $domain->name) $_SESSION['account']->smb_domain = $domain; $_SESSION['account']->smb_displayName = $_POST['f_smb_displayName']; if ($_SESSION['config']->is_samba3()) switch ($_POST['f_smb_mapgroup']) { case '*'._('Domain Guests'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '514'; break; case '*'._('Domain Users'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '513'; break; case '*'._('Domain Admins'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '512'; break; case $_SESSION['account']->general_username: $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-". (2 * getgid($_SESSION['account']->general_username) + $_SESSION['account']->smb_domain->RIDbase +1); break; } else switch ($_POST['f_smb_mapgroup']) { case '*'._('Domain Guests'): $_SESSION['account']->smb_mapgroup = '514'; break; case '*'._('Domain Users'): $_SESSION['account']->smb_mapgroup = '513'; break; case '*'._('Domain Admins'): $_SESSION['account']->smb_mapgroup = '512'; break; case $_SESSION['account']->general_username: $_SESSION['account']->smb_mapgroup = (2 * getgid($_SESSION['account']->general_username) + 1001); break; } // 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': // Write all general values into $_SESSION['account'] $i=0; while ($_SESSION['account']->quota[$i][0]) { $_SESSION['account']->quota[$i][2] = $_POST['f_quota_'.$i.'_2']; $_SESSION['account']->quota[$i][3] = $_POST['f_quota_'.$i.'_3']; $_SESSION['account']->quota[$i][6] = $_POST['f_quota_'.$i.'_6']; $_SESSION['account']->quota[$i][7] = $_POST['f_quota_'.$i.'_7']; // Check if values are OK and set automatic values. if not error-variable will be set 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++; } break; case 'final': // Write all general values into $_SESSION['account'] if ($_POST['f_final_changegids']) $_SESSION['final_changegids'] = $_POST['f_final_changegids'] ; break; } // Write HTML-Header and part of Table echo $_SESSION['header']; echo ""; echo _("Create new Account"); echo "\n". "\n". "\n". "\n"; do { // X-Or, only one if() can be true if ($_POST['next_members']) { if (!is_array($errors)) $select_local='groupmembers'; else $select_local=$_POST['select']; break; } if ($_POST['next_general']) { if (!is_array($errors)) $select_local='general'; else $select_local=$_POST['select']; break; } if ($_POST['next_samba']) { if (!is_array($errors)) $select_local='samba'; else $select_local=$_POST['select']; break; } if ($_POST['next_quota']) { if (!is_array($errors)) $select_local='quota'; else $select_local=$_POST['select']; break; } if ($_POST['next_final']) { if (!isset($errors)) $select_local='final'; else $select_local=$_POST['select']; break; } if ($_POST['next_reset']) { $_SESSION['account'] = $_SESSION['account_old']; $_SESSION['account']->unix_password=''; $_SESSION['account']->smb_password=''; $_SESSION['account']->smb_flagsW = 0; $_SESSION['account']->general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1); $select_local = $_POST['select']; break; } if ( $_POST['create'] ) { // Create-Button was pressed if ($_SESSION['account_old']) $result = modifygroup($_SESSION['account'],$_SESSION['account_old']); else $result = creategroup($_SESSION['account']); // account.inc if ( $result==1 || $result==3 ) $select_local = 'finish'; else $select_local = 'final'; break; } // Reset variables if recreate-button was pressed if ($_POST['createagain']) { $select_local='general'; unset($_SESSION['account']); $_SESSION['account'] = loadGroupProfile('default'); $_SESSION['account'] ->type = 'group'; break; } if ($_POST['backmain']) { $select_local='backmain'; echo "\n"; break; } if ($_POST['load']) { $_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']; // load profile if ($_POST['f_general_selectprofile']!='') $values = loadGroupProfile($_POST['f_general_selectprofile']); if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $_SESSION['account']->$key = $val; } // load quotas from profile and check if they are valid $values = getquotas('group', $_SESSION['account_old']->general_username); if (isset($_SESSION['account']->quota[0])) { // check quotas from profile $i=0; // check quota settings while (isset($_SESSION['account']->quota[$i])) { $found = (-1); for ($j=0; $jquota); $j++) if ($values->quota[$j][0]==$_SESSION['account']->quota[$i][0]) $found = $j; if ($found==-1) unset($_SESSION['account']->quota[$i]); else { $_SESSION['account']->quota[$i][1] = $values->quota[$found][1]; $_SESSION['account']->quota[$i][5] = $values->quota[$found][5]; $_SESSION['account']->quota[$i][4] = $values->quota[$found][4]; $_SESSION['account']->quota[$i][8] = $values->quota[$found][8]; $i++; } } $_SESSION['account']->quota = array_values($_SESSION['account']->quota); } else { // No quotas saved in profile if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $_SESSION['account']->$key = $val; } } // select general page after group has been loaded $select_local='general'; break; } if ($_POST['save']) { // save profile saveGroupProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); // select last page displayed before user is created $select_local='final'; break; } if ($_POST['groupmembers']) { $select_local='groupmembers'; break; } // Set selected page to general if no page was defined. should only true if groupedit.php wasn't called by itself if (!$select_local) $select_local='general'; } while(0); echo "\n"; echo "
\n"; if (is_array($errors)) { echo "\n"; for ($i=0; $i"; } // print_r($_SESSION['account']); switch ($select_local) { // Select which part of page will be loaded // general = startpage, general account paramters // unix = page with all shadow-options and password // samba = page with all samba-related parameters e.g. smbpassword // quota = page with all quota-related parameters e.g. hard file quota // personal = page with all personal-related parametergs, e.g. phone number // final = last page shown before account is created/modified // if account is modified commands might be ran are shown // finish = page shown after account has been created/modified case 'groupmembers': ldapreload('user'); echo "\n"; echo "
\n\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($_SESSION['config']->is_samba3()) { echo "\n
"; } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($_SESSION['account_old'])) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "
". _('Additional group members') . "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n\n
"; echo _('Group members'); echo ""; if (count($_SESSION['account']->unix_memberUid)!=0) { echo "\n"; } echo "
"; echo " "; echo "\">

"; echo ""._('Help')."
"; echo _('Available users'); echo "\n"; if (count($_SESSION['userDN'])!=0) { echo "\n"; } echo "
\n
\n
\n"; break; case 'general': // General Account Settings // load list of profiles $profilelist = getGroupProfiles(); // Show page info echo "\n"; echo "\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($_SESSION['config']->is_samba3()) { echo "\n
"; } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($_SESSION['account_old'])) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "\n\n\n
"; echo "
"; echo _("General properties"); echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n". "\n\n\n\n\n\n\n
"; echo _("Groupname")."*"; echo "". "general_username."\">". ""._('Help')."
"; echo _('GID number'); echo "general_uidNumber."\">". ""._('Help'). "
"; echo _('Description'); echo "general_gecos."\">"._('Help')."
"; echo _('Suffix'); echo ""._('Help'). "
"; echo _('Values with * are required'); echo "
\n
"; if (count($profilelist)!=0) { echo "
"; echo _("Load profile"); echo "\n\n\n\n\n
"; echo "\n". ""; echo _('Help')."
\n
\n"; } echo "
\n
\n"; break; case 'samba': // Samba Settings $samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix()); echo "\n"; echo "\n\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; echo "\n
"; echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($_SESSION['account_old'])) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "
"._('Samba properties')."\n"; echo "\n\n\n\n\n\n\n'."\n".''."\n".''."\n"; echo "
"; echo _("Display name"); echo "". "smb_displayName."\">". ""._('Help')."
"; echo _('Windows groupname'); echo "". ''._('Help').''. '
'; echo _('Domain'); echo ''._('Help').'
\n
\n
\n"; break; case 'quota': // Quota Settings if (!isset($_SESSION['account']->quota[0]) ) { // load quotas $values = getquotas('group', $_SESSION['account']->general_username); if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $_SESSION['account']->$key = $val; } if (is_object($values) && isset($_SESSION['account_old'])) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $_SESSION['account_old']->$key = $val; } } echo "\n"; echo "\n\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($_SESSION['config']->is_samba3()) { echo "\n
"; } echo "\n
"; echo ""; if (isset($_SESSION['account_old'])) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo ''; echo "
"._('Quota properties')."\n"; echo "'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; echo ''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; $i=0; while ($_SESSION['account']->quota[$i][0]) { echo ''; // used blocks echo ''; // blocks soft limit echo ''; // blocks hard limit echo ''; // block grace period echo ''; // used inodes echo ''; // inodes soft limit echo ''; // inodes hard limit echo ''; // inodes grace period $i++; } echo "
"; echo _('Mountpoint'); echo ''; echo _('Used blocks'); echo ''; echo _('Soft block limit'); echo ''; echo _('Hard block limit'); echo ''; echo _('Grace block period'); echo ''; echo _('Used inodes'); echo ''; echo _('Soft inode limit'); echo ''; echo _('Hard inode limit'); echo ''; echo _('Grace inode period'); echo '
'._('Help').''._('Help').''. ''._('Help').''._('Help').''. ''._('Help').''._('Help').''. ''._('Help').''._('Help').''. ''._('Help').'
'.$_SESSION['account']->quota[$i][0].''.$_SESSION['account']->quota[$i][1].''.$_SESSION['account']->quota[$i][4].''.$_SESSION['account']->quota[$i][5].''.$_SESSION['account']->quota[$i][8].'
\n
\n
\n"; break; case 'final': // Final Settings $disabled = ""; if ($_SESSION['config']->is_samba3()) { if (!isset($_SESSION['account']->smb_domain)) { // Samba page nit viewd; can not create group because if missing options $disabled = "disabled"; } } echo ''; echo "\n"; echo "\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($_SESSION['config']->is_samba3()) { echo "\n
"; } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($_SESSION['account_old'])) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "\n\n\n
"; echo "
"; echo _("Save profile"); echo "\n\n\n\n\n
"; echo ''; echo "'._('Help'); echo "
\n
\n
\n"; echo "
"; if ($_SESSION['account_old']) echo _('Modify'); else echo _('Create'); echo "\n"; echo ""; if (($_SESSION['account_old']) && ($_SESSION['account']->general_uidNumber != $_SESSION['account_old']->general_uidNumber)) { echo ''; StatusMessage ('INFO', _('GID-number has changed. You have to run the following command as root in order to change existing file-permissions:'), 'find / -gid ' . $_SESSION['account_old' ]->general_uidNumber . ' -exec chgrp ' . $_SESSION['account']->general_uidNumber . ' {} \;'); echo ''."\n"; echo ''."\n"; } if ($disabled == "disabled") { // Samba page nit viewd; can not create group because if missing options echo ""; StatusMessage("ERROR", _("Samba Options not set!"), _("Please check settings on samba page.")); echo ""; } if (isset($_SESSION['account_old']->general_objectClass)) { if (($_SESSION['config']->is_samba3()) && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) { echo ''; StatusMessage('WARN', _('ObjectClass sambaGroupMapping not found.'), _('Have to add objectClass sambaGroupMapping.')); echo "\n"; } if (!in_array('posixGroup', $_SESSION['account_old']->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass posixGroup not found.'), _('Have to add objectClass posixGroup.')); echo "\n"; } } echo "
'; echo ''; echo _('Change GID-Number of all users in group to new value'); echo '
'."\n"; echo "
\n
\n
"; break; case 'finish': // Final Settings if (($_SESSION['config']->samba3 =='yes') && !isset($_SESSION['Account']->smb_mapgroup)) $disabled = 'disabled'; else $disabled = ''; echo ''; echo "
"._('Success')."\n"; echo ""; echo ''."\n".'
'; echo _('Group').' '; echo $_SESSION['account']->general_username; if ($_SESSION['account_old']) echo ' '._('has been modified').'.'; else echo ' '._('has been created').'.'; echo '
'; if (!$_SESSION['account_old']) { echo' '; } echo ''. ''. '
'; echo _('Please press here if meta-refresh didn\'t work.'); echo "\n"; if (isset($_SESSION['shelllist'])) unset($_SESSION['shelllist']); if (isset($_SESSION['account'])) unset($_SESSION['account']); if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); break; } // Print end of HTML-Page echo ''; ?>