Created
March 2, 2014 18:41
-
-
Save sanderpotjer/9311435 to your computer and use it in GitHub Desktop.
Migration script example for custom Joomla migrations, related article: http://magazine.joomla.org/issues/issue-mar-2014/item/1794-complex-joomla-15-migration-with-minimal-downtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('_JEXEC', 1); | |
// Connect with Joomla | |
define('JPATH_BASE', __DIR__); | |
require_once JPATH_BASE . '/includes/defines.php'; | |
require_once JPATH_BASE . '/includes/framework.php'; | |
// Database connection | |
$db = JFactory::getDBO(); | |
/** | |
* Module changes | |
*/ | |
// Get the modules that need changes | |
$query = $db->getQuery(true); | |
$query->select('*') | |
->from('#__modules') | |
->where('id IN (233,294,357)'); | |
$db->setQuery($query); | |
$modules = $db->loadObjectList('id'); | |
foreach($modules as $module) | |
{ | |
$module->params = json_decode($module->params); | |
} | |
// Change startLevel | |
if ($modules[233]->params->startLevel == 2) | |
{ | |
$modules[233]->params->startLevel = 3; | |
echo('<strong>Module [233]:</strong> startLevel: 3 <br/>'); | |
} | |
// Set menutype | |
if (empty($modules[294]->params->menutype)) | |
{ | |
$modules[294]->params->menutype = 'mainmenu'; | |
echo('<strong>Module [294]:</strong> menutype: mainmenu <br/>'); | |
} | |
// Hide breadcrumb "You are here" | |
if (!$modules[357]->params->showHere) | |
{ | |
$modules[357]->params->showHere = 0; | |
echo('<strong>Module [357]:</strong> showHere: 0 <br/>'); | |
} | |
// Save new module params | |
foreach($modules as $id=>$module) | |
{ | |
$params = json_encode($module->params); | |
$mod = new JObject(); | |
$mod->id = $id; | |
$mod->params = $params; | |
$result = $db->updateObject('#__modules', $mod, 'id'); | |
} | |
/** | |
* Component changes | |
*/ | |
// ZOO access fixes | |
$query = $db->getQuery(true); | |
$fields = array('access=1'); | |
$conditions = array('access=0'); | |
$query->update($db->quoteName('#__zoo_item'))->set($fields)->where($conditions); | |
$db->setQuery($query); | |
$result = $db->query(); | |
echo('<strong>ZOO:</strong> Access set to 1 <br/>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment