source: sandbox/2.4.1-novabusca/home.php @ 6754

Revision 6754, 6.9 KB checked in by niltonneto, 12 years ago (diff)

Ticket #0000 - Copiadas as alterações do Trunk. Versão final da 2.4.1.

  • 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
101        // Default Applications (Home Page)
102        $default_apps = Array(                 
103                        'workflow',                     
104                        'expressoMail1_2',
105                        'calendar',
106                        'news_admin'
107                );
108        $sorted_apps = array();
109        $user_apps = $GLOBALS['phpgw_info']['user']['apps'];
110        @reset($user_apps);     
111        for($i = 0; $i < count($default_apps);$i++) {
112                if(array_key_exists($default_apps[$i], $user_apps)){
113                        $sorted_apps[] = $default_apps[$i];
114                }               
115        }
116       
117        foreach($GLOBALS['phpgw_info']['user']['apps'] as $i => $p) {
118                $sorted_apps[] = $p['name'];
119        }
120
121        $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated');
122        $done = array();
123        // Display elements, within appropriate table cells     
124        @reset($sorted_apps);
125        $idx = 1;
126        echo "<table width='100%' cellpadding=5>";
127        foreach($sorted_apps as $appname)
128        {
129                if((int)$done[$appname] == 1 || empty($appname)){
130                        continue;
131                }
132                $varnames = $portal_oldvarnames;
133                $varnames[] = 'homepage_display';
134                $thisd = 0;
135                $tmp = '';
136
137                foreach($varnames as $varcheck)
138                {
139
140                        /*if($appname == 'expressoMail1_2') {
141                                $tmp = $appname;
142                                $appname = 'expressoMail';
143                        }*/
144
145                        if(array_search($appname, $default_apps) !== False){
146                                $thisd = 1;
147                                break;
148                        }
149                        if($GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]=='True') {
150                                $thisd = 1;
151                                break;
152                        }
153                        else  {
154                                $_thisd = (int)$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck];
155                                if($_thisd > 0) {
156                                        $thisd = $_thisd;
157                                        break;
158                                }
159                        }
160                }
161
162               if($thisd > 0)
163                {
164                        if($tmp) {
165                $appname = $tmp;
166                                $tmp = '';
167                        }
168                        if($idx == 0) {
169                                print '<tr>';
170                        }
171                        print '<td style="vertical-align:top;" width="45%">';
172                        $GLOBALS['phpgw']->hooks->single('home',$appname);
173                        print '</td>';
174
175                        if($idx == 2){
176                                $idx = 0;
177                                print '</tr>';
178                        }
179                        $idx++;
180                        $neworder[] = $appname;
181                }
182                $done[$appname] = 1;
183        }
184        print '</table>';
185
186        $GLOBALS['phpgw']->common->phpgw_footer();
187?>
Note: See TracBrowser for help on using the repository browser.