0
|
1 |
<?php
|
|
2 |
|
|
3 |
function display_template($tpl, $assign = array())
|
|
4 |
{
|
|
5 |
$smarty = new Smarty();
|
|
6 |
|
|
7 |
$smarty->setTemplateDir(ACCOUNTS . 'includes/templates/');
|
|
8 |
$smarty->setCompileDir(ACCOUNTS . 'includes/templates/compiled/');
|
|
9 |
$smarty->setConfigDir(ACCOUNTS . 'includes/templates/');
|
|
10 |
$smarty->setCacheDir(ACCOUNTS . 'includes/templates/cache/');
|
|
11 |
|
|
12 |
$smarty->assign('session', $_SESSION);
|
|
13 |
|
|
14 |
$smarty->assign('user', isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : false);
|
|
15 |
if ( isset($_SERVER['REMOTE_USER']) )
|
|
16 |
$smarty->assign('userinfo', $ui = ldap_get_user($_SERVER['REMOTE_USER']));
|
|
17 |
|
3
|
18 |
$smarty->assign('is_admin', IS_ADMIN);
|
|
19 |
|
0
|
20 |
if ( $ui === false )
|
|
21 |
redirect('/logout');
|
|
22 |
|
|
23 |
$smarty->assign('msgcodes', array(
|
|
24 |
'error' => E_ERROR
|
|
25 |
, 'warning' => E_WARNING
|
|
26 |
, 'notice' => E_NOTICE
|
|
27 |
));
|
|
28 |
|
|
29 |
foreach ( $assign as $key => $value )
|
|
30 |
{
|
|
31 |
$smarty->assign($key, $value);
|
|
32 |
}
|
|
33 |
|
|
34 |
$smarty->display("$tpl.tpl");
|
|
35 |
}
|
|
36 |
|
|
37 |
function parse_template($tpl, $assign = array())
|
|
38 |
{
|
|
39 |
$smarty = new Smarty();
|
|
40 |
|
|
41 |
$smarty->setTemplateDir(ACCOUNTS . 'includes/templates/');
|
|
42 |
$smarty->setCompileDir(ACCOUNTS . 'includes/templates/compiled/');
|
|
43 |
$smarty->setConfigDir(ACCOUNTS . 'includes/templates/');
|
|
44 |
$smarty->setCacheDir(ACCOUNTS . 'includes/templates/cache/');
|
|
45 |
|
|
46 |
foreach ( $assign as $key => $value )
|
|
47 |
{
|
|
48 |
$smarty->assign($key, $value);
|
|
49 |
}
|
|
50 |
|
|
51 |
return $smarty->fetch("$tpl.tpl");
|
|
52 |
}
|
|
53 |
|
|
54 |
function smarty_function_clear_messages($params)
|
|
55 |
{
|
|
56 |
$_SESSION['messages'] = array();
|
|
57 |
}
|