forked from glFusion/evlist
/
autoinstall.php
254 lines (212 loc) · 9.3 KB
/
autoinstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
// +--------------------------------------------------------------------------+
// | evList A calendar solution for glFusion |
// +--------------------------------------------------------------------------+
// | autoinstall.php |
// | |
// | glFusion Auto Installer module |
// +--------------------------------------------------------------------------+
// | Copyright (C) 2009 by the following authors: |
// | |
// | Mark R. Evans mark AT glfusion DOT org |
// +--------------------------------------------------------------------------+
// | |
// | This program 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. |
// | |
// | This program 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. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +--------------------------------------------------------------------------+
/**
* Automatic installation of the evList plugin
* @package evlist
*/
if (!defined ('GVERSION')) {
die ('This file can not be used on its own.');
}
global $_DB_dbms;
/** Include plugin-required files */
require_once $_CONF['path'].'plugins/evlist/evlist.php';
require_once $_CONF['path'].'plugins/evlist/sql/'.$_DB_dbms.'_install.php';
require_once $_CONF['path'].'plugins/evlist/sql/def_events.php';
// +--------------------------------------------------------------------------+
// | Plugin installation options |
// +--------------------------------------------------------------------------+
$INSTALL_plugin['evlist'] = array(
'installer' => array('type' => 'installer',
'version' => '1',
'mode' => 'install'),
'plugin' => array( 'type' => 'plugin',
'name' => $_EV_CONF['pi_name'],
'ver' => $_EV_CONF['pi_version'],
'gl_ver' => $_EV_CONF['gl_version'],
'url' => $_EV_CONF['pi_url'],
'display' => $_EV_CONF['pi_display_name']),
array( 'type' => 'table',
'table' => $_TABLES['evlist_events'],
'sql' => $_SQL['evlist_events'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_submissions'],
'sql' => $_SQL['evlist_submissions'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_repeat'],
'sql' => $_SQL['evlist_repeat'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_categories'],
'sql' => $_SQL['evlist_categories'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_lookup'],
'sql' => $_SQL['evlist_lookup'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_remlookup'],
'sql' => $_SQL['evlist_remlookup'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_detail'],
'sql' => $_SQL['evlist_detail'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_calendars'],
'sql' => $_SQL['evlist_calendars'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_tickets'],
'sql' => $_SQL['evlist_tickets'],
),
array( 'type' => 'table',
'table' => $_TABLES['evlist_tickettypes'],
'sql' => $_SQL['evlist_tickettypes'],
),
array( 'type' => 'group',
'group' => 'evList Admin',
'desc' => 'Administrator of the evList Plugin',
'variable' => 'admin_group_id',
'addroot' => true,
'admin' => true,
),
array( 'type' => 'feature',
'feature' => 'evlist.submit',
'desc' => 'May bypass the evList submission queue',
'variable' => 'submit_feature_id',
),
array( 'type' => 'mapping',
'group' => 'admin_group_id',
'feature' => 'submit_feature_id',
'log' => 'Adding evList Submit feature to the evList admin group',
),
array( 'type' => 'feature',
'feature' => 'evlist.admin',
'desc' => 'Administrative access to the evList plugin',
'variable' => 'admin_feature_id',
),
array( 'type' => 'mapping',
'group' => 'admin_group_id',
'feature' => 'admin_feature_id',
'log' => 'Adding evList Admin feature to the evList admin group',
),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_events']),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_detail']),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_categories']),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_calendars']),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_submissions']),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_repeat']),
array('type' => 'sql', 'sql' => $DEFVALUES['evlist_tickettypes']),
array( 'type' => 'block',
'name' => 'evlist_upcoming',
'title' => 'Upcoming Events',
'phpblockfn' => 'phpblock_evlist_upcoming',
'block_type' => 'phpblock',
'group_id' => 'admin_group_id',
),
array( 'type' => 'block',
'name' => 'evlist_smallmonth',
'title' => 'Event Calendar',
'phpblockfn' => 'phpblock_evlist_smallmonth',
'block_type' => 'phpblock',
'group_id' => 'admin_group_id',
'is_enabled' => 0,
),
);
/**
* Puts the datastructures for this plugin into the glFusion database
* Note: Corresponding uninstall routine is in functions.inc
*
* @return boolean True if successful False otherwise
*/
function plugin_install_evlist()
{
global $INSTALL_plugin, $_EV_CONF, $_TABLES;
$pi_name = $_EV_CONF['pi_name'];
$pi_display_name = $_EV_CONF['pi_display_name'];
$pi_version = $_EV_CONF['pi_version'];
COM_errorLog("Attempting to install the $pi_display_name plugin", 1);
$ret = INSTALLER_install($INSTALL_plugin[$pi_name]);
if ($ret > 0) {
return false;
}
return true;
}
// These are required for the evEvent class. They're included here
// since functions.inc isn't available until the plugin is installed
define(EVLIST_PI_PATH, dirname(__FILE__));
function USES_evlist_functions()
{ require_once EVLIST_PI_PATH . '/evlist_functions.inc.php'; }
function USES_evlist_views()
{ require_once EVLIST_PI_PATH . '/evlist_views.inc.php'; }
function USES_evlist_class_event()
{ require_once EVLIST_PI_PATH . '/classes/evEvent.class.php'; }
function USES_evlist_class_detail()
{ require_once EVLIST_PI_PATH . '/classes/evDetail.class.php'; }
function USES_evlist_class_repeat()
{ require_once EVLIST_PI_PATH . '/classes/evRepeat.class.php'; }
function USES_evlist_class_calendar()
{ require_once EVLIST_PI_PATH . '/classes/evCalendar.class.php'; }
/**
* Post-installation activity.
* Create the repeating event records for the sample data that was loaded.
*/
function X_plugin_postinstall_evlist()
{
global $_TABLES, $_CONF, $_EV_CONF;
require_once $_CONF['path'].'/plugins/evlist/functions.inc';
// Now create the repeat records for the default events
USES_evlist_class_event();
$sql = "SELECT id FROM {$_TABLES['evlist_events']}";
$res = DB_query($sql);
$Ev = new evEvent();
while ($A = DB_fetchArray($res, false)) {
$Ev->Read($A['id']);
$Ev->UpdateRepeats();
}
// Clear the template cache since we've introduced some new css.
// Might not be needed outside of testing where the plugin is repeatedly
// installed & removed, but doesn't hurt.
CTL_clearCache();
}
/**
* Loads the configuration records for the Online Config Manager
*
* @return boolean true = proceed with install, false = an error occured
*
*/
function plugin_load_configuration_evlist()
{
global $_CONF;
require_once $_CONF['path'] . 'plugins/evlist/install_defaults.php';
return plugin_initconfig_evlist();
}
?>