source: branches/2.3/preferences/index.php @ 1873

Revision 1873, 5.0 KB checked in by wmerlotto, 14 years ago (diff)

Ticket #731 - Revertendo a revisão [1611], conforme bug encontrado.

  • 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                        $type = $session_data['type'];
56                }
57                else
58                {
59                        $type = $GLOBALS['HTTP_GET_VARS']['type'];
60                        $session_data = array('type' => $type);
61                        $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data);
62                }
63
64                $tabs[] = array(
65                        'label' => lang('Your preferences'),
66                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=user')
67                );
68                $tabs[] = array(
69                        'label' => lang('Default preferences'),
70                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=default')
71                );
72                $tabs[] = array(
73                        'label' => lang('Forced preferences'),
74                        'link'  => $GLOBALS['phpgw']->link('/preferences/index.php','type=forced')
75                );
76
77                switch($type)
78                {
79                        case 'user':    $selected = 0; break;
80                        case 'default': $selected = 1; break;
81                        case 'forced':  $selected = 2; break;
82                }
83                $pref_tpl->set_var('tabs',$GLOBALS['phpgw']->common->create_tabs($tabs,$selected));
84        }
85
86        // This func called by the includes to dump a row header
87        function section_start($appname='',$icon='')
88        {
89                global $pref_tpl;
90
91                $pref_tpl->set_var('icon_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
92//              $pref_tpl->set_var('link_backcolor',$GLOBALS['phpgw_info']['theme']['row_off']);
93                $pref_tpl->set_var('a_name',$appname);
94                $pref_tpl->set_var('app_name',$GLOBALS['phpgw_info']['apps'][$appname]['title']);
95                $pref_tpl->set_var('app_icon',$icon);
96                if ($icon)
97                {
98                        $pref_tpl->parse('rows','app_row',True);
99                }
100                else
101                {
102                        $pref_tpl->parse('rows','app_row_noicon',True);
103                }
104        }
105
106        function section_item($pref_link='',$pref_text='')
107        {
108                global $pref_tpl;
109
110                $pref_tpl->set_var('pref_link',$pref_link);
111
112                if (strtolower($pref_text) == 'grant access' && $GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
113                {
114                        return False;
115                }
116                else
117                {
118                        $pref_tpl->set_var('pref_text',$pref_text);
119                }
120
121                $pref_tpl->parse('rows','link_row',True);
122        }
123
124        function section_end()
125        {
126                global $pref_tpl;
127
128                $pref_tpl->parse('rows','spacer_row',True);
129        }
130
131        function display_section($appname,$file,$file2=False)
132        {
133                if ($file2)
134                {
135                        $file = $file2;
136                }
137                section_start($appname,$GLOBALS['phpgw']->common->image($appname,Array('navbar',$appname)));
138
139                while(list($text,$url) = each($file))
140                {
141                        if (($text == 'Change your Password') && ($GLOBALS['phpgw_info']['server']['use_https'] == 1))
142                        {
143                                $url = 'https://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/changepassword.php';
144                        }
145
146                        if($text == 'Expresso Offline' &&
147                                $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_expresso_offline']!='True')
148                                continue;
149                        if($text == 'Programed Archiving' && 
150                                $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages']!='1')
151                                continue;                       
152                        section_item($url,lang($text));
153                }
154                section_end();
155        }
156
157        $GLOBALS['phpgw']->hooks->process('preferences',array('preferences'));
158        $pref_tpl->pfp('out','list');
159        $GLOBALS['phpgw']->common->phpgw_footer();
160?>
Note: See TracBrowser for help on using the repository browser.