Skip to content

Commit dc836c5

Browse files
committed
Sync with branch 'development'
2 parents 2d1efc8 + 3a2db58 commit dc836c5

File tree

186 files changed

+2548
-2052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+2548
-2052
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ include/config.php
44
nbproject/
55
lang/French
66
.htaccess
7-
vendor
87
composer.lock

Plugins/Test.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 2015 FeatherBB
5+
* based on code by (C) 2008-2012 FluxBB
6+
* and Rickard Andersson (C) 2002-2008 PunBB
7+
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
8+
*/
9+
10+
namespace Plugins;
11+
12+
use \FeatherBB\Plugin as Plugin;
13+
14+
class Test extends Plugin
15+
{
16+
public static $name = 'A Test plugin';
17+
public static $description = "Just a useless plugin to check everything is all right! And it seems so ;)";
18+
19+
public function runHooks()
20+
{
21+
$this->hooks->bind('get_forum_actions', function ($forum_actions) {
22+
$forum_actions[] = '<a href="' . get_link('mark-read/') . '">Test1</a>';
23+
return $forum_actions;
24+
});
25+
26+
// $this->hooks->bind('get_forum_actions', function ($forum_actions) {
27+
// $forum_actions[] = '<a href="' . get_link('mark-read/') . '">Test2</a>';
28+
// return $forum_actions;
29+
// });
30+
}
31+
32+
public function run()
33+
{
34+
$this->hooks->bind('get_forum_actions', function ($forum_actions) {
35+
$forum_actions[] = '<a href="' . get_link('mark-read/') . '">Test1</a>';
36+
return $forum_actions;
37+
});
38+
39+
$this->hooks->bind('get_forum_actions', function ($forum_actions) {
40+
$forum_actions[] = '<a href="' . get_link('mark-read/') . '">Test2</a>';
41+
return $forum_actions;
42+
});
43+
}
44+
45+
public static function test()
46+
{
47+
echo 'test';
48+
}
49+
}

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
{"name": "beaver"}
1212
],
1313
"autoload": {
14-
"classmap": ["plugins", "include/classes"],
15-
"psr-0": { "plugin\\": "plugins/" }
16-
},
17-
"require-dev": {
18-
"phpunit/phpunit": "4.1.*"
14+
"classmap": ["include/classes/"],
15+
"psr-4" : {
16+
"Plugins\\" : "/plugin"
17+
}
1918
}
2019
}

controller/admin/bans.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function display()
4949
'admin_console' => true,
5050
'page' => $p,
5151
'title' => array(feather_escape($this->config['o_board_title']), __('Admin'), __('Bans'), __('Results head')),
52-
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . paginate_old($num_pages, $p, '?find_ban=&amp;' . implode('&amp;', $ban_info['query_str'])),
52+
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . $this->feather->url->paginate_old($num_pages, $p, '?find_ban=&amp;' . implode('&amp;', $ban_info['query_str'])),
5353
'ban_data' => $ban_data['data'],
5454
)
5555
)->addTemplate('admin/bans/search_ban.php')->display();

controller/admin/categories.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public function add_category()
3131
{
3232
$cat_name = feather_trim($this->request->post('cat_name'));
3333
if ($cat_name == '') {
34-
redirect(get_link('admin/categories/'), __('Must enter name message'));
34+
redirect($this->feather->url->get('admin/categories/'), __('Must enter name message'));
3535
}
3636

3737
if ($this->model->add_category($cat_name)) {
38-
redirect(get_link('admin/categories/'), __('Category added redirect'));
38+
redirect($this->feather->url->get('admin/categories/'), __('Category added redirect'));
3939
} else { //TODO, add error message
40-
redirect(get_link('admin/categories/'), __('Category added redirect'));
40+
redirect($this->feather->url->get('admin/categories/'), __('Category added redirect'));
4141
}
4242
}
4343

@@ -52,15 +52,15 @@ public function edit_categories()
5252
'name' => feather_escape($properties['name']),
5353
'order' => (int) $properties['order'], );
5454
if ($category['name'] == '') {
55-
redirect(get_link('admin/categories/'), __('Must enter name message'));
55+
redirect($this->feather->url->get('admin/categories/'), __('Must enter name message'));
5656
}
5757
$this->model->update_category($category);
5858
}
5959

6060
// Regenerate the quick jump cache
6161
$this->feather->cache->store('quickjump', \model\cache::get_quickjump());
6262

