source: trunk/preferences/index.php @ 2

Revision 2, 4.1 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * phpGroupWare - preferences                                               *
4        * http://www.phpgroupware.org                                              *
5        * Written by Joseph Engo <jengo@phpgroupware.org>                          *
6        * --------------------------------------------                             *
7        *  This program is free software; you can redistribute it and/or modify it *
8        *  under the terms of the GNU General Public License as published by the   *
9        *  Free Software Foundation; either version 2 of the License, or (at your  *
10        *  option) any later version.                                              *
11        \**************************************************************************/
12
13
14        $phpgw_info = array();
15        $GLOBALS['phpgw_info']['flags'] = array(
16                'currentapp' => 'preferences',
17                'disable_Template_class' => True
18        );
19        include('../header.inc.php');
20
21        $pref_tpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
22        $templates = Array(
23                'pref' => 'index.tpl'
24        );
25
26        $pref_tpl->set_file($templates);
27
28        $pref_tpl->set_block('pref','list');
29        $pref_tpl->set_block('pref','app_row');
30        $pref_tpl->set_block('pref','app_row_noicon');
31        $pref_tpl->set_block('pref','link_row');
32        $pref_tpl->set_block('pref','spacer_row');
33
34        if ($GLOBALS['phpgw']->acl->check('run',1,'admin'))
35        {
36                // This is where we will keep track of our position.
37                // Developers won't have to pass around a variable then
38                $session_data = $GLOBALS['phpgw']->session->appsession('session_data','preferences');
39
40                if (! is_array($session_data))
41                {
42                        $session_data = array('type' => 'user');
43                        $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data);
44                }
45
46                if (! $GLOBALS['HTTP_GET_VARS']['type'])
47                {
48                        $type = $session_data['type'];
49                }
50                else
51                {
52                        $type = $GLOBALS['HTTP_GET_VARS']['type'];
53                        $session_data = array('type' => $type);
54                        $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data);
55                }
56
57                $tabs[] = array(
58                        'label' => lang('Your preferences'),
59                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=user')
60                );
61                $tabs[] = array(
62                        'label' => lang('Default preferences'),
63                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=default')
64                );
65                $tabs[] = array(
66                        'label' => lang('Forced preferences'),
67                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=forced')
68                );
69
70                switch($type)
71                {
72                        case 'user':    $selected = 0; break;
73                        case 'default': $selected = 1; break;
74                        case 'forced':  $selected = 2; break;
75                }
76                $pref_tpl->set_var('tabs',$GLOBALS['phpgw']->common->create_tabs($tabs,$selected));
77        }
78
79        // This func called by the includes to dump a row header
80        function section_start($appname='',$icon='')
81        {
82                global $pref_tpl;
83
84                $pref_tpl->set_var('icon_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
85//              $pref_tpl->set_var('link_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
86                $pref_tpl->set_var('a_name',$appname);
87                $pref_tpl->set_var('app_name',$GLOBALS['phpgw_info']['apps'][$appname]['title']);
88                $pref_tpl->set_var('app_icon',$icon);
89                if ($icon)
90                {
91                        $pref_tpl->parse('rows','app_row',True);
92                }
93                else
94                {
95                        $pref_tpl->parse('rows','app_row_noicon',True);
96                }
97        }
98
99        function section_item($pref_link='',$pref_text='')
100        {
101                global $pref_tpl;
102
103                $pref_tpl->set_var('pref_link',$pref_link);
104
105                if (strtolower($pref_text) == 'grant access' && $GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
106                {
107                        return False;
108                }
109                else
110                {
111                        $pref_tpl->set_var('pref_text',$pref_text);
112                }
113
114                $pref_tpl->parse('rows','link_row',True);
115        }
116
117        function section_end()
118        {
119                global $pref_tpl;
120
121                $pref_tpl->parse('rows','spacer_row',True);
122        }
123
124        function display_section($appname,$file,$file2=False)
125        {
126                if ($file2)
127                {
128                        $file = $file2;
129                }
130                section_start($appname,$GLOBALS['phpgw']->common->image($appname,Array('navbar',$appname)));
131
132                while(list($text,$url) = each($file))
133                {
134                        section_item($url,lang($text));
135                }
136                section_end();
137        }
138
139        $GLOBALS['phpgw']->hooks->process('preferences',array('preferences'));
140        $pref_tpl->pfp('out','list');
141        $GLOBALS['phpgw']->common->phpgw_footer();
142?>
Note: See TracBrowser for help on using the repository browser.