Fixed minor things and added missing file
[vanilla-miry.git] / settings.php
blob3053d84391bc456549dbe4b4c6efc6bd83046d2a
1 <?php
2 /*
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: Web forms that handle manipulating user & application settings
14 include('appg/settings.php');
15 $Configuration['SELF_URL'] = 'settings.php';
16 include('appg/init_vanilla.php');
18 // Ensure the user is allowed to view this page (they must have at least one of the following permissions)
19 $RequiredPermissions = array('PERMISSION_CHECK_FOR_UPDATES',
20 'PERMISSION_APPROVE_APPLICANTS',
21 'PERMISSION_MANAGE_REGISTRATION',
22 'PERMISSION_ADD_ROLES',
23 'PERMISSION_EDIT_ROLES',
24 'PERMISSION_REMOVE_ROLES',
25 'PERMISSION_ADD_CATEGORIES',
26 'PERMISSION_EDIT_CATEGORIES',
27 'PERMISSION_REMOVE_CATEGORIES',
28 'PERMISSION_SORT_CATEGORIES',
29 'PERMISSION_CHANGE_APPLICATION_SETTINGS',
30 'PERMISSION_MANAGE_EXTENSIONS',
31 'PERMISSION_MANAGE_LANGUAGE',
32 'PERMISSION_MANAGE_STYLES',
33 'PERMISSION_MANAGE_THEMES');
34 $Allowed = 0;
35 $RequiredPermissionsCount = count($RequiredPermissions);
36 $i = 0;
37 for ($i = 0; $i < $RequiredPermissionsCount; $i++) {
38 if ($Context->Session->User->Permission($RequiredPermissions[$i])) {
39 $Allowed = 1;
40 break;
43 if (!$Allowed) {
44 Redirect(GetUrl($Configuration, 'index.php'));
47 // 1. DEFINE VARIABLES AND PROPERTIES SPECIFIC TO THIS PAGE
49 $Head->BodyId = 'SettingsPage';
50 $Menu->CurrentTab = 'settings';
51 $Panel->CssClass = 'SettingsPanel';
52 $Panel->BodyCssClass = 'SettingsPageBody';
53 if ($Context->PageTitle == '') $Context->PageTitle = $Context->GetDefinition('AdministrativeSettings');
55 // 2. BUILD PAGE CONTROLS
57 // Build the control panel
58 $AdminOptions = $Context->GetDefinition('AdministrativeOptions');
59 $Panel->AddList($AdminOptions, 20);
60 if ($Context->Session->User->Permission('PERMISSION_CHANGE_APPLICATION_SETTINGS')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('ApplicationSettings'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=Globals'), '', '', 10);
61 if ($Context->Session->User->Permission('PERMISSION_CHECK_FOR_UPDATES')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('UpdatesAndReminders'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=UpdateCheck'), '', '', 20);
62 if ($Context->Session->User->Permission('PERMISSION_MANAGE_EXTENSIONS')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('ManageExtensions'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=Extensions'), '', '', 60);
63 if ($Context->Session->User->Permission('PERMISSION_MANAGE_THEMES')
64 || $Context->Session->User->Permission('PERMISSION_MANAGE_STYLES')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('ManageThemeAndStyle'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=ThemeChange'), '', '', 70);
65 if ($Context->Session->User->Permission('PERMISSION_MANAGE_LANGUAGE')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('LanguageManagement'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=LanguageChange'), '', '', 80);
66 if ($Context->Session->User->Permission('PERMISSION_ADD_ROLES')
67 || $Context->Session->User->Permission('PERMISSION_EDIT_ROLES')
68 || $Context->Session->User->Permission('PERMISSION_REMOVE_ROLES')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('RoleManagement'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=Roles'), '', '', 30);
70 if ($Context->Configuration['USE_CATEGORIES']
71 && ($Context->Session->User->Permission('PERMISSION_ADD_CATEGORIES')
72 || $Context->Session->User->Permission('PERMISSION_EDIT_CATEGORIES')
73 || $Context->Session->User->Permission('PERMISSION_REMOVE_CATEGORIES')
74 || $Context->Session->User->Permission('PERMISSION_SORT_CATEGORIES')
76 ) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('CategoryManagement'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=Categories'), '', '', 50);
78 if ($Context->Session->User->Permission('PERMISSION_MANAGE_REGISTRATION')) $Panel->AddListItem($AdminOptions, $Context->GetDefinition('RegistrationManagement'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=RegistrationChange'), '', '', 40);
80 // Create the default view
81 $SettingsHelp = $Context->ObjectFactory->CreateControl($Context, 'SettingsHelp');
83 // Forms
84 $CategoryForm = $Context->ObjectFactory->CreateControl($Context, 'CategoryForm');
85 $RoleForm = $Context->ObjectFactory->CreateControl($Context, 'RoleForm');
86 $GlobalsForm = $Context->ObjectFactory->CreateControl($Context, 'GlobalsForm');
87 $UpdateCheck = $Context->ObjectFactory->CreateControl($Context, 'UpdateCheck');
88 $ExtensionForm = $Context->ObjectFactory->CreateControl($Context, 'ExtensionForm');
89 $ThemeAndStyleForm = $Context->ObjectFactory->CreateControl($Context, 'ThemeAndStyleForm');
90 $RegistrationForm = $Context->ObjectFactory->CreateControl($Context, 'RegistrationForm');
91 $LanguageForm = $Context->ObjectFactory->CreateControl($Context, 'LanguageForm');
92 $ApplicantsForm = $Context->ObjectFactory->CreateControl($Context, 'ApplicantsForm');
93 $ApplicantData = false;
94 if ($Context->Session->User->Permission('PERMISSION_APPROVE_APPLICANTS') && !$Configuration['ALLOW_IMMEDIATE_ACCESS']) {
95 $UserManager = $Context->ObjectFactory->NewContextObject($Context, 'UserManager');
96 $ApplicantData = $UserManager->GetUsersByRoleID(0);
97 $ApplicantCount = $Context->Database->RowCount($ApplicantData);
98 $ApplicantsForm->ApplicantData = $ApplicantData;
99 $Panel->AddListItem($AdminOptions, $Context->GetDefinition('MembershipApplicants'), GetUrl($Configuration, 'settings.php', '', '', '', '', 'PostBackAction=Applicants'), $ApplicantCount.' '.$Context->GetDefinition('New'), '', 100);
102 // 3. ADD CONTROLS TO THE PAGE
104 $Page->AddRenderControl($Head, $Configuration['CONTROL_POSITION_HEAD']);
105 $Page->AddRenderControl($Menu, $Configuration['CONTROL_POSITION_MENU']);
106 $Page->AddRenderControl($Panel, $Configuration['CONTROL_POSITION_PANEL']);
107 $Page->AddRenderControl($NoticeCollector, $Configuration['CONTROL_POSITION_NOTICES']);
108 $Page->AddRenderControl($SettingsHelp, $Configuration['CONTROL_POSITION_BODY_ITEM']);
109 $Page->AddRenderControl($CategoryForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 10);
110 $Page->AddRenderControl($RoleForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 20);
111 $Page->AddRenderControl($GlobalsForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 30);
112 $Page->AddRenderControl($UpdateCheck, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 40);
113 $Page->AddRenderControl($ExtensionForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 50);
114 $Page->AddRenderControl($ThemeAndStyleForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 60);
115 $Page->AddRenderControl($RegistrationForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 70);
116 $Page->AddRenderControl($LanguageForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 80);
117 $Page->AddRenderControl($ApplicantsForm, $Configuration['CONTROL_POSITION_BODY_ITEM'] + 90);
118 $Page->AddRenderControl($Foot, $Configuration['CONTROL_POSITION_FOOT']);
119 $Page->AddRenderControl($PageEnd, $Configuration['CONTROL_POSITION_PAGE_END']);
122 // 4. FIRE PAGE EVENTS
124 $Page->FireEvents();