Move package disowning to a separate page
[aur.git] / web / html / pkgbase.php
blob7c24b7928c5507f5f5cb351b51a05fc557f6f26c
1 <?php
3 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
5 include_once("aur.inc.php");
6 set_lang();
7 include_once('pkgfuncs.inc.php');
8 check_sid();
11 * Retrieve package base ID and name, unless initialized by the routing
12 * framework.
14 if (!isset($base_id) || !isset($pkgbase_name)) {
15 if (isset($_GET['ID'])) {
16 $base_id = intval($_GET['ID']);
17 $pkgbase_name = pkgbase_name_from_id($_GET['ID']);
18 } else if (isset($_GET['N'])) {
19 $base_id = pkgbase_from_name($_GET['N']);
20 $pkgbase_name = $_GET['N'];
21 } else {
22 unset($base_id, $pkgbase_name);
25 if (isset($base_id) && ($base_id == 0 || $base_id == NULL || $pkgbase_name == NULL)) {
26 header("HTTP/1.0 404 Not Found");
27 include "./404.php";
28 return;
32 /* Set the title to package base name. */
33 $title = $pkgbase_name;
35 /* Grab the list of package base IDs to be operated on. */
36 $ids = array();
37 if (isset($_POST['IDs'])) {
38 foreach ($_POST['IDs'] as $id => $i) {
39 $id = intval($id);
40 if ($id > 0) {
41 $ids[] = $id;
46 /* Perform package base actions. */
47 $ret = false;
48 $output = "";
49 if (check_token()) {
50 if (current_action("do_Flag")) {
51 list($ret, $output) = pkgbase_flag($ids);
52 } elseif (current_action("do_UnFlag")) {
53 list($ret, $output) = pkgbase_unflag($ids);
54 } elseif (current_action("do_Adopt")) {
55 list($ret, $output) = pkgbase_adopt($ids, true, NULL);
56 } elseif (current_action("do_Disown")) {
57 if (isset($_POST['confirm_Disown'])) {
58 $via = isset($_POST['via']) ? $_POST['via'] : NULL;
59 list($ret, $output) = pkgbase_adopt($ids, false, $via);
60 } else {
61 $output = __("The selected packages have not been disowned, check the confirmation checkbox.");
62 $ret = false;
64 } elseif (current_action("do_Vote")) {
65 list($ret, $output) = pkgbase_vote($ids, true);
66 } elseif (current_action("do_UnVote")) {
67 list($ret, $output) = pkgbase_vote($ids, false);
68 } elseif (current_action("do_Delete")) {
69 if (isset($_POST['confirm_Delete'])) {
70 $via = isset($_POST['via']) ? $_POST['via'] : NULL;
71 if (!isset($_POST['merge_Into']) || empty($_POST['merge_Into'])) {
72 list($ret, $output) = pkgbase_delete($ids, NULL, $via);
73 unset($_GET['ID']);
75 else {
76 $merge_base_id = pkgbase_from_name($_POST['merge_Into']);
77 if (!$merge_base_id) {
78 $output = __("Cannot find package to merge votes and comments into.");
79 $ret = false;
80 } elseif (in_array($merge_base_id, $ids)) {
81 $output = __("Cannot merge a package base with itself.");
82 $ret = false;
83 } else {
84 list($ret, $output) = pkgbase_delete($ids, $merge_base_id, $via);
85 unset($_GET['ID']);
89 else {
90 $output = __("The selected packages have not been deleted, check the confirmation checkbox.");
91 $ret = false;
93 } elseif (current_action("do_Notify")) {
94 list($ret, $output) = pkgbase_notify($ids);
95 } elseif (current_action("do_UnNotify")) {
96 list($ret, $output) = pkgbase_notify($ids, false);
97 } elseif (current_action("do_DeleteComment")) {
98 list($ret, $output) = pkgbase_delete_comment();
99 } elseif (current_action("do_ChangeCategory")) {
100 list($ret, $output) = pkgbase_change_category($base_id);
101 } elseif (current_action("do_FileRequest")) {
102 list($ret, $output) = pkgreq_file($ids, $_POST['type'], $_POST['merge_into'], $_POST['comments']);
103 } elseif (current_action("do_CloseRequest")) {
104 list($ret, $output) = pkgreq_close($_POST['reqid'], $_POST['reason'], $_POST['comments']);
105 } elseif (current_action("do_EditComaintainers")) {
106 list($ret, $output) = pkgbase_set_comaintainers($base_id, explode("\n", $_POST['users']));
109 if (isset($_REQUEST['comment'])) {
110 $uid = uid_from_sid($_COOKIE["AURSID"]);
111 pkgbase_add_comment($base_id, $uid, $_REQUEST['comment']);
112 $ret = true;
115 if ($ret) {
116 if (current_action("do_CloseRequest") ||
117 (current_action("do_Delete") && $_POST['via'])) {
118 /* Redirect back to package request page on success. */
119 header('Location: ' . get_pkgreq_route());
120 exit();
121 } if (isset($base_id)) {
122 /* Redirect back to package base page on success. */
123 header('Location: ' . get_pkgbase_uri($pkgbase_name));
124 exit();
125 } else {
126 /* Redirect back to package search page. */
127 header('Location: ' . get_pkg_route());
128 exit();
133 $pkgs = pkgbase_get_pkgnames($base_id);
134 if (!$output && count($pkgs) == 1) {
135 /* Not a split package. Redirect to the package page. */
136 if (empty($_SERVER['QUERY_STRING'])) {
137 header('Location: ' . get_pkg_uri($pkgs[0]));
138 } else {
139 header('Location: ' . get_pkg_uri($pkgs[0]) . '?' . $_SERVER['QUERY_STRING']);
143 $details = pkgbase_get_details($base_id);
144 html_header($title, $details);
147 <?php if ($output): ?>
148 <?php if ($ret): ?>
149 <p class="pkgoutput"><?= $output ?></p>
150 <?php else: ?>
151 <ul class="errorlist"><li><?= $output ?></li></ul>
152 <?php endif; ?>
153 <?php endif; ?>
155 <?php
156 include('pkg_search_form.php');
157 if (isset($_COOKIE["AURSID"])) {
158 pkgbase_display_details($base_id, $details, $_COOKIE["AURSID"]);
159 } else {
160 pkgbase_display_details($base_id, $details, null);
163 html_footer(AURWEB_VERSION);