packages.php 3.4 KB
Newer Older
1
<?php
pjmattal's avatar
pjmattal committed
2

3
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
pjmattal's avatar
pjmattal committed
4

5
6
7
8
include_once("aur.inc.php");      # access AUR common functions
set_lang();                       # this sets up the visitor's language
include_once('pkgfuncs.inc.php'); # package specific functions
check_sid();                      # see if they're still logged in
9

10
# Set the title to the current query if required
11
12
if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) {
	$title = $pkgname;
13
14
} else if (isset($_GET['N'])) {
	$title = $pkgname = $_GET['N'];
15
16
} else if (!empty($_GET['K'])) {
	$title = __("Search Criteria") . ": " . $_GET['K'];
17
18
19
20
} else {
	$title = __("Packages");
}

21
# Retrieve account type
eric's avatar
eric committed
22
23
24
25
26
27
if (isset($_COOKIE["AURSID"])) {
	$atype = account_from_sid($_COOKIE["AURSID"]);
} else {
	$atype = "";
}

28
# Grab the list of Package IDs to be operated on
29
30
31
$ids = array();
if (isset($_POST['IDs'])) {
	foreach ($_POST['IDs'] as $id => $i) {
32
33
34
35
		$id = intval($id);
		if ($id > 0) {
			$ids[] = $id;
		}
36
37
	}
}
38

39
# Determine what action to do
40
$output = "";
Dan McGee's avatar
Dan McGee committed
41
if (current_action("do_Flag")) {
42
	$output = pkg_flag($atype, $ids, true);
Dan McGee's avatar
Dan McGee committed
43
} elseif (current_action("do_UnFlag")) {
44
	$output = pkg_flag($atype, $ids, False);
Dan McGee's avatar
Dan McGee committed
45
} elseif (current_action("do_Adopt")) {
46
	$output = pkg_adopt($atype, $ids, true);
Dan McGee's avatar
Dan McGee committed
47
} elseif (current_action("do_Disown")) {
48
	$output = pkg_adopt($atype, $ids, False);
Dan McGee's avatar
Dan McGee committed
49
} elseif (current_action("do_Vote")) {
50
	$output = pkg_vote($atype, $ids, true);
Dan McGee's avatar
Dan McGee committed
51
} elseif (current_action("do_UnVote")) {
52
	$output = pkg_vote($atype, $ids, False);
Dan McGee's avatar
Dan McGee committed
53
} elseif (current_action("do_Delete")) {
54
	if (isset($_POST['confirm_Delete'])) {
55
56
57
58
59
60
61
62
63
64
65
66
67
68
		if (!isset($_POST['merge_Into']) || empty($_POST['merge_Into'])) {
			$output = pkg_delete($atype, $ids, NULL);
			unset($_GET['ID']);
		}
		else {
			$mergepkgid = pkgid_from_name($_POST['merge_Into']);
			if ($mergepkgid) {
				$output = pkg_delete($atype, $ids, $mergepkgid);
				unset($_GET['ID']);
			}
			else {
				$output = __("Cannot find package to merge votes and comments into.");
			}
		}
69
70
71
72
	}
	else {
		$output = __("The selected packages have not been deleted, check the confirmation checkbox.");
	}
Dan McGee's avatar
Dan McGee committed
73
} elseif (current_action("do_Notify")) {
74
	$output = pkg_notify($atype, $ids);
Dan McGee's avatar
Dan McGee committed
75
} elseif (current_action("do_UnNotify")) {
76
	$output = pkg_notify($atype, $ids, False);
Dan McGee's avatar
Dan McGee committed
77
} elseif (current_action("do_DeleteComment")) {
78
	$output = pkg_delete_comment($atype);
Dan McGee's avatar
Dan McGee committed
79
} elseif (current_action("do_ChangeCategory")) {
80
	$output = pkg_change_category($atype);
81
82
83
84
}

html_header($title);
?>
eric's avatar
eric committed
85

Loui Chang's avatar
Loui Chang committed
86
87
88
89
90
<?php if ($output): ?>
	<p class="pkgoutput"><?php print $output ?></p>
<?php endif; ?>

<?php
Loui Chang's avatar
Loui Chang committed
91
if (isset($_GET['ID'])) {
92
	include('pkg_search_form.php');
Loui Chang's avatar
Loui Chang committed
93
	if (!$_GET['ID'] = intval($_GET['ID'])) {
eric's avatar
eric committed
94
		print __("Error trying to retrieve package details.")."<br />\n";
eric's avatar
eric committed
95
	} else {
96
97
98
99
100
101
		if (isset($_COOKIE["AURSID"])) {
			package_details($_GET['ID'], $_COOKIE["AURSID"]);
		}
		else {
			package_details($_GET['ID'], null);
		}
eric's avatar
eric committed
102
	}
103
104
105
106
107
108
109
110
111
112
113
114
} else if (isset($_GET['N'])) {
	include('pkg_search_form.php');
	if (!$pkgid = pkgid_from_name($_GET['N'])) {
		print __("Error trying to retrieve package details.")."<br />\n";
	} else {
		if (isset($_COOKIE["AURSID"])) {
			package_details($pkgid, $_COOKIE["AURSID"]);
		}
		else {
			package_details($pkgid, null);
		}
	}
115
} else {
116
	if (!isset($_GET['K']) && !isset($_GET['SB'])) {
117
118
119
		$_GET['SB'] = 'v';
		$_GET['SO'] = 'd';
	}
Dan McGee's avatar
Dan McGee committed
120
121
122
123
124
	if (isset($_COOKIE["AURSID"])) {
		pkg_search_page($_COOKIE["AURSID"]);
	} else {
		pkg_search_page();
	}
eric's avatar
eric committed
125
}
eric's avatar
eric committed
126

tardo's avatar
tardo committed
127
html_footer(AUR_VERSION);
128