/** * Get the next step * * @return step object */ public function getStep($name = false, $json = true) { // Check if step is loaded if (empty($name)) { return false; } JLoader::import('helpers.jupgradepro', JPATH_COMPONENT_ADMINISTRATOR); $params = JUpgradeproHelper::getParams(); $limit = $this->chunk = $params->chunk_limit; // Getting the total if (isset($this->source)) { $this->total = JUpgradeproHelper::getTotal($this); } // We must to fragment the steps if ($this->total > $limit) { if ($this->cache == 0 && $this->status == 0) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) { $this->cache = round(($this->total - 1) / $limit, 0, PHP_ROUND_HALF_DOWN); } else { $this->cache = round(($this->total - 1) / $limit); } $this->start = 0; $this->stop = $limit - 1; $this->first = true; $this->debug = "{{{1}}}"; } else { if ($this->cache == 1 && $this->status == 1) { $this->start = $this->cid; $this->cache = 0; $this->stop = $this->total - 1; $this->debug = "{{{2}}}"; $this->first = false; } else { if ($this->cache > 0) { $this->start = $this->cid; $this->stop = $this->start - 1 + $limit; $this->cache = $this->cache - 1; $this->debug = "{{{3}}}"; $this->first = false; if ($this->stop > $this->total) { $this->stop = $this->total - 1; $this->next = true; } else { $this->middle = true; } } } } // Status == 1 $this->status = 1; } else { if ($this->total == 0) { $this->stop = -1; $this->next = 1; $this->first = true; if ($this->name == $this->laststep) { $this->end = true; } $this->cache = 0; $this->status = 2; $this->debug = "{{{4}}}"; } else { $this->start = 0; $this->first = 1; $this->cache = 0; $this->status = 1; $this->stop = $this->total - 1; $this->debug = "{{{5}}}"; } } // Mark if is the end of the step if ($this->name == $this->laststep && $this->cache == 1) { $this->end = true; } // updating the status flag $this->_updateStep(); return $this->getParameters(); }
function __construct(JUpgradeproStep $step = null) { // Set the current step $this->_step = $step; jimport('legacy.component.helper'); jimport('cms.version.version'); JLoader::import('helpers.jupgradepro', JPATH_COMPONENT_ADMINISTRATOR); // Get the component parameters $this->params = JUpgradeproHelper::getParams(); // Create the dabatase instance for this installation $this->_db = JFactory::getDBO(); // Get the driver JLoader::register('JUpgradeproDriver', JPATH_LIBRARIES . '/matware/jupgrade/driver.php'); if ($this->_step instanceof JUpgradeproStep) { $this->_step->table = $this->getSourceTable(); } // Initialize the driver $this->_driver = JUpgradeproDriver::getInstance($step); // Get the total if (!empty($step->source)) { $this->_total = JUpgradeproHelper::getTotal($step); } // Set timelimit to 0 if (!@ini_get('safe_mode')) { if (!empty($this->params->timelimit)) { set_time_limit(0); } } // Make sure we can see all errors. if (!empty($this->params->error_reporting)) { error_reporting(E_ALL); @ini_set('display_errors', 1); } // MySQL grants check $query = "SHOW GRANTS FOR CURRENT_USER"; $this->_db->setQuery($query); $list = $this->_db->loadRowList(); $grant = empty($list[1][0]) ? $list[0][0] : $list[1][0]; if (strpos($grant, 'DROP') == true || strpos($grant, 'ALL') == true) { $this->canDrop = true; } }