packages.php 2.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

eric's avatar
eric committed
5
6
include("aur.inc");         # access AUR common functions
set_lang();                 # this sets up the visitor's language
7
8
include('pkgfuncs.inc');    # package specific functions
include_lang('search_po.inc');   # use some form of this for i18n support
eric's avatar
eric committed
9
check_sid();                # see if they're still logged in
10

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

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

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

35
# Determine what action to do
36
$output = "";
Simo Leone's avatar
Simo Leone committed
37
if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
38
	$output = pkg_flag($atype, $ids, True);
Simo Leone's avatar
Simo Leone committed
39
} elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) {
40
	$output = pkg_flag($atype, $ids, False);
Simo Leone's avatar
Simo Leone committed
41
} elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) {
42
	$output = pkg_adopt($atype, $ids, True);
43
} elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) {
44
	$output = pkg_adopt($atype, $ids, False);
Simo Leone's avatar
Simo Leone committed
45
} elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) {
46
	$output = pkg_vote($atype, $ids, True);
Simo Leone's avatar
Simo Leone committed
47
} elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) {
48
	$output = pkg_vote($atype, $ids, False);
49
} elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) {
50
51
	$output = pkg_delete($atype, $ids);
	unset($_GET['ID']);
52
} elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) {
53
	$output = pkg_notify($atype, $ids);
54
} elseif ($_POST['action'] == "do_UnNotify" || isset($_POST['do_UnNotify'])) {
55
56
57
58
59
60
61
62
63
64
	$output = pkg_notify($atype, $ids, False);
}

html_header($title);

if ($output):
?>
<div class="pkgoutput"><?php print $output ?></div><br />
<?php
endif;
eric's avatar
eric committed
65

66
if (isset($_GET["ID"])) {
67
	include('pkg_search_form.php');
Callan Barrett's avatar
Callan Barrett committed
68
	if (!intval($_GET["ID"])) {
eric's avatar
eric committed
69
		print __("Error trying to retrieve package details.")."<br />\n";
eric's avatar
eric committed
70
	} else {
Callan Barrett's avatar
Callan Barrett committed
71
		package_details($_GET["ID"], $_COOKIE["AURSID"]);
eric's avatar
eric committed
72
	}
73
} else {
74
	pkg_search_page($_COOKIE["AURSID"]);
eric's avatar
eric committed
75
}
eric's avatar
eric committed
76

tardo's avatar
tardo committed
77
html_footer(AUR_VERSION);
78