Project

General

Profile

« Previous | Next » 

Revision 6751b3e7

Added by Jim Pingle over 14 years ago

Generalize this function and use it in more places to reduce duplicated code.

View differences:

etc/inc/upgrade_config.inc
2213 2213
	}
2214 2214
}
2215 2215

  
2216
function upgrade_071_to_072() {
2217
	global $config;
2218

  
2219
	if (is_array($config['sysctl']['item'])) {
2220
		foreach($config['sysctl']['item'] as & $sysctl) {
2221
			if (!empty($sysctl['desc'])) {
2222
				$sysctl['descr'] = $sysctl['desc'];
2223
				unset($sysctl['desc']);
2224
			}
2225
		}
2226
	}
2227
}
2228

  
2229
function desc_to_descr(& $section) {
2216
function rename_field(& $section, $oldname, $newname) {
2230 2217
	if (is_array($section)) {
2231 2218
		foreach($section as & $item) {
2232
			if (!empty($item['desc'])) {
2233
				$item['descr'] = $item['desc'];
2234
				unset($item['desc']);
2219
			if (!empty($item[$oldname])) {
2220
				$item[$newname] = $item[$oldname];
2221
				unset($item[$oldname]);
2235 2222
			}
2236 2223
		}
2237 2224
	}
2238 2225
}
2239 2226

  
2227
function upgrade_071_to_072() {
2228
	global $config;
2229
	rename_field($config['sysctl']['item'], 'desc', 'descr');
2230
}
2231

  
2240 2232
function upgrade_072_to_073() {
2241 2233
	global $config;
2242
	desc_to_descr($config['load_balancer']['monitor_type']);
2243
	desc_to_descr($config['load_balancer']['lbpool']);
2244
	desc_to_descr($config['load_balancer']['lbaction']);
2245
	desc_to_descr($config['load_balancer']['lbprotocol']);
2246
	desc_to_descr($config['load_balancer']['virtual_server']);
2234
	rename_field($config['load_balancer']['monitor_type'], 'desc', 'descr');
2235
	rename_field($config['load_balancer']['lbpool'], 'desc', 'descr');
2236
	rename_field($config['load_balancer']['lbaction'], 'desc', 'descr');
2237
	rename_field($config['load_balancer']['lbprotocol'], 'desc', 'descr');
2238
	rename_field($config['load_balancer']['virtual_server'], 'desc', 'descr');
2247 2239
}
2248 2240

  
2249 2241
function upgrade_073_to_074() {
2250 2242
	global $config;
2251

  
2252
	if (is_array($config['system']['user'])) {
2253
		foreach($config['system']['user'] as & $userent) {
2254
			if (!empty($userent['fullname'])) {
2255
				$userent['descr'] = $userent['fullname'];
2256
				unset($userent['fullname']);
2257
			}
2258
		}
2259
	}
2243
	rename_field($config['system']['user'], 'fullname', 'descr');
2260 2244
}
2261 2245
?>

Also available in: Unified diff