xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit 63e34cf9032bb7b108b51c97ccbd1efbd1e5cd7b

Fix delete repo function
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-10-29 20:45
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-10-29 20:45
Parent(s): 2ccd4da309196c89d776950b3b2e9efec32a6c60
Signing key:
Tree: 24414f72f573aa1b9d0855cb5a8bbf78b93378ea
File Lines added Lines deleted
TODO 2 0
inc/repo.inc.php 3 0
inc/state.inc.php 12 0
inc/user/repo/delete/delete.php 30 14
inc/user/repo/rights/rights.php 36 18
inc/util.inc.php 0 2
root/index.php 11 1
root/themes/default/index.html 2 1
root/themes/default/main.css 10 9
root/themes/default/repo/main.html 1 1
root/themes/default/user/repo/delete/done.html 1 0
root/themes/default/user/repo/delete/no.html 1 0
root/themes/default/user/repo/delete/sure.html 19 0
root/themes/default/user/repo/rights/form.html 2 3
root/themes/default/user/repo/rights/list/line.html 1 1
File TODO changed (mode: 100644) (index 6638c0e..f7838c4)
29 29 dirs like YYYY/MM/DD/HH/MM/job dirs like YYYY/MM/DD/HH/MM/job
30 30 [ ] Use some named pipes to signal q.php/cron.php to do some stuff. [ ] Use some named pipes to signal q.php/cron.php to do some stuff.
31 31 [ ] [ ]
32 [ ] Check if we can give rights for a non-owning repo!
33 We should check if the user that gives rights is the owner!
32 34
33 35
34 36 == Medium == == Medium ==
File inc/repo.inc.php changed (mode: 100644) (index fd47157..2ae3888)
... ... function rg_repo_info($db, $rr)
164 164 return $ret; return $ret;
165 165 } }
166 166
167 // small fixes
168 $row['HTML:description'] = nl2br($row['description']);
169
167 170 $row['exists'] = 1; $row['exists'] = 1;
168 171 $row['ok'] = 1; $row['ok'] = 1;
169 172
File inc/state.inc.php changed (mode: 100644) (index e54b157..021200d)
... ... function rg_state_get($db, $var)
40 40 return $ret; return $ret;
41 41 } }
42 42
43 /*
44 * Return a state as uint
45 */
46 function rg_state_get_uint($db, $var)
47 {
48 $r = rg_state_get($db, $var);
49 if ($r === FALSE)
50 return FALSE;
51
52 return intval($r);
53 }
54
43 55 /* /*
44 56 * Set state * Set state
45 57 */ */
File inc/user/repo/delete/delete.php changed (mode: 100644) (index fab6c27..2dba86d)
1 1 <?php <?php
2 2 rg_log("/inc/user/repo/delete/delete"); rg_log("/inc/user/repo/delete/delete");
3 3
4 $are_you_sure = rg_var_uint("are_you_sure");
5
6 $repo_delete_more = $repo_admin_more;
4 7 $_delete = ""; $_delete = "";
5 8
6 9 $errmsg = array(); $errmsg = array();
7 10
8 do {
9 $r = rg_repo_delete($db, $ri['repo_id'], $rg_ui);
10 if ($r === FALSE) {
11 $errmsg[] = rg_repo_error();
12 break;
11 $_show_form = 1;
12 if ($doit == 1) {
13 if ($are_you_sure == 0) {
14 $_delete .= rg_template("user/repo/delete/no.html", $repo_delete_more);
15 $_show_form = 0;
16 } else {
17 do {
18 if (!rg_token_valid($db, $sid, $token)) {
19 $del_errmsg[] = "invalid token; try again";
20 break;
21 }
22
23 $r = rg_repo_delete($db, $ri['repo_id'], $rg_ui);
24 if ($r === FALSE) {
25 $errmsg[] = rg_repo_error();
26 break;
27 }
28
29 $_delete .= rg_template("user/repo/delete/done.html", $repo_delete_more);
30 $_show_form = 0;
31 } while (0);
13 32 } }
14 } while (0);
15
16 $_err = implode("<br />\n", $errmsg);
17 if (!empty($_err)) {
18 $_delete .= $_err;
19 } else {
20 // redirect to repo page
21 $url = rg_re_userpage($rg_ui);
22 rg_redirect($url);
33 }
34
35 if ($_show_form == 1) {
36 $repo_delete_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
37 $repo_delete_more['rg_form_token'] = rg_token_get($db, $sid);
38 $_delete .= rg_template("user/repo/delete/sure.html", $repo_delete_more);
23 39 } }
24 40
25 41 ?> ?>
File inc/user/repo/rights/rights.php changed (mode: 100644) (index 7eb1660..cef3b69)
... ... $repo_rights_more = $repo_admin_more;
5 5 $_rights = ""; $_rights = "";
6 6
7 7 $target_user = rg_var_str("target_user"); $target_user = rg_var_str("target_user");
8 $rights = rg_rights_a2s(rg_var_str("rights"));
9 $remove_uid = rg_var_uint("remove_uid");
8 $rights = isset($_REQUEST['rights']) ? rg_rights_a2s(rg_var_str("rights")) : $rg_repo_rights_default;
9 $delete = rg_var_uint("delete");
10 10 $edit_uid = rg_var_uint("edit_uid"); $edit_uid = rg_var_uint("edit_uid");
11 $grant = rg_var_uint("grant");
12 $rights_delete_ids = rg_var_str("rights_delete_ids");
11 13
12 14 // we need it in forms // we need it in forms
13 15 $repo_id = $ri['repo_id']; $repo_id = $ri['repo_id'];
14 16
15 17 $errmsg = array(); $errmsg = array();
18 $del_errmsg = array();
16 19
17 rg_log("\tDEBUG remove_uid=$remove_uid");
20 $repo_rights_more['target_user'] = $target_user;
21 $repo_rights_more['rights'] = $rights;
18 22
19 while ($remove_uid > 0) {
20 $e = rg_repo_rights_set($db, $ri, $remove_uid, "");
21 if ($e !== TRUE) {
22 $errmsg[] = rg_repo_error();
23 while ($delete == 1) {
24 if (!rg_token_valid($db, $sid, $token)) {
25 $del_errmsg[] = "invalid token; try again";
26 break;
27 }
28
29 if (empty($rights_delete_ids)) {
30 $del_errmsg[] = "No user(s) selected.";
23 31 break; break;
24 32 } }
25 33
34 foreach ($rights_delete_ids as $remove_uid => $junk) {
35 $e = rg_repo_rights_set($db, $ri, $remove_uid, "");
36 if ($e !== TRUE) {
37 $del_errmsg[] = rg_repo_error();
38 break;
39 }
40 }
41
26 42 break; break;
27 43 } }
28 44
 
