-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_thanks_mod.php
More file actions
386 lines (361 loc) · 12 KB
/
Copy pathinstall_thanks_mod.php
File metadata and controls
386 lines (361 loc) · 12 KB
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<?php
/**
*
* @author Sergeiy Varzaev (Ïàëû÷) phpbbguru.net varzaev@mail.ru
* @version $Id: install_thanks_mod.php 135 2012-10-10 10:02:51 Ïàëû÷ $
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
define('UMIL_AUTO', true);
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if (!file_exists($phpbb_root_path . 'umil/umil_auto.' . $phpEx))
{
trigger_error('Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR);
}
// The name of the mod to be displayed during installation.
$mod_name = 'THANKS_INSTALLED';
/*
* The name of the config variable which will hold the currently installed version
* You do not need to set this yourself, UMIL will handle setting and updating the version itself.
*/
$version_config_name = 'thanks_mod_version';
/*
* The language file which will be included when installing
* Language entries that should exist in the language file for UMIL (replace $mod_name with the mod's name you set to $mod_name above)
* $mod_name
* 'INSTALL_' . $mod_name
* 'INSTALL_' . $mod_name . '_CONFIRM'
* 'UPDATE_' . $mod_name
* 'UPDATE_' . $mod_name . '_CONFIRM'
* 'UNINSTALL_' . $mod_name
* 'UNINSTALL_' . $mod_name . '_CONFIRM'
*/
$language_file = 'mods/thanks_mod';
/*
* Options to display to the user (this is purely optional, if you do not need the options you do not have to set up this variable at all)
* Uses the acp_board style of outputting information, with some extras (such as the 'default' and 'select_user' options)
$options = array(
'test_username' => array('lang' => 'TEST_USERNAME', 'type' => 'text:40:255', 'explain' => true, 'default' => $user->data['username'], 'select_user' => true),
'test_boolean' => array('lang' => 'TEST_BOOLEAN', 'type' => 'radio:yes_no', 'default' => true),
);
*/
/*
* Optionally we may specify our own logo image to show in the upper corner instead of the default logo.
* $phpbb_root_path will get prepended to the path specified
* Image height should be 50px to prevent cut-off or stretching.
*/
$logo_img = '';
/*
* The array of versions and actions within each.
* You do not need to order it a specific way (it will be sorted automatically), however, you must enter every version, even if no actions are done for it.
*
* You must use correct version numbering. Unless you know exactly what you can use, only use X.X.X (replacing X with an integer).
* The version numbering must otherwise be compatible with the version_compare function - http://php.net/manual/en/function.version-compare.php
*/
$versions = array(
// Version 1.2.5
'1.2.5' => array(
'custom' => 'uninstall_thanks',
// Lets add a config setting
'config_add' => array(
array('remove_thanks', '1'),
array('thanks_postlist_view', '1'),
array('thanks_profilelist_view', '1'),
array('thanks_counters_view', '1'),
array('thanks_number', '100'),
array('thanks_info_page', '1'),
array('thanks_only_first_post', '0'),
),
// Now to add some permission settings
'permission_add' => array(
array('f_thanks', false),
array('u_viewthanks', true),
),
// How about we give some default permissions then as well?
'permission_set' => array(
// Global permissions
array('ROLE_USER_STANDARD', 'u_viewthanks', 'role', true),
array('REGISTERED', 'u_viewthanks', 'group', true),
// Local Permissions (local permissions can not be set for groups)
array('ROLE_FORUM_STANDARD', 'f_thanks', 'role', true),
),
// Now to add a table (this uses the layout from develop/create_schema_files.php and from phpbb_db_tools)
'table_add' => array(
array($table_prefix . 'thanks', array(
'COLUMNS' => array(
'post_id' => array('UINT', 0),
'poster_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
),
'PRIMARY_KEY' => array('post_id', 'user_id'),
),
),
),
// Lets add a new column to the phpbb_users table
'table_column_add' => array(
array($table_prefix . 'users', 'user_allow_thanks_pm', array('BOOL', 0)),
),
),
// Version 1.2.6
//* module_remove($class, $parent = 0, $module = '')
'1.2.6' => array(
'custom' => 'update_module',
// Lets add a config setting
'config_add' => array(
array('thanks_number_post', '10'),
),
),
// Version 1.2.7
'1.2.7' => array(
// Now lets add some modules to the ACP
'module_add' => array(
array('acp', 'ACP_CAT_DOT_MODS', 'ACP_THANKS'),
array('acp', 'ACP_THANKS', array(
'module_basename' => 'thanks',
'module_langname' => 'ACP_THANKS_SETTINGS',
'module_mode' => 'thanks',
'module_auth' => 'acl_a_board',
),
),
array('acp', 'ACP_THANKS', array(
'module_basename' => 'thanks_refresh',
'module_langname' => 'ACP_THANKS_REFRESH',
'module_mode' => 'thanks',
'module_auth' => 'acl_a_board',
),
),
array('acp', 'ACP_THANKS', array(
'module_basename' => 'thanks_truncate',
'module_langname' => 'ACP_THANKS_TRUNCATE',
'module_mode' => 'thanks',
'module_auth' => 'acl_a_board',
),
),
),
),
// Version 1.2.8
'1.2.8' => array(
// Lets add a config setting
'config_add' => array(
array('thanks_post_reput_view', '1'),
array('thanks_topic_reput_view', '1'),
array('thanks_forum_reput_view', '0'),
array('thanks_reput_height', '15'),
array('thanks_reput_level', '10'),
array('thanks_number_digits', '2'),
array('thanks_number_row_reput', '5'),
array('thanks_reput_graphic', '1'),
array('thanks_reput_image', 'styles/prosilver/theme/images/reput_star_gold.gif'),
array('thanks_reput_image_back', 'styles/prosilver/theme/images/reput_star_back.gif'),
array('thanks_time_view', '1'),
array('thanks_top_number', '5'),
),
// Now lets add some modules to the ACP
'module_add' => array(
array('acp', 'ACP_THANKS', array(
'module_basename' => 'thanks_reput',
'module_langname' => 'ACP_THANKS_REPUT_SETTINGS',
'module_mode' => 'thanks',
'module_auth' => 'acl_a_board',
),
),
),
// Now to add some permission settings
'permission_add' => array(
array('u_viewtoplist', true),
),
// How about we give some default permissions then as well?
'permission_set' => array(
// Global Group permissions
array('REGISTERED', 'u_viewtoplist', 'group', true),
array('ROLE_USER_STANDARD', 'u_viewtoplist', 'role', true),
),
// Lets add a new column to the phpbb_thanks
'table_column_add' => array(
array($table_prefix . 'thanks', 'topic_id', array('UINT', 0)),
array($table_prefix . 'thanks', 'forum_id', array('UINT', 0)),
array($table_prefix . 'thanks', 'thanks_time', array('UINT:11', 0)),
),
// update thanks table
'custom' => 'update_thanks_table',
),
// Version 1.2.9
'1.2.9' => array(
// Lets add a new column to the phpbb_users table
'table_column_add' => array(
array($table_prefix . 'users', 'user_allow_thanks_email', array('BOOL', 0)),
),
),
// Version 1.3.0
'1.3.0' => array(
),
// Version 1.3.1
'1.3.1' => array(
// Now to add some permission settings
'permission_add' => array(
array('m_thanks', true),
),
// How about we give some default permissions then as well?
'permission_set' => array(
array('ROLE_MOD_FULL', 'm_thanks', 'role', true),
array('GLOBAL_MODERATORS', 'm_thanks', 'group', true),
),
),
// Version 1.3.2
'1.3.2' => array(
// Lets add a config setting
'config_add' => array(
array('thanks_forum_reput_view_column', '0'),
array('thanks_topic_reput_view_column', '0'),
),
),
// Version 1.3.3
'1.3.3' => array(
// Lets add a config setting
'config_add' => array(
array('thanks_notice_on', '0'),
),
// Lets update a config setting
'config_update' => array(
array('thanks_reput_image', 'images/rating/reput_star_gold.gif'),
array('thanks_reput_image_back', 'images/rating/reput_star_back.gif'),
array('thanks_top_number', '0'),
),
// How about we give some default permissions then as well?
'permission_set' => array(
// Local Permissions (local permissions can not be set for groups)
array('ROLE_FORUM_FULL', 'f_thanks', 'role', true),
),
),
// Version 1.3.4
'1.3.4' => array(
// Lets add a config setting
'config_add' => array(
array('thanks_global_announce', '1'),
),
// How about we give some default permissions then as well?
'permission_set' => array(
// Local Permissions (local permissions can not be set for groups)
array('ROLE_FORUM_FULL', 'f_thanks', 'role', true),
array('ROLE_FORUM_POLLS', 'f_thanks', 'role', true),
array('ROLE_FORUM_LIMITED', 'f_thanks', 'role', true),
array('ROLE_FORUM_LIMITED_POLLS', 'f_thanks', 'role', true),
array('ROLE_USER_FULL', 'u_viewtoplist', 'role', true),
array('ROLE_USER_LIMITED', 'u_viewtoplist', 'role', true),
array('ROLE_USER_NOPM', 'u_viewtoplist', 'role', true),
array('ROLE_USER_NOAVATAR', 'u_viewtoplist', 'role', true),
array('ROLE_USER_FULL', 'u_viewthanks', 'role', true),
array('ROLE_USER_LIMITED', 'u_viewthanks', 'role', true),
array('ROLE_USER_NOPM', 'u_viewthanks', 'role', true),
array('ROLE_USER_NOAVATAR', 'u_viewthanks', 'role', true),
),
//Cache purge
'cache_purge' => array(
array('template', 0),
array('imageset', 0),
array('theme', 0),
array(),
),
'table_index_add' => array(
array($table_prefix . 'thanks', 'post_id', array('post_id')),
array($table_prefix . 'thanks', 'topic_id', array('topic_id')),
array($table_prefix . 'thanks', 'forum_id', array('forum_id')),
array($table_prefix . 'thanks', 'user_id', array('user_id')),
array($table_prefix . 'thanks', 'poster_id', array('poster_id')),
),
),
// Version 1.3.5
'1.3.5' => array(
//Cache purge
'cache_purge' => array(
array('template', 0),
),
),
);
// Include the UMIF Auto file and everything else will be handled automatically.
include($phpbb_root_path . 'umil/umil_auto.' . $phpEx);
/*
*
* @param string $action The action (install|update|uninstall) will be sent through this.
* @param string $version The version this is being run for will be sent through this.
*/
function update_thanks_table($action, $version)
{
global $db, $table_prefix, $umil;
if ($action != 'uninstall')
{
if (!defined('THANKS_TABLE'))
{
define('THANKS_TABLE', $table_prefix . 'thanks');
}
$sql = 'UPDATE '. THANKS_TABLE .'
SET forum_id = (SELECT forum_id
FROM '. POSTS_TABLE .'
WHERE post_id = '. THANKS_TABLE .'.post_id)';
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
$sql = 'UPDATE '. THANKS_TABLE .'
SET topic_id = (SELECT topic_id
FROM '. POSTS_TABLE .'
WHERE post_id = '. THANKS_TABLE .'.post_id)';
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
}
/**
* Return a string
* The string will be shown as the action performed (command). It will show any SQL errors as a failure, otherwise success
*/
return 'THANKS_CUSTOM0_FUNCTION';
/**
* Return an array
* With the keys command and result to specify the command and the result
* Returning a result (other than SUCCESS) assumes a failure
*/
/* return array(
'command' => 'EXAMPLE_CUSTOM_FUNCTION',
'result' => 'FAIL',
);*/
/**
* Return an array
* With the keys command and result (same as above) with an array for the command.
* With an array for the command it will use sprintf the first item in the array with the following items.
* Returning a result (other than SUCCESS) assumes a failure
*/
/* return array(
'command' => array(
'EXAMPLE_CUSTOM_FUNCTION',
$username,
$number,
$etc,
),
'result' => 'FAIL',
);*/
}
function update_module($action, $version)
{
global $umil;
if ($action == 'update')
{
$umil-> module_remove('acp', 'ACP_MESSAGES', 'ACP_THANKS');
}
return 'THANKS_CUSTOM1_FUNCTION';
}
function uninstall_thanks($action, $version)
{
global $umil;
if ($action == 'uninstall')
{
$umil-> cache_purge();
}
return 'THANKS_CUSTOM2_FUNCTION';
}
?>