packages.php 2.89 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 = "";
Simo Leone's avatar
Simo Leone committed
41
if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
42
	$output = pkg_flag($atype, $ids, True);
Simo Leone's avatar
Simo Leone committed
43
} elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) {
44
	$output = pkg_flag($atype, $ids, False);
Simo Leone's avatar
Simo Leone committed
45
} elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) {
46
	$output = pkg_adopt($atype, $ids, True);
47
} elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) {
48
	$output = pkg_adopt($atype, $ids, False);
Simo Leone's avatar
Simo Leone committed
49
} elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) {
50
	$output = pkg_vote($atype, $ids, True);
Simo Leone's avatar
Simo Leone committed
51
} elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) {
52
	$output = pkg_vote($atype, $ids, False);
53
} elseif ($_POST['action'] == "do_Delete" || isset($_POST['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.");
	}
61
} elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) {
62
	$output = pkg_notify($atype, $ids);
63
} elseif ($_POST['action'] == "do_UnNotify" || isset($_POST['do_UnNotify'])) {
64
	$output = pkg_notify($atype, $ids, False);
65
66
67
68
} elseif ($_POST['action'] == "do_DeleteComment" || isset($_POST["do_DeleteComment"])) {
	$output = pkg_delete_comment($atype);
} elseif ($_POST['action'] == "do_ChangeCategory" || isset($_POST['do_ChangeCategory'])) {
	$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';
	}
91
	pkg_search_page($_COOKIE["AURSID"]);
eric's avatar
eric committed
92
}
eric's avatar
eric committed
93

tardo's avatar
tardo committed
94
html_footer(AUR_VERSION);
95