63-
redirect(get_link('admin/categories/'), __('Categories updated redirect'));
63+
redirect($this->feather->url->get('admin/categories/'), __('Categories updated redirect'));
6464
}
6565

6666
public function delete_category()
@@ -72,13 +72,13 @@ public function delete_category()
7272
}
7373

7474
if (intval($this->request->post('disclaimer')) != 1) {
75-
redirect(get_link('admin/categories/'), __('Delete category not validated'));
75+
redirect($this->feather->url->get('admin/categories/'), __('Delete category not validated'));
7676
}
7777

7878
if ($this->model->delete_category($cat_to_delete)) {
79-
redirect(get_link('admin/categories/'), __('Category deleted redirect'));
79+
redirect($this->feather->url->get('admin/categories/'), __('Category deleted redirect'));
8080
} else {
81-
redirect(get_link('admin/categories/'), __('Unable to delete category'));
81+
redirect($this->feather->url->get('admin/categories/'), __('Unable to delete category'));
8282
}
8383
}
8484

controller/admin/forums.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public function add_forum()
3636
$cat_id = (int) $this->request->post('cat');
3737

3838
if ($cat_id < 1) {
39-
redirect(get_link('admin/forums/'), __('Must be valid category'));
39+
redirect($this->feather->url->get('admin/forums/'), __('Must be valid category'));
4040
}
4141

4242
if ($fid = $this->model->add_forum($cat_id, __('New forum'))) {
4343
// Regenerate the quick jump cache
4444
$this->feather->cache->store('quickjump', \model\cache::get_quickjump());
45-
redirect(get_link('admin/forums/edit/'.$fid.'/'), __('Forum added redirect'));
45+
redirect($this->feather->url->get('admin/forums/edit/'.$fid.'/'), __('Forum added redirect'));
4646
} else {
47-
redirect(get_link('admin/forums/'), __('Unable to add forum'));
47+
redirect($this->feather->url->get('admin/forums/'), __('Unable to add forum'));
4848
}
4949
}
5050

@@ -58,13 +58,13 @@ public function edit_forum($forum_id)
5858
'forum_desc' => $this->request->post('forum_desc') ? feather_linebreaks(feather_trim($this->request->post('forum_desc'))) : NULL,
5959
'cat_id' => (int) $this->request->post('cat_id'),
6060
'sort_by' => (int) $this->request->post('sort_by'),
61-
'redirect_url' => url_valid($this->request->post('redirect_url')) ? feather_escape($this->request->post('redirect_url')) : NULL);
61+
'redirect_url' => $this->feather->url->is_valid($this->request->post('redirect_url')) ? feather_escape($this->request->post('redirect_url')) : NULL);
6262

6363
if ($forum_data['forum_name'] == '') {
64-
redirect(get_link('admin/forums/edit/'.$forum_id.'/'), __('Must enter name message'));
64+
redirect($this->feather->url->get('admin/forums/edit/'.$forum_id.'/'), __('Must enter name message'));
6565
}
6666
if ($forum_data['cat_id'] < 1) {
67-
redirect(get_link('admin/forums/edit/'.$forum_id.'/'), __('Must be valid category'));
67+
redirect($this->feather->url->get('admin/forums/edit/'.$forum_id.'/'), __('Must be valid category'));
6868
}
6969

7070
$this->model->update_forum($forum_id, $forum_data);
@@ -100,15 +100,15 @@ public function edit_forum($forum_id)
100100
// Regenerate the quick jump cache
101101
$this->feather->cache->store('quickjump', \model\cache::get_quickjump());
102102

103-
redirect(get_link('admin/forums/edit/'.$forum_id.'/'), __('Forum updated redirect'));
103+
redirect($this->feather->url->get('admin/forums/edit/'.$forum_id.'/'), __('Forum updated redirect'));
104104

105105
} elseif ($this->request->post('revert_perms')) {
106106
$this->model->delete_permissions($forum_id);
107107

108108
// Regenerate the quick jump cache
109109
$this->feather->cache->store('quickjump', \model\cache::get_quickjump());
110110

111-
redirect(get_link('admin/forums/edit/'.$forum_id.'/'), __('Perms reverted redirect'));
111+
redirect($this->feather->url->get('admin/forums/edit/'.$forum_id.'/'), __('Perms reverted redirect'));
112112
}
113113

