source: branches/2.2/home.php @ 5051

Revision 5051, 5.6 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #2261 - Corrigido os varios redirecionamentos no modulo mobile

  • 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        $current_url = substr($_SERVER["SCRIPT_NAME"], 0, strpos($_SERVER["SCRIPT_NAME"],'home.php'));
15
16        if (!is_file('header.inc.php'))
17        {
18                Header('Location: '.$current_url.'setup/index.php');
19                exit;
20        }
21
22        $GLOBALS['sessionid'] = @$_GET['sessionid'] ? $_GET['sessionid'] : @$_COOKIE['sessionid'];
23        if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid'])
24        {
25                Header('Location: '.$current_url.'login.php?cd=10');
26                exit;
27        }
28
29        $GLOBALS['phpgw_info']['flags'] = array(
30                'noheader'                => True,
31                'nonavbar'                => True,
32                'currentapp'              => 'home',
33                'enable_network_class'    => True,
34                'enable_contacts_class'   => True,
35                'enable_nextmatchs_class' => True
36        );
37        include('header.inc.php');
38       
39        //detect browser
40        require_once('phpgwapi/inc/class.browser.inc.php');
41       
42        $ifMobile       = false;
43        $browser        = new browser();
44       
45       
46        switch( $browser->get_platform() )
47        {
48                case browser::PLATFORM_IPHONE:
49                case browser::PLATFORM_IPOD:
50                case browser::PLATFORM_IPAD:
51                case browser::PLATFORM_BLACKBERRY:
52                case browser::PLATFORM_ANDROID:                                         
53                        $ifMobile = false;
54                        break;                 
55        }
56       
57        if( $ifMobile )
58        {
59                if( $_GET['dont_redirect_if_moble'] != 1 )
60                {
61                        $GLOBALS['phpgw']->redirect('/mobile/index.php');
62                        exit;                   
63                }
64        }
65       
66       
67        $GLOBALS['phpgw_info']['flags']['app_header']=lang('home');
68
69        // Commented by alpeb: The following prevented anonymous users to get a home page. Perhaps it was done with anonymous users such as the ones
70        // 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.
71        /*if ($GLOBALS['phpgw']->session->session_flags == 'A')
72        {
73                if ($_SERVER['HTTP_REFERER'] && strstr($_SERVER['HTTP_REFERER'],'home.php') === False)
74                {
75                        $GLOBALS['phpgw']->redirect($_SERVER['HTTP_REFERER']);
76                }
77                else
78                {
79                        // redirect to the login-page, better then giving an empty page
80                        $GLOBALS['phpgw']->redirect('login.php');
81                }
82                exit;
83        }*/
84
85        if ($GLOBALS['phpgw_info']['server']['force_default_app'] && $GLOBALS['phpgw_info']['server']['force_default_app'] != 'user_choice')
86        {
87                $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['phpgw_info']['server']['force_default_app'];
88        }
89
90        if ($_GET['cd']=='yes' && $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] &&
91                $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['user']['preferences']['common']['default_app']])
92        {
93                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] . '/' . 'index.php'));
94        }
95        else
96        {
97                $GLOBALS['phpgw']->common->phpgw_header();
98                echo parse_navbar();
99        }
100        // Default Applications (Home Page)
101        $default_apps = Array(                 
102                        'workflow',                     
103                        'expressoMail1_2',
104                        'calendar',
105                        'news_admin'
106                );
107        $sorted_apps = array();
108        $user_apps = $GLOBALS['phpgw_info']['user']['apps'];
109        @reset($user_apps);     
110        for($i = 0; $i < count($default_apps);$i++) {
111                if(array_key_exists($default_apps[$i], $user_apps)){
112                        $sorted_apps[] = $default_apps[$i];
113                }               
114        }
115       
116        foreach($GLOBALS['phpgw_info']['user']['apps'] as $i => $p) {
117                $sorted_apps[] = $p['name'];
118        }
119       
120        $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated');
121        $done = array();
122        // Display elements, within appropriate table cells     
123        @reset($sorted_apps);
124        $idx = 1;
125        echo "<table width='100%' cellpadding=5>";
126        foreach($sorted_apps as $appname)
127        {
128                if((int)$done[$appname] == 1 || empty($appname)){
129                        continue;
130                }               
131                $varnames = $portal_oldvarnames;
132                $varnames[] = 'homepage_display';
133                $thisd = 0;
134                $tmp = '';
135               
136                foreach($varnames as $varcheck)
137                {
138                                                                       
139                        /*if($appname == 'expressoMail1_2') {
140                                $tmp = $appname;
141                                $appname = 'expressoMail';
142                        }*/                             
143
144                        if(array_search($appname, $default_apps) !== False){
145                                $thisd = 1;
146                                break;
147                        }
148                        if($GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]=='True') {
149                                $thisd = 1;
150                                break;
151                        }
152                        else  {
153                                $_thisd = (int)$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck];
154                                if($_thisd > 0) {
155                                        $thisd = $_thisd;
156                                        break;
157                                }
158                        }
159                }
160
161                if($thisd > 0)
162                {
163                        if($tmp) {
164                $appname = $tmp;
165                                $tmp = '';
166                        }
167                        if($idx == 0) {                         
168                                print '<tr>';
169                        }
170                        print '<td style="vertical-align:top;" width="45%">';
171                        $GLOBALS['phpgw']->hooks->single('home',$appname);                     
172                        print '</td>';
173                       
174                        if($idx == 2){
175                                $idx = 0;
176                                print '</tr>';
177                        }                       
178                        $idx++;
179                        $neworder[] = $appname;
180                }
181                $done[$appname] = 1;
182        }
183        print '</table>';
184        $GLOBALS['phpgw']->common->phpgw_footer();
185?>
Note: See TracBrowser for help on using the repository browser.