... ... while ($edit_uid > 0) {
41 57 break; break;
42 58 } }
43 59
44 $target_user = $target_ui['username'];
45 $rights = $r['rights'];
60 $repo_rights_more['target_user'] = $target_ui['username'];
61 $repo_rights_more['rights'] = $r['rights'];
46 62 break; break;
47 63 } }
48 64
49 while ($doit == 1) {
65 // Adding
66 while ($grant == 1) {
50 67 if (!rg_token_valid($db, $sid, $token)) { if (!rg_token_valid($db, $sid, $token)) {
51 68 $errmsg[] = "invalid token; try again"; $errmsg[] = "invalid token; try again";
52 return;
69 break;
53 70 } }
54 71
55 72 // lookup user // lookup user
 
... ... while ($doit == 1) {
67 84 } }
68 85
69 86 // no need to pre-fill user beause was just added // no need to pre-fill user beause was just added
70 $target_user = "";
71 $rights = "";
87 $repo_rights_more['target_user'] = "";
88 $repo_rights_more['rights'] = "";
72 89 break; break;
73 90 } }
74 91
92 $repo_rights_more['rg_form_token'] = rg_token_get($db, $sid);
93 $repo_rights_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
94 $repo_rights_more['HTML:del_errmsg'] = rg_template_errmsg($del_errmsg);
95 $repo_rights_more['HTML:rights_checkboxes'] = rg_rights_checkboxes("repo", $rights);
96
75 97 // list rights // list rights
76 98 $rights_list = rg_repo_rights_load($db, $ri); $rights_list = rg_repo_rights_load($db, $ri);
77 99 if ($rights_list === FALSE) if ($rights_list === FALSE)
78 $_rights .= rg_warning("Cannot load rights. Try later");
100 $_rights .= rg_warning("Cannot load rights. Try later.");
79 101 else else
80 102 $_rights .= rg_template_table("user/repo/rights/list", $rights_list, $repo_rights_more); $_rights .= rg_template_table("user/repo/rights/list", $rights_list, $repo_rights_more);
81 103
82 104 $_rights .= "<br />\n"; $_rights .= "<br />\n";
83 105
84 $repo_rights_more['rg_action'] = $cop;
85 $repo_rights_more['rg_form_token'] = rg_token_get($db, $sid);
86 $repo_rights_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
87 $repo_rights_more['HTML:rights_checkboxes'] = rg_rights_checkboxes("repo", $rights);
88 106 $_rights .= rg_template("user/repo/rights/form.html", $repo_rights_more); $_rights .= rg_template("user/repo/rights/form.html", $repo_rights_more);
89 107 ?> ?>
File inc/util.inc.php changed (mode: 100644) (index 6f3f07d..8e5a3d0)
... ... function rg_replace_conditionals_block($block, &$stack)
486 486 */ */
487 487 function rg_replace_conditionals($block) function rg_replace_conditionals($block)
488 488 { {
489 rg_log("rg_replace_conditionals");
490
491 489 $ret = array(); $ret = array();
492 490
493 491 $stack = array(); $stack = array();
File root/index.php changed (mode: 100644) (index d95974b..03d0592)
2 2 error_reporting(E_ALL); error_reporting(E_ALL);
3 3 ini_set("track_errors", "On"); ini_set("track_errors", "On");
4 4
5 $more = array();
5 6 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
6 7 require_once("/etc/rocketgit/config.php"); require_once("/etc/rocketgit/config.php");
7 8 require_once($INC . "/init.inc.php"); require_once($INC . "/init.inc.php");
 
... ... $op = ""; $subop = ""; $subsubop = ""; $cop = "";
26 27 $rr = array("user" => "", "repo" => "", "prefix" => ""); $rr = array("user" => "", "repo" => "", "prefix" => "");
27 28 $paras = array(); $paras = array();
28 29 $rg_ui = array(); $rg_ui = array();
29 $more = array();
30 30
31 31 // We have variable 'vv' passed from webserver - build 'op' and rest of paras // We have variable 'vv' passed from webserver - build 'op' and rest of paras
32 32 $vv = rg_var_str("vv"); $vv = rg_var_str("vv");
 
... ... if ($rg_ui['uid'] > 0)
146 146 else else
147 147 $more['rg_username'] = ""; $more['rg_username'] = "";
148 148
149
150 // Some variables from the database
151 $r = rg_state_get_uint($db, "first_install");
152 if ($r > 0) {
153 $more['first_install_text'] = gmdate("Y-m-d H:i", $r);
154 } else {
155 $more['first_install_text'] = "?";
156 }
157
158
149 159 rg_prof_end("MAIN"); rg_prof_end("MAIN");
150 160
151 161 // TODO: Do something with the profiling, here // TODO: Do something with the profiling, here
File root/themes/default/index.html changed (mode: 100644) (index f3485a7..5a9fa5a)
51 51
52 52 <td> <td>
53 53 Copyright: <a href="http://kernel.embedromix.ro/">Catalin(ux) M. BOIE</a><br /> Copyright: <a href="http://kernel.embedromix.ro/">Catalin(ux) M. BOIE</a><br />
54 Version: @@rg_version@@
54 Version: @@rg_version@@<br />
55 Install date: @@first_install_text@@
55 56 </td> </td>
56 57 </tr> </tr>
57 58 </tbody> </tbody>
File root/themes/default/main.css changed (mode: 100644) (index 83062c4..8396c17)
... ... body {
7 7 font-family: helvetica, sans-serif; font-family: helvetica, sans-serif;
8 8 font-size: 10pt; font-size: 10pt;
9 9 line-height: 105%; line-height: 105%;
10 background-color: #DDDDDD;
10 11 } }
11 12
12 13 table { table {
 
... ... form input[type="submit"] {
82 83 .menu ul li { display: inline; } .menu ul li { display: inline; }
83 84 .menu ul li a { .menu ul li a {
84 85 text-decoration: none; text-decoration: none;
85 color: #666666;
86 color: #FFFFFF;
86 87 font-size: 11pt; font-size: 11pt;
87 88 font-weight: bold; font-weight: bold;
88 89 padding: 3px 12px 3px 0px; padding: 3px 12px 3px 0px;
89 90 } }
90 .menu ul li a:hover { color: #AAAAAA; }
91 .menu ul li a:hover { color: #FF0000; }
91 92 .menu ul li a.selected { color: #BBBBBB; } .menu ul li a.selected { color: #BBBBBB; }
92 93 .menu ul li a.selected:hover { color: #CCCCCC; } .menu ul li a.selected:hover { color: #CCCCCC; }
93 94
 
... ... form input[type="submit"] {
108 109 #header { #header {
109 110 overflow: hidden; overflow: hidden;
110 111 border-bottom: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;
111 background-color: #FFFFFF;
112 background-color: #888888;
112 113 padding: 0 15px 0 15px; padding: 0 15px 0 15px;
113 114 } }
114 115 #header table { #header table {
115 116 border-collapse: collapse; border-collapse: collapse;
116 117 border: 0; border: 0;
117 118 border-spacing: 0; border-spacing: 0;
118 background-color: #FFFFFF;
119 background-color: #888888;
119 120 margin: 3px 0 3px 0; margin: 3px 0 3px 0;
120 121 } }
121 122 #header table td { #header table td {
 
... ... form input[type="submit"] {
138 139 #footer { #footer {
139 140 overflow: hidden; overflow: hidden;
140 141 border-top: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC;
141 background-color: #FFFFFF;
142 142 padding: 5px 15px 5px 15px; padding: 5px 15px 5px 15px;
143 143 } }
144 144 #footer table { #footer table {
145 145 border-collapse: collapse; border-collapse: collapse;
146 146 border: 0; border: 0;
147 147 border-spacing: 0; border-spacing: 0;
148 background-color: #FFFFFF;
149 148 } }
150 149 #footer table td { #footer table td {
151 150 padding: 3px 40px 3px 0; padding: 3px 40px 3px 0;
152 151 border: 0px; border: 0px;
153 152 font-size: 10pt; font-size: 10pt;
154 153 line-height: 120%; line-height: 120%;
154 background-color: #DDDDDD;
155 155 } }
156 156
157 157 .formarea { .formarea {
 
... ... form input[type="submit"] {
212 212 .submenu { .submenu {
213 213 border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
214 214 border-bottom: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;
215 background-color: #FFFFBB;
215 background-color: #888888;
216 216 margin-bottom: 3px; margin-bottom: 3px;
217 display: table;
217 display: block;
218 padding-left: 5px;
218 219 } }
219 220 .submenu ul li {} .submenu ul li {}
220 221
 
... ... form input[type="submit"] {
238 239 margin: 3px 0px; margin: 3px 0px;
239 240 } }
240 241
241 .repo_body { display: table; }
242 .repo_body { display: block; }
242 243
243 244 .urls { padding: 3px 0px; margin: 5px 0px; } .urls { padding: 3px 0px; margin: 5px 0px; }
244 245 .urls ul { list-style-type: none; } .urls ul { list-style-type: none; }
File root/themes/default/repo/main.html changed (mode: 100644) (index 0aecffb..1f60940)
11 11 @@urls@@ @@urls@@
12 12 </div> </div>
13 13
14 <div class="menu submenu" style="clear: both;">
14 <div class="menu submenu">
15 15 <ul> <ul>
16 16 <li><a href="@@url_repo@@/source">Source</a></li> <li><a href="@@url_repo@@/source">Source</a></li>
17 17 <li><a href="@@url_repo@@/mr">Merge requests</a></li> <li><a href="@@url_repo@@/mr">Merge requests</a></li>
File root/themes/default/user/repo/delete/done.html added (mode: 100644) (index 0000000..0457089)
1 The repository was deleted.
File root/themes/default/user/repo/delete/no.html added (mode: 100644) (index 0000000..69bcc79)
1 I am glad the you changed your mind!
File root/themes/default/user/repo/delete/sure.html added (mode: 100644) (index 0000000..3520c39)
1 <div class="warning">
2
3 <form method="post" action="@@url@@">
4 <input type="hidden" name="doit" value="1" />
5 <input type="hidden" name="token" value="@@rg_form_token@@" />
6
7 <label class="form_item_title" for="are_you_sure">Are you sure?</label><br />
8 <select name="are_you_sure">
9 <option value="0">No</option>
10 <option value="1">Yes</option>
11 </select>
12 <br />
13 <br />
14
15 <input type="submit" name="button" value="Do it!" />
16
17 </form>
18
19 </div>
File root/themes/default/user/repo/rights/form.html renamed from inc/user/repo/rights/form.html (similarity 75%) (mode: 100644) (index 41f9ca0..ff0cf6f)
4 4
5 5 @@errmsg@@ @@errmsg@@
6 6
7 <form method="post" action="@@rg_action@@">
8 <input type="hidden" name="repo_id" value="@@repo_id@@" />
9 <input type="hidden" name="doit" value="1" />
7 <form method="post" action="@@url@@">
8 <input type="hidden" name="grant" value="1" />
10 9 <input type="hidden" name="token" value="@@rg_form_token@@" /> <input type="hidden" name="token" value="@@rg_form_token@@" />
11 10
12 11 <label class="form_item_title" for="target_user">User</label><br /> <label class="form_item_title" for="target_user">User</label><br />
File root/themes/default/user/repo/rights/list/line.html changed (mode: 100644) (index f43b969..88ed164)
1 1 <tr> <tr>
2 <td><input type="checkbox" name="rights_delete_ids[@@rights_uid@@]" /></td>
2 <td><input type="checkbox" name="rights_delete_ids[@@right_uid@@]" /></td>
3 3 <td>@@username@@</td> <td>@@username@@</td>
4 4 <td>@@itime_text@@</td> <td>@@itime_text@@</td>
5 5 <td>@@rights_text@@</td> <td>@@rights_text@@</td>
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master