Beispiel #1
0
	public function runBackup()
	{
		$ret_array = array();
		
		$ajaxTask = $this->getState('ajax');

		switch($ajaxTask)
		{
			case 'start':
				// Description is passed through a strict filter which removes HTML
				$description = $this->getState('description');
				// The comment is passed through the Safe HTML filter (note: use 2 to force no filtering)
				$comment = $this->getState('comment');
				$jpskey = $this->getState('jpskey');

				$tag = $this->getState('tag');

				// Try resetting the engine
				AECoreKettenrad::reset();

				// Remove any stale memory files left over from the previous step

				if(empty($tag)) $tag = AEPlatform::get_backup_origin();
				AEUtilTempvars::reset($tag);
				
				$kettenrad =& AECoreKettenrad::load($tag);

				// Take care of System Restore Point setup
				if($tag == 'restorepoint') {
					// Fetch the extension's version information
					require_once JPATH_COMPONENT_ADMINISTRATOR.DS.'liveupdate'.DS.'classes'.DS.'xmlslurp.php';
					$slurp = new LiveUpdateXMLSlurp();
					$exttype = $this->getState('type');
					switch($exttype) {
						case 'component':
							$extname = 'com_';
							break;
						case 'module':
							$extname = 'mod_';
							break;
						case 'plugin':
							$extname = 'plg_';
							break;
						case 'template':
							$extname = 'tpl_';
							break;
					}
					$extname .= $this->getState('name');
					$info = $slurp->getInfo($extname, '');
					
					// Get the configOverrides for this extension
					AEPlatform::$configOverrides = $this->getConfigOverridesForSRP($extname, $info);
					
					// Create an SRP descriptor
					$srpdescriptor = array(
						'type'			=> $this->getState('type'),
						'name'			=> $this->getState('name'),
						'group'			=> $this->getState('group'),
						'version'		=> $info['version'],
						'date'			=> $info['date']
					);

					// Set the description and comment
					$description = "System Restore Point - ".JText::_($exttype).": $extname";
					$comment = "---BEGIN SRP---\n".json_encode($srpdescriptor)."\n---END SRP---";
					$jpskey = '';
					
					// Set a custom finalization action queue
					AEPlatform::$configOverrides['volatile.core.finalization.action_handlers'] = array(
						new AEFinalizationSrpquotas()						
					);
					AEPlatform::$configOverrides['volatile.core.finalization.action_queue'] = array(
						'remove_temp_files',
						'update_statistics',
						'update_filesizes',
						'apply_srp_quotas'
					);
				}
				
				$options = array(
					'description'	=> $description,
					'comment'		=> $comment,
					'jpskey'		=> $jpskey
				);
				$kettenrad->setup($options);
				$kettenrad->tick();
				if( ($kettenrad->getState() != 'running') && ($tag == 'restorepoint') ) {
					$kettenrad->tick();
				}
				$ret_array  = $kettenrad->getStatusArray();
				$kettenrad->resetWarnings(); // So as not to have duplicate warnings reports
				AECoreKettenrad::save($tag);
				break;

			case 'step':
				$tag = $this->getState('tag');
				$kettenrad =& AECoreKettenrad::load($tag);
				$kettenrad->tick();
				$ret_array  = $kettenrad->getStatusArray();
				$kettenrad->resetWarnings(); // So as not to have duplicate warnings reports
				AECoreKettenrad::save($tag);

				if($ret_array['HasRun'] == 1)
				{
					// Clean up
					AEFactory::nuke();
					AEUtilTempvars::reset($tag);
				}
				break;

			default:
				break;
		}
		
		return $ret_array;
	}