Skip to content

Commit 2b54be3

Browse files
committed
Merge pull request #85 from featherbb/plugins
Small clean up (yeah, I'm a maniac too)
2 parents 55e3d0d + 6de0b65 commit 2b54be3

File tree

13 files changed

+23
-90
lines changed

13 files changed

+23
-90
lines changed

featherbb/Controller/Admin/Forums.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
$this->config = $this->feather->config;
2424
$this->user = $this->feather->user;
2525
$this->request = $this->feather->request;
26-
$this->model = new \FeatherBB\Model\Admin\forums();
26+
$this->model = new \FeatherBB\Model\Admin\Forums();
2727
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/forums.mo');
2828
}
2929

featherbb/Controller/Admin/Groups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct()
2222
$this->config = $this->feather->config;
2323
$this->user = $this->feather->user;
2424
$this->request = $this->feather->request;
25-
$this->model = new \FeatherBB\Model\Admin\groups();
25+
$this->model = new \FeatherBB\Model\Admin\Groups();
2626
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/groups.mo');
2727
}
2828

featherbb/Controller/Admin/Index.php

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ public function __construct()
2626
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/index.mo');
2727
}
2828

29-
public function remove_install_folder($directory)
30-
{
31-
foreach(glob("{$directory}/*") as $file)
32-
{
33-
if(is_dir($file)) {
34-
$this->remove_install_folder($file);
35-
} else {
36-
unlink($file);
37-
}
38-
}
39-
$deleted = rmdir($directory);
40-
41-
return $deleted;
42-
}
43-
4429
public function display($action = null)
4530
{
4631
// Check for upgrade
@@ -60,24 +45,14 @@ public function display($action = null)
6045
Url::redirect($this->feather->urlFor('adminIndex'), sprintf(__('New version available message'), '<a href="http://featherbb.org/">FeatherBB.org</a>'));
6146
}
6247
}
63-
// Remove /install
64-
elseif ($action == 'remove_install_file') {
65-
$deleted = $this->remove_install_folder($this->feather->forum_env['FEATHER_ROOT'].'install');
66-
67-
if ($deleted) {
68-
Url::redirect($this->feather->urlFor('adminIndex'), __('Deleted install.php redirect'));
69-
} else {
70-
throw new Error(__('Delete install.php failed'), 500);
71-
}
72-
}
7348

7449
AdminUtils::generateAdminMenu('index');
7550

7651
$this->feather->template->setPageInfo(array(
77-
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Index')),
78-
'active_page' => 'admin',
79-
'admin_console' => true
80-
)
81-
)->addTemplate('admin/index.php')->display();
52+
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Index')),
53+
'active_page' => 'admin',
54+
'admin_console' => true
55+
)
56+
)->addTemplate('admin/index.php')->display();
8257
}
8358
}

featherbb/Controller/Admin/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct()
2121
$this->config = $this->feather->config;
2222
$this->user = $this->feather->user;
2323
$this->request = $this->feather->request;
24-
$this->model = new \FeatherBB\Model\Admin\options();
24+
$this->model = new \FeatherBB\Model\Admin\Options();
2525
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/options.mo');
2626
}
2727

featherbb/Controller/Admin/Parser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
$this->config = $this->feather->config;
2424
$this->user = $this->feather->user;
2525
$this->request = $this->feather->request;
26-
$this->model = new \FeatherBB\Model\Admin\parser();
26+
$this->model = new \FeatherBB\Model\Admin\Parser();
2727
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/parser.mo');
2828
}
2929

@@ -53,7 +53,6 @@ public function display()
5353

5454
if ($this->request->post('form_sent')) {
5555

56-
5756
// Upload new smiley image to style/img/smilies
5857
if ($this->request->post('upload') && isset($_FILES['new_smiley']) && isset($_FILES['new_smiley']['error'])) {
5958
$f = $_FILES['new_smiley'];

featherbb/Controller/Admin/Permissions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct()
2121
$this->config = $this->feather->config;
2222
$this->user = $this->feather->user;
2323
$this->request = $this->feather->request;
24-
$this->model = new \FeatherBB\Model\Admin\permissions();
24+
$this->model = new \FeatherBB\Model\Admin\Permissions();
2525
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/permissions.mo');
2626
}
2727

featherbb/Controller/Admin/Plugins.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,43 +73,4 @@ public function deactivate($plugin = null)
7373
Url::redirect($this->feather->urlFor('adminPlugins'), array('warning', 'Plugin deactivated!'));
7474
}
7575

