phpldapadmin/htdocs/template_engine.php

70 lines
2.4 KiB
PHP
Raw Normal View History

2009-06-30 09:29:51 +00:00
<?php
2009-06-30 11:46:44 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/template_engine.php,v 1.45.2.1 2007/12/26 09:26:32 wurley Exp $
2009-06-30 09:29:51 +00:00
/**
* Template render engine.
* @param dn $dn DN of the object being edited. (For editing existing entries)
* @param dn $container DN where the new object will be created. (For creating new entries)
* @param string $template to use for new entry. (For creating new entries)
* @todo schema attr keys should be in lowercase.
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
*/
/**
*/
2009-06-30 10:46:00 +00:00
require_once './common.php';
2009-06-30 10:26:08 +00:00
2009-06-30 10:46:00 +00:00
$entry['dn']['encode'] = get_request('dn','REQUEST');
$entry['dn']['string'] = rawurldecode($entry['dn']['encode']);
$entry['template'] = get_request('template','REQUEST',false,'');
2009-06-30 09:29:51 +00:00
# If we have a DN, then this is to edit the entry.
2009-06-30 10:46:00 +00:00
if ($entry['dn']['string']) {
$ldapserver->dnExists($entry['dn']['string'])
or pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($entry['dn']['string'])));
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
$tree = get_cached_item($ldapserver->server_id,'tree');
2009-06-30 10:40:33 +00:00
2009-06-30 10:46:00 +00:00
if ($tree) {
$entry['dn']['tree'] = $tree->getEntry($entry['dn']['string']);
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
if (! $entry['dn']['tree']) {
/*
* The entry doesn't exists in the tree because it
* may be filtered ; as we ask for its display, we
* add all the same the entry in the tree
*/
$tree->addEntry($entry['dn']['string']);
$entry['dn']['tree'] = $tree->getEntry($entry['dn']['string']);
2009-06-30 09:29:51 +00:00
}
2009-06-30 10:46:00 +00:00
if ($entry['dn']['tree']) {
2009-06-30 11:46:44 +00:00
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);');
2009-06-30 10:46:00 +00:00
$entry['dn']['tree']->accept($reader);
2009-06-30 10:26:08 +00:00
2009-06-30 11:46:44 +00:00
eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_writer').'($ldapserver);');
2009-06-30 10:46:00 +00:00
$entry['dn']['tree']->accept($writer);
2009-06-30 09:29:51 +00:00
}
2009-06-30 10:26:08 +00:00
}
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
} else {
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
# Create a new empty entry
2009-06-30 11:46:44 +00:00
$entryfactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','entry_factory');
2009-06-30 10:46:00 +00:00
eval('$entry_factory = new '.$entryfactoryclass.'();');
$entry['dn']['tree'] = $entry_factory->newCreatingEntry('');
2009-06-30 10:26:08 +00:00
2009-06-30 10:46:00 +00:00
# Init the entry with incoming data
2009-06-30 11:46:44 +00:00
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);');
2009-06-30 10:46:00 +00:00
$entry['dn']['tree']->accept($reader);
2009-06-30 10:26:08 +00:00
2009-06-30 10:46:00 +00:00
# Display the creating entry
2009-06-30 11:46:44 +00:00
eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_writer').'($ldapserver);');
2009-06-30 10:46:00 +00:00
$entry['dn']['tree']->accept($writer);
2009-06-30 10:26:08 +00:00
}
?>