@@ -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 ()
0 commit comments