114114
} else {
@@ -134,7 +134,7 @@ public function delete_forum($forum_id)
134134
// Regenerate the quick jump cache
135135
$this->feather->cache->store('quickjump', \model\cache::get_quickjump());
136136

137-
redirect(get_link('admin/forums/'), __('Forum deleted redirect'));
137+
redirect($this->feather->url->get('admin/forums/'), __('Forum deleted redirect'));
138138

139139
} else { // If the user hasn't confirmed
140140

@@ -162,7 +162,7 @@ public function edit_positions()
162162
// Regenerate the quick jump cache
163163
$this->feather->cache->store('quickjump', \model\cache::get_quickjump());
164164

165-
redirect(get_link('admin/forums/'), __('Forums updated redirect'));
165+
redirect($this->feather->url->get('admin/forums/'), __('Forums updated redirect'));
166166
}
167167

168168
public function display()

controller/admin/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function display($action = null)
6565
$deleted = $this->remove_install_folder($this->feather->forum_env['FEATHER_ROOT'].'install');
6666

6767
if ($deleted) {
68-
redirect(get_link('admin/'), __('Deleted install.php redirect'));
68+
redirect($this->feather->url->get('admin/'), __('Deleted install.php redirect'));
6969
} else {
7070
message(__('Delete install.php failed'));
7171
}

controller/admin/parser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function display()
4141
if ($this->request->post('reset') || !file_exists($cache_file)) {
4242
require_once(FEATHER_ROOT.'include/bbcd_source.php');
4343
require_once(FEATHER_ROOT.'include/bbcd_compile.php');
44-
redirect(get_link('admin/parser/'), $lang_admin_parser['reset_success']);
44+
redirect($this->feather->url->get('admin/parser/'), $lang_admin_parser['reset_success']);
4545
}
4646

4747
// Load the current BBCode $pd array from include/parser_data.inc.php.
@@ -65,7 +65,7 @@ public function display()
6565
if (preg_match('%^image/%', $f['type'])) { // If we have an image file type?
6666
if ($f['size'] > 0 && $f['size'] <= $this->config['o_avatars_size']) {
6767
if (move_uploaded_file($f['tmp_name'], FEATHER_ROOT .'img/smilies/'. $name)) {
68-
redirect(get_link('admin/parser/'), $lang_admin_parser['upload success']);
68+
redirect($this->feather->url->get('admin/parser/'), $lang_admin_parser['upload success']);
6969
} else { // Error #1: 'Smiley upload failed. Unable to move to smiley folder.'.
7070
message($lang_admin_parser['upload_err_1']);
7171
}
@@ -199,7 +199,7 @@ public function display()
199199
}
200200

201201
require_once('include/bbcd_compile.php'); // Compile $bbcd and save into $pd['bbcd']
202-
redirect(get_link('admin/parser/'), $lang_admin_parser['save_success']);
202+
redirect($this->feather->url->get('admin/parser/'), $lang_admin_parser['save_success']);
203203
}
204204

205205
\FeatherBB\AdminUtils::generateAdminMenu('parser');

controller/admin/plugins.php

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,69 +28,67 @@ public function __autoload($class_name)
2828

2929
public function index()
3030
{
31-
if (!$this->user->is_admmod) {
32-
message(__('No permission'), '403');
33-
}
34-
3531
// Update permissions
3632
// if ($this->feather->request->isPost()) {
3733
// $this->model->update_permissions();
3834
// }
3935

40-
// $this->header->setTitle($page_title)->setActivePage('admin')->enableAdminConsole()->display();
41-
4236
generate_admin_menu('plugins');
4337

44-
$pluginsList = \FeatherBB\Plugin::getPluginsList();
38+
$pluginsList = \FeatherBB\AdminUtils::getValidPlugins();
39+
// var_dump($pluginsList);
40+
$activePlugins = $this->feather->cache->isCached('active_plugins') ? $this->feather->cache->retrieve('active_plugins') : array();
41+
// var_dump($activePlugins);
4542

4643
$this->feather->view2->setPageInfo(array(
4744
'admin_console' => true,
4845
'active_page' => 'admin',
49-
'focus_element' => array('bans', 'new_ban_user'),
5046
'pluginsList' => $pluginsList,
47+
'activePlugins' => $activePlugins,
5148
'title' => array(feather_escape($this->config['o_board_title']), __('Admin'), 'Plugins'),
5249
)
5350
)->addTemplate('admin/plugins.php')->display();
54-
55-
// $this->feather->render('admin/plugins.php', array(
56-
// 'pluginsList' => $pluginsList
57-
// )
58-
// );
59-
//
60-
// $this->footer->display();
6151
}
6252

