';
}
}
public function drawTemplateCreatingEntryStepFormStart($entry, $step) {
if ($entry->getSelectedTemplateName()) {
if ($step < $this->laststep) {
echo '';
}
protected function drawTemplateCreatingEntryShownAttributes($entry) {
if (!$entry->getSelectedTemplateName()) {
$this->draw('DefaultCreatingEntry::ShownAttributes', $entry);
return;
}
foreach ($this->shown_attributes as $attr) {
$page = $attr->getProperty('page');
if ($page == $this->step) {
$this->draw('', $attr);
echo "\n";
//} elseif ($page < $this->step) {
} else {
// the displayed attributes are the visible attributes in shown_attributes list
$attr->hide();
$this->hidden_attributes[] = $attr;
}
}
}
protected function drawTemplateCreatingEntryHiddenAttributes($entry) {
if (!$entry->getSelectedTemplateName()) {
$this->draw('DefaultCreatingEntry::HiddenAttributes', $entry);
return;
}
foreach ($this->hidden_attributes as $attr) {
//$page = $attr->hasProperty('page') ? $attr->getProperty('page') : -1;
//if ($page <= $this->step) {
$this->draw('', $attr);
echo "\n";
//}
}
}
protected function drawTemplateCreatingEntryJavascript($entry) {
$this->draw('DefaultCreatingEntry::Javascript', $entry);
$templates = new Templates($this->ldapserver->server_id);
foreach ($entry->getAttributes() as $attribute) {
if ($attribute->hasProperty('onchange')) {
$onchange = $attribute->getProperty('onchange');
if (is_array($onchange)) {
foreach ($onchange as $value)
$templates->OnChangeAdd($this->ldapserver,$attribute->getName(),$value);
} else {
$templates->OnChangeAdd($this->ldapserver,$attribute->getName(),$onchange);
}
}
}
$hash = $templates->getJsHash();
echo '';
}
/********************************/
/* Paint a TemplateEditingEntry */
/********************************/
public function visitTemplateEditingEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$entry->getDn());
$template = get_request('template','REQUEST');
if ($template) {
if ($template == 'none') {
$this->visit('DefaultEditingEntry::Start', $entry);
return;
} else {
$entry->setSelectedTemplateName($template);
}
}
if ($entry->getSelectedTemplateName()) {
# if we already choose an editing template, use it to display the entry
$this->visit('DefaultEditingEntry::Start', $entry);
} elseif ($entry->getTemplatesCount() <= 0) {
# if no template is available for this entry, draws it
# to the parent manner
$this->visit('DefaultEditingEntry::Start', $entry);
} elseif (($entry->getTemplatesCount() == 1) && !$entry->hasDefaultTemplate()) {
$templates = &$entry->getTemplates();
$template_names = array_keys($templates);
$entry->setSelectedTemplateName($template_names[0]);
$this->visit('DefaultEditingEntry::Start', $entry);
} else {
$this->visit_attributes = false;
# propose the template choice
$this->draw('TemplateChoice', $entry);
}
}
public function visitTemplateEditingEntryEnd($entry) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$entry->getDn());
if ($this->visit_attributes) {
$this->visit('DefaultEditingEntry::End', $entry);
$entry->setSelectedTemplateName('');
}
}
protected function drawTemplateEditingEntryTemplateChoice($entry) {
$this->draw('Title', $entry);
$this->draw('Subtitle', $entry);
echo "\n";
printf('
%s
',_('Select a template to edit the entry'));
$href = sprintf('cmd.php?%s', array_to_query_string($_GET,array('meth'),false));
echo '';
}
protected function drawTemplateEditingEntryShownAttributes($entry) {
foreach ($this->shown_attributes as $attr) {
// @todo if this->page == attr->page
$this->draw('', $attr);
echo "\n";
}
}
protected function drawTemplateEditingEntryHiddenAttributes($entry) {
printf('', $entry->getSelectedTemplateName());
$this->draw('DefaultEditingEntry::HiddenAttributes', $entry);
}
protected function drawTemplateEditingEntryJavascript($entry) {
$this->draw('DefaultEditingEntry::Javascript', $entry);
$templates = new Templates($this->ldapserver->server_id);
foreach ($entry->getAttributes() as $attribute) {
if ($attribute->hasProperty('onchange')) {
$onchange = $attribute->getProperty('onchange');
if (is_array($onchange)) {
foreach ($onchange as $value)
$templates->OnChangeAdd($this->ldapserver,$attribute->getName(),$value);
} else {
$templates->OnChangeAdd($this->ldapserver,$attribute->getName(),$onchange);
}
}
}
$hash = $templates->getJsHash();
echo '';
}
/**************************/
/* Paint an Attribute */
/**************************/
protected function drawAttribute($attribute) {
if ($attribute->isVisible()) $this->draw('Informations', $attribute);
$this->draw('Values', $attribute);
}
protected function drawAttributeJavascript($attribute) {
echo '';
}
protected function drawAttributeFocusJavascript($attribute, $component) {
$entry = $attribute->getEntry();
if ($entry)
echo $this->get('AttributeFocusJavascript', $entry, $attribute, $component);
}
protected function drawAttributeBlurJavascript($attribute, $component) {
$entry = $attribute->getEntry();
if ($entry)
echo $this->get('AttributeBlurJavascript', $entry, $attribute, $component);
}
protected function drawAttributeValidateJavascript($attribute, $component, $silence, $var_valid) {
if ($attribute->isRequired()) {
echo 'var vals = getAttributeValues("new", "'.$attribute->getName().'");
if (vals.length <= 0) {
'.$var_valid.' = false;
alertError("'._('This attribute is required')._(':').' '.$attribute->getFriendlyName().'", '.$silence.');
}';
echo 'var comp = getAttributeComponents("new", "'.$attribute->getName().'");
for (var i = 0; i < comp.length; i++) {
comp[i].style.backgroundColor = '.$var_valid.' ? "white" : \'#ffffba\';
}';
}
}
protected function getEntryAttributeFocusJavascript($entry, $attribute, $component) {
return '';
}
protected function getEntryAttributeBlurJavascript($entry, $attribute, $component) {
return '';
}
protected function getDefaultCreatingEntryAttributeBlurJavascript($entry, $attribute, $component) {
return "\n\t\t\t\t\t\t".'validate_'.$attribute->getName().'('.$component.', false);'."\n";
}
protected function getTemplateCreatingEntryAttributeBlurJavascript($entry, $attribute, $component) {
$j = 'fill('.$component.'.id, pla_getComponentValue('.$component.'));';
//$j .= $this->get('DefaultCreatingEntry::AttributeBlurJavascript',$entry, $attribute, $component);
return $j;
}
protected function getDefaultEditingEntryAttributeBlurJavascript($entry, $attribute, $component) {
return "\n\t\t\t\t\t\t".'validate_'.$attribute->getName().'('.$component.', false);'."\n";
}
protected function getTemplateEditingEntryAttributeBlurJavascript($entry, $attribute, $component) {
$j = 'fill('.$component.'.id, pla_getComponentValue('.$component.'));';
//$j .= $this->get('DefaultEditingEntry::AttributeBlurJavascript',$entry, $attribute, $component);
return $j;
}
protected function drawAttributeFillJavascript($attribute, $component_id, $component_value) {
echo "\n\t\t\t\t\t\t".'validate_'.$attribute->getName().'(pla_getComponentById('.$component_id.'), false);'."\n";
}
protected function drawAttributeInformations($attribute) {
if (($this->context == ENTRY_WRITER_EDITING_CONTEXT) && $attribute->hasBeenModified()) echo '
';
else echo '
';
echo '
';
$this->draw('Name', $attribute);
echo '
';
echo '
';
# Setup the $attr_note, which will be displayed to the right of the attr name (if any)
if ($_SESSION['plaConfig']->GetValue('appearance', 'show_attribute_notes')) {
$this->draw('Notes', $attribute);
}
echo '
';
echo '
';
}
protected function drawAttributeNotes($attribute) {
$attr_note = '';
$alias_note = $this->get('AliasNote', $attribute);
if ($alias_note) {
if (trim($attr_note)) $attr_note .= ', ';
$attr_note .= $alias_note;
}
$required_note = $this->get('RequiredNote', $attribute);
if ($required_note) {
if (trim($attr_note)) $attr_note .= ', ';
$attr_note .= $required_note;
}
$rdn_note = $this->get('RdnNote', $attribute);
if ($rdn_note) {
if (trim($attr_note)) $attr_note .= ', ';
$attr_note .= $rdn_note;
}
if ($attr_note) printf('%s', $attr_note);
if ($attribute->isReadOnly() && $this->ldapserver->isAttrReadOnly($attribute->getName())) {
printf('(%s)',
_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),
_('read only'));
}
}
protected function drawAttributeValues($attribute) {
if ($attribute->isVisible()) $this->draw('StartValueLine', $attribute);
# draws values
$value_count = $attribute->getValueCount();
$i = 0;
for (; $i < $value_count; $i++) {
$this->draw('Value', $attribute, $i);
}
if ($this->context == ENTRY_WRITER_CREATION_CONTEXT) {
$blankvalue_count = $attribute->getMaxValueCount();
if ($blankvalue_count < 0) $blankvalue_count = 1;
else $blankvalue_count -= $value_count;
for ($j = 0; $j < $blankvalue_count; $j++) {
$this->draw('BlankValue', $attribute, $i + $j);
}
}
if ($attribute->isVisible()) {
$this->draw('Menu', $attribute);
$this->draw('EndValueLine', $attribute);
}
}
protected function drawAttributeMenu($attribute) {
$i = 0;
$item = '';
while (($item = $this->get('MenuItem', $attribute, $i)) !== false) {
if ($item) {
echo '
'.$item.'
';
}
$i++;
}
}
protected function getAttributeMenuItem($attribute, $i) {
if ($this->context != ENTRY_WRITER_EDITING_CONTEXT)
return false;
switch ($i) {
case IdAttributeAddValueMenuItem :
if ($attribute->isVisible() && !$attribute->isReadOnly()
&& !$attribute->isRdn() && $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) {
if ($attribute->getMaxValueCount() < 0 || $attribute->getValueCount() < $attribute->getMaxValueCount()) {
return $this->get('AddValueMenuItem', $attribute);
}
}
return '';
case IdAttributeModifyMemberMenuItem :
if (in_array($attribute->getName(), $_SESSION['plaConfig']->GetValue('modify_member','groupattr'))) {
if ($attribute->isVisible() && !$attribute->isReadOnly() && !$attribute->isRdn()
&& ($_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')
|| $_SESSION['plaConfig']->isCommandAvailable('attribute_delete_value'))) {
return $this->get('ModifyMemberMenuItem', $attribute);
}
}
return '';
case IdAttributeRenameMenuItem :
if ($attribute->isVisible() && $attribute->isRdn() && !$attribute->isReadOnly()
&& $_SESSION['plaConfig']->isCommandAvailable('entry_rename')) {
return $this->get('RenameMenuItem', $attribute);
}
return '';
default :
return false;
}
}
protected function drawAttributeStartValueLine($attribute) {
if (($this->context == ENTRY_WRITER_EDITING_CONTEXT) && $attribute->hasBeenModified()) {
echo '
';
} else {
echo '
';
}
echo '
';
}
protected function drawAttributeEndValueLine($attribute) {
echo '
';
echo '
';
if (($this->context == ENTRY_WRITER_EDITING_CONTEXT) && $attribute->hasBeenModified()) {
echo '
';
}
}
protected function drawAttributeValue($attribute, $i) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s, %d)',1,__FILE__,__LINE__,__METHOD__,$attribute->getName(),$i);
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($attribute->isVisible()) {
echo '
';
}
}
/**
* Save the current value to detect changes
*/
protected function drawAttributeOldValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
printf('',
htmlspecialchars($attribute->getName()), $i, htmlspecialchars($val));
}
/**
* Display the current value
*/
protected function drawAttributeNewValue($attribute, $i) {
if (!$attribute->isVisible()) {
$this->draw('HiddenValue', $attribute, $i);
} elseif ($attribute->isReadOnly() || ($attribute->getEntry() && $attribute->getEntry()->getDn() && $attribute->isRdn())) {
$this->draw('ReadOnlyValue', $attribute, $i);
} else {
$this->draw('ReadWriteValue', $attribute, $i);
}
}
protected function drawAttributeBlankValue($attribute, $i) {
$this->draw('Value', $attribute, $i);
}
protected function drawAttributeHiddenValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
printf('',
htmlspecialchars($attribute->getName()), $i, htmlspecialchars($attribute->getName()), $i,
htmlspecialchars($val));
}
protected function drawAttributeReadOnlyValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
printf(' ',
htmlspecialchars($attribute->getName()), $i, htmlspecialchars($attribute->getName()),
$i, htmlspecialchars($val), ($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '');
}
protected function drawAttributeReadWriteValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
if ($attribute->hasProperty('helper')) {
echo '
';
}
/* 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. */
$id = sprintf('new_values_%s_%s', htmlspecialchars($attribute->getName()), $i);
printf('',
htmlspecialchars($attribute->getName()), $i, $id,
htmlspecialchars($val), $attribute->getName(), $attribute->getName(),
($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '',
($attribute->getMaxLength() > 0) ? 'maxlength="'.$attribute->getMaxLength().'"' : '');
if ($attribute->hasProperty('helper')) {
echo '
';
}
}
protected function getAttributeDefaultValueHelper($attribute, $i) {
$params = $attribute->getProperty('helper');
# Should only return 1 default entry.
if (isset($params['value']) && ! is_array($params['value']))
return $params['value'];
# If there are multiple values, return the first one.
else if (isset($params['value']) && is_array($params['value']))
return array_shift($params['value']);
# No default values, return a blank.
else
return '';
}
protected function getAttributeRenameMenuItem($attribute) {
$encoded_dn = '';
if ($attribute->getEntry()) $encoded_dn = rawurlencode($attribute->getEntry()->getDn());
if (!$encoded_dn) return; // creating entry
$url_base = sprintf('cmd.php?server_id=%s&dn=%s', $this->ldapserver->server_id, $encoded_dn);
$href = sprintf('%s&cmd=rename_form', $url_base);
return sprintf('(%s)', htmlspecialchars($href), _('rename'));
}
protected function getAttributeAddValueMenuItem($attribute) {
/* Draw the "add value" link under the list of values for this attributes */
$encoded_dn = '';
$template = '';
if ($attribute->getEntry()) {
$encoded_dn = rawurlencode($attribute->getEntry()->getDn());
if (method_exists($attribute->getEntry(), 'getSelectedTemplateName'))
$template = $attribute->getEntry()->getSelectedTemplateName();
}
if (!$encoded_dn) return; // creating entry
$href = sprintf('cmd.php?cmd=add_value_form&server_id=%s&dn=%s%s&attr=%s',
$this->ldapserver->server_id, $encoded_dn, $template ? "&template=$template" : '', rawurlencode($attribute->getName()));
return sprintf('(%s)',
htmlspecialchars($href), sprintf(_('Add an additional value to attribute \'%s\''),
$attribute->getName()), _('add value'));
}
protected function getAttributeModifyMemberMenuItem($attribute) {
$dn = ($attribute->getEntry()) ? $attribute->getEntry()->getDn() : '';
$encoded_dn = ($dn) ? rawurlencode($dn) : '';
if (!$encoded_dn) return; // creating entry
$href = sprintf('cmd.php?cmd=modify_member_form&server_id=%s&dn=%s&attr=%s',
$this->ldapserver->server_id, $encoded_dn, rawurlencode($attribute->getName()));
return sprintf('(%s)',
htmlspecialchars($href), sprintf(_('Modify members for \'%s\''), $dn), _('modify group members'));
}
protected function drawAttributeIcon($attribute, $val) {
if (is_dn_string($val) || $this->ldapserver->isDNAttr($attribute->getName())) {
$this->draw('DnValueIcon', $attribute, $val);
} elseif (is_mail_string($val)) {
$this->draw('MailValueIcon', $attribute, $val);
} elseif (is_url_string($val)) {
$this->draw('UrlValueIcon', $attribute, $val);
} else {
$icon = $attribute->getIcon();
if ($icon) printf(' ', $icon);
}
}
protected function drawAttributeDnValueIcon($attribute, $val) {
if (strlen($val) <= 0) {
echo ' ';
} elseif ($this->ldapserver->dnExists($val)) {
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$this->ldapserver->server_id,$val);
printf(' ',_('Go to'),
htmlspecialchars($val), htmlspecialchars($href));
} else {
printf(' ',_('DN not available'),htmlspecialchars($val));
}
}
protected function drawAttributeMailValueIcon($attribute, $val) {
$img = '';
if (strlen($val) <= 0) echo $img;
else printf(''.$img.'', htmlspecialchars($val));
echo ' ';
}
protected function drawAttributeUrlValueIcon($attribute, $val) {
$img = '';
if (strlen($val) <= 0) echo $img;
else printf(''.$img.'', htmlspecialchars($val));
echo ' ';
}
protected function drawAttributeName($attribute) {
$config = $_SESSION['plaConfig'];
$attr_display = $attribute->getFriendlyName();
if ($attribute->getEntry() && $attribute->getEntry()->getDn() // if not creating attribute
&& $config->isCommandAvailable('schema') ) {
$href = sprintf('cmd.php?cmd=schema&server_id=%s&view=attributes&viewvalue=%s',
$this->ldapserver->server_id, real_attr_name($attribute->getName()));
printf('%s', $attribute->getName(), htmlspecialchars($href), $attr_display);
} else {
printf('%s', $attr_display);
}
}
protected function getAttributeAliasNote($attribute) {
# is there a user-friendly translation available for this attribute?
$friendly_name = $attribute->getFriendlyName();
if ($friendly_name != $attribute->getName()) {
return "getName()) . "\">alias";
} else {
return '';
}
}
protected function getAttributeRequiredNote($attribute) {
# is this attribute required by an objectClass ?
$required_by = '';
if ($attribute->getEntry()) {
$schema_attr = $this->ldapserver->getSchemaAttribute($attribute->getName(),$attribute->getEntry()->getDn());
if ($schema_attr) {
$entry_attributes = $attribute->getEntry()->getAttributes();
$objectclass_attribute = null;
foreach ($entry_attributes as $entry_attribute) {
# It seems that some LDAP servers (Domino) returns attributes in lower case?
if ($entry_attribute->getName() == 'objectClass'
|| $entry_attribute->getName() == 'objectclass') {
$objectclass_attribute = $entry_attribute;
break;
}
}
if ($objectclass_attribute) {
$classes = arrayLower($objectclass_attribute->getValues());
foreach ($schema_attr->getRequiredByObjectClasses() as $required) {
if (in_array(strtolower($required), $classes)) {
$required_by .= $required . ' ';
}
}
}
}
}
if ($required_by) {
return "" . _('required') . "";
} else {
return '';
}
}
protected function getAttributeRdnNote($attribute) {
# is this attribute required because its the RDN
if ($attribute->isRdn()) {
return "" . 'rdn' . " ";
} else {
return '';
}
}
protected function drawAttributeRequiredSymbol($attribute) {
echo '*';
}
/***************************/
/* Paint a BinaryAttribute */
/***************************/
protected function drawBinaryAttributeValues($attribute) {
$valcount = $attribute->getValueCount();
if ($attribute->isVisible()) {
$this->draw('StartValueLine', $attribute);
echo '';
echo _('Binary value');
if ($valcount > 0) {
if (strcasecmp($attribute->getName(), 'objectSid') == 0) {
printf(' (%s)', binSIDtoText($attribute->getValue(0)));
}
}
echo ' ';
if ($valcount > 0) {
if ($attribute->getEntry() && $attribute->getEntry()->getDn()) {
$href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s',
$this->ldapserver->server_id, rawurlencode($attribute->getEntry()->getDn()),
$attribute->getName());
if ($valcount > 1) {
for ($i=1; $i<=$valcount; $i++) {
printf(' %s(%s) ',
htmlspecialchars($href), $i, _('download value'), $i);
}
} else {
printf(' %s ',
htmlspecialchars($href),_('download value'));
}
}
if (! $attribute->isReadOnly() && $_SESSION['plaConfig']->isCommandAvailable('attribute_delete')) {
printf(''.
' %s',
$attribute->getName(), $attribute->getFriendlyName(), _('delete attribute'));
}
} elseif ($attribute->isReadOnly() || ! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) {
printf(' ',
_("[no value]"));
} else {
$i = 0;
$val = '';
$id = sprintf('new_values_%s_%s', htmlspecialchars($attribute->getName()), $i);
printf(' ',
htmlspecialchars($attribute->getName()), $i, $id,
htmlspecialchars($val), $attribute->getName(), $attribute->getName(),
($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '',
($attribute->getMaxLength() > 0) ? 'maxlength="'.$attribute->getMaxLength().'"' : '');
}
echo '';
$this->draw('EndValueLine', $attribute);
} else {
for ($i=0; $i<$valcount; $i++) {
$n = $attribute->getFileName($i);
$p = $attribute->getFilePath($i);
if ($n && $p) {
printf('',
htmlspecialchars($attribute->getName()), $i, md5("$n|$p"));
printf('',
htmlspecialchars($attribute->getName()), $i, md5("$n|$p"));
}
}
}
}
protected function drawBinaryAttributeJavascript($attribute) {
$this->draw('Attribute::Javascript', $attribute);
$dn = '';
if ($attribute->getEntry()) $dn = $attribute->getEntry()->getDn();
if (!$dn) return;
static $already_draw = false;
if ($already_draw) return;
else $already_draw = true;
echo '
';
echo '
';
}
protected function drawBinaryAttributeBlurJavascript($attribute, $component) {
}
/***************************/
/* Paint a DateAttribute */
/***************************/
protected function drawDateAttributeReadWriteValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
printf(' ',
$attribute->getName(), $i, htmlspecialchars($attribute->getName()), $i, htmlspecialchars($val),
$attribute->getName(), $attribute->getName(),
($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '',
($attribute->getMaxLength() > 0) ? 'maxlength="'.$attribute->getMaxLength().'"' : '');
draw_date_selector_link($attribute->getName().'_'.$i);
echo '';
}
protected function drawDateAttributeJavascript($attribute) {
$this->draw('Attribute::Javascript', $attribute);
$entry['date'] = $_SESSION['plaConfig']->GetValue('appearance','date_attrs');
$entry['time'] = $_SESSION['plaConfig']->GetValue('appearance','date_attrs_showtime');
$entry['format'] = $_SESSION['plaConfig']->GetValue('appearance', 'date');
if (isset($entry['date'][$attribute->getName()]))
$entry['format'] = $entry['date'][$attribute->getName()];
//included in class page to avoid multiple inclusions
//printf('','../htdocs/'.JSDIR);
printf('','../htdocs/'.JSDIR);
printf('','../htdocs/'.JSDIR);
printf('','../htdocs/'.JSDIR);
for ($i = 0; $i <= $attribute->getValueCount(); $i++) {
printf('',$attribute->getName(),$i,$entry['format']);
if (in_array_ignore_case($attribute->getName(),array_keys($entry['time'])) && ($entry['time'][$attribute->getName()]))
printf('',$attribute->getName(),$i,'true');
}
}
/***************************/
/* Paint a DnAttribute */
/***************************/
protected function drawDnAttributeReadWriteValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
if ($attribute->hasProperty('helper')) {
echo '
';
}
$input_name = sprintf('new_values[%s][%s]', htmlspecialchars($attribute->getName()), $i);
$input_id = sprintf('new_values_%s_%s', htmlspecialchars($attribute->getName()), $i);
printf(' ',
$input_name, $input_id, htmlspecialchars($val),
$attribute->getName(), $attribute->getName(),
($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '',
($attribute->getMaxLength() > 0) ? 'maxlength="'.$attribute->getMaxLength().'"' : '');
/* draw a link for popping up the entry browser if this is the type of attribute
* that houses DNs. */
draw_chooser_link("entry_form.$input_id", false);
echo '';
if ($attribute->hasProperty('helper')) {
echo '
';
$this->draw('Helper', $attribute, $i);
echo '
';
}
}
protected function drawDnAttributeIcon($attribute, $val) {
$this->draw('DnValueIcon', $attribute, $val);
}
/***************************/
/* Paint a GidAttribute */
/***************************/
protected function drawGidAttributeReadWriteValue($attribute, $i) {
$this->draw('Attribute::ReadWriteValue', $attribute, $i);
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
$dn = '';
if ($attribute->getEntry()) $dn = $attribute->getEntry()->getDn();
# If this is a gidNumber on a non-PosixGroup entry, lookup its name and description for convenience
if (! in_array_ignore_case('posixGroup', $this->ldapserver->getDNAttr($dn, 'objectClass'))) {
$gid_number = $val;
$search_group_filter = "(&(objectClass=posixGroup)(gidNumber=$val))";
$group = $this->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('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$this->ldapserver->server_id, rawurlencode($group_dn));
echo '';
printf('%s', htmlspecialchars($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 '';
}
}
}
/***************************/
/* Paint a JpegAttribute */
/***************************/
protected function drawJpegAttributeValues($attribute) {
if ($attribute->isVisible()) {
$this->draw('StartValueLine', $attribute);
$value_count = $attribute->getValueCount();
if ($value_count > 0) {
/* Don't draw the delete buttons if there is more than one jpegPhoto
* (phpLDAPadmin can't handle this case yet) */
if ($attribute->getEntry() && $attribute->getEntry()->getDn()) {
draw_jpeg_photos($this->ldapserver, $attribute->getEntry()->getDn(),
$attribute->getName(), ! $attribute->isReadOnly()
&& $_SESSION['plaConfig']->isCommandAvailable('attribute_delete'));
}
} elseif ($attribute->isReadOnly() || ! $_SESSION['plaConfig']->isCommandAvailable('attribute_add_value')) {
printf(' ',_('[no value]'));
} else {
$i = 0;
$val = '';
$id = sprintf('new_values_%s_%s', htmlspecialchars($attribute->getName()), $i);
printf(' ',
htmlspecialchars($attribute->getName()), $i, $id,
htmlspecialchars($val), $attribute->getName(), $attribute->getName(),
($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '',
($attribute->getMaxLength() > 0) ? 'maxlength="'.$attribute->getMaxLength().'"' : '');
}
$this->draw('EndValueLine', $attribute);
} else {
$this->draw('BinaryAttribute::Values', $attribute);
}
}
/******************************/
/* Paint a MultiLineAttribute */
/******************************/
protected function drawMultiLineAttributeReadOnlyValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
printf(' ',
($attribute->getRows() > 0) ? 'rows="'.$attribute->getRows().'"' : '',
($attribute->getCols() > 0) ? 'cols="'.$attribute->getCols().'"' : '',
htmlspecialchars($attribute->getName()), $i,
htmlspecialchars($attribute->getName()), $i,
htmlspecialchars($val));
}
protected function drawMultiLineAttributeReadWriteValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
printf('',
($attribute->getRows() > 0) ? 'rows="'.$attribute->getRows().'"' : '',
($attribute->getCols() > 0) ? 'cols="'.$attribute->getCols().'"' : '',
htmlspecialchars($attribute->getName()), $i,
htmlspecialchars($attribute->getName()), $i,
$attribute->getName(), $attribute->getName(),
htmlspecialchars($val));
}
/********************************/
/* Paint a ObjectClassAttribute */
/********************************/
protected function drawObjectClassAttributeNewValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
$schema_object = ($val) ? $this->ldapserver->getSchemaObjectClass($val) : false;
$structural = (is_object($schema_object) && $schema_object->getType() == 'structural');
if (!$attribute->isVisible()) {
$this->draw('HiddenValue', $attribute, $i);
} elseif ($structural) {
# Is this value is a structural objectClass, make it read-only
printf('',
htmlspecialchars($attribute->getName()), $i,
htmlspecialchars($attribute->getName()), $i, htmlspecialchars($val));
printf(' (%s) ',
_('This is a structural ObjectClass and cannot be removed.'),
_('structural'));
} else {
$this->draw('Attribute::NewValue', $attribute, $i);
}
}
protected function drawObjectClassAttributeIcon($attribute, $val) {
if (strlen($val) > 0) {
$href = htmlspecialchars(sprintf('cmd.php?cmd=schema&server_id=%s&view=objectClasses&viewvalue=%s',
$this->ldapserver->server_id, $val));
printf(' ',
_('View the schema description for this objectClass'), htmlspecialchars($href));
}
}
/*****************************/
/* Paint a PasswordAttribute */
/*****************************/
protected function drawPasswordAttributeOldValue($attribute, $i) {
//if ($this->context == ENTRY_WRITER_CREATION_CONTEXT) {
$this->draw('Attribute::OldValue', $attribute, $i);
//}
}
protected function drawPasswordAttributeHiddenValue($attribute, $i) {
if ($this->context == ENTRY_WRITER_CREATION_CONTEXT) {
$this->draw('Attribute::HiddenValue', $attribute, $i);
}
}
protected function drawPasswordAttributeReadOnlyValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
$enc_type = get_enc_type($val);
if ($val == '') $enc_type = get_default_hash($this->ldapserver->server_id);
$obfuscate_password = obfuscate_password_display($enc_type);
printf(' ',
($obfuscate_password ? 'password' : 'text'),
htmlspecialchars($attribute->getName()), $i, htmlspecialchars($attribute->getName()),
$i, htmlspecialchars($val), ($attribute->getSize() > 0) ? 'size="'.$attribute->getSize().'"' : '');
if ($val != '') $this->draw('CheckLink', $attribute, 'new_values_'.htmlspecialchars($attribute->getName()).'_'.$i);
}
protected function drawPasswordAttributeReadWriteValue($attribute, $i) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
$enc_type = get_enc_type($val);
# Set the default hashing type if the password is blank (must be newly created)
if ($val == '') {
$enc_type = get_default_hash($this->ldapserver->server_id);
}
//printf('', $attribute->getName(), $i, htmlspecialchars($val));
//if (strlen($val) > 0) {
// if (obfuscate_password_display($enc_type)) {
// echo htmlspecialchars(preg_replace('/./','*', $val));
// } else {
// echo htmlspecialchars($val);
// }
// echo ' ';
//}
echo '