';
}
protected function drawDefaultCreatingEntryShownAttributes($entry) {
$attrs = array();
# Put required attributes first
foreach ($this->shown_attributes as $sa)
if ($sa->isRequired()) $attrs[] = $sa;
foreach ($this->shown_attributes as $sa)
if (!$sa->isRequired()) $attrs[] = $sa;
$has_required_attrs = false;
$has_optional_attrs = false;
foreach ($attrs as $attr) {
if ($attr->isRequired()) {
if (!$has_required_attrs) {
printf('
%s
', _('Required Attributes'));
$has_required_attrs = true;
}
} else {
if (!$has_optional_attrs) {
if (!$has_required_attrs) {
printf('
';
}
}
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,$entry);
echo "\n";
} 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) {
$this->draw('',$attr,$entry);
echo "\n";
}
}
protected function drawTemplateCreatingEntryJavascript($entry) {
printf("\n\n",__METHOD__);
$this->draw('DefaultCreatingEntry::Javascript', $entry);
$templates = new Templates($this->index);
foreach ($entry->getAttributes() as $attribute) {
if ($attribute->hasProperty('onchange')) {
$onchange = $attribute->getProperty('onchange');
if (is_array($onchange)) {
foreach ($onchange as $value)
$templates->OnChangeAdd($this->getLDAPServer(),$attribute->getName(),$value);
} else {
$templates->OnChangeAdd($this->getLDAPServer(),$attribute->getName(),$onchange);
}
}
}
$hash = $templates->getJsHash();
echo '';
printf("\n\n",__METHOD__);
}
/********************************/
/* 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,$entry);
echo "\n";
}
}
protected function drawTemplateEditingEntryHiddenAttributes($entry) {
printf('', $entry->getSelectedTemplateName());
$this->draw('DefaultEditingEntry::HiddenAttributes', $entry);
}
protected function drawTemplateEditingEntryJavascript($entry) {
printf("\n\n",__METHOD__);
$this->draw('DefaultEditingEntry::Javascript', $entry);
$templates = new Templates($this->index);
foreach ($entry->getAttributes() as $attribute) {
if ($attribute->hasProperty('onchange')) {
$onchange = $attribute->getProperty('onchange');
if (is_array($onchange)) {
foreach ($onchange as $value)
$templates->OnChangeAdd($this->getLDAPServer(),$attribute->getName(),$value);
} else {
$templates->OnChangeAdd($this->getLDAPServer(),$attribute->getName(),$onchange);
}
}
}
$hash = $templates->getJsHash();
echo '';
printf("\n\n",__METHOD__);
}
/**************************/
/* Paint an Attribute */
/**************************/
protected function drawAttribute($attribute,$entry) {
if ($attribute->isVisible()) $this->draw('Informations', $attribute);
$this->draw('Values',$attribute,$entry);
}
protected function drawAttributeJavascript($attribute) {
echo ''."\n";
}
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" : \'#FFFFA0\';
comp[i].style.color = '.$var_valid.' ? "black" : \'#00005F\';
}';
}
}
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.'));';
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.'));';
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[APPCONFIG]->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;
}
$hint_note = $this->get('HintNote',$attribute);
if ($hint_note) {
if (trim($attr_note)) $attr_note .= ', ';
$attr_note .= $hint_note;
}
if ($attr_note) printf('%s', $attr_note);
if ($attribute->isReadOnly() && $this->getLDAPServer()->isAttrReadOnly($attribute->getName())) {
printf('(%s)',
_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),
_('read only'));
}
}
protected function drawAttributeValues($attribute,$entry) {
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,$entry);
}
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,$entry);
}
}
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()
&& $_SESSION[APPCONFIG]->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[APPCONFIG]->GetValue('modify_member','groupattr'))) {
if ($attribute->isVisible() && !$attribute->isReadOnly() && !$attribute->isRdn()
&& ($_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')
|| $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value'))) {
return $this->get('ModifyMemberMenuItem', $attribute);
}
}
return '';
case IdAttributeRenameMenuItem :
if ($attribute->isVisible() && $attribute->isRdn() && !$attribute->isReadOnly()
&& $_SESSION[APPCONFIG]->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,$entry) {
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) {
if ($this->context == ENTRY_WRITER_EDITING_CONTEXT)
$val = $attribute->getValue($i);
else
$val = '';
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,$entry) {
if (!$attribute->isVisible()) {
$this->draw('HiddenValue', $attribute, $i);
$this->draw('Javascript',$attribute);
} elseif ($attribute->isReadOnly() || ($attribute->getEntry() && $attribute->getEntry()->getDn() && $attribute->isRdn())) {
/* If this is the RDN, we need to see if it has multiple values. If it does, and the multivalues are not
* not in the RDN, then we need to make them editable. */
if ($attribute->isRdn()) {
$rdn = split('\+',get_rdn($entry->getDN()));
if (in_array(sprintf('%s=%s',$attribute->getName(),$attribute->getValue($i)),$rdn))
$this->draw('ReadOnlyValue', $attribute, $i);
else
$this->draw('ReadWriteValue', $attribute, $i);
} else
$this->draw('ReadOnlyValue', $attribute, $i);
} else {
$this->draw('ReadWriteValue', $attribute, $i);
}
}
protected function drawAttributeBlankValue($attribute,$i,$entry) {
$this->draw('Value',$attribute,$i,$entry);
}
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->index, $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->index, $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->index, $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->getLDAPServer()->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) {
printf(' ',IMGDIR);
} elseif ($this->getLDAPServer()->dnExists($val)) {
printf(' ',
_('Go to'),htmlspecialchars($val),$this->index,rawurlencode($val),IMGDIR);
} else {
printf(' ',_('DN not available'),htmlspecialchars($val),IMGDIR);
}
}
protected function drawAttributeMailValueIcon($attribute, $val) {
$img = sprintf('',IMGDIR,_('Mail'));
if (strlen($val) <= 0) echo $img;
else printf(''.$img.'', htmlspecialchars($val));
echo ' ';
}
protected function drawAttributeUrlValueIcon($attribute, $val) {
$img = sprintf('',IMGDIR,_('URL'));
$url = split(' +',$val,2);
if (strlen($val) <= 0) echo $img;
else printf('%s',htmlspecialchars($url[0]),$img);
echo ' ';
}
protected function drawAttributeName($attribute) {
$config = $_SESSION[APPCONFIG];
$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->index, 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 sprintf('%s',
_('Note'),$friendly_name,_('is an alias for'),$attribute->getName(),_('alias'));
else
return '';
}
protected function getAttributeRequiredNote($attribute) {
# is this attribute required by an objectClass ?
$required_by = '';
if ($attribute->getEntry()) {
$schema_attr = $this->getLDAPServer()->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 getAttributeHintNote($attribute) {
# Is there a hint for this attribute
if ($attribute->getHint()) {
return sprintf('%s ',htmlspecialchars($attribute->getHint()),_('hint'));
} 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->index, rawurlencode($attribute->getEntry()->getDn()),
$attribute->getName());
if ($valcount > 1) {
for ($i=1; $i<=$valcount; $i++) {
printf(' %s(%s) ',
htmlspecialchars($href), $i,IMGDIR,_('download value'), $i);
}
} else {
printf(' %s ',
htmlspecialchars($href),IMGDIR,_('download value'));
}
}
if (! $attribute->isReadOnly() && $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete')) {
printf(''.
' %s',
$attribute->getName(), $attribute->getFriendlyName(),IMGDIR,_('delete attribute'));
}
} elseif ($attribute->isReadOnly() || ! $_SESSION[APPCONFIG]->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) {
printf("\n\n",__METHOD__);
$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 '
';
printf("\n\n",__METHOD__);
}
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 ''."\n";
}
protected function drawDateAttributeJavascript($attribute) {
printf("\n\n",__METHOD__);
$this->draw('Attribute::Javascript', $attribute);
$entry['date'] = $_SESSION[APPCONFIG]->GetValue('appearance','date_attrs');
$entry['time'] = $_SESSION[APPCONFIG]->GetValue('appearance','date_attrs_showtime');
$entry['format'] = $_SESSION[APPCONFIG]->GetValue('appearance', 'date');
if (isset($entry['date'][$attribute->getName()]))
$entry['format'] = $entry['date'][$attribute->getName()];
printf('',JSDIR);
printf('',JSDIR);
printf('',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');
}
printf("\n\n",__METHOD__);
}
/***************************/
/* 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 '
';
}
echo "\n";
}
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->getLDAPServer()->getDNAttr($dn, 'objectClass'))) {
$gid_number = $val;
$search_group_filter = "(&(objectClass=posixGroup)(gidNumber=$val))";
$group = $this->getLDAPServer()->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->index, 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->getLDAPServer(), $attribute->getEntry()->getDn(),
$attribute->getName(), ! $attribute->isReadOnly()
&& $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete'));
}
} elseif ($attribute->isReadOnly() || ! $_SESSION[APPCONFIG]->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,$entry) {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
$schema_object = ($val) ? $this->getLDAPServer()->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,$entry);
}
}
protected function drawObjectClassAttributeIcon($attribute, $val) {
if (strlen($val) > 0) {
$href = sprintf('cmd.php?cmd=schema&server_id=%s&view=objectClasses&viewvalue=%s',
$this->index, $val);
printf(' ',
_('View the schema description for this objectClass'), htmlspecialchars($href),IMGDIR);
}
}
/*****************************/
/* Paint a PasswordAttribute */
/*****************************/
protected function drawPasswordAttributeOldValue($attribute, $i) {
$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->index);
$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->index);
echo '
';
}
} else {
$val = $attribute->getValue($i);
if (!is_string($val)) $val = '';
if ($i < 0) $i = 0;
if ($attribute->hasProperty('helper'))
echo '
';
$found = false;
$empty_value = false;
$id = 'new_values_'.htmlspecialchars($attribute->getName()).'_'.$i;
# If we are a required attribute, and the selection is blank, then the user cannot submit this form.
if ($attribute->isRequired() && ! count($attribute->getSelection()))
system_message(array(
'title'=>_('Template Value Error'),
'body'=>sprintf('This template uses a selection list for attribute [%s], however the selection list is empty. You may need to create some dependancy entries in your LDAP server so that this attribute renders with values. Alternatively, you may be able to define the appropriate selection values in the template file.',$attribute->getName()),
'type'=>'warn'));
printf('';
if ($attribute->hasProperty('helper')) {
echo '