|
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 |
|
18 if ( $ui === false ) |
|
19 redirect('/logout'); |
|
20 |
|
21 $smarty->assign('msgcodes', array( |
|
22 'error' => E_ERROR |
|
23 , 'warning' => E_WARNING |
|
24 , 'notice' => E_NOTICE |
|
25 )); |
|
26 |
|
27 foreach ( $assign as $key => $value ) |
|
28 { |
|
29 $smarty->assign($key, $value); |
|
30 } |
|
31 |
|
32 $smarty->display("$tpl.tpl"); |
|
33 } |
|
34 |
|
35 function parse_template($tpl, $assign = array()) |
|
36 { |
|
37 $smarty = new Smarty(); |
|
38 |
|
39 $smarty->setTemplateDir(ACCOUNTS . 'includes/templates/'); |
|
40 $smarty->setCompileDir(ACCOUNTS . 'includes/templates/compiled/'); |
|
41 $smarty->setConfigDir(ACCOUNTS . 'includes/templates/'); |
|
42 $smarty->setCacheDir(ACCOUNTS . 'includes/templates/cache/'); |
|
43 |
|
44 foreach ( $assign as $key => $value ) |
|
45 { |
|
46 $smarty->assign($key, $value); |
|
47 } |
|
48 |
|
49 return $smarty->fetch("$tpl.tpl"); |
|
50 } |
|
51 |
|
52 function smarty_function_clear_messages($params) |
|
53 { |
|
54 $_SESSION['messages'] = array(); |
|
55 } |