packages.php 2.58 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;
	}
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
55
56
57
58
59
60
	if (isset($_POST['confirm_Delete'])) {
		$output = pkg_delete($atype, $ids);
		unset($_GET['ID']);
	}
	else {
		$output = __("The selected packages have not been deleted, check the confirmation checkbox.");
	}
Dan McGee's avatar
Dan McGee committed
61
} elseif (current_action("do_Notify")) {
62
	$output = pkg_notify($atype, $ids);
Dan McGee's avatar
Dan McGee committed
63
} elseif (current_action("do_UnNotify")) {
64
	$output = pkg_notify($atype, $ids, False);
Dan McGee's avatar
Dan McGee committed
65
} elseif (current_action("do_DeleteComment")) {
66
	$output = pkg_delete_comment($atype);
Dan McGee's avatar
Dan McGee committed
67
} elseif (current_action("do_ChangeCategory")) {
68
	$output = pkg_change_category($atype);
69
70
71
72
}

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

Loui Chang's avatar
Loui Chang committed
74
75
76
77
78
<?php if ($output): ?>
	<p class="pkgoutput"><?php print $output ?></p>
<?php endif; ?>

<?php
Loui Chang's avatar
Loui Chang committed
79
if (isset($_GET['ID'])) {
80
	include('pkg_search_form.php');
Loui Chang's avatar
Loui Chang committed
81
	if (!$_GET['ID'] = intval($_GET['ID'])) {
eric's avatar
eric committed
82
		print __("Error trying to retrieve package details.")."<br />\n";
eric's avatar
eric committed
83
	} else {
Loui Chang's avatar
Loui Chang committed
84
		package_details($_GET['ID'], $_COOKIE["AURSID"]);
eric's avatar
eric committed
85
	}
86
} else {
87
	if (!isset($_GET['K']) && !isset($_GET['SB'])) {
88
89
90
		$_GET['SB'] = 'v';
		$_GET['SO'] = 'd';
	}
Dan McGee's avatar
Dan McGee committed
91
92
93
94
95
	if (isset($_COOKIE["AURSID"])) {
		pkg_search_page($_COOKIE["AURSID"]);
	} else {
		pkg_search_page();
	}
eric's avatar
eric committed
96
}
eric's avatar
eric committed
97

tardo's avatar
tardo committed
98
html_footer(AUR_VERSION);
99