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

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

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

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

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

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

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

Loui Chang's avatar
Loui Chang committed
60
61
62
63
64
<?php if ($output): ?>
	<p class="pkgoutput"><?php print $output ?></p>
<?php endif; ?>

<?php
Loui Chang's avatar
Loui Chang committed
65
if (isset($_GET['ID'])) {
66
	include('pkg_search_form.php');
Loui Chang's avatar
Loui Chang committed
67
	if (!$_GET['ID'] = intval($_GET['ID'])) {
eric's avatar
eric committed
68
		print __("Error trying to retrieve package details.")."<br />\n";
eric's avatar
eric committed
69
	} else {
Loui Chang's avatar
Loui Chang committed
70
		package_details($_GET['ID'], $_COOKIE["AURSID"]);
eric's avatar
eric committed
71
	}
72
} else {
73
	if (!isset($_GET['K']) && !isset($_GET['SB'])) {
74
75
76
		$_GET['SB'] = 'v';
		$_GET['SO'] = 'd';
	}
77
	pkg_search_page($_COOKIE["AURSID"]);
eric's avatar
eric committed
78
}
eric's avatar
eric committed
79

tardo's avatar
tardo committed
80
html_footer(AUR_VERSION);
81