76-
public function display()
77-
{
78-
// The plugin to load should be supplied via GET
79-
$plugin = $this->request->get('plugin') ? $this->request->get('plugin') : '';
80-
if (!preg_match('%^AM?P_(\w*?)\.php$%i', $plugin)) {
81-
throw new Error(__('Bad request'), 400);
82-
}
83-
84-
// AP_ == Admins only, AMP_ == admins and moderators
85-
$prefix = substr($plugin, 0, strpos($plugin, '_'));
86-
if ($this->user->g_moderator == '1' && $prefix == 'AP') {
87-
throw new Error(__('No permission'), 403);
88-
}
89-
90-
// Make sure the file actually exists
91-
if (!file_exists($this->feather->forum_env['FEATHER_ROOT'].'plugins/'.$plugin)) {
92-
throw new Error(sprintf(__('No plugin message'), Utils::escape($plugin)), 400);
93-
}
94-
95-
// Construct REQUEST_URI if it isn't set TODO?
96-
if (!isset($_SERVER['REQUEST_URI'])) {
97-
$_SERVER['REQUEST_URI'] = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '').'?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
98-
}
99-
100-
// Attempt to load the plugin. We don't use @ here to suppress error messages,
101-
// because if we did and a parse error occurred in the plugin, we would only
102-
// get the "blank page of death"
103-
include $this->feather->forum_env['FEATHER_ROOT'].'plugins/'.$plugin;
104-
if (!defined('FEATHER_PLUGIN_LOADED')) {
105-
throw new Error(sprintf(__('Plugin failed message'), Utils::escape($plugin)));
106-
}
107-
108-
$this->feather->template->setPageInfo(array(
109-
'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), str_replace('_', ' ', substr($plugin, strpos($plugin, '_') + 1, -4))),
110-
'active_page' => 'admin',
111-
'admin_console' => true,
112-
)
113-
)->addTemplate('admin/loader.php')->display();
114-
}
11576
}

featherbb/Controller/Admin/Reports.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use FeatherBB\Core\AdminUtils;
1313
use FeatherBB\Core\Utils;
14+
use FeatherBB\Core\Url;
1415

1516
class Reports
1617
{
@@ -21,15 +22,18 @@ public function __construct()
2122
$this->config = $this->feather->config;
2223
$this->user = $this->feather->user;
2324
$this->request = $this->feather->request;
24-
$this->model = new \FeatherBB\Model\Admin\reports();
25+
$this->model = new \FeatherBB\Model\Admin\Reports();
2526
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/reports.mo');
2627
}
2728

2829
public function display()
2930
{
3031
// Zap a report
3132
if ($this->feather->request->isPost()) {
32-
$this->model->zap_report();
33+
$zap_id = intval(key($this->request->post('zap_id')));
34+
$user_id = $this->user->id;
35+
$this->model->zap_report($zap_id, $user_id);
36+
Url::redirect($this->feather->urlFor('adminReports'), __('Report zapped redirect'));
3337
}
3438

3539
AdminUtils::generateAdminMenu('reports');

featherbb/Controller/Admin/Statistics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct()
2222
$this->config = $this->feather->config;
2323
$this->user = $this->feather->user;
2424
$this->request = $this->feather->request;
25-
$this->model = new \FeatherBB\Model\Admin\statistics();
25+
$this->model = new \FeatherBB\Model\Admin\Statistics();
2626
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/admin/index.mo');
2727
}
2828

featherbb/Controller/Edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct()
2222
$this->config = $this->feather->config;
2323
$this->user = $this->feather->user;
2424
$this->request = $this->feather->request;
25-
$this->model = new \FeatherBB\Model\edit();
25+
$this->model = new \FeatherBB\Model\Edit();
2626
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/register.mo');
2727
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/prof_reg.mo');
2828
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->user->language.'/post.mo');

0 commit comments

Comments
 (0)