Skip to content

Commit

Permalink
[Kunena#130] Improved JUpgrade support (usergroups, install Kunena)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Sep 1, 2011
1 parent 590d0de commit 255684d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
45 changes: 39 additions & 6 deletions administrator/components/com_kunena/install/j16upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

defined ( '_JEXEC' ) or die ();

define ( 'KPATH_ADMIN', dirname ( dirname ( __FILE__ ) ) );
if (file_exists(JPATH_SITE.'/includes/version.php')) require_once JPATH_SITE.'/includes/version.php';

/**
* Kunena 1.6 migration class from Joomla 1.5 to Joomla 1.6
Expand Down Expand Up @@ -38,6 +38,7 @@ class jUpgradeComponentKunena extends jUpgrade {
* @since 1.6.4
*/
protected function detectExtension() {
$this->api = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
return true;
}

Expand All @@ -48,7 +49,11 @@ protected function detectExtension() {
* @since 1.6.4
*/
protected function getCopyTables() {
require_once KPATH_ADMIN.'/install/schema.php';
if (!is_file($this->api)) {
throw new Exception('Please install new version of JUpgrade!');
}
require_once $this->api;
require_once KPATH_ADMIN . '/install/schema.php';
$schema = new KunenaModelSchema();
$tables = $schema->getSchemaTables('');
return array_values($tables);
Expand All @@ -68,8 +73,12 @@ protected function getCopyTables() {
* @since 1.6.4
* @throws Exception
*/
protected function migrateExtensionCustom()
{
protected function migrateExtensionCustom() {
if (!is_file($this->api)) {
throw new Exception('Please install new version of JUpgrade!');
}
require_once $this->api;

// Need to initialize application
jimport ('joomla.environment.uri');
$app = JFactory::getApplication('administrator');
Expand Down Expand Up @@ -141,6 +150,30 @@ protected function migrateExtensionCustom()
if (!$success) echo "ERROR";
}
}
// Delete old manifest file
jimport('joomla.filesystem.file');
if (file_exists(JPATH_ADMINISTRATOR.'/components/com_kunena/kunena.j16.xml')) {
JFile::delete(JPATH_ADMINISTRATOR.'/components/com_kunena/kunena.xml');
JFile::move(JPATH_ADMINISTRATOR.'/components/com_kunena/kunena.j16.xml', JPATH_ADMINISTRATOR.'/components/com_kunena/kunena.xml');
}

jimport('joomla.plugin.helper');

// Mark Kunena as discovered and install it
$component->client_id = 1;
$component->state = -1;
$component->store();
jimport('joomla.installer.installer');
$installer = JInstaller::getInstance();
$installer->discover_install($component->extension_id);
// Start Kunena installer
require_once dirname ( __FILE__ ) . '/model.php';
$kunena = new KunenaModelInstall();
// Install system plugin
$kunena->installSystemPlugin();
// Install English language
$kunena->installLanguage('en-GB', 'English');

return true;
}

Expand Down Expand Up @@ -173,7 +206,7 @@ protected function copyTable_kunena_categories($table) {
// Do some custom post processing on the list.
foreach ($rows as &$row) {
if (!isset($row['accesstype']) || $row['accesstype'] == 'none' ) {
if ($row['admin_access'] != 0) {
if ($row['admin_access'] != 0 && isset($map[$row['admin_access']])) {
$row['admin_access'] = $map[$row['admin_access']];
}
if ($row['pub_access'] == -1) {
Expand All @@ -187,7 +220,7 @@ protected function copyTable_kunena_categories($table) {
} elseif ($row['pub_access'] == 1) {
// Nobody
$row['pub_access'] = 8;
} else {
} elseif (isset($map[$row['pub_access']])) {
// User groups
$row['pub_access'] = $map[$row['pub_access']];
}
Expand Down
5 changes: 1 addition & 4 deletions administrator/components/com_kunena/install/j16upgrade.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?xml version="1.0" ?>
<!DOCTYPE jupgrade>
<jupgrade>
<name>Kunena 1.7 Update Site</name>
<collection>http://update.kunena.org/1.7</collection>

<installer>
<file>administrator/components/com_kunena/install/j16upgrade.php</file>
<class>jUpgradeComponentKunena</class>
</installer>

<!-- The folders to copy to the new site. -->
<folders>
<folder>media/kunena</folder>
<folder>administrator/components/com_kunena</folder>
<folder>components/com_kunena</folder>
<folder>media/kunena</folder>
</folders>
</jupgrade>
1 change: 1 addition & 0 deletions administrator/components/com_kunena/kunena.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<menu task="showtrashview" img="components/com_kunena/media/icons/trash-favicon.png">COM_KUNENA_TRASH_MANAGER</menu>
</submenu>
<files>
<filename>kunena.j16.xml</filename>
<filename>api.php</filename>
<filename>admin.kunena.php</filename>
<filename>install.script.php</filename>
Expand Down
1 change: 1 addition & 0 deletions components/com_kunena/CHANGELOG.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
1-September-2011 Matias
# [#126] Articles bbcode: \n is converted to <br>
^ [#128] Use update collection in Joomla 1.7 (show updates also for modules)
^ [#130] Improved JUpgrade support (usergroups, install Kunena)

31-August-2011 Matias
# [#121] Joomla 1.7: fix broken French admin language file
Expand Down

0 comments on commit 255684d

Please sign in to comment.