haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); $friendly_attrs = process_friendly_attr_table(); // @todo might not need this. $pjs = array(); # REMOVE THSE @todo $today = date('U'); $shadow_before_today_attrs = arrayLower(array('shadowLastChange','shadowMin')); $shadow_after_today_attrs = arrayLower(array('shadowMax','shadowExpire','shadowWarning','shadowInactive')); $shadow_format_attrs = array_merge($shadow_before_today_attrs,$shadow_after_today_attrs); # END REMOVE # If we have a DN, then this is to edit the entry. if (isset($_REQUEST['dn'])) { $dn = $_GET['dn']; $decoded_dn = rawurldecode($dn); $encoded_dn = rawurlencode($decoded_dn); if (! $ldapserver->haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); $ldapserver->dnExists($dn) or pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn))); $rdn = get_rdn($dn); $attrs = $ldapserver->getDNAttrs($dn,false,$config->GetValue('deref','view')); $modified_attrs = isset($_REQUEST['modified_attrs']) ? $_REQUEST['modified_attrs'] : false; $show_internal_attrs = isset($_REQUEST['show_internal_attrs']) ? true : false; # If an entry has more children than this, stop searching and display this amount with a '+' $max_children = 100; } else { $dn = ''; $rdn = ''; $encoded_dn = ''; if ($_REQUEST['template'] == 'custom') { include TMPLDIR.'template_header.php'; require TMPLDIR.'creation/custom.php'; die(); } else { $templates = new Templates($ldapserver->server_id); $template = $templates->getCreationTemplate($_REQUEST['template']); } } include TMPLDIR.'template_header.php'; /* * When we get here, (either a new entry, or modifying an existing entry), if the * empty_attrs array has content, then we need to ask the user for this information. */ if (isset($template['empty_attrs'])) { masort($template['empty_attrs'],'page,order',1); # What page are we working on. $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; printf('

%s

