<?php
	/****************************************************************************\
	* phpGroupWare - FUDforum 2.6.0 equivalent                                   *
	* http://fud.prohost.org/                                                    *
	* Written by Ilia Alshanetsky <ilia@prohost.org>                             *
	* -------------------------------------------                                *
	*  This program is free software; you can redistribute it and/or modify it   *
	*  under the terms of the GNU General Public License as published by the     *
	*  Free Software Foundation; either version 2 of the License, or (at your    *
	*  option) any later version.                                                *
	\****************************************************************************/

class fud_sidebox_hooks
{
	function all_hooks($args)
	{
		if (!function_exists('db_saq')) {
			fud_use('db.inc');
		}
		if ($GLOBALS['phpgw_info']['server']['db_type'] == 'pgsql' && !function_exists('pg_query'))
		{
			function pg_query($conn, $sql)
			{
				return pg_exec($conn, $sql);
			}
		}
		$GLOBALS['adm_file'] = array();
		list($GLOBALS['fudh_uopt'], $theme_name) = db_saq("SELECT u.users_opt, t.name FROM phpgw_fud_users u INNER JOIN phpgw_fud_themes t ON t.id=u.theme WHERE u.id!=1 AND u.phpgw_id=".(int)$GLOBALS['phpgw_info']['user']['account_id']);
		$GLOBALS['fudh_uopt'] = (int) $GLOBALS['fudh_uopt'];
		if (!empty($GLOBALS['phpgw_info']['user']['apps']['admin'])) {
			$GLOBALS['fudh_uopt'] |= 1048576;
		}
		include_once($GLOBALS['DATA_DIR'].'include/theme/'.str_replace(' ', '_', $theme_name).'/usercp.inc');

		/* regular user links */
		if (!empty($GLOBALS['t'])) {
			foreach($GLOBALS['usr_file'] as $key => $val)
			{
				$GLOBALS['usr_file'][$key]['url'] = $val['url'] .'&click_history='.$GLOBALS['phpgw']->session->generate_click_history();
				if (preg_match('|(.*)<span([^>]*)>(.*)</span>(.*)|si', $GLOBALS['usr_file'][$key]['text'], $matches))
				{
					if ($GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'] == 'probusiness')
						$GLOBALS['usr_file'][$key]['text'] = $matches[1].$matches[3].$matches[4];
				}
			}
			display_sidebox('fudforum', lang('Preferences'), $GLOBALS['usr_file'], false);
		}

		/* admin stuff */
		if ($GLOBALS['adm_file']) {
			foreach($GLOBALS['adm_file'] as $key => $val)
				$GLOBALS['adm_file'][$key]['url'] = $val['url'] .'&click_history='.$GLOBALS['phpgw']->session->generate_click_history();
			display_sidebox('fudforum', lang('Administration'), $GLOBALS['adm_file'], false);
		}
	}
}

?>
