-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
controller.php
262 lines (218 loc) · 6.39 KB
/
controller.php
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
<?php
/**
* @version $Id$
* @package Joomla
* @subpackage Installer
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.application.component.controller');
jimport('joomla.client.helper');
/**
* Installer Controller
*
* @package Joomla
* @subpackage Installer
* @since 1.5
*/
class InstallerController extends JController
{
/**
* Display the extension installer form
*
* @access public
* @return void
* @since 1.5
*/
function installform()
{
$model = &$this->getModel( 'Install' );
$view = &$this->getView( 'Install');
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$view->setModel( $model, true );
$view->display();
}
/**
* Install an extension
*
* @access public
* @return void
* @since 1.5
*/
function doInstall()
{
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$model = &$this->getModel( 'Install' );
$view = &$this->getView( 'Install' );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
if ($model->install()) {
$cache = &JFactory::getCache('mod_menu');
$cache->clean();
}
$view->setModel( $model, true );
$view->display();
}
/**
* Manage an extension type (List extensions of a given type)
*
* @access public
* @return void
* @since 1.5
*/
function manage()
{
$type = JRequest::getWord('type', 'components');
$model = &$this->getModel( $type );
$view = &$this->getView( $type );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$view->setModel( $model, true );
$view->display();
}
/**
* Discover handler
*/
function discover() {
$model = &$this->getModel('discover');
$view = &$this->getView( 'discover' );
$model->discover();
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$view->setModel( $model, true );
$view->display();
}
function discover_install() {
$model = &$this->getModel('discover');
$view = &$this->getView( 'discover' );
$model->discover_install();
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$view->setModel( $model, true );
$view->display();
}
function discover_purge() {
$model = &$this->getModel('discover');
$model->purge();
$this->setRedirect('index.php?option=com_installer&task=manage&type=discover', $model->_message);
}
/**
* Enable an extension (If supported)
*
* @access public
* @return void
* @since 1.5
*/
function enable()
{
// Check for request forgeries
JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' );
$type = JRequest::getWord('type', 'components');
$model = &$this->getModel( $type );
$view = &$this->getView( $type );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
if (method_exists($model, 'enable')) {
$eid = JRequest::getVar('eid', array(), '', 'array');
JArrayHelper::toInteger($eid, array());
$model->enable($eid);
}
$view->setModel( $model, true );
$view->display();
}
/**
* Disable an extension (If supported)
*
* @access public
* @return void
* @since 1.5
*/
function disable()
{
// Check for request forgeries
JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' );
$type = JRequest::getWord('type', 'components');
$model = &$this->getModel( $type );
$view = &$this->getView( $type );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
if (method_exists($model, 'disable')) {
$eid = JRequest::getVar('eid', array(), '', 'array');
JArrayHelper::toInteger($eid, array());
$model->disable($eid);
}
$view->setModel( $model, true );
$view->display();
}
/**
* Remove an extension (Uninstall)
*
* @access public
* @return void
* @since 1.5
*/
function remove() {
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$type = JRequest::getWord('type', 'components');
$model = &$this->getModel( $type );
$view = &$this->getView( $type );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$eid = JRequest::getVar('eid', array(), '', 'array');
// Update to handle components radio box
// Checks there is only one extensions, we're uninstalling components
// and then checks that the zero numbered item is set (shouldn't be a zero
// if the eid is set to the proper format)
if((count($eid) == 1) && ($type == 'components') && (isset($eid[0]))) $eid = array($eid[0] => 0);
JArrayHelper::toInteger($eid, array());
$result = $model->remove($eid);
$view->setModel( $model, true );
$view->display();
}
// Should probably use multiple controllers here
function update()
{
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$type = JRequest::getWord('type', 'components');
$model = &$this->getModel( $type );
$view = &$this->getView( $type );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$uid = JRequest::getVar('uid', array(), '', 'array');
JArrayHelper::toInteger($uid, array());
$result = $model->update($uid);
$view->setModel( $model, true );
$view->display();
}
function update_find() {
// Find updates
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$type = JRequest::getWord('type', 'components');
$model = &$this->getModel( $type );
$view = &$this->getView( $type );
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$view->assignRef('ftp', $ftp);
$model->purge();
$result = $model->findUpdates();
$view->setModel( $model, true );
$view->display();
}
function update_purge() {
// Purge updates
$model = &$this->getModel('update');
$model->purge();
$this->setRedirect('index.php?option=com_installer&task=manage&type=update', $model->_message);
}
}