summaryrefslogtreecommitdiff
blob: f3f08a9da58656c9a622c4143c82f27b27d88784 (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
<?

	require_once 'header.php';
	require_once '../class.portage.tree.php';
	require_once '../class.portage.category.php';
	require_once '../class.portage.package.php';
	
	$sql = "SELECT id, name FROM category ORDER BY name;";
	$arr_categories = $db->getAssoc($sql);
	
	$table = 'package';
	
	foreach($arr_categories as $category_id => $category_name) {
	
		$obj_category = new PortageCategory($category_name);
		
		$arr_packages = $obj_category->getPackages();
		
		$arr_diff = importDiff('package', $arr_packages, "category = $category_id");
		
		if(count($arr_diff['delete'])) {
			foreach($arr_diff['delete'] as $name) {
				$sql = "DELETE FROM $table WHERE name = ".$db->quote($name)." AND category = $category_id;";
				shell::msg($sql);
				$db->query($sql);
			}
		}
		
		if(count($arr_diff['insert'])) {
			foreach($arr_diff['insert'] as $name) {
			
				$obj_package = new PortagePackage($obj_category->name, $name);
			
 				$arr_insert = array('category' => $category_id, 'name' => $name, 'changelog' => $obj_package->changelog);
				$db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT);
			}
		}
		
	}
	
?>