',$template['description']); echo "\n\n"; if (isset($_REQUEST['nextpage']) && ! $_REQUEST['nextpage']) { /* * destinationcontainer is an otherride of dn. * needed for such "actions" other than create.php */ if (!isset($template['destinationcontainer'])) $new_dn = sprintf('%s=%s,%s',$template['rdn'],$_REQUEST['form'][$template['rdn']],$_REQUEST['container']); else $new_dn = sprintf('%s',$template['destinationcontainer']); /* * default action is create.php * you can change this behavior by setting myscript.php in template header */ if (!isset($template['action'])) echo '
'; else printf ('',rawurlencode($template['action'])); printf('',htmlspecialchars($new_dn)); } else { echo ''; } if (isset($_REQUEST['form'])) { foreach ($_REQUEST['form'] as $attr => $value) { # Check for any with post actions. if (isset($template['attribute'][$attr]['post']) && $_REQUEST['page'] == $template['attribute'][$attr]['page']+1) { if (preg_match('/^=php\.(\w+)\((.*)\)$/',$template['attribute'][$attr]['post'],$matches)) { switch ($matches[1]) { case 'Password' : preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$matches[2],$matchall); $enc = $_REQUEST[$matchall[1][0]]; $password = $_REQUEST['form'][$matchall[1][1]]; if (trim($password)) { $value = password_hash($password,$enc); $_REQUEST['form'][$attr] = $value; } break; case 'SambaPassword' : $matchall = explode(',',$matches[2]); $attr = preg_replace('/%/','',$matchall[1]); # If we have no password, then dont hash nothing! if (! trim($_REQUEST['form'][$attr])) break; $sambapassword = new smbHash; switch ($matchall[0]) { case 'LM' : $value = $sambapassword->lmhash($_REQUEST['form'][$attr]); break; case 'NT' : $value = $sambapassword->nthash($_REQUEST['form'][$attr]); break; default : $value = null; } $_REQUEST['form'][$attr] = $value; break; case 'Join' : preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$matches[2],$matchall); $matchattrs = explode(',',$matches[2]); $char = $matchattrs[0]; $values = array(); foreach ($matchall[1] as $joinattr) { if (isset($_REQUEST['form'][$joinattr])) $values[] = $_REQUEST['form'][$joinattr]; else if (isset($_REQUEST[$joinattr])) $values[] = $_REQUEST[$joinattr]; else pla_error(sprintf(_('Your template is missing variable (%s)'),$joinattr)); } $value = implode($char,$values); $_REQUEST['form'][$attr] = $value; break; default: pla_error(sprintf(_('Your template has an unknown post function (%s).'),$matches[1])); } } } if (is_array($value)) foreach ($value as $item) printf('',$attr,$item); else printf('',$attr,$value); } # Have we got a Binary Attribute? if (isset($_FILES['form']['name']) && is_array($_FILES['form']['name'])) { foreach ($_FILES['form']['name'] as $attr => $details) { if (is_uploaded_file($_FILES['form']['tmp_name'][$attr])) { $file = $_FILES['form']['tmp_name'][$attr]; $f = fopen($file,'r'); $binary_data = fread($f,filesize($file)); fclose($f); // @todo: This may need to be implemented. //if (is_binary_option_required($ldapserver,$attr)) // $attr .= ';binary'; $_SESSION['submitform'][$attr] = $binary_data; printf('',$attr); } } } } printf('',$ldapserver->server_id); printf('',htmlspecialchars($_REQUEST['template'])); printf('',rawurlencode(serialize(array_values($template['objectclass'])))); printf('',$page+1); echo "\n\n"; echo '
'; echo ''; echo ''; echo "\n\n"; echo ''; if (isset($template['askcontainer']) && $template['askcontainer'] && $page == 1) { if (! (isset($template['regexp']) && isset($template['regexp']))) { echo ''; echo ''; printf(''; echo ''; } else { echo ''; echo ''; printf('',htmlspecialchars($_REQUEST['container'])); echo ''; } } else { printf('',htmlspecialchars($_REQUEST['container'])); } $count = 0; $nextpage = 0; $mustitems = 0; foreach ($template['empty_attrs'] as $attr => $detail) { $mustitem = false; $verifyitem = false; $type = isset($detail['type']) ? $detail['type'] : 'text'; if (! isset($detail['page'])) $detail['page'] = 1; $size = isset($detail['size']) ? $detail['size'] : 20; $maxlength = isset($detail['maxlength']) ? $detail['maxlength'] : null; $rows = isset($detail['rows']) ? $detail['rows'] : null; $cols = isset($detail['cols']) ? $detail['cols'] : null; # Check that the page number is correct. if ($detail['page'] < $page && ! isset($attr[$attr])) { # ERROR: This attribute should be set by now. print "We should have set [$attr] by now.
"; } elseif ($detail['page'] == $page) { $count++; echo ''; # Some conditional checking. # $detail['must'] & $detail['disable'] cannot be set at the same time. # except when "action" is other than create.php if (isset($detail['must']) && $detail['must'] && isset($detail['disable']) && $detail['disable'] && (!isset($template['action']) || ($template['action']) == 'create.php')) pla_error(sprintf(_('Attribute [%s] is a MUST attribute, so it cannot be disabled.'),$attr)); # If this attribute is disabled, go to the next one. if (isset($detail['disable']) && $detail['disable']) continue; # Evaluate our Default Value, if its a function call result. if (isset($detail['value'])) { if (is_array($detail['value'])) { # If value is an array, then it must a select list. $type = 'select'; $defaultresult = sprintf(''; $detail['value'] = $defaultresult; } else { $detail['value'] = $templates->EvaluateDefault($ldapserver,$detail['value'],$_REQUEST['container'],null, (isset($detail['default']) ? $detail['default'] : null)); } #if the default has a select list, then change the type to select if (preg_match('/','hidden',$attr,$attr,$detail['value']); continue; } else { pla_error(sprintf(_('Attribute [%s] is a HIDDEN attribute, however, it is missing a VALUE in your template.'),$attr)); } } # This is a displayed attribute. # Flag it as a must attribute so that we do get a value. if (isset($detail['must']) && $detail['must'] && ! isset($detail['presubmit']) && $type != 'select') { $mustitems++; $mustitem = true; } # Display the icon if one is required. if (isset($detail['icon']) && trim($detail['icon'])) printf('',$detail['icon']); else printf(''); echo ''; # Calculate the events. # @todo: Need to change js so that if a must attr is auto populated, it decrements the total and enables the submit. if (isset($detail['onchange'])) { if (is_array($detail['onchange'])) { foreach ($detail['onchange'] as $value) $templates->OnChangeAdd($ldapserver,$attr,$value); } else { $templates->OnChangeAdd($ldapserver,$attr,$detail['onchange']); } } # Display the input box. echo '',$detail['hint']); else echo ''; echo ''."\n"; # Do we have a verify attribute? if (isset($detail['verify']) && ($detail['verify'])) { $verifyitems = true; echo ''."\n"; } # Is this a multiarray input? if (isset($detail['array']) && ($detail['array'])) { for ($i=2; $i <= $detail['array']; $i++) { echo ''; printf(''."\n"; } } # Do we have a helper. # Side helpers are handled above. # @todo: Helpers must have an onchange or onsubmit. # @todo: Helpers must have an id field. # @todo: Helpers must have an post field. if (isset($detail['helper']) && (! isset($detail['helper']['location']) || $detail['helper']['location'] != 'side')) { echo ''; echo ''; printf('',$templates->HelperValue($detail['helper']['value'],$detail['helper']['id'])); } if (isset($detail['spacer']) && $detail['spacer']) echo ''; # See if there are any future ones - if there are and we dont ask any this round, then thats an error. } elseif ($detail['page'] > $page) { $nextpage++; } } # @todo: Proper error message required. if ($nextpage && ! $count) pla_error(sprintf(_('We are missing a page for [%s] attributes.'),$nextpage)); # If there is no count, display the summary if (! $count) { printf('', $template['icon'],_('Create Object'),htmlspecialchars($new_dn)); echo ''; $counter = 0; foreach ($_REQUEST['form'] as $attr => $value) { # Remove blank attributes. if (! is_array($_REQUEST['form'][$attr]) && trim($_REQUEST['form'][$attr]) == '') { unset($_REQUEST['form'][$attr]); continue; } $attrs[] = $attr; printf('',$attr,htmlspecialchars($item)); } } else { $display = $value; if (isset($template['attribute'][$attr]['type']) && $template['attribute'][$attr]['type'] == 'password') { $enc = (isset($_REQUEST['enc'])) ? $_REQUEST['enc'] : get_enc_type($value); if (obfuscate_password_display($enc)) $display = '********'; } printf('',$value); printf('%s',$attr,htmlspecialchars($display)); } } if (isset($_SESSION['submitform'])) { echo ''; foreach (array_keys($_SESSION['submitform']) as $attr) { printf('',$attr); } } } echo ''; if (! $nextpage && isset($_REQUEST['nextpage']) && ! $_REQUEST['nextpage']) { # Look for any presubmit functions. foreach ($template['empty_attrs'] as $attr => $detail) { if (isset($template['attribute'][$attr]['presubmit']) && ! isset($_REQUEST['form'][$attr])) { printf('', ($counter++%2==0?'even':'odd'),$attr,htmlspecialchars(_('(Auto evaluated on submission.)'))); printf('',$attr); } } printf('', _('Create Object'),$mustitems ? 'disabled' : ''); } elseif ($nextpage) { printf('', _('Next Page'),$mustitems ? 'disabled' : ''); } else { printf('', _('Proceed >>'),$mustitems ? 'disabled' : ''); } echo '
 
 Container DN: ', htmlspecialchars($_REQUEST['container'])); draw_chooser_link('template_form.container'); echo '
 Container DN:', htmlspecialchars($_REQUEST['container'])); printf('
