source: trunk/preferences/index.php @ 1611

Revision 1611, 5.1 KB checked in by eduardoalex, 14 years ago (diff)

Ticket #731 - Corrigida a funcao getTypeSignature e setada uma variavel global para controle das abas

  • 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        //Check preferences that influences the hooks
26        $c = CreateObject('phpgwapi.config','expressoMail1_2');
27        $c->read_repository();
28        $current_config = $c->config_data;
29        $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_expresso_offline'] = $current_config['enable_expresso_offline'];
30        /*print_r($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']);
31        exit;*/
32       
33        $pref_tpl->set_file($templates);
34
35        $pref_tpl->set_block('pref','list');
36        $pref_tpl->set_block('pref','app_row');
37        $pref_tpl->set_block('pref','app_row_noicon');
38        $pref_tpl->set_block('pref','link_row');
39        $pref_tpl->set_block('pref','spacer_row');
40
41        if ($GLOBALS['phpgw']->acl->check('run',1,'admin'))
42        {
43                // This is where we will keep track of our position.
44                // Developers won't have to pass around a variable then
45                $session_data = $GLOBALS['phpgw']->session->appsession('session_data','preferences');
46
47                if (! is_array($session_data))
48                {
49                        $session_data = array('type' => 'user');
50                        $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data);
51                }
52
53                if (! $GLOBALS['HTTP_GET_VARS']['type'])
54                {
55                        $GLOBALS['HTTP_GET_VARS']['type'] = $session_data['type'];
56                        $type = $session_data['type'];
57                }
58                else
59                {
60                        $type = $GLOBALS['HTTP_GET_VARS']['type'];
61                        $session_data = array('type' => $type);
62                        $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data);
63                }
64
65                $tabs[] = array(
66                        'label' => lang('Your preferences'),
67                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=user')
68                );
69                $tabs[] = array(
70                        'label' => lang('Default preferences'),
71                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=default')
72                );
73                $tabs[] = array(
74                        'label' => lang('Forced preferences'),
75                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=forced')
76                );
77
78                switch($type)
79                {
80                        case 'user':    $selected = 0; break;
81                        case 'default': $selected = 1; break;
82                        case 'forced':  $selected = 2; break;
83                }
84                $pref_tpl->set_var('tabs',$GLOBALS['phpgw']->common->create_tabs($tabs,$selected));
85        }
86
87        // This func called by the includes to dump a row header
88        function section_start($appname='',$icon='')
89        {
90                global $pref_tpl;
91
92                $pref_tpl->set_var('icon_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
93//              $pref_tpl->set_var('link_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
94                $pref_tpl->set_var('a_name',$appname);
95                $pref_tpl->set_var('app_name',$GLOBALS['phpgw_info']['apps'][$appname]['title']);
96                $pref_tpl->set_var('app_icon',$icon);
97                if ($icon)
98                {
99                        $pref_tpl->parse('rows','app_row',True);
100                }
101                else
102                {
103                        $pref_tpl->parse('rows','app_row_noicon',True);
104                }
105        }
106
107        function section_item($pref_link='',$pref_text='')
108        {
109                global $pref_tpl;
110
111                $pref_tpl->set_var('pref_link',$pref_link);
112
113                if (strtolower($pref_text) == 'grant access' && $GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
114                {
115                        return False;
116                }
117                else
118                {
119                        $pref_tpl->set_var('pref_text',$pref_text);
120                }
121
122                $pref_tpl->parse('rows','link_row',True);
123        }
124
125        function section_end()
126        {
127                global $pref_tpl;
128
129                $pref_tpl->parse('rows','spacer_row',True);
130        }
131
132        function display_section($appname,$file,$file2=False)
133        {
134                if ($file2)
135                {
136                        $file = $file2;
137                }
138                section_start($appname,$GLOBALS['phpgw']->common->image($appname,Array('navbar',$appname)));
139
140                while(list($text,$url) = each($file))
141                {
142                        if (($text == 'Change your Password') && ($GLOBALS['phpgw_info']['server']['use_https'] == 1))
143                        {
144                                $url = 'https://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/changepassword.php';
145                        }
146
147                        if($text == 'Expresso Offline' &&
148                                $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_expresso_offline']!='True')
149                                continue;
150                        if($text == 'Programed Archiving' && 
151                                $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages']!='1')
152                                continue;                       
153                        section_item($url,lang($text));
154                }
155                section_end();
156        }
157
158        $GLOBALS['phpgw']->hooks->process('preferences',array('preferences'));
159        $pref_tpl->pfp('out','list');
160        $GLOBALS['phpgw']->common->phpgw_footer();
161?>
Note: See TracBrowser for help on using the repository browser.