source: branches/1.2/home.php @ 223

Revision 223, 4.9 KB checked in by niltonneto, 16 years ago (diff)

Correção para forçar usuário "cair" na página inicial,
mesmo que ele tente acessar o /login.php

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare                                                               *
4        * http://www.egroupware.org                                                *
5        * The file written by Joseph Engo <jengo@phpgroupware.org>                 *
6        * This file modified by Greg Haygood <shrykedude@bellsouth.net>            *
7        * --------------------------------------------                             *
8        *  This program is free software; you can redistribute it and/or modify it *
9        *  under the terms of the GNU General Public License as published by the   *
10        *  Free Software Foundation; either version 2 of the License, or (at your  *
11        *  option) any later version.                                              *
12        \**************************************************************************/
13        $phpgw_info = array();
14        if (!is_file('header.inc.php'))
15        {
16                Header('Location: setup/index.php');
17                exit;
18        }
19
20        $GLOBALS['sessionid'] = @$_GET['sessionid'] ? $_GET['sessionid'] : @$_COOKIE['sessionid'];
21        if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid'])
22        {
23                Header('Location: login.php?cd=10');
24                exit;
25        }
26
27        $GLOBALS['phpgw_info']['flags'] = array(
28                'noheader'                => True,
29                'nonavbar'                => True,
30                'currentapp'              => 'home',
31                'enable_network_class'    => True,
32                'enable_contacts_class'   => True,
33                'enable_nextmatchs_class' => True
34        );
35        include('header.inc.php');
36        $GLOBALS['phpgw_info']['flags']['app_header']=lang('home');
37
38        // Commented by alpeb: The following prevented anonymous users to get a home page. Perhaps it was done with anonymous users such as the ones
39        // used by  wiki and sitemgr in mind. However, if you mark a normal user as anonymous just to avoid being shown in sessions and access log (like you would for an admin that doesn't want to be noticed), the user won't be able to login anymore. That's why I commented the code.
40        /*if ($GLOBALS['phpgw']->session->session_flags == 'A')
41        {
42                if ($_SERVER['HTTP_REFERER'] && strstr($_SERVER['HTTP_REFERER'],'home.php') === False)
43                {
44                        $GLOBALS['phpgw']->redirect($_SERVER['HTTP_REFERER']);
45                }
46                else
47                {
48                        // redirect to the login-page, better then giving an empty page
49                        $GLOBALS['phpgw']->redirect('login.php');
50                }
51                exit;
52        }*/
53
54        if ($GLOBALS['phpgw_info']['server']['force_default_app'] && $GLOBALS['phpgw_info']['server']['force_default_app'] != 'user_choice')
55        {
56                $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['phpgw_info']['server']['force_default_app'];
57        }
58
59        if ($_GET['cd']=='yes' && $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] &&
60                $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['user']['preferences']['common']['default_app']])
61        {
62                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] . '/' . 'index.php'));
63        }
64        else
65        {
66                $GLOBALS['phpgw']->common->phpgw_header();
67                echo parse_navbar();
68        }
69        // Default Applications (Home Page)
70        $default_apps = Array(                 
71                        'workflow',                     
72                        'expressoMail1_2',
73                        'calendar',
74                        'news_admin'
75                );
76        $sorted_apps = array();
77        $user_apps = $GLOBALS['phpgw_info']['user']['apps'];
78        @reset($user_apps);     
79        for($i = 0; $i < count($default_apps);$i++) {
80                if(array_key_exists($default_apps[$i], $user_apps)){
81                        $sorted_apps[] = $default_apps[$i];
82                }               
83        }
84       
85        foreach($GLOBALS['phpgw_info']['user']['apps'] as $i => $p) {
86                $sorted_apps[] = $p['name'];
87        }
88       
89        $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated');
90        $done = array();
91        // Display elements, within appropriate table cells     
92        @reset($sorted_apps);
93        $idx = 1;
94        echo "<table width='100%' cellpadding=5>";
95        foreach($sorted_apps as $appname)
96        {
97                if((int)$done[$appname] == 1 || empty($appname)){
98                        continue;
99                }               
100                $varnames = $portal_oldvarnames;
101                $varnames[] = 'homepage_display';
102                $thisd = 0;
103                $tmp = '';
104               
105                foreach($varnames as $varcheck)
106                {
107                                                                       
108                        /*if($appname == 'expressoMail1_2') {
109                                $tmp = $appname;
110                                $appname = 'expressoMail';
111                        }*/                             
112
113                        if(array_search($appname, $default_apps) !== False){
114                                $thisd = 1;
115                                break;
116                        }
117                        if($GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]=='True') {
118                                $thisd = 1;
119                                break;
120                        }
121                        else  {
122                                $_thisd = (int)$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck];
123                                if($_thisd > 0) {
124                                        $thisd = $_thisd;
125                                        break;
126                                }
127                        }
128                }
129
130                if($thisd > 0)
131                {
132                        if($tmp) {
133                $appname = $tmp;
134                                $tmp = '';
135                        }
136                        if($idx == 0) {                         
137                                print '<tr>';
138                        }
139                        print '<td style="vertical-align:top;" width="45%">';
140                        $GLOBALS['phpgw']->hooks->single('home',$appname);                     
141                        print '</td>';
142                       
143                        if($idx == 2){
144                                $idx = 0;
145                                print '</tr>';
146                        }                       
147                        $idx++;
148                        $neworder[] = $appname;
149                }
150                $done[$appname] = 1;
151        }
152        print '</table>';
153        $GLOBALS['phpgw']->common->phpgw_footer();
154?>
Note: See TracBrowser for help on using the repository browser.