Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.8] Quick Advanced Editor 6.1.2 (Show sceditor in quick reply and quick edit)
#41
Create a custom upgrade process?
// _activate() routine
function foo_activate()
{
	global $cache;

	// Insert/update version into cache
	$plugins = $cache->read('foo_plugins');
	if(!$plugins)
	{
		$plugins = array();
	}

	$info = foo_info();

	if(!isset($plugins['foo']))
	{
		$plugins['foo'] = $info['versioncode'];
	}

	/*~*~* RUN UPDATES START *~*~*/
	if($info['versioncode'] > $plugins['foo'])
	{
		if($info['versioncode'] == 561)
		{
			if($plugins['foo'] == 560)
			{
				//Fix: Autosave draft feature
				//assuming 560 is the version where this feature was implemented
			}
			if($plugins['foo'] <= 560)
			{
				//add settings for 560 and lower
			}
			if($plugins['foo'] < 560)
			{
				//remove settings for lower to 560
			}
		}
	}
	/*~*~* RUN UPDATES END *~*~*/

	$plugins['foo'] = $info['versioncode'];
	$cache->update('foo_plugins', $plugins);
}

// _uninstall() routine
function foo_uninstall()
{
	global $cache;

	// Delete version from cache
	$plugins = (array)$cache->read('foo_plugins');

	if(isset($plugins['foo']))
	{
		unset($plugins['foo']);
	}

	if(!empty($plugins))
	{
		$cache->update('foo_plugins', $plugins);
	}
	else
	{
		$cache->delete('foo_plugins');
	}
}

Deactivate -> Uplaod new files -> Activate -> Congratulations you have updated without losing changes!
Reply


Messages In This Thread
RE: Quick Advanced Editor 5.6.1 (Show sceditor in quick reply and quick edit) - by Omar G. - 2014-11-10, 08:32 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)