Icon '; # Display the label. if (isset($detail['description']) && (trim($detail['description']))) printf('%s:',$detail['description'],$detail['display']); elseif (isset($detail['display'])) printf('%s:',$detail['display']); else printf('%s:',_('No DISPLAY/DESCRIPTION attribute in template file')); echo ''; # Is this a binary attribute if ($ldapserver->isAttrBinary($attr)) { printf('',$attr); if (! ini_get('file_uploads')) printf('
%s
', _('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.')); else printf('
%s: %s
', _('Maximum file size'),ini_get('upload_max_filesize')); } elseif (in_array($type,array('text','password'))) { printf('', $type,$size,$attr,(isset($detail['array']) && ($detail['array'] > 1) ? '[]' : ''),$attr, (isset($detail['value']) ? $detail['value'] : ''), "onBlur=\"fill('$attr', this.value);\"", (isset($detail['disable']) ? 'disabled' : ''), ($maxlength ? sprintf(' maxlength="%s" ',$maxlength) : '')); } elseif ($type == 'textarea') { printf('', $size,$attr,(isset($detail['array']) && ($detail['array'] > 1) ? '[]' : ''),$attr, (isset($detail['value']) ? $detail['value'] : ''), ($cols ? $cols : 35), ($rows ? $rows : 4), "onBlur=\"fill('$attr', this.value);\"", (isset($detail['disable']) ? 'disabled' : '')); } elseif ($type == 'select') { printf($detail['value'],$attr, "onBlur=\"fill('$attr', this.value);\"", (isset($detail['disable']) ? 'disabled' : ' ')); } # Disabled items dont get submitted. # @todo need to add some js to enable them on submit, or add them as hidden items. if ($mustitem) echo ' *'; # Do we have a helper, and is it configured for the side. if (isset($detail['helper']) && isset($detail['helper']['location']) && $detail['helper']['location'] == 'side' && isset($detail['helper']['value'])) { printf(' %s',$templates->HelperValue($detail['helper']['value'], (isset($detail['helper']['id']) ? $detail['helper']['id'] : ''),$_REQUEST['container'],$ldapserver,null, isset($detail['helper']['default']) ? $detail['helper']['default'] : '')); } if (isset($detail['hint']) && (trim($detail['hint']))) printf(' (hint: %s)
 '; # Display the label. if (isset($detail['description']) && (trim($detail['description']))) printf('%s %s:',_('Verify'),$detail['description'],$detail['display']); else printf('%s %s:',_('Verify'),$detail['display']); echo ''; if (in_array($type,array('text','password'))) { printf('', $type,$attr."V",$attr."V",(isset($detail['value']) ? $detail['value'] : ''), sprintf('onBlur="check(form.%s,form.%sV)"',$attr,$attr)); } echo '
  ', $type,$attr,$attr.$i,(isset($detail['value']) ? $detail['value'] : ''), '', isset($detail['disable']) ? 'disabled' : ''); if (isset($detail['helper']) && isset($detail['helper']['location']) && $detail['helper']['location'] == 'side' && isset($detail['helper']['value'])) { printf(' %s',$templates->HelperValue($detail['helper']['value'], (isset($detail['helper']['id']) ? $detail['helper']['id'] : ''),$_REQUEST['container'],$ldapserver,$i)); } echo '
 '; # Display the label. if (isset($detail['helper']['description']) && (trim($detail['helper']['description']))) printf('%s:',$detail['helper']['description'],$detail['helper']['display']); else printf('%s:',$detail['helper']['display']); echo '%s