6353
public function activate()
6454
{
65-
if (!$this->user->is_admmod) {
66-
message(__('No permission'), '403');
67-
}
68-
69-
// Update permissions
70-
// if ($this->feather->request->isPost()) {
71-
// $this->model->update_permissions();
72-
// }
73-
7455
// The plugin to load should be supplied via GET
75-
$plugin = $this->request->get('plugin') ? $this->request->get('plugin') : null;
76-
if (!$plugin) {
56+
$class = $this->request->get('plugin') ? $this->request->get('plugin') : null;
57+
if (!$class) {
7758
message(__('Bad request'), '404');
7859
}
7960

80-
// Require all valid filenames...
81-
\FeatherBB\Plugin::getPluginsList();
82-
// And make sure the plugin actually extends base Plugin class
83-
if (!property_exists('\plugin\\'.$plugin, 'isFeatherPlugin')) {
84-
message(sprintf(__('No plugin message'), feather_escape($plugin)));
61+
// Check if plugin follows PSR-4 conventions and extends base forum plugin
62+
if (!class_exists($class) || !property_exists($class, 'isValidFBPlugin')) {
63+
message(sprintf(__('No plugin message'), feather_escape($class)));
8564
}
8665

66+
$plugin = new $class;
8767
try {
88-
\FeatherBB\Plugin::activate($plugin);
89-
redirect(get_link('admin/plugins/'), 'Plugin '.feather_escape($plugin).' activated');
68+
$plugin->activate($class);
9069
} catch (\Exception $e) {
9170
redirect(get_link('admin/plugins/'), feather_escape($e->getMessage()));
9271
}
72+
// Plugin has been activated, confirm and redirect
73+
redirect(get_link('admin/plugins/'), 'Plugin "'.$class::$name.'" activated!');
74+
}
75+
76+
public function deactivate()
77+
{
78+
// The plugin to load should be supplied via GET
79+
$class = $this->request->get('plugin') ? $this->request->get('plugin') : null;
80+
if (!$class) {
81+
message(__('Bad request'), '404');
82+
}
9383

84+
$plugin = new $class;
85+
try {
86+
$plugin->deactivate($class);
87+
} catch (\Exception $e) {
88+
redirect(get_link('admin/plugins/'), feather_escape($e->getMessage()));
89+
}
90+
// Plugin has been activated, confirm and redirect
91+
redirect(get_link('admin/plugins/'), 'Plugin "'.$class::$name.'" deactivated!');
9492
}
9593

9694
public function display()

controller/admin/users.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function display()
9999
$start_from = 50 * ($p - 1);
100100

101101
// Generate paging links
102-
$paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . paginate_old($num_pages, $p, '?find_user=&amp;'.implode('&amp;', $search['query_str']));
102+
$paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . $this->feather->url->paginate_old($num_pages, $p, '?find_user=&amp;'.implode('&amp;', $search['query_str']));
103103

104104
// Some helper variables for permissions
105105
$can_delete = $can_move = $this->user->g_id == FEATHER_ADMIN;
@@ -153,7 +153,7 @@ public function ipstats($id)
153153
'active_page' => 'admin',
154154
'admin_console' => true,
155155
'page' => $p,
156-
'paging_links' => '<span class="pages-label">'.__('Pages').' </span>'.paginate_old($num_pages, $p, '?ip_stats='.$id),
156+
'paging_links' => '<span class="pages-label">'.__('Pages').' </span>'.$this->feather->url->paginate_old($num_pages, $p, '?ip_stats='.$id),
157157
'start_from' => $start_from,
158158
'ip_data' => $this->model->get_ip_stats($id, $start_from),
159159
)
@@ -180,7 +180,7 @@ public function showusers($ip)
180180
'title' => array(feather_escape($this->config['o_board_title']), __('Admin'), __('Users'), __('Results head')),
181181
'active_page' => 'admin',
182182
'admin_console' => true,
183-
'paging_links' => '<span class="pages-label">'.__('Pages').' </span>'.paginate_old($num_pages, $p, '?ip_stats='.$ip),
183+
'paging_links' => '<span class="pages-label">'.__('Pages').' </span>'.$this->feather->url->paginate_old($num_pages, $p, '?ip_stats='.$ip),
184184
'page' => $p,
185185
'start_from' => $start_from,
186186
'info' => $this->model->get_info_poster($ip, $start_from),

0 commit comments

Comments
 (0)