forked from cynial/STBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.php
More file actions
164 lines (137 loc) · 3.28 KB
/
Copy pathplugins.php
File metadata and controls
164 lines (137 loc) · 3.28 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
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* STBlog
*
* 基于Codeigniter的单用户多权限开源博客系统
*
*
* @package STBLOG
* @author Saturn
* @copyright Copyright (c) 2009 - 2010, cnsaturn.com.
* @license GNU General Public License 2.0
* @link http://code.google.com/p/stblog/
* @since Version 0.1
* @filesource
*/
// ------------------------------------------------------------------------
/**
* STBLOG Plugins Class
*
* 本类用于Plugins管理逻辑
*
* @package STBLOG
* @subpackage Controller
* @category Admin Controller
* @author Saturn <huyanggang@gmail.com>
* @link http://code.google.com/p/stblog/
*/
class Plugins extends ST_Auth_Controller {
/**
* 传递到对应视图的数据
*
* @access private
* @var array
*/
private $_data = array();
/**
* 解析函数
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
/** privilege confirm */
$this->auth->exceed('administrator');
$this->utility->clear_db_cache();
$this->load->model('plugins_mdl');
/** common data */
$this->_data['parentPage'] = 'dashboard';
$this->_data['currentPage'] = 'plugins';
$this->_data['page_title'] = '插件管理';
}
/**
* 默认执行函数
*
* @access public
* @return void
*/
public function index()
{
redirect('admin/plugins/manage');
}
/**
* 插件管理
*
* @access public
* @return void
*/
public function manage()
{
$plugins = $this->plugins_mdl->get_all_plugins_info();
$activated_plugins = $this->utility->get_active_plugins();
$deactivated_plugins = array();
foreach($plugins as $plugin)
{
if(!in_array($plugin, $activated_plugins))
{
$deactivated_plugins[] = $plugin;
}
}
$this->_data['activated_plugins'] = $activated_plugins;
$this->_data['deactivated_plugins'] = $deactivated_plugins;
$this->load->view('admin/plugins', $this->_data);
}
/**
* 激活插件
*
* @access public
* @param string $name 插件目录名
* @return void
*/
public function activate($name)
{
$plugin = $this->plugins_mdl->get($name);
$activated = 0;
if($plugin && is_array($plugin))
{
$this->plugins_mdl->active($plugin);
$activated++;
}
($activated >0)
?$this->_redirect_with_msg('success', '成功激活插件')
:$this->_redirect_with_msg('error', '没有插件被激活');
}
/**
* 禁用插件
*
* @access public
* @param string $name 插件目录名
* @return void
*/
public function deactivate($name)
{
$plugin = $this->plugins_mdl->get(strtolower($name));
$deactivated = 0;
if($plugin && is_array($plugin))
{
$this->plugins_mdl->deactive($plugin);
$deactivated++;
}
($deactivated >0)
?$this->_redirect_with_msg('success', '成功禁用插件')
:$this->_redirect_with_msg('error', '没有插件被禁用');
}
/** Todo: 插件管理(插件自定义参数设置) */
public function config($name)
{
}
private function _redirect_with_msg($flag, $msg)
{
$this->session->set_flashdata($flag, $msg);
go_back();
}
}
/* End of file Plugins.php */
/* Location: ./application/controllers/admin/Plugins.php */