Create%s :%s
',($counter++%2==0?'even':'odd')); printf('',$attr); $countitems = false; if (is_array($value)) foreach ($value as $item) { if (($item || $item == '0') && ! isset($unique[$item])) { $unique[$item] = 1; if ($countitems) printf ('
',($counter++%2==0?'even':'odd')); $countitems = true; printf('', array_search($attr,$attrs),$item); printf('%s%s
%s
%s%s', ($counter++%2==0?'even':'odd'),$attr,_('Binary value not displayed')); printf('
%s%s



'; echo '
'; if ($mustitems) printf('',$mustitems); printf('',$nextpage); echo '
'."\n\n"; printf(''._('Page %d').'',$page); echo "\n\n"; if ($mustitems) { $jstext = ' '; $pjs[] = $jstext; } if (isset($verifyitems) && $verifyitems) { //@todo: Return focus to the first item. $pjs[] = ' '; } # User needs to submit form to continue. foreach ($pjs as $script) echo $script; die(); } if (! isset($template)) $template['attrs'] = $attrs; # If we get here - we are displaying/editing the entry. # Sort these entries. uksort($template['attrs'],'sortAttrs'); $js_date_attrs = $config->GetValue('appearance','date_attrs'); $js[] = sprintf('',$config->GetValue('appearance','date')); foreach ($template['attrs'] as $attr => $vals) { if (! is_array($vals)) $vals = array($vals); flush(); $schema_attr = $ldapserver->getSchemaAttribute($attr,$dn); if ($schema_attr) $attr_syntax = $schema_attr->getSyntaxOID(); else $attr_syntax = null; if (! strcasecmp($attr,'dn')) continue; # has the config.php specified that this attribute is to be hidden or shown? if ($ldapserver->isAttrHidden($attr)) continue; # Setup the $attr_note, which will be displayed to the right of the attr name (if any) $attr_note = ''; # is there a user-friendly translation available for this attribute? if (isset($friendly_attrs[ strtolower($attr) ])) { $attr_display = $friendly_attrs[ strtolower($attr) ]; $attr_note = "alias"; } else { $attr_display = $attr; } # is this attribute required by an objectClass? $required_by = ''; if ($schema_attr) foreach ($schema_attr->getRequiredByObjectClasses() as $required) { if (isset($attrs['objectClass']) && ! is_array($attrs['objectClass'])) $attrs['objectClass'] = array($attrs['objectClass']); if (isset($attrs['objectClass']) && in_array(strtolower($required),arrayLower($attrs['objectClass']))) $required_by .= $required . ' '; # It seems that some LDAP servers (Domino) returns attributes in lower case? elseif (isset($attrs['objectclass']) && in_array(strtolower($required),arrayLower($attrs['objectclass']))) $required_by .= $required . ' '; } if ($required_by) { if (trim($attr_note)) $attr_note .= ', '; $attr_note .= "" . _('required') . " "; } # is this attribute required because its the RDN if (preg_match("/^${attr}=/",$rdn)) { if (trim($attr_note)) $attr_note .= ', '; $attr_note .= " " . 'rdn' . " "; } if (is_array($modified_attrs) && in_array($attr,$modified_attrs)) $is_modified_attr = true; else $is_modified_attr = false; if ($is_modified_attr) echo ''; else echo ''; echo ''; if ($config->GetValue('appearance','show_schema_link')) { $schema_href = sprintf('schema.php?server_id=%s&view=attributes&viewvalue=%s', $ldapserver->server_id,real_attr_name($attr)); printf('%s',$attr,$schema_href,$attr_display); } else { printf('%s',$attr_display); } echo ''; if ($config->GetValue('appearance','show_attribute_notes')) { echo ''; if ($attr_note) printf('%s',$attr_note); if ($ldapserver->isAttrReadOnly($attr)) printf('(%s)',_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),_('read only')); echo ''; } echo ''; if ($is_modified_attr) echo ''; else echo ''; echo ''; /* * Is this attribute a jpegPhoto? */ if ($ldapserver->isJpegPhoto($attr)) { /* Don't draw the delete buttons if there is more than one jpegPhoto (phpLDAPadmin can't handle this case yet) */ if ($ldapserver->isReadOnly() || $ldapserver->isAttrReadOnly($attr)) draw_jpeg_photos($ldapserver,$dn,$attr,false); else draw_jpeg_photos($ldapserver,$dn,$attr,true); # proceed to the next attribute echo ''; if ($is_modified_attr) echo ''; continue; } /* * Is this attribute binary? */ if ($ldapserver->isAttrBinary($attr)) { $href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s', $ldapserver->server_id,$encoded_dn,$attr); echo ''; echo _('Binary value'); if (! strcasecmp($attr,'objectSid')) printf(' (%s)',binSIDtoText($vals[0])); echo '
'; if (count($vals) > 1) { for ($i=1; $i<=count($vals); $i++) printf('Save %s(%s)
', $href,$i,_('download value'),$i); } else { printf('Save %s
',$href,_('download value')); } if (! $ldapserver->isReadOnly() && ! $ldapserver->isAttrReadOnly($attr)) printf('Trash %s', $attr,_('delete attribute')); echo '
'; echo ''; echo ''; if ($is_modified_attr) echo ''; continue; } /* * Note: at this point,the attribute must be text-based (not binary or jpeg) */ # If this is the userPassword attribute, add the javascript so we can call check password later. if (! strcasecmp($attr,'userPassword')) { $js[] = ' '; } /* * If this server is in read-only mode or this attribute is configured as read_only, * simply draw the attribute values and continue. */ if ($ldapserver->isReadOnly() || $ldapserver->isAttrReadOnly($attr) || (preg_match("/^${attr}=/",$rdn))) { if (is_array($vals)) { foreach ($vals as $i => $val) { if (trim($val) == '') printf('[%s]
',_('empty')); elseif (! strcasecmp($attr,'userPassword') && $config->GetValue('appearance','obfuscate_password_display')) { $user_password = $val; echo preg_replace('/./','*',$val).'
'; } elseif (in_array(strtolower($attr),$shadow_format_attrs)) { $shadow_date = shadow_date($attrs,$attr); echo htmlspecialchars($val).' '; echo ''; if (($today < $shadow_date) && in_array(strtolower($attr),$shadow_before_today_attrs)) echo ''.htmlspecialchars("(".strftime($config->GetValue('appearance','date'),$shadow_date).")").''; elseif ($today > $shadow_date && in_array(strtolower($attr),$shadow_after_today_attrs)) echo ''.htmlspecialchars("(".strftime($config->GetValue('appearance','date'),$shadow_date).")").''; else echo htmlspecialchars("(".strftime($config->GetValue('appearance','date'),shadow_date($attrs,$attr)).")"); echo ''; } else echo htmlspecialchars($val).'
'; } } if (! strcasecmp($attr,'userPassword') && isset($user_password)) printf('%s',base64_encode($user_password),_('Check password...')); if (preg_match("/^${attr}=/",$rdn)) printf('(%s)',$rename_href,_('rename')); echo ''; echo ''; if ($is_modified_attr) echo ''; continue; } /* * Is this a userPassword attribute? */ if (0 == strcasecmp($attr,'userpassword')) { foreach ($vals as $user_password) { $enc_type = get_enc_type($user_password); # Set the default hashing type if the password is blank (must be newly created) if ($user_password == '') $enc_type = get_default_hash($ldapserver->server_id); printf('',htmlspecialchars($user_password)); echo ''; printf('',($enc_type == '' ? 'clear' : $enc_type)); if (obfuscate_password_display($enc_type)) echo htmlspecialchars(preg_replace('/./','*',$user_password)); else echo htmlspecialchars($user_password); echo '
'; printf('', (obfuscate_password_display($enc_type) ? 'password' : 'text'),htmlspecialchars($user_password)); echo enc_type_select_list($enc_type); echo '
'; printf('%s',base64_encode($user_password),_('Check password...')); echo '
'; } /* Draw the "add value" link under the list of values for this attributes */ if (! $ldapserver->isReadOnly() && ($schema_attr = $ldapserver->getSchemaAttribute($attr,$dn)) && ! $schema_attr->getIsSingleValue()) { $add_href = sprintf('add_value_form.php?server_id=%s&dn=%s&attr=%s', $ldapserver->server_id,$encoded_dn,rawurlencode($attr)); printf('
(%s)
', $add_href,sprintf(_('Add an additional value to attribute \'%s\''),$attr),_('add value')); } echo ''; echo ''; if ($is_modified_attr) echo ''; continue; } /* * Is this a boolean attribute? */ if ($ldapserver->isAttrBoolean($attr)) { $val = $vals[0]; printf('',htmlspecialchars($attr),htmlspecialchars($val)); printf(''; echo ''; echo ''; if ($is_modified_attr) echo ''; continue; } /* * Is this a date type attribute? */ if (in_array_ignore_case($attr,array_keys($js_date_attrs))) { $val = $vals[0]; printf('',htmlspecialchars($attr),htmlspecialchars($val)); printf(' ', $attr,htmlspecialchars($attr),htmlspecialchars($val)); draw_date_selector_link($attr); echo ''; echo ''; $js[] = sprintf('',$attr,$js_date_attrs[$attr]); $js_datetime_attrs = $config->GetValue('appearance','date_attrs_showtime'); if (in_array_ignore_case($attr,array_keys($js_datetime_attrs)) && ($js_datetime_attrs[$attr])) $js[] = sprintf('',$attr,'true'); if ($is_modified_attr) echo ''; continue; } /* * End of special case attributes (non plain text). */ /* * This is a plain text attribute, to be displayed and edited in plain text. */ foreach ($vals as $i => $val) { $input_name = sprintf('new_values[%s][%s]',htmlspecialchars($attr),$i); /* We smack an id="..." tag in here that doesn't have [][] in it to allow the draw_chooser_link() to identify it after the user clicks. */ $input_id = sprintf('new_values_%s_%s',htmlspecialchars($attr),$i); /* The old_values array will let update.php know if the entry contents changed between the time the user loaded this page and saved their changes. */ printf('', htmlspecialchars($attr),$i,htmlspecialchars($val)); # Is this value is a structural objectClass, make it read-only if (! strcasecmp($attr,'objectClass')) { printf('Info ', _('View the schema description for this objectClass'),$ldapserver->server_id,strtolower(htmlspecialchars($val))); $schema_object = $ldapserver->getSchemaObjectClass($val); # This should be an object, but we'll test it anyway if (is_object($schema_object) && $schema_object->getType() == 'structural') { printf(' %s (%s)
', $val,_('This is a structural ObjectClass and cannot be removed.'),_('structural')); printf('',$input_name,$input_id,htmlspecialchars($val)); continue; } } if (is_dn_string($val) || $ldapserver->isDNAttr($attr)) if ($ldapserver->dnExists($val)) { printf('Go ', htmlspecialchars($val),$ldapserver->server_id,rawurlencode($val)); } else { printf('N/E ', htmlspecialchars($val),$ldapserver->server_id,rawurlencode($val)); } elseif (is_mail_string($val)) printf('Mail ',htmlspecialchars($val)); elseif (is_url_string($val)) printf('URL ',htmlspecialchars($val)); if ($ldapserver->isMultiLineAttr($attr,$val)) printf('',$input_name,$input_id,htmlspecialchars($val)); else printf(' ',$input_name,$input_id,htmlspecialchars($val)); /* draw a link for popping up the entry browser if this is the type of attribute that houses DNs. */ if ($ldapserver->isDNAttr($attr)) draw_chooser_link("edit_form.$input_id",false); echo '
'; # If this is a gidNumber on a non-PosixGroup entry, lookup its name and description for convenience if (! strcasecmp($attr,'gidNumber') && ! in_array_ignore_case('posixGroup',$ldapserver->getDNAttr($dn,'objectClass'))) { $gid_number = $val; $search_group_filter = "(&(objectClass=posixGroup)(gidNumber=$val))"; $group = $ldapserver->search(null,null,$search_group_filter,array('dn','description')); if (count($group) > 0) { echo '
'; $group = array_pop($group); $group_dn = $group['dn']; $group_name = explode('=',get_rdn($group_dn)); $group_name = $group_name[1]; $href = sprintf('template_engine.php?server_id=%s&dn=%s',$ldapserver->server_id,urlencode($group_dn)); echo ''; printf('%s',$href,htmlspecialchars($group_name)); $description = isset($group['description']) ? $group['description'] : null; if (is_array($description)) { foreach ($description as $item) printf(' (%s)',htmlspecialchars($item)); } else { printf(' (%s)',htmlspecialchars($description)); } echo ''; } } # Show the dates for all the shadow attributes. if (in_array(strtolower($attr),$shadow_format_attrs)) { if (($shadow_date = shadow_date($attrs,$attr)) !== false) { echo '
'; echo ''; if (($today < $shadow_date) && in_array(strtolower($attr),$shadow_before_today_attrs)) echo ''.htmlspecialchars(strftime($config->GetValue('appearance','date'),$shadow_date)).''; elseif ($today > $shadow_date && in_array(strtolower($attr),$shadow_after_today_attrs)) echo ''.htmlspecialchars(strftime($config->GetValue('appearance','date'),$shadow_date)).''; else echo htmlspecialchars(strftime($config->GetValue('appearance','date'),$shadow_date)); echo ''; } } } /* end foreach value */ /* Draw the "add value" link under the list of values for this attributes */ if (! $ldapserver->isReadOnly() && ($schema_attr = $ldapserver->getSchemaAttribute($attr,$dn)) && ! $schema_attr->getIsSingleValue()) { $add_href = sprintf('add_value_form.php?server_id=%s&dn=%s&attr=%s', $ldapserver->server_id,$encoded_dn,rawurlencode($attr)); printf('
(%s)
', $add_href,sprintf(_('Add an additional value to attribute \'%s\''),$attr),_('add value')); if (in_array($schema_attr->name,$config->GetValue('modify_member','groupattr'))) { $add_href = sprintf('modify_member_form.php?server_id=%s&dn=%s&attr=%s', $ldapserver->server_id,$encoded_dn,rawurlencode($attr)); printf('
(%s)
', $add_href,sprintf('%s %s',_('Modify members for'),$dn),_('modify group members')); } } echo ''; echo ''; if ($is_modified_attr) echo ''; echo "\n"; flush(); } /* End foreach ($attrs as $attr => $vals) */ if (! $ldapserver->isReadOnly()) printf('
', _('Save Changes')); else printf(''); ?>