3 * Copyright 2003 Mark O'Sullivan
4 * This file is part of Vanilla.
5 * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
6 * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
7 * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8 * The latest source code for Vanilla is available at www.lussumo.com
9 * Contact Mark O'Sullivan at mark [at] lussumo [dot] com
11 * Description: Constants and objects specific to forum pages.
13 // Make sure this file was not accessed directly and prevent register_globals configuration array attack
14 if (!defined('IN_VANILLA')) exit();
17 include_once($Configuration['APPLICATION_PATH'].'appg/headers.php');
18 include_once($Configuration['APPLICATION_PATH'].'appg/database.php');
19 include_once($Configuration['DATABASE_PATH']);
20 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Functions.php');
21 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Database.php');
22 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.'.$Configuration['DATABASE_SERVER'].'.php');
23 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.SqlBuilder.php');
24 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.MessageCollector.php');
25 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.ErrorManager.php');
26 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.ObjectFactory.php');
27 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.StringManipulator.php');
28 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Context.php');
29 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Delegation.php');
30 include_once($Configuration['LIBRARY_PATH'].'Framework/Framework.Class.Control.php');
31 include_once($Configuration['LIBRARY_PATH'].'Vanilla/Vanilla.Functions.php');
32 include_once($Configuration['LIBRARY_PATH'].$Configuration['AUTHENTICATION_MODULE']);
33 include_once($Configuration['LIBRARY_PATH'].'People/People.Class.Session.php');
34 include_once($Configuration['LIBRARY_PATH'].'People/People.Class.PasswordHash.php');
35 include_once($Configuration['LIBRARY_PATH'].'People/People.Class.User.php');
37 // INSTANTIATE THE CONTEXT OBJECT
38 // The context object handles the following:
39 // - Open a connection to the database
40 // - Create a user session (autologging in any user with valid cookie credentials)
41 // - Instantiate debug and warning collectors
42 // - Instantiate an error manager
43 // - Define global variables relative to the current context (SelfUrl
45 $Context = new Context($Configuration);
46 $Context->DatabaseTables
= &$DatabaseTables;
47 $Context->DatabaseColumns
= &$DatabaseColumns;
49 // Start the session management
50 $Context->StartSession();
52 // DEFINE THE LANGUAGE DICTIONARY
53 include($Configuration['LANGUAGES_PATH'].$Configuration['LANGUAGE'].'/definitions.php');
54 include($Configuration['APPLICATION_PATH'].'conf/language.php');
55 // By cleaning the output buffer and restarting, it makes downloading work
56 // properly with utf-8 encoding (this was a bug in previous versions).
57 // http://lussumo.com/community/discussion/4442/
61 // INSTANTIATE THE PAGE OBJECT
62 // The page object handles collecting all page controls
63 // and writing them when it's events are fired.
64 $Page = $Context->ObjectFactory
->NewContextObject($Context, 'Page', $Configuration['PAGE_EVENTS']);
66 // FIRE INITIALIZATION EVENT
67 $Page->FireEvent('Page_Init');
69 // DEFINE THE MASTER PAGE CONTROLS
70 $Head = $Context->ObjectFactory
->CreateControl($Context, 'Head');
71 $Menu = $Context->ObjectFactory
->CreateControl($Context, 'Menu');
72 $Panel = $Context->ObjectFactory
->CreateControl($Context, 'Panel');
73 $NoticeCollector = $Context->ObjectFactory
->CreateControl($Context, 'NoticeCollector');
74 $Foot = $Context->ObjectFactory
->CreateControl($Context, 'Filler', 'foot.php');
75 $PageEnd = $Context->ObjectFactory
->CreateControl($Context, 'PageEnd');
77 // BUILD THE PAGE HEAD
78 // Every page will require some basic definitions for the header.
79 $Head->AddScript('js/global.js');
80 $Head->AddScript('js/vanilla.js');
81 $Head->AddScript('js/ajax.js');
82 $Head->AddScript('js/ac.js');
83 $Head->AddStyleSheet($Context->StyleUrl
.'vanilla.css', 'screen', 100, '');
84 $Head->AddStyleSheet($Context->StyleUrl
.'vanilla.print.css', 'print', 101, '');
86 // BUILD THE MAIN MENU
87 $Menu->AddTab($Context->GetDefinition('Discussions'), 'discussions', GetUrl($Configuration, './'), '', $Configuration['TAB_POSITION_DISCUSSIONS']);
88 if ($Configuration['USE_CATEGORIES']) $Menu->AddTab($Context->GetDefinition('Categories'), 'categories', GetUrl($Configuration, 'categories.php'), '', $Configuration['TAB_POSITION_CATEGORIES']);
89 $Menu->AddTab($Context->GetDefinition('Search'), 'search', GetUrl($Configuration, 'search.php'), '', $Configuration['TAB_POSITION_SEARCH']);
90 if ($Context->Session
->UserID
> 0) {
91 // Make sure they should be seeing the settings tab
92 $RequiredPermissions = array('PERMISSION_CHECK_FOR_UPDATES',
93 'PERMISSION_APPROVE_APPLICANTS',
94 'PERMISSION_MANAGE_REGISTRATION',
95 'PERMISSION_ADD_ROLES',
96 'PERMISSION_EDIT_ROLES',
97 'PERMISSION_REMOVE_ROLES',
98 'PERMISSION_ADD_CATEGORIES',
99 'PERMISSION_EDIT_CATEGORIES',
100 'PERMISSION_REMOVE_CATEGORIES',
101 'PERMISSION_SORT_CATEGORIES',
102 'PERMISSION_CHANGE_APPLICATION_SETTINGS',
103 'PERMISSION_MANAGE_EXTENSIONS',
104 'PERMISSION_MANAGE_LANGUAGE',
105 'PERMISSION_MANAGE_STYLES',
106 'PERMISSION_MANAGE_THEMES');
108 $RequiredPermissionsCount = count($RequiredPermissions);
110 for ($i = 0; $i < $RequiredPermissionsCount; $i++
) {
111 if ($Context->Session
->User
->Permission($RequiredPermissions[$i])) {
112 $Menu->AddTab($Context->GetDefinition('Settings'), 'settings', GetUrl($Configuration, 'settings.php'), '', $Configuration['TAB_POSITION_SETTINGS']);
117 // Add the account tab
118 $Menu->AddTab($Context->GetDefinition('Account'), 'account', GetUrl($Configuration, 'account.php'), '', $Configuration['TAB_POSITION_ACCOUNT']);
121 // Define the context object's passthru variables
122 $Context->PassThruVars
['SetBookmarkOnClick'] = '';
124 // INCLUDE EXTENSIONS
125 include($Configuration['APPLICATION_PATH'].'conf/extensions.php');
127 $Panel->AddString($Context->GetDefinition('PanelFooter'), 500);
129 // Make sure to get all delegates from the extensions into objects which were
130 // constructed before the extensions were loaded.
131 $Head->GetDelegatesFromContext();
132 $Menu->GetDelegatesFromContext();
133 $Panel->GetDelegatesFromContext();
134 $NoticeCollector->GetDelegatesFromContext();
135 $Foot->GetDelegatesFromContext();
136 $PageEnd->GetDelegatesFromContext();
138 // If the sign-in and sign-out urls have not been modified from their default
139 // values, concatenate them with the web root so that they link correctly if
140 // mod_rewrite is on.
141 if ($Configuration['SIGNIN_URL'] == 'people.php') $Configuration['SIGNIN_URL'] = $Configuration['WEB_ROOT'].$Configuration['SIGNIN_URL'];
142 if ($Configuration['SIGNOUT_URL'] == 'people.php?PostBackAction=SignOutNow') $Configuration['SIGNOUT_URL'] = $Configuration['WEB_ROOT'].$Configuration['SIGNOUT_URL'];