/** * Cleanup * * @return none * @since 1.2.0 */ function getCleanup() { /** * Initialize jupgrade class */ $jupgrade = new jUpgrade(); // Getting the component parameter with global settings $params = $jupgrade->getParams(); // If REST is enable, cleanup the source jupgrade_steps table if ($params->method == 'rest') { $jupgrade->requestRest('cleanup'); } // Get the prefix $prefix = $this->_db->getPrefix(); // Set all cid, status and cache to 0 $query = "UPDATE jupgrade_steps SET cid = 0, status = 0, cache = 0"; $this->_db->setQuery($query); $this->_db->query(); // Convert the params to array $core_skips = (array) $params; // Skiping the steps setted by user foreach ($core_skips as $k => $v) { $core = substr($k, 0, 9); $name = substr($k, 10, 18); if ($core == "skip_core") { if ($v == 1) { // Set all status to 0 and clear state $query = "UPDATE jupgrade_steps SET status = 2 WHERE name = '{$name}'"; $this->runQuery($query); if ($name == 'users') { $query = "UPDATE jupgrade_steps SET status = 2 WHERE name = 'arogroup'"; $this->runQuery($query); $query = "UPDATE jupgrade_steps SET status = 2 WHERE name = 'usergroupmap'"; $this->runQuery($query); } } } if ($k == 'skip_extensions') { if ($v == 1) { $query = "UPDATE jupgrade_steps SET status = 2 WHERE name = 'extensions'"; $this->runQuery($query); } } } // Cleanup 3rd extensions $query = "DELETE FROM jupgrade_steps WHERE id > 18"; //$this->runQuery ($query); // Truncate the selected tables $tables = array(); $tables[] = 'jupgrade_categories'; $tables[] = 'jupgrade_menus'; $tables[] = 'jupgrade_modules'; $tables[] = "{$this->_db->getPrefix()}menu_types"; $tables[] = "{$this->_db->getPrefix()}content"; for ($i = 0; $i < count($tables); $i++) { if ($jupgrade->canDrop) { $query = "TRUNCATE TABLE `{$tables[$i]}`"; } else { $query = "DELETE FROM `{$tables[$i]}`"; } $this->runQuery($query); } // Cleanup the menu table if ($params->skip_core_menus != 1) { $query = "DELETE FROM {$this->_db->getPrefix()}menu WHERE id > 1"; $this->runQuery($query); } // Insert needed value $query = "INSERT INTO `jupgrade_menus` ( `old`, `new`) VALUES ( 0, 0)"; $this->runQuery($query); // Insert uncategorized id $query = "INSERT INTO `jupgrade_categories` (`old`, `new`) VALUES (0, 2)"; $this->runQuery($query); // Delete uncategorized categories if ($params->skip_core_categories != 1) { $query = "DELETE FROM {$prefix}categories WHERE id > 1"; $this->runQuery($query); } // Change the id of the admin user if ($params->skip_core_users != 1) { $query = "UPDATE {$prefix}users SET id = 10 WHERE username = '******'"; $this->runQuery($query); $query = "UPDATE {$prefix}user_usergroup_map SET user_id = 10 WHERE group_id = 8"; $this->runQuery($query); } // Done checks if (class_exists('JVersion')) { $this->returnError(100, 'DONE'); } }