public function run29Update()
{
// Create the themes table
$this->Database->query("CREATE TABLE `tl_theme` (\n\t\t\t `id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t `tstamp` int(10) unsigned NOT NULL default '0',\n\t\t\t `name` varchar(128) NOT NULL default '',\n\t\t\t `author` varchar(128) NOT NULL default '',\n\t\t\t `screenshot` varchar(255) NOT NULL default '',\n\t\t\t `folders` blob NULL,\n\t\t\t `templates` varchar(255) NOT NULL default '',\n\t\t\t PRIMARY KEY (`id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
// Add a PID column to the child tables
$this->Database->query("ALTER TABLE `tl_module` ADD `pid` int(10) unsigned NOT NULL default '0'");
$this->Database->query("ALTER TABLE `tl_style_sheet` ADD `pid` int(10) unsigned NOT NULL default '0'");
$this->Database->query("ALTER TABLE `tl_layout` ADD `pid` int(10) unsigned NOT NULL default '0'");
$this->Database->query("UPDATE tl_module SET pid=1");
$this->Database->query("UPDATE tl_style_sheet SET pid=1");
$this->Database->query("UPDATE tl_layout SET pid=1");
// Create a theme from the present resources
$this->Database->prepare("INSERT INTO tl_theme SET tstamp=?, name=?")->execute(time(), \Config::get('websiteTitle'));
// Adjust the back end user permissions
$this->Database->query("ALTER TABLE `tl_user` ADD `themes` blob NULL");
$this->Database->query("ALTER TABLE `tl_user_group` ADD `themes` blob NULL");
// Adjust the user and group rights
$objUser = $this->Database->execute("SELECT id, modules, 'tl_user' AS tbl FROM tl_user WHERE modules!='' UNION SELECT id, modules, 'tl_user_group' AS tbl FROM tl_user_group WHERE modules!=''");
while ($objUser->next()) {
$modules = \StringUtil::deserialize($objUser->modules);
if (!is_array($modules) || empty($modules)) {
continue;
}
$themes = array();
foreach ($modules as $k => $v) {
if ($v == 'css' || $v == 'modules ' || $v == 'layout') {
$themes[] = $v;
unset($modules[$k]);
}
}
if (!empty($themes)) {
$modules[] = 'themes';
}
$modules = array_values($modules);
$set = array('modules' => !empty($modules) ? serialize($modules) : null, 'themes' => !empty($themes) ? serialize($themes) : null);
$this->Database->prepare("UPDATE " . $objUser->tbl . " %s WHERE id=?")->set($set)->execute($objUser->id);
}
// Featured news
if ($this->Database->fieldExists('news_featured', 'tl_module')) {
$this->Database->query("ALTER TABLE `tl_module` CHANGE `news_featured` `news_featured` varchar(16) NOT NULL default ''");
$this->Database->query("UPDATE tl_module SET news_featured='featured' WHERE news_featured='1'");
}
// Other version 2.9 updates
$this->Database->query("UPDATE tl_member SET country='gb' WHERE country='uk'");
$this->Database->query("ALTER TABLE `tl_module` CHANGE `news_jumpToCurrent` `news_jumpToCurrent` varchar(16) NOT NULL default ''");
$this->Database->query("UPDATE tl_module SET news_jumpToCurrent='show_current' WHERE news_jumpToCurrent=1");
$this->Database->query("ALTER TABLE `tl_user` ADD `useCE` char(1) NOT NULL default ''");
$this->Database->query("UPDATE tl_user SET useCE=1");
}