Annotation of /mambo/branches/4.6/administrator/components/com_installer/admin.installer.php
Parent Directory
|
Revision Log
Revision 837 - (view) (download)
| 1 : | alwarren | 772 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo Open Source | ||
| 4 : | * @subpackage Installer | ||
| 5 : | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * | ||
| 8 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 9 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 10 : | * Mambo is Free Software | ||
| 11 : | */ | ||
| 12 : | |||
| 13 : | /** ensure this file is being included by a parent file */ | ||
| 14 : | defined( '_VALID_MOS' ) or die( T_('Direct Access to this location is not allowed.') ); | ||
| 15 : | |||
| 16 : | require_once( $mainframe->getPath( 'admin_html' ) ); | ||
| 17 : | require_once( $mainframe->getPath( 'class' ) ); | ||
| 18 : | |||
| 19 : | $element = mosGetParam( $_REQUEST, 'element', '' ); | ||
| 20 : | $client = mosGetParam( $_REQUEST, 'client', '' ); | ||
| 21 : | // ensure user has access to this function | ||
| 22 : | if (!$acl->acl_check( 'administration', 'install', 'users', $my->usertype, $element . 's', 'all' ) ) { | ||
| 23 : | mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') ); | ||
| 24 : | } | ||
| 25 : | |||
| 26 : | // map the element to the required derived class | ||
| 27 : | $classMap = array( | ||
| 28 : | 'universal' => 'mosInstaller', | ||
| 29 : | 'component' => 'mosInstaller', | ||
| 30 : | 'language' => 'mosInstaller', | ||
| 31 : | 'mambot' => 'mosInstaller', | ||
| 32 : | 'module' => 'mosInstaller', | ||
| 33 : | 'template' => 'mosInstaller', | ||
| 34 : | 'include' => 'mosInstaller', | ||
| 35 : | 'parameters' => 'mosInstaller' | ||
| 36 : | ); | ||
| 37 : | |||
| 38 : | if (array_key_exists ( $element, $classMap )) { | ||
| 39 : | // require_once( $mainframe->getPath( 'installer_class', $element ) ); | ||
| 40 : | |||
| 41 : | switch ($task) { | ||
| 42 : | |||
| 43 : | case 'uploadfile': | ||
| 44 : | uploadPackage( $classMap[$element], $option, $element, $client ); | ||
| 45 : | break; | ||
| 46 : | |||
| 47 : | case 'installfromdir': | ||
| 48 : | installFromDirectory( $classMap[$element], $option, $element, $client ); | ||
| 49 : | break; | ||
| 50 : | |||
| 51 : | case 'installfromurl': | ||
| 52 : | installFromUrl ($classMap[$element], $option, $element, $client); | ||
| 53 : | break; | ||
| 54 : | |||
| 55 : | case 'thesource': | ||
| 56 : | HTML_installer::theSourceForm($option, $element, $client); | ||
| 57 : | break; | ||
| 58 : | |||
| 59 : | case 'addon': | ||
| 60 : | HTML_installer::AddonForm($classMap[$element], $option, $element, $client); | ||
| 61 : | break; | ||
| 62 : | |||
| 63 : | case 'remove': | ||
| 64 : | $uninstaller = $element.'_uninstall'; | ||
| 65 : | if (is_callable($uninstaller)) { | ||
| 66 : | $cid = mosGetParam($_REQUEST, 'cid', array(0)); | ||
| 67 : | if (is_array($cid) AND isset($cid[0])) { | ||
| 68 : | $uninstaller ($cid[0], $option, $client); | ||
| 69 : | exit (); | ||
| 70 : | } | ||
| 71 : | mosRedirect(returnTo($option, $element, $client), T_('There was nothing selected to be uninstalled') ); | ||
| 72 : | } | ||
| 73 : | else mosRedirect(returnTo($option, $element, $client), T_('Uninstaller not found for element [%s]') ); | ||
| 74 : | break; | ||
| 75 : | |||
| 76 : | default: | ||
| 77 : | $path = $mosConfig_absolute_path . "/administrator/components/com_installer/$element/$element.php"; | ||
| 78 : | |||
| 79 : | if (file_exists( $path )) { | ||
| 80 : | require $path; | ||
| 81 : | } else { | ||
| 82 : | echo sprintf(T_('Installer not found for element [%s]'), $element); | ||
| 83 : | } | ||
| 84 : | break; | ||
| 85 : | } | ||
| 86 : | } | ||
| 87 : | else { | ||
| 88 : | echo sprintf(T_('Installer not available for element [%s]'), $element); | ||
| 89 : | } | ||
| 90 : | |||
| 91 : | |||
| 92 : | function returnTo ($option, $element, $client) { | ||
| 93 : | switch ($element) { | ||
| 94 : | case 'template': | ||
| 95 : | return "index2.php?option=com_templates&client=$client"; | ||
| 96 : | case 'language': | ||
| 97 : | return "index2.php?option=com_languages"; | ||
| 98 : | default: | ||
| 99 : | return "index2.php?option=$option&element=$element"; | ||
| 100 : | } | ||
| 101 : | } | ||
| 102 : | |||
| 103 : | /** | ||
| 104 : | * @param string The class name for the installer | ||
| 105 : | * @param string The URL option | ||
| 106 : | * @param string The element name | ||
| 107 : | */ | ||
| 108 : | function uploadPackage( $installerClass, $option, $element, $client ) { | ||
| 109 : | global $mainframe; | ||
| 110 : | |||
| 111 : | // Check if file uploads are enabled | ||
| 112 : | if (!(bool)ini_get('file_uploads')) { | ||
| 113 : | $message = new mosError (T_('The installer can\'t continue before file uploads are enabled. Please use the install from directory method.'), _MOS_ERROR_FATAL); | ||
| 114 : | HTML_installer::showInstallMessage($message, T_('Installer - Error'), returnTo( $option, $element, $client )); | ||
| 115 : | exit(); | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | // Check that the zlib is available | ||
| 119 : | if(!extension_loaded('zlib')) { | ||
| 120 : | $message = new mosError (T_('The installer can\'t continue before zlib is installed'), _MOS_ERROR_FATAL); | ||
| 121 : | HTML_installer::showInstallMessage($message, T_('Installer - Error'), returnTo( $option, $element, $client )); | ||
| 122 : | exit(); | ||
| 123 : | } | ||
| 124 : | |||
| 125 : | $userfile = mosGetParam( $_FILES, 'userfile', null ); | ||
| 126 : | |||
| 127 : | if (!$userfile) { | ||
| 128 : | $message = new mosError (T_('No file selected'), _MOS_ERROR_FATAL); | ||
| 129 : | HTML_installer::showInstallMessage($message, T_('Upload new module - error'), returnTo($option, $element, $client)); | ||
| 130 : | exit(); | ||
| 131 : | } | ||
| 132 : | |||
| 133 : | $userfile_name = $userfile['name']; | ||
| 134 : | |||
| 135 : | chanh | 837 | |
| 136 : | if (get_magic_quotes_gpc()==0) $userfile['tmp_name'] = stripslashes($userfile['tmp_name']); | ||
| 137 : | if (uploadFile( $userfile['tmp_name'], $userfile['name'], $message )) { | ||
| 138 : | // if (uploadFile( stripslashes($userfile['tmp_name']), $userfile['name'], $message )) { | ||
| 139 : | alwarren | 772 | $installer =& new $installerClass(); |
| 140 : | if (!$installer->extractArchive( $userfile['name'] )) { | ||
| 141 : | $installer->cleanUpInstall(); | ||
| 142 : | HTML_installer::showInstallMessage( $installer->getErrors(), sprintf(T_('Upload %s - Upload Failed'), $element), | ||
| 143 : | returnTo( $option, $element, $client ) ); | ||
| 144 : | } | ||
| 145 : | $ret = $installer->install(); | ||
| 146 : | $installer->cleanUpInstall(); | ||
| 147 : | HTML_installer::showInstallMessage( $installer->getErrors(), T_('Upload ').$element.' - '.($ret ? T_('Success') : T_('Failed')), | ||
| 148 : | returnTo( $option, $element, $client ) ); | ||
| 149 : | } | ||
| 150 : | else HTML_installer::showInstallMessage( $message, sprintf(T_('Upload %s - Upload Error'), $element), | ||
| 151 : | returnTo( $option, $element, $client ) ); | ||
| 152 : | } | ||
| 153 : | |||
| 154 : | /** | ||
| 155 : | * Install a template from a directory | ||
| 156 : | * @param string The URL option | ||
| 157 : | */ | ||
| 158 : | function installFromDirectory( $installerClass, $option, $element, $client ) { | ||
| 159 : | $userfile = mosGetParam( $_REQUEST, 'userfile', '' ); | ||
| 160 : | if (!$userfile) { | ||
| 161 : | mosRedirect( "index2.php?option=$option&element=module", T_('Please select a directory') ); | ||
| 162 : | } | ||
| 163 : | $path = mosPathName( $userfile ); | ||
| 164 : | if (!is_dir( $path )) { | ||
| 165 : | $path = dirname( $path ); | ||
| 166 : | } | ||
| 167 : | $installer =& new $installerClass(); | ||
| 168 : | $ret = $installer->install( $path ); | ||
| 169 : | $installer->cleanUpInstall(); | ||
| 170 : | HTML_installer::showInstallMessage( $installer->getErrors(), T_('Install new ').$element.' - '.($ret ? T_('Success') : T_('Error')), | ||
| 171 : | returnTo( $option, $element, $client ) ); | ||
| 172 : | } | ||
| 173 : | /** | ||
| 174 : | * Install a template from an HTTP URL | ||
| 175 : | * @param string The URL option | ||
| 176 : | */ | ||
| 177 : | function installFromUrl( $installerClass, $option, $element, $client ) { | ||
| 178 : | // Check that the zlib is available | ||
| 179 : | if(!extension_loaded('zlib')) { | ||
| 180 : | $message = new mosError (T_('The installer can\'t continue before zlib is installed'), _MOS_ERROR_FATAL); | ||
| 181 : | HTML_installer::showInstallMessage($message, 'Installer - Error', returnTo( $option, $element, $client )); | ||
| 182 : | exit(); | ||
| 183 : | } | ||
| 184 : | $userurl = mosGetParam( $_REQUEST, 'userurl', '' ); | ||
| 185 : | if (!$userurl) { | ||
| 186 : | $message = new mosError (T_('Please select an HTTP URL'), _MOS_ERROR_FATAL); | ||
| 187 : | HTML_installer::showInstallMessage($message, T_('Installer - Error'), returnTo($option, $element, $client)); | ||
| 188 : | } | ||
| 189 : | foreach ($userurl as $value) { | ||
| 190 : | $url_data = parse_url($value); | ||
| 191 : | if (isset($url_data['path'])) $userfilename = basename($url_data['path']); | ||
| 192 : | else $userfilename = ''; | ||
| 193 : | if (!$userfilename) { | ||
| 194 : | $message = new mosError (T_('The URL did not define a file name'), _MOS_ERROR_FATAL); | ||
| 195 : | HTML_installer::showInstallMessage($message, T_('Installer - Error'), returnTo($option, $element, $client)); | ||
| 196 : | } | ||
| 197 : | if (uploadUrl($value, $userfilename, $message )) { | ||
| 198 : | $installer = new $installerClass(); | ||
| 199 : | if (!$installer->extractArchive($userfilename)) { | ||
| 200 : | $installer->cleanUpInstall(); | ||
| 201 : | HTML_installer::showInstallMessage( $installer->getErrors(), T_('Upload ').$element.' - '.T_('Failed'), | ||
| 202 : | returnTo( $option, $element, $client ) ); | ||
| 203 : | } | ||
| 204 : | $ret = $installer->install(); | ||
| 205 : | $installer->cleanUpInstall(); | ||
| 206 : | HTML_installer::showInstallMessage( $installer->getErrors(), T_('Upload ').$element.' - '.($ret ? T_('Success') : T_('Failed')), | ||
| 207 : | returnTo( $option, $element, $client ) ); | ||
| 208 : | } else { | ||
| 209 : | HTML_installer::showInstallMessage( $message, T_('Upload ').$element.' - '.T_('Error'), | ||
| 210 : | returnTo( $option, $element, $client ) ); | ||
| 211 : | } | ||
| 212 : | } | ||
| 213 : | } | ||
| 214 : | /** | ||
| 215 : | * @param string The name of the php (temporary) uploaded file | ||
| 216 : | * @param string The name of the file to put in the temp directory | ||
| 217 : | * @param string The message to return | ||
| 218 : | */ | ||
| 219 : | function uploadFile( $filename, $userfile_name, &$error ) { | ||
| 220 : | global $mosConfig_absolute_path; | ||
| 221 : | $baseDir = mosPathName( $mosConfig_absolute_path . '/media' ); | ||
| 222 : | |||
| 223 : | if (file_exists( $baseDir )) { | ||
| 224 : | if (is_writable( $baseDir )) { | ||
| 225 : | if (move_uploaded_file( $filename, $baseDir . $userfile_name )) { | ||
| 226 : | if (mosChmod( $baseDir . $userfile_name )) { | ||
| 227 : | return true; | ||
| 228 : | } else { | ||
| 229 : | $msg = T_('Failed to change the permissions of the uploaded file.'); | ||
| 230 : | } | ||
| 231 : | } else { | ||
| 232 : | $msg = T_('Failed to move uploaded file to <code>/media</code> directory.'); | ||
| 233 : | } | ||
| 234 : | } else { | ||
| 235 : | $msg = T_('Upload failed as <code>/media</code> directory is not writable.'); | ||
| 236 : | } | ||
| 237 : | } else { | ||
| 238 : | $msg = T_('Upload failed as <code>/media</code> directory does not exist.'); | ||
| 239 : | } | ||
| 240 : | $error = new mosError ($msg, _MOS_ERROR_FATAL); | ||
| 241 : | return false; | ||
| 242 : | } | ||
| 243 : | /** | ||
| 244 : | * @param string The name of the php (temporary) uploaded file | ||
| 245 : | * @param string The name of the file to put in the temp directory | ||
| 246 : | * @param string The message to return | ||
| 247 : | */ | ||
| 248 : | function uploadUrl( $userurl, $userfilename, &$error ) { | ||
| 249 : | global $mosConfig_absolute_path; | ||
| 250 : | $baseDir = mosPathName( $mosConfig_absolute_path . '/media' ); | ||
| 251 : | if (file_exists( $baseDir )) { | ||
| 252 : | if (is_writable( $baseDir )) { | ||
| 253 : | if ($fpin = fopen($userurl, 'rb') AND is_resource($fpin)) { | ||
| 254 : | if ($fpout = fopen($baseDir.$userfilename, 'wb') AND is_resource($fpout)) { | ||
| 255 : | while (!feof($fpin)) { | ||
| 256 : | $data = fgets($fpin, 1024); | ||
| 257 : | fwrite($fpout, $data); | ||
| 258 : | } | ||
| 259 : | fclose($fpout); | ||
| 260 : | fclose($fpin); | ||
| 261 : | if (mosChmod( $baseDir.$userfilename )) return true; | ||
| 262 : | else $msg = T_('Failed to change the permissions of the uploaded file.'); | ||
| 263 : | } | ||
| 264 : | else $msg = T_('Failed to open the local file from the URL.'); | ||
| 265 : | } | ||
| 266 : | else $msg = T_('Failed to open the specified URL.'); | ||
| 267 : | } | ||
| 268 : | else $msg = T_('Upload failed as <code>/media</code> directory is not writable.'); | ||
| 269 : | } | ||
| 270 : | else $msg = T_('Upload failed as <code>/media</code> directory does not exist.'); | ||
| 271 : | $error = new mosError ($msg, _MOS_ERROR_FATAL); | ||
| 272 : | return false; | ||
| 273 : | } | ||
| 274 : | |||
| 275 : | /** | ||
| 276 : | * Component uninstall method | ||
| 277 : | * @param int The id of the module | ||
| 278 : | * @param string The URL option | ||
| 279 : | * @param int The client id | ||
| 280 : | */ | ||
| 281 : | function component_uninstall( $cid, $option, $client=0 ) { | ||
| 282 : | $database =& mamboDatabase::getInstance(); | ||
| 283 : | $sql = "SELECT * FROM #__components WHERE id=$cid"; | ||
| 284 : | $database->setQuery($sql); | ||
| 285 : | if (!$database->loadObject( $row )) { | ||
| 286 : | $message = new mosError ($database->stderr(true), _MOS_ERROR_FATAL); | ||
| 287 : | HTML_installer::showInstallMessage($message, T_('Uninstall - error'), "index2.php?option=$option&element=component"); | ||
| 288 : | exit(); | ||
| 289 : | } | ||
| 290 : | if ($row->iscore) { | ||
| 291 : | $message = new mosError (sprintf(T_('Component %s is a core component, and can not be uninstalled.<br />You need to unpublish it if you don\'t want to use it'), $row->name), _MOS_ERROR_FATAL); | ||
| 292 : | HTML_installer::showInstallMessage($message, 'Uninstall - error', "index2.php?option=$option&element=component"); | ||
| 293 : | exit(); | ||
| 294 : | } | ||
| 295 : | // Try to find the XML file | ||
| 296 : | $here = mosPathName( mamboCore::get('mosConfig_absolute_path').'/administrator/components/'.$row->option ); | ||
| 297 : | $filesindir = mosReadDirectory($here, '.xml$'); | ||
| 298 : | if (count($filesindir) > 0) { | ||
| 299 : | $allerrors = new mosErrorSet(); | ||
| 300 : | foreach ($filesindir as $file) { | ||
| 301 : | $parser =& new mosUninstallXML ($here.$file); | ||
| 302 : | $parser->uninstall(); | ||
| 303 : | $allerrors->mergeAnother($parser->errors); | ||
| 304 : | } | ||
| 305 : | $ret = ($allerrors->getMaxLevel() < _MOS_ERROR_FATAL); | ||
| 306 : | HTML_installer::showInstallMessage( $allerrors->getErrors(), T_('Uninstall component - ').($ret ? T_('Success') : T_('Error')), | ||
| 307 : | returnTo( $option, 'component', $client ) ); | ||
| 308 : | } | ||
| 309 : | else { | ||
| 310 : | $com_name = $row->option; | ||
| 311 : | $dir = new mosDirectory(mosPathName(mamboCore::get('mosConfig_absolute_path').'/components/'.$com_name)); | ||
| 312 : | $dir->deleteAll(); | ||
| 313 : | $dir = new mosDirectory(mosPathName(mamboCore::get('mosConfig_absolute_path').'/administrator/components/'.$com_name)); | ||
| 314 : | $dir->deleteAll(); | ||
| 315 : | $sql = "DELETE FROM #__components WHERE `option`='$com_name'"; | ||
| 316 : | $database->setQuery($sql); | ||
| 317 : | $database->query(); | ||
| 318 : | $message = new mosError (T_('Uninstaller could not find XML file, but cleaned database'), _MOS_ERROR_WARN); | ||
| 319 : | HTML_installer::showInstallMessage($message, T_('Uninstall ').T_('component - ').T_('Success'), returnTo($option, 'component', $client)); | ||
| 320 : | } | ||
| 321 : | exit(); | ||
| 322 : | } | ||
| 323 : | |||
| 324 : | /** | ||
| 325 : | * Module uninstall method | ||
| 326 : | * @param int The id of the module | ||
| 327 : | * @param string The URL option | ||
| 328 : | * @param int The client id | ||
| 329 : | */ | ||
| 330 : | function module_uninstall( $id, $option, $client=0 ) { | ||
| 331 : | $database =& mamboDatabase::getInstance(); | ||
| 332 : | $mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); | ||
| 333 : | $query = "SELECT module, iscore, client_id FROM #__modules WHERE id = '$id'"; | ||
| 334 : | $database->setQuery( $query ); | ||
| 335 : | $database->loadObject( $row ); | ||
| 336 : | if ($row->iscore) { | ||
| 337 : | $message = new mosError (sprintf(T_('%s is a core module, and can not be uninstalled.<br />You need to unpublish it if you don\'t want to use it'), $row->title), _MOS_ERROR_FATAL); | ||
| 338 : | HTML_installer::showInstallMessage($message, 'Uninstall - error', returnTo( $option, 'module', $row->client_id ? '' : 'admin' ) ); | ||
| 339 : | exit(); | ||
| 340 : | } | ||
| 341 : | $query = "DELETE FROM #__modules_menu WHERE moduleid=$id"; | ||
| 342 : | $database->setQuery( $query ); | ||
| 343 : | if (!$database->query()) { | ||
| 344 : | $msg = $database->stderr; | ||
| 345 : | die( $msg ); | ||
| 346 : | } | ||
| 347 : | if ( $row->client_id ) $basepath = $mosConfig_absolute_path . '/administrator/modules/'; | ||
| 348 : | else $basepath = $mosConfig_absolute_path . '/modules/'; | ||
| 349 : | $xmlfile = $basepath . $row->module . '.xml'; | ||
| 350 : | $parser =& new mosUninstallXML ($xmlfile); | ||
| 351 : | $parser->uninstall(); | ||
| 352 : | $ret = ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL); | ||
| 353 : | HTML_installer::showInstallMessage( $parser->errors->getErrors(), T_('Uninstall module - ').($ret ? T_('Success') : T_('Error')), | ||
| 354 : | returnTo( $option, 'module', $client ) ); | ||
| 355 : | exit (); | ||
| 356 : | } | ||
| 357 : | |||
| 358 : | /** | ||
| 359 : | * Mambot install method | ||
| 360 : | * @param int The id of the module | ||
| 361 : | * @param string The URL option | ||
| 362 : | * @param int The client id | ||
| 363 : | */ | ||
| 364 : | function mambot_uninstall( $id, $option, $client=0 ) { | ||
| 365 : | $database =& mamboDatabase::getInstance(); | ||
| 366 : | $mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); | ||
| 367 : | $database->setQuery( "SELECT name, folder, element, iscore FROM #__mambots WHERE id = $id" ); | ||
| 368 : | $database->loadObject( $row ); | ||
| 369 : | if ($database->getErrorNum()) { | ||
| 370 : | $message = new mosError ($database->stderr(), _MOS_ERROR_FATAL); | ||
| 371 : | HTML_installer::showInstallMessage($message, T_('Uninstall - error'), | ||
| 372 : | returnTo( $option, 'mambot', $client ) ); | ||
| 373 : | exit(); | ||
| 374 : | } | ||
| 375 : | if ($row == null) { | ||
| 376 : | $message = new mosError (T_('Invalid object id'), _MOS_ERROR_FATAL); | ||
| 377 : | HTML_installer::showInstallMessage($message, T_('Uninstall - error'), returnTo($option, 'mambot', $client)); | ||
| 378 : | exit(); | ||
| 379 : | } | ||
| 380 : | if (trim( $row->folder ) == '') { | ||
| 381 : | $message = new mosError (T_('Folder field empty, cannot remove files'), _MOS_ERROR_FATAL); | ||
| 382 : | HTML_installer::showInstallMessage($message, T_('Uninstall - error'), returnTo($option, 'mambot', $client)); | ||
| 383 : | exit(); | ||
| 384 : | } | ||
| 385 : | $xmlfile = $mosConfig_absolute_path.'/mambots/'.$row->folder.'/'.$row->element.'.xml'; | ||
| 386 : | if (file_exists($xmlfile)) { | ||
| 387 : | $parser =& new mosUninstallXML ($xmlfile); | ||
| 388 : | $ret = $parser->uninstall(); | ||
| 389 : | $showerrors = $parser->getErrors(); | ||
| 390 : | } | ||
| 391 : | else { | ||
| 392 : | $database->setQuery("DELETE FROM #__mambots WHERE id = $id"); | ||
| 393 : | $ret = $database->query(); | ||
| 394 : | $showerrors = new mosError (T_('Uninstaller did its best with no XML file present'), _MOS_ERROR_WARN); | ||
| 395 : | } | ||
| 396 : | HTML_installer::showInstallMessage( $showerrors, T_('Uninstall mambot - ').($ret ? T_('Success') : T_('Error')), | ||
| 397 : | returnTo( $option, 'mambot', $client ) ); | ||
| 398 : | exit (); | ||
| 399 : | } | ||
| 400 : | |||
| 401 : | /** | ||
| 402 : | * Template uninstall method | ||
| 403 : | * @param int The id of the module | ||
| 404 : | * @param string The URL option | ||
| 405 : | * @param int The client id | ||
| 406 : | */ | ||
| 407 : | function template_uninstall( $id, $option, $client=0 ) { | ||
| 408 : | $id = str_replace( array( '\\', '/' ), '', $id ); | ||
| 409 : | $mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); | ||
| 410 : | // Find if normal or admin template and delete corresponding files & directories | ||
| 411 : | if ($client=='admin') { | ||
| 412 : | $basepath = mamboCore::get('mosConfig_absolute_path').'/administrator/templates/' . $id; | ||
| 413 : | } | ||
| 414 : | else { | ||
| 415 : | $basepath = mamboCore::get('mosConfig_absolute_path').'/templates/' . $id; | ||
| 416 : | } | ||
| 417 : | //Use $basepath to remove the template files and directory | ||
| 418 : | $tdir = new mosDirectory($basepath); | ||
| 419 : | $tdir->deleteAll(); | ||
| 420 : | |||
| 421 : | $message = new mosError (T_('Uninstall template - '), _MOS_ERROR_INFORM); | ||
| 422 : | HTML_installer::showInstallMessage($message, T_('Success'), returnTo($option, 'template', $client)); | ||
| 423 : | exit (); | ||
| 424 : | } | ||
| 425 : | |||
| 426 : | /** | ||
| 427 : | * Language uninstall method | ||
| 428 : | * @param int The id of the module | ||
| 429 : | * @param string The URL option | ||
| 430 : | * @param int The client id | ||
| 431 : | */ | ||
| 432 : | function language_uninstall( $id, $option, $client=0 ) { | ||
| 433 : | $id = str_replace( array( '\\', '/' ), '', $id ); | ||
| 434 : | $basepath = mamboCore::get('mosConfig_absolute_path').'/language/'; | ||
| 435 : | $xmlfile = $basepath . $id . '.xml'; | ||
| 436 : | // see if there is an xml install file, must be same name as element | ||
| 437 : | if (file_exists( $xmlfile )) { | ||
| 438 : | $parser =& new mosUninstallXML ($xmlfile); | ||
| 439 : | $parser->uninstall(); | ||
| 440 : | $ret = ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL); | ||
| 441 : | HTML_installer::showInstallMessage( $parser->errors->getErrors(), T_('Uninstall language - ').($ret ? T_('Success') : T_('Error')), | ||
| 442 : | returnTo( $option, 'language', $client ) ); | ||
| 443 : | } | ||
| 444 : | else { | ||
| 445 : | $message = new mosError (T_('Language id empty, cannot remove files'), _MOS_ERROR_FATAL); | ||
| 446 : | HTML_installer::showInstallMessage($message, T_('Uninstall - error'), "index2.php?option=com_languages"); | ||
| 447 : | } | ||
| 448 : | exit(); | ||
| 449 : | } | ||
| 450 : | |||
| 451 : | |||
| 452 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

