packages.php 2.56 KB
Newer Older
1
<?php
pjmattal's avatar
pjmattal committed
2
3
4

set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');

eric's avatar
eric committed
5
include("aur.inc");         # access AUR common functions
6
include("pkgfuncs.inc");    # package specific functions
eric's avatar
eric committed
7
8
include("search_po.inc");   # use some form of this for i18n support
set_lang();                 # this sets up the visitor's language
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
# TODO: Convert this to a normal array of IDs to operate on and convert the
# functions to use this format
Callan Barrett's avatar
Callan Barrett committed
31
isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array();
32

33
34
35
html_header($title);

# Determine what action to do
Simo Leone's avatar
Simo Leone committed
36
if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
37
38
39
	print "<p>";
	print pkg_flag($atype, $ids, True);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
40
} elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) {
41
42
43
	print "<p>";
	print pkg_flag($atype, $ids, False);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
44
} elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) {
45
46
47
	print "<p>";
	print pkg_adopt($atype, $ids, True);
	print "</p>";
48
49
50
51
} elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) {
	print "<p>";
	print pkg_adopt($atype, $ids, False);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
52
} elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) {
53
54
55
	print "<p>";
	print pkg_vote($atype, $ids, True);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
56
} elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) {
57
58
59
	print "<p>";
	print pkg_vote($atype, $ids, False);
	print "</p>";
60
61
62
63
} elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) {
	print "<p>";
	print pkg_delete($atype, $ids);
	print "</p>";
64
65
66
67
68
69
70
71
} elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) {
	print "<p>";
	print pkg_notify($atype, $ids);
	print "</p>";
} elseif ($_POST['action'] == "do_UnNotify" || isset($_POST['do_UnNotify'])) {
	print "<p>";
	print pkg_notify($atype, $ids, False);
	print "</p>";
Callan Barrett's avatar
Callan Barrett committed
72
} elseif (isset($_GET["ID"])) {
eric's avatar
eric committed
73

Callan Barrett's avatar
Callan Barrett committed
74
	if (!intval($_GET["ID"])) {
eric's avatar
eric committed
75
76
		print __("Error trying to retrieve package details.")."<br />\n";
		
eric's avatar
eric committed
77
	} else {
Callan Barrett's avatar
Callan Barrett committed
78
		package_details($_GET["ID"], $_COOKIE["AURSID"]);
eric's avatar
eric committed
79
80
	}

81
} else {
82
	pkg_search_page($_COOKIE["AURSID"]);
eric's avatar
eric committed
83
}
eric's avatar
eric committed
84

tardo's avatar
tardo committed
85
html_footer(AUR_VERSION);
86