source: trunk/preferences/index.php @ 1231

Revision 1231, 4.8 KB checked in by eduardoalex, 15 years ago (diff)

Ticket #548 - Tornar o Expresso Offline opcional para o adm.

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