File: template_engine.php

package info (click to toggle)
ldap-account-manager 4.7.1-1%2Bdeb8u1
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 42,924 kB
  • sloc: php: 67,802; perl: 379; pascal: 215; xml: 214; sh: 177; makefile: 167
file content (57 lines) | stat: -rw-r--r-- 2,201 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
 * Template render engine.
 *
 * @package phpLDAPadmin
 * @subpackage Page
 * @author The phpLDAPadmin development team
 */

/**
The template engine has the following responsibilities:
* If we are passed a DN, then we are editing an existing entry
* If we are not passed a DN, then we are passed a container (and creating a new entry in that container)

In both cases, we are optionally passed a template ID. 
* If we have a template ID, then we'll render the creation/editing using that template
* If we are not passed a template ID, then we'll either:
	* Present a list of available templates,
	* Present the default template, because there are non available (due to hidden,regexp or non-existant)
	* Present the only template, if there is only one.

Creating and editing entries use two objects:
* A template object which describes how the template should be rendered (and what values should asked for, etc)
* A page object, which is responsible for actually sending out the HTML to the browser.

So:
* we init a new TemplateRender object
* we init a new Template object
* set the DN or container on the template object
	* If setting the DN, this in turn should read the "old values" from the LDAP server
* If we are not on the first page (ie: 2nd, 3rd, 4th step, etc), we should accept the post values that we have obtained thus far

* Finally submit the update to "update_confirm", or the create to "create", when complete.
 */

require './common.php';

$request = array();
$request['dn'] = get_request('dn','REQUEST');
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));

# If we have a DN, then this is to edit the entry.
if ($request['dn']) {
	$app['server']->dnExists($request['dn'])
		or error(sprintf('%s (%s)',_('No such entry'),pretty_print_dn(htmlspecialchars($request['dn']))),'error','index.php');

	$request['page']->setDN($request['dn']);
	$request['page']->accept();

} else {
	if ($app['server']->isReadOnly())
		error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');

	$request['page']->setContainer(get_request('container','REQUEST'));
	$request['page']->accept();
}
?>