source: trunk/phpgwapi/inc/functions.inc.php @ 266

Revision 266, 22.6 KB checked in by niltonneto, 16 years ago (diff)

Internacionalização das mensagens de erros.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2         /**************************************************************************\
3         * eGroupWare API - phpgwapi loader                                         *
4         * This file written by Dan Kuykendall <seek3r@phpgroupware.org>            *
5         * and Joseph Engo <jengo@phpgroupware.org>                                 *
6         * Has a few functions, but primary role is to load the phpgwapi            *
7         * Copyright (C) 2000, 2001 Dan Kuykendall                                  *
8         * -------------------------------------------------------------------------*
9         * This library is part of the eGroupWare API                               *
10         * http://www.egroupware.org/api                                            *
11         * ------------------------------------------------------------------------ *
12         * This library is free software; you can redistribute it and/or modify it  *
13         * under the terms of the GNU Lesser General Public License as published by *
14         * the Free Software Foundation; either version 2.1 of the License,         *
15         * or any later version.                                                    *
16         * This library is distributed in the hope that it will be useful, but      *
17         * WITHOUT ANY WARRANTY; without even the implied warranty of               *
18         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
19         * See the GNU Lesser General Public License for more details.              *
20         * You should have received a copy of the GNU Lesser General Public License *
21         * along with this library; if not, write to the Free Software Foundation,  *
22         * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
23         \**************************************************************************/
24       
25       
26        /***************************************************************************\
27        * If running in PHP3, then force admin to upgrade                           *
28        \***************************************************************************/
29
30        error_reporting(error_reporting() & ~E_NOTICE);
31
32        if (!function_exists('version_compare'))//version_compare() is only available in PHP4.1+
33        {
34                echo 'eGroupWare requires PHP 4.1 or greater.<br>';
35                echo 'Please contact your System Administrator';
36                exit;
37        }
38
39        include(PHPGW_API_INC.'/common_functions.inc.php');
40       
41        /*!
42         @function lang
43         @abstract function to handle multilanguage support
44        */
45        function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='')
46        {
47                if(is_array($m1))
48                {
49                        $vars = $m1;
50                }
51                else
52                {
53                        $vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10);
54                }
55                // Get the translation from Lang File, if the database is down.
56                if(!$GLOBALS['phpgw']->translation){
57                        $fn = PHPGW_SERVER_ROOT.'/phpgwapi/setup/phpgw_'.$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE'].'.lang';
58                        if (file_exists($fn)){
59                                $fp = fopen($fn,'r');
60                                while ($data = fgets($fp,16000)){
61                                        list($message_id,$app_name,$null,$content) = explode("\t",substr($data,0,-1));
62                                        $GLOBALS['phpgw_info']['phpgwapi']['lang'][$message_id] =  $content;
63                                }
64                                fclose($fp);
65                        }
66                        $return = str_replace('%1',$vars[0],$GLOBALS['phpgw_info']['phpgwapi']['lang'][$key]);                 
67                        return $return; 
68                }
69                $value = $GLOBALS['phpgw']->translation->translate("$key",$vars);
70                return $value;
71        }
72
73        /* Make sure the header.inc.php is current. */
74        if ($GLOBALS['phpgw_info']['server']['versions']['header'] < $GLOBALS['phpgw_info']['server']['versions']['current_header'])
75        {
76                echo '<center><b>You need to port your settings to the new header.inc.php version by running <a href="setup/manageheader.php">setup/headeradmin</a>.</b></center>';
77                exit;
78        }
79
80        /* Make sure the developer is following the rules. */
81        if (!isset($GLOBALS['phpgw_info']['flags']['currentapp']))
82        {
83                /* This object does not exist yet. */
84        /*      $GLOBALS['phpgw']->log->write(array('text'=>'W-MissingFlags, currentapp flag not set'));*/
85
86                echo '<b>!!! YOU DO NOT HAVE YOUR $GLOBALS[\'phpgw_info\'][\'flags\'][\'currentapp\'] SET !!!';
87                echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>';
88        }
89
90        magic_quotes_runtime(false);
91        print_debug('sane environment','messageonly','api');
92
93        /****************************************************************************\
94        * Multi-Domain support                                                       *
95        \****************************************************************************/
96       
97        /* make them fix their header */
98        if (!isset($GLOBALS['phpgw_domain']))
99        {
100                echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>';
101                exit;
102        }
103        if (!isset($GLOBALS['phpgw_info']['server']['default_domain']) ||       // allow to overwrite the default domain
104                !isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]))
105        {
106                reset($GLOBALS['phpgw_domain']);
107                list($GLOBALS['phpgw_info']['server']['default_domain']) = each($GLOBALS['phpgw_domain']);
108        }
109        if (isset($_POST['login']))     // on login
110        {
111                $GLOBALS['login'] = $_POST['login'];
112                if (strstr($GLOBALS['login'],'@') === False || count($GLOBALS['phpgw_domain']) == 1)
113                {
114                        $GLOBALS['login'] .= '@' . get_var('logindomain',array('POST'),$GLOBALS['phpgw_info']['server']['default_domain']);
115                }
116                $parts = explode('@',$GLOBALS['login']);
117                $GLOBALS['phpgw_info']['user']['domain'] = array_pop($parts);
118        }
119        else    // on "normal" pageview
120        {
121                $GLOBALS['phpgw_info']['user']['domain'] = get_var('domain', array('GET', 'COOKIE'), FALSE);
122        }
123
124        if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
125        {
126                $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_host'];
127                $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_port'];
128                $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_name'];
129                $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_user'];
130                $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_pass'];
131                $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_type'];
132        }
133        else
134        {
135                $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_host'];
136                $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_port'];
137                $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_name'];
138                $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_user'];
139                $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_pass'];
140                $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_type'];
141        }
142
143        if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
144        {
145                unset ($GLOBALS['phpgw_domain']); // we kill this for security reasons
146        }
147
148        print_debug('domain',@$GLOBALS['phpgw_info']['user']['domain'],'api');
149
150         /****************************************************************************\
151         * These lines load up the API, fill up the $phpgw_info array, etc            *
152         \****************************************************************************/
153         /* Load main class */
154        $GLOBALS['phpgw'] = CreateObject('phpgwapi.phpgw');
155         /************************************************************************\
156         * Load up the main instance of the db class.                             *
157         \************************************************************************/
158        $GLOBALS['phpgw']->db           = CreateObject('phpgwapi.db');
159        if ($GLOBALS['phpgw']->debug)
160        {
161                $GLOBALS['phpgw']->db->Debug = 1;
162        }
163        $GLOBALS['phpgw']->db->Halt_On_Error = 'no';
164        $GLOBALS['phpgw']->db->connect(
165                $GLOBALS['phpgw_info']['server']['db_name'],
166                $GLOBALS['phpgw_info']['server']['db_host'],
167                $GLOBALS['phpgw_info']['server']['db_port'],
168                $GLOBALS['phpgw_info']['server']['db_user'],
169                $GLOBALS['phpgw_info']['server']['db_pass'],
170                $GLOBALS['phpgw_info']['server']['db_type']
171        );
172        @$GLOBALS['phpgw']->db->query("SELECT COUNT(config_name) FROM phpgw_config");
173        if(!@$GLOBALS['phpgw']->db->next_record())
174        {
175                $setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/');
176                /* BEGIN - CELEPAR - jakjr - 05/06/2006 */
177                /*echo '<center><b>Fatal Error:</b> It appears that you have not created the database tables for '
178                        .'eGroupWare.  Click <a href="' . $setup_dir . '">here</a> to run setup.</center>';*/
179                echo '<center><b>'.lang("ExpressoLivre is unavailable at this moment. Code %1<br>Please, try later.","001").'</b></center>';
180                /* END - CELEPAR - jakjr - 05/06/2006 */
181                exit;
182        }
183        $GLOBALS['phpgw']->db->Halt_On_Error = 'yes';
184
185        /* Fill phpgw_info["server"] array */
186        // An Attempt to speed things up using cache premise
187        $GLOBALS['phpgw']->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__);
188        if ($GLOBALS['phpgw']->db->num_rows())
189        {
190                $GLOBALS['phpgw']->db->next_record();
191                $GLOBALS['phpgw_info']['server']['cache_phpgw_info'] = stripslashes($GLOBALS['phpgw']->db->f('config_value'));
192        }
193
194        $cache_query = "select content from phpgw_app_sessions where"
195                ." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
196
197        $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
198        $server_info_cache = $GLOBALS['phpgw']->db->num_rows();
199
200        if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $server_info_cache)
201        {
202                $GLOBALS['phpgw']->db->next_record();
203                $GLOBALS['phpgw_info']['server'] = unserialize(stripslashes($GLOBALS['phpgw']->db->f('content')));
204        }
205        else
206        {
207                $GLOBALS['phpgw']->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__);
208                while ($GLOBALS['phpgw']->db->next_record())
209                {
210                        $GLOBALS['phpgw_info']['server'][$GLOBALS['phpgw']->db->f('config_name')] = stripslashes($GLOBALS['phpgw']->db->f('config_value'));
211                }
212
213                if(@isset($GLOBALS['phpgw_info']['server']['cache_phpgw_info']))
214                {
215                        if($server_info_cache)
216                        {
217                                $cache_query = "DELETE FROM phpgw_app_sessions WHERE sessionid='0' and loginid='0' and app='phpgwapi' and location='config'";
218                                $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
219                        }
220                        $cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
221                                . "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')";
222                        $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
223                }
224        }
225        unset($cache_query);
226        unset($server_info_cache);
227        if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) && !$_SERVER['HTTPS'])
228        {
229                Header('Location: https://' . $GLOBALS['phpgw_info']['server']['hostname'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . $_SERVER['REQUEST_URI']);
230                exit;
231        }
232
233        /****************************************************************************\
234        * This is a global constant that should be used                              *
235        * instead of / or \ in file paths                                            *
236        \****************************************************************************/
237        define('SEP',filesystem_separator());
238
239        /************************************************************************\
240        * Required classes                                                       *
241        \************************************************************************/
242        $GLOBALS['phpgw']->log          = CreateObject('phpgwapi.errorlog');
243        $GLOBALS['phpgw']->translation  = CreateObject('phpgwapi.translation');
244        $GLOBALS['phpgw']->common       = CreateObject('phpgwapi.common');
245        $GLOBALS['phpgw']->hooks        = CreateObject('phpgwapi.hooks');
246        $GLOBALS['phpgw']->auth         = CreateObject('phpgwapi.auth');
247        $GLOBALS['phpgw']->accounts     = CreateObject('phpgwapi.accounts');
248        $GLOBALS['phpgw']->acl          = CreateObject('phpgwapi.acl');
249        $GLOBALS['phpgw']->session      = CreateObject('phpgwapi.sessions');
250        $GLOBALS['phpgw']->preferences  = CreateObject('phpgwapi.preferences');
251        $GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications');
252        print_debug('main class loaded', 'messageonly','api');
253        if (! isset($GLOBALS['phpgw_info']['flags']['included_classes']['error']) ||
254                ! $GLOBALS['phpgw_info']['flags']['included_classes']['error'])
255        {
256                include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php');
257                $GLOBALS['phpgw_info']['flags']['included_classes']['error'] = True;
258        }
259
260        /*****************************************************************************\
261        * ACL defines - moved here to work for xml-rpc/soap, also                     *
262        \*****************************************************************************/
263        define('PHPGW_ACL_READ',1);
264        define('PHPGW_ACL_ADD',2);
265        define('PHPGW_ACL_EDIT',4);
266        define('PHPGW_ACL_DELETE',8);
267        define('PHPGW_ACL_PRIVATE',16);
268        define('PHPGW_ACL_GROUP_MANAGERS',32);
269        define('PHPGW_ACL_CUSTOM_1',64);
270        define('PHPGW_ACL_CUSTOM_2',128);
271        define('PHPGW_ACL_CUSTOM_3',256);
272
273        /****************************************************************************\
274        * Forcing the footer to run when the rest of the script is done.             *
275        \****************************************************************************/
276        register_shutdown_function(array($GLOBALS['phpgw']->common, 'phpgw_final'));
277
278        /****************************************************************************\
279        * Stuff to use if logging in or logging out                                  *
280        \****************************************************************************/
281        if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout')
282        {
283                if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login')
284                {
285                        if (@$_POST['login'] != '')
286                        {
287                                if (count($GLOBALS['phpgw_domain']) > 1)
288                                {
289                                        list($login) = explode('@',$_POST['login']);
290                                }
291                                else
292                                {
293                                        $login = $_POST['login'];
294                                }
295                                print_debug('LID',$login,'app');
296                                $login_id = $GLOBALS['phpgw']->accounts->name2id($login);
297                                print_debug('User ID',$login_id,'app');
298                                $GLOBALS['phpgw']->accounts->accounts($login_id);
299                                $GLOBALS['phpgw']->preferences->preferences($login_id);
300                                $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time');
301                        }
302                }
303        /**************************************************************************\
304        * Everything from this point on will ONLY happen if                        *
305        * the currentapp is not login or logout                                    *
306        \**************************************************************************/
307        }
308        else
309        {
310                if (! $GLOBALS['phpgw']->session->verify())
311                {
312                        // we forward to the same place after the re-login
313                        if ($GLOBALS['phpgw_info']['server']['webserver_url'] && $GLOBALS['phpgw_info']['server']['webserver_url'] != '/')
314                        {
315                                list(,$relpath) = explode($GLOBALS['phpgw_info']['server']['webserver_url'],$_SERVER['PHP_SELF'],2);
316                        }
317                        else    // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given)
318                        {
319                                if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches))
320                                {
321                                        $relpath = $matches[1];
322                                }
323                        }
324                        // this removes the sessiondata if its saved in the URL
325                        $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']);
326                        Header('Location: '.$GLOBALS['phpgw_info']['server']['webserver_url'].'/login.php?cd=10&phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')));
327                        exit;
328                }
329
330                $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time');
331
332                /* A few hacker resistant constants that will be used throught the program */
333                define('PHPGW_TEMPLATE_DIR', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi'));
334                define('PHPGW_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_path', 'phpgwapi'));
335                define('PHPGW_IMAGES_FILEDIR', ExecMethod('phpgwapi.phpgw.common.get_image_dir', 'phpgwapi'));
336                define('PHPGW_APP_ROOT', ExecMethod('phpgwapi.phpgw.common.get_app_dir'));
337                define('PHPGW_APP_INC', ExecMethod('phpgwapi.phpgw.common.get_inc_dir'));
338                define('PHPGW_APP_TPL', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir'));
339                define('PHPGW_IMAGES', ExecMethod('phpgwapi.phpgw.common.get_image_path'));
340                define('PHPGW_APP_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_dir'));
341
342                /*      define('PHPGW_APP_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_dir()); */
343
344                /* Moved outside of this logic
345                define('PHPGW_ACL_READ',1);
346                define('PHPGW_ACL_ADD',2);
347                define('PHPGW_ACL_EDIT',4);
348                define('PHPGW_ACL_DELETE',8);
349                define('PHPGW_ACL_PRIVATE',16);
350                */
351
352                /********* This sets the user variables *********/
353                $GLOBALS['phpgw_info']['user']['private_dir'] = $GLOBALS['phpgw_info']['server']['files_dir']
354                        . '/users/'.$GLOBALS['phpgw_info']['user']['userid'];
355
356                /* This will make sure that a user has the basic default prefs. If not it will add them */
357                $GLOBALS['phpgw']->preferences->verify_basic_settings();
358
359                /********* Optional classes, which can be disabled for performance increases *********/
360                while ($phpgw_class_name = each($GLOBALS['phpgw_info']['flags']))
361                {
362                        if (ereg('enable_',$phpgw_class_name[0]))
363                        {
364                                $enable_class = str_replace('enable_','',$phpgw_class_name[0]);
365                                $enable_class = str_replace('_class','',$enable_class);
366                                eval('$GLOBALS["phpgw"]->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');');
367                        }
368                }
369                unset($enable_class);
370                reset($GLOBALS['phpgw_info']['flags']);
371
372                /*************************************************************************\
373                * These lines load up the templates class                                 *
374                \*************************************************************************/
375                if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class'])
376                {
377                        $GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
378                }
379
380                /*************************************************************************\
381                * These lines load up the themes                                          *
382                \*************************************************************************/
383                if (! $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])
384                {
385                        if (@$GLOBALS['phpgw_info']['server']['template_set'] == 'user_choice')
386                        {
387                                $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = 'default';
388                        }
389                        else
390                        {
391                                $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $GLOBALS['phpgw_info']['server']['template_set'];
392                        }
393                }
394                if (@$GLOBALS['phpgw_info']['server']['force_theme'] == 'user_choice')
395                {
396                        if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme']))
397                        {
398                                $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = 'default';
399                        }
400                }
401                else
402                {
403                        if (isset($GLOBALS['phpgw_info']['server']['force_theme']))
404                        {
405                                $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $GLOBALS['phpgw_info']['server']['force_theme'];
406                        }
407                }
408
409                if(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '.theme'))
410                {
411                        include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '.theme');
412                }
413                elseif(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme'))
414                {
415                        include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme');
416                }
417                else
418                {
419                        /* Hope we don't get to this point.  Better then the user seeing a */
420                        /* complety back screen and not know whats going on                */
421                        echo '<body bgcolor="FFFFFF">';
422                        $GLOBALS['phpgw']->log->write(array('text'=>'F-Abort, No themes found'));
423
424                        exit;
425                }
426                unset($theme_to_load);
427
428                /*************************************************************************\
429                * If they are using frames, we need to set some variables                 *
430                \*************************************************************************/
431                if (((isset($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) &&
432                        $GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) &&
433                        $GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') ||
434                        ($GLOBALS['phpgw_info']['server']['useframes'] == 'always'))
435                {
436                        $GLOBALS['phpgw_info']['flags']['navbar_target'] = 'phpgw_body';
437                }
438
439                /*************************************************************************\
440                * Verify that the users session is still active otherwise kick them out   *
441                \*************************************************************************/
442                if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' &&
443                        $GLOBALS['phpgw_info']['flags']['currentapp'] != 'about')
444                {
445                        // This will need to use ACL in the future
446                        if (! $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']] ||
447                                (@$GLOBALS['phpgw_info']['flags']['admin_only'] &&
448                                ! $GLOBALS['phpgw_info']['user']['apps']['admin']))
449                        {
450                                $GLOBALS['phpgw']->common->phpgw_header();
451                                if ($GLOBALS['phpgw_info']['flags']['noheader'])
452                                {
453                                        echo parse_navbar();
454                                }
455
456                                $GLOBALS['phpgw']->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp']));
457
458                                echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
459                                $GLOBALS['phpgw']->common->phpgw_exit(True);
460                        }
461                }
462
463                if(!is_object($GLOBALS['phpgw']->datetime))
464                {
465                        $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time');
466                }
467                $GLOBALS['phpgw']->applications->read_installed_apps(); // to get translated app-titles
468               
469                /*************************************************************************\
470                * Load the header unless the developer turns it off                       *
471                \*************************************************************************/
472                if (!@$GLOBALS['phpgw_info']['flags']['noheader'])
473                {
474                        $GLOBALS['phpgw']->common->phpgw_header();
475                }
476
477                /*************************************************************************\
478                * Load the app include files if the exists                                *
479                \*************************************************************************/
480                /* Then the include file */
481                if (PHPGW_APP_INC != "" &&
482                   ! preg_match ("/phpgwapi/i", PHPGW_APP_INC) &&
483                   file_exists(PHPGW_APP_INC . '/functions.inc.php') &&
484                   !isset($_GET['menuaction']))
485                {
486                        include(PHPGW_APP_INC . '/functions.inc.php');
487                }
488                if (!@$GLOBALS['phpgw_info']['flags']['noheader'] &&
489                        !@$GLOBALS['phpgw_info']['flags']['noappheader'] &&
490                        file_exists(PHPGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction']))
491                {
492                        include(PHPGW_APP_INC . '/header.inc.php');
493                }
494        }
Note: See TracBrowser for help on using the repository browser.