source: branches/2.3/home.php @ 3435

Revision 3435, 5.1 KB checked in by eduardoalex, 13 years ago (diff)

Ticket #1244 - Corrigindo [3434] que teve codigo comitado errado.

  • 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        $GLOBALS['phpgw_info']['flags']['app_header']=lang('home');
39
40        // Commented by alpeb: The following prevented anonymous users to get a home page. Perhaps it was done with anonymous users such as the ones
41        // 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.
42        /*if ($GLOBALS['phpgw']->session->session_flags == 'A')
43        {
44                if ($_SERVER['HTTP_REFERER'] && strstr($_SERVER['HTTP_REFERER'],'home.php') === False)
45                {
46                        $GLOBALS['phpgw']->redirect($_SERVER['HTTP_REFERER']);
47                }
48                else
49                {
50                        // redirect to the login-page, better then giving an empty page
51                        $GLOBALS['phpgw']->redirect('login.php');
52                }
53                exit;
54        }*/
55
56        if ($GLOBALS['phpgw_info']['server']['force_default_app'] && $GLOBALS['phpgw_info']['server']['force_default_app'] != 'user_choice')
57        {
58                $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['phpgw_info']['server']['force_default_app'];
59        }
60
61        if ($_GET['cd']=='yes' && $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] &&
62                $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['user']['preferences']['common']['default_app']])
63        {
64                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] . '/' . 'index.php'));
65        }
66        else
67        {
68                $GLOBALS['phpgw']->common->phpgw_header();
69                echo parse_navbar();
70        }
71        // Default Applications (Home Page)
72        $default_apps = Array(                 
73                        'workflow',                     
74                        'expressoMail1_2',
75                        'calendar',
76                        'news_admin'
77                );
78        $sorted_apps = array();
79        $user_apps = $GLOBALS['phpgw_info']['user']['apps'];
80        @reset($user_apps);     
81        for($i = 0; $i < count($default_apps);$i++) {
82                if(array_key_exists($default_apps[$i], $user_apps)){
83                        $sorted_apps[] = $default_apps[$i];
84                }               
85        }
86       
87        foreach($GLOBALS['phpgw_info']['user']['apps'] as $i => $p) {
88                $sorted_apps[] = $p['name'];
89        }
90       
91        $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated');
92        $done = array();
93        // Display elements, within appropriate table cells     
94        @reset($sorted_apps);
95        $idx = 1;
96        echo "<table width='100%' cellpadding=5>";
97        foreach($sorted_apps as $appname)
98        {
99                if((int)$done[$appname] == 1 || empty($appname)){
100                        continue;
101                }               
102                $varnames = $portal_oldvarnames;
103                $varnames[] = 'homepage_display';
104                $thisd = 0;
105                $tmp = '';
106               
107                foreach($varnames as $varcheck)
108                {
109                                                                       
110                        /*if($appname == 'expressoMail1_2') {
111                                $tmp = $appname;
112                                $appname = 'expressoMail';
113                        }*/                             
114
115                        if(array_search($appname, $default_apps) !== False){
116                                $thisd = 1;
117                                break;
118                        }
119                        if($GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]=='True') {
120                                $thisd = 1;
121                                break;
122                        }
123                        else  {
124                                $_thisd = (int)$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck];
125                                if($_thisd > 0) {
126                                        $thisd = $_thisd;
127                                        break;
128                                }
129                        }
130                }
131
132                if($thisd > 0)
133                {
134                        if($tmp) {
135                $appname = $tmp;
136                                $tmp = '';
137                        }
138                        if($idx == 0) {                         
139                                print '<tr>';
140                        }
141                        print '<td style="vertical-align:top;" width="45%">';
142                        $GLOBALS['phpgw']->hooks->single('home',$appname);                     
143                        print '</td>';
144                       
145                        if($idx == 2){
146                                $idx = 0;
147                                print '</tr>';
148                        }                       
149                        $idx++;
150                        $neworder[] = $appname;
151                }
152                $done[$appname] = 1;
153        }
154        print '</table>';
155        $GLOBALS['phpgw']->common->phpgw_footer();
156?>
Note: See TracBrowser for help on using the repository browser.