Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Updates.php « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 386f0abc890ddf47ad2ffe679ff46d4c7cb403dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @category Piwik
 * @package Piwik
 */

/**
 * Abstract class for update scripts
 *
 * @example core/Updates/0.4.2.php
 * @package Piwik
 */
abstract class Piwik_Updates
{
	/**
	 * Return SQL to be executed in this update
	 *
	 * @param string  $schema  Schema name
	 * @return array( 
	 *              'ALTER .... ' => '1234', // if the query fails, it will be ignored if the error code is 1234
	 *              'ALTER .... ' => false,  // if an error occurs, the update will stop and fail
	 *                                       // and user will have to manually run the query
	 *         )
	 */
	static function getSql($schema = 'Myisam')
	{
		return array();
	}

	/**
	 * Incremental version update
	 */
	static function update()
	{
	}

	/**
	 * Tell the updater that this is a major update.
	 * Leads to a more visible notice.
	 */
	static function isMajorUpdate()
	{
		return false;
	}

	/**
	 * Helper method to enable maintenance mode during large updates
	 */
	static function enableMaintenanceMode()
	{
		$config = Piwik_Config::getInstance();
		$config->init();
		
		$tracker = $config->Tracker;
		$tracker['record_statistics'] = 0;
		$config->Tracker = $tracker;
		
		$general = $config->General;
		$general['maintenance_mode'] = 1;
		$config->General = $general;
		
		$config->forceSave();
	}
	
	/**
	 * Helper method to disable maintenance mode after large updates
	 */
	static function disableMaintenanceMode()
	{
		$config = Piwik_Config::getInstance();
		$config->init();
		
		$tracker = $config->Tracker;
		$tracker['record_statistics'] = 1;
		$config->Tracker = $tracker;
		
		$general = $config->General;
		$general['maintenance_mode'] = 0;
		$config->General = $general;
		
		$config->forceSave();
	}



	public static function deletePluginFromConfigFile($pluginToDelete)
	{
		$config = Piwik_Config::getInstance();
		$config->init();
		if (isset($config->Plugins['Plugins']))
		{
			$plugins = $config->Plugins['Plugins'];
			if (($key = array_search($pluginToDelete, $plugins)) !== false) {
				unset($plugins[$key]);
			}
			$config->Plugins['Plugins'] = $plugins;

			$pluginsInstalled = $config->PluginsInstalled['PluginsInstalled'];
			if (($key = array_search($pluginToDelete, $pluginsInstalled)) !== false) {
				unset($pluginsInstalled[$key]);
			}
			$config->PluginsInstalled = $pluginsInstalled;

			$config->forceSave();
		}
	}

	public static function deletePluginFromFilesystem($plugin)
	{
		Piwik::unlinkRecursive( PIWIK_INCLUDE_PATH . '/plugins/' . $plugin, $deleteRootToo = true);
	}

}