1<?php 2 /**************************************************************************\ 3 * phpGroupWare * 4 * http://www.phpgroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: navbar.inc.php 16322 2005-12-07 23:08:55Z skwashd $ */ 13 14 function parse_navbar($force = False) 15 { 16 $tpl = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR); 17 $tpl->set_unknowns('remove'); 18 19 $tpl->set_file( 20 array( 21 'navbar' => 'navbar.tpl', 22 'navbar_app' => 'navbar_app.tpl' 23 ) 24 ); 25 26 $var['navbar_color'] = $GLOBALS['phpgw_info']['theme']['navbar_bg']; 27 28 if ($GLOBALS['phpgw_info']['flags']['navbar_target']) 29 { 30 $target = ' target="' . $GLOBALS['phpgw_info']['flags']['navbar_target'] . '"'; 31 } 32 33 $i = 1; 34 foreach($GLOBALS['phpgw_info']['navbar'] as $app => $app_data) 35 { 36 if ($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format'] == 'text') 37 { 38 $tabs[$i]['label'] = $app_data['title']; 39 $tabs[$i]['link'] = $app_data['url']; 40 if (ereg($GLOBALS['phpgw_info']['navbar'][$app],$PHP_SELF)) 41 { 42 $selected = $i; 43 } 44 $i++; 45 } 46 else 47 { 48 $title = '<img src="' . $app_data['icon'] . '" alt="' . $app_data['title'] . '" title="' 49 . $app_data['title'] . '" border="0">'; 50 if ($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format'] == 'icons_and_text') 51 { 52 $title .= "<br />" . $app_data['title']; 53 $var['width'] = '7%'; 54 } 55 else 56 { 57 $var['width'] = '3%'; 58 } 59 60 $var['value'] = '<a href="' . $app_data['url'] . '"' . $target . '>' . $title . '</a>'; 61 $var['align'] = 'center'; 62 $tpl->set_var($var); 63 $tpl->parse('applications','navbar_app',True); 64 } 65 } 66 if ($GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format'] == 'text') 67 { 68 $var['navbar_color'] = $GLOBALS['phpgw_info']['theme']['bg_color']; 69 $var['align'] = 'right'; 70 $var['value'] = $GLOBALS['phpgw']->common->create_tabs($tabs,$selected,-1); 71 $tpl->set_var($var); 72 $tpl->parse('applications','navbar_app',True); 73 } 74 75 if ($GLOBALS['phpgw_info']['server']['showpoweredbyon'] == 'top') 76 { 77 $var['powered_by'] = lang('Powered by phpGroupWare version %1',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']); 78 } 79 if (isset($GLOBALS['phpgw_info']['navbar']['admin']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) 80 { 81 $var['current_users'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions') 82 . '"> ' . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>'; 83 } 84 $now = time(); 85 $var['user_info'] = $GLOBALS['phpgw']->common->display_fullname() . ' - ' 86 . lang($GLOBALS['phpgw']->common->show_date($now,'l')) . ' ' 87 . $GLOBALS['phpgw']->common->show_date($now,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); 88// . lang($GLOBALS['phpgw']->common->show_date($now,'F')) . ' ' 89// . $GLOBALS['phpgw']->common->show_date($now,'d, Y'); 90 91 // Maybe we should create a common function in the phpgw_accounts_shared.inc.php file 92 // to get rid of duplicate code. 93 if ( $GLOBALS['phpgw']->acl->check('changepassword', 1, 'preferences') ) 94 { 95 if ( intval($GLOBALS['phpgw_info']['user']['lastpasswd_change']) == 0) 96 { 97 $api_messages = lang('You are required to change your password during your first login') 98 . '<br /> Click <a href="' . $GLOBALS['phpgw']->link('/preferences/changepassword.php') . '">here</a>'; 99 } 100 else if ($GLOBALS['phpgw_info']['user']['lastpasswd_change'] < time() - (86400*30)) 101 { 102 $api_messages = lang('it has been more than %1 days since you changed your password',30) 103 . '<br /> Click <a href="' . $GLOBALS['phpgw']->link('/preferences/changepassword.php') . '">' . lang('here') . '</a>'; 104 } 105 106 if($api_messages) 107 { 108 $url = parse_url($GLOBALS['phpgw']->link('/preferences/changepassword.php')); 109 if($_SERVER['PHP_SELF'] != $url['path']) 110 { 111 $var['messages'] = $api_messages; 112 } 113 } 114 } 115 116 // This is gonna change 117 if (isset($cd)) 118 { 119 $var['messages'] = $api_messages . '<br />' . checkcode($cd); 120 } 121 122 if (isset($GLOBALS['phpgw_info']['flags']['app_header'])) 123 { 124 $var['current_app_header'] = $GLOBALS['phpgw_info']['flags']['app_header']; 125 $var['th_bg'] = $GLOBALS['phpgw_info']['theme']['th_bg']; 126 } 127 else 128 { 129 $tpl->set_block('navbar','app_header','app_header'); 130 $var['app_header'] = ''; 131 } 132 133 $tpl->set_var($var); 134 $tpl->pfp('out','navbar'); 135 // If the application has a header include, we now include it 136 if (!@$GLOBALS['phpgw_info']['flags']['noappheader'] && @isset($GLOBALS['HTTP_GET_VARS']['menuaction'])) 137 { 138 list($app,$class,$method) = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); 139 if (is_array($GLOBALS[$class]->public_functions) && $GLOBALS[$class]->public_functions['header']) 140 { 141 $GLOBALS[$class]->header(); 142 } 143 } 144 $GLOBALS['phpgw']->hooks->process('after_navbar'); 145 return; 146 } 147 148 function parse_navbar_end() 149 { 150 if ($GLOBALS['phpgw_info']['server']['showpoweredbyon'] == 'bottom') 151 { 152 $tpl = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR); 153 $tpl->set_unknowns('remove'); 154 155 $tpl->set_file( 156 array( 157 'footer' => 'footer.tpl' 158 ) 159 ); 160 $var = Array( 161 'table_bg_color' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 162 ); 163 $var['powered_by'] = lang('Powered by phpGroupWare version %1',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']); 164 if (isset($GLOBALS['phpgw_info']['navbar']['admin']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers']) 165 { 166 $var['current_users'] = '<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicurrentsessions.list_sessions') 167 . '"> ' . lang('Current users') . ': ' . $GLOBALS['phpgw']->session->total() . '</a>'; 168 } 169 $now = time(); 170 $var['user_info'] = $GLOBALS['phpgw']->common->display_fullname() . ' - ' 171 . lang($GLOBALS['phpgw']->common->show_date($now,'l')) . ' ' 172 . $GLOBALS['phpgw']->common->show_date($now,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); 173 $tpl->set_var($var); 174 $GLOBALS['phpgw']->hooks->process('navbar_end'); 175 $tpl->pfp('out','footer'); 176 } 177 } 178