File inc/repo.inc.php changed (mode: 100644) (index ed54763..fd47157) |
... |
... |
$rg_repo_rights = array( |
28 |
28 |
); |
); |
29 |
29 |
|
|
30 |
30 |
// What rights are on by default |
// What rights are on by default |
|
31 |
|
// TODO: this should go into conf file? |
31 |
32 |
$rg_repo_rights_default = "FMH"; |
$rg_repo_rights_default = "FMH"; |
32 |
33 |
|
|
33 |
34 |
rg_rights_register("repo", $rg_repo_rights); |
rg_rights_register("repo", $rg_repo_rights); |
|
... |
... |
function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, |
279 |
280 |
// and for permission reasons (we are 'apache' user here) |
// and for permission reasons (we are 'apache' user here) |
280 |
281 |
|
|
281 |
282 |
rg_prof_end("repo_create"); |
rg_prof_end("repo_create"); |
282 |
|
|
|
283 |
283 |
return $ret; |
return $ret; |
284 |
284 |
} |
} |
285 |
285 |
|
|
|
... |
... |
function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, |
289 |
289 |
function rg_repo_delete($db, $repo_id, $rg_ui) |
function rg_repo_delete($db, $repo_id, $rg_ui) |
290 |
290 |
{ |
{ |
291 |
291 |
rg_prof_start("repo_delete"); |
rg_prof_start("repo_delete"); |
292 |
|
|
|
293 |
292 |
rg_log("repo_delete: rg_uid=" . $rg_ui['uid'] . ", repo_id=$repo_id"); |
rg_log("repo_delete: rg_uid=" . $rg_ui['uid'] . ", repo_id=$repo_id"); |
294 |
293 |
|
|
295 |
294 |
// TODO: Check rights |
// TODO: Check rights |
|
... |
... |
function rg_repo_delete($db, $repo_id, $rg_ui) |
304 |
303 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
305 |
304 |
|
|
306 |
305 |
rg_prof_end("repo_delete"); |
rg_prof_end("repo_delete"); |
307 |
|
|
|
308 |
306 |
return TRUE; |
return TRUE; |
309 |
307 |
} |
} |
310 |
308 |
|
|
|
... |
... |
function rg_repo_delete($db, $repo_id, $rg_ui) |
315 |
313 |
function rg_repo_update($db, $user, &$new) |
function rg_repo_update($db, $user, &$new) |
316 |
314 |
{ |
{ |
317 |
315 |
rg_prof_start("repo_update"); |
rg_prof_start("repo_update"); |
318 |
|
|
|
319 |
316 |
rg_log("repo_update: user=" . $user |
rg_log("repo_update: user=" . $user |
320 |
|
. " repo_id=" . $new['repo_id'] |
|
321 |
|
. " name=[" . $new['name'] . "]" |
|
322 |
|
. " max_commit_size=" . $new['max_commit_size'] |
|
323 |
|
. " description=[" . $new['description'] . "]" |
|
324 |
|
. " default_rights=" . $new['default_rights'] |
|
325 |
|
. " max_users=" . $new['max_users']); |
|
|
317 |
|
. " new=" . rg_array2string($new)); |
326 |
318 |
|
|
327 |
319 |
if (rg_repo_ok($new['name']) !== TRUE) |
if (rg_repo_ok($new['name']) !== TRUE) |
328 |
320 |
return FALSE; |
return FALSE; |
|
... |
... |
function rg_repo_update($db, $user, &$new) |
364 |
356 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
365 |
357 |
|
|
366 |
358 |
rg_prof_end("repo_update"); |
rg_prof_end("repo_update"); |
367 |
|
|
|
368 |
359 |
return TRUE; |
return TRUE; |
369 |
360 |
} |
} |
370 |
361 |
|
|
|
... |
... |
function rg_repo_update($db, $user, &$new) |
374 |
365 |
function rg_repo_list_query($db, $url, $sql) |
function rg_repo_list_query($db, $url, $sql) |
375 |
366 |
{ |
{ |
376 |
367 |
rg_prof_start("repo_list_query"); |
rg_prof_start("repo_list_query"); |
377 |
|
|
|
378 |
368 |
rg_log("repo_list_query: url=$url, sql=$sql..."); |
rg_log("repo_list_query: url=$url, sql=$sql..."); |
379 |
369 |
|
|
380 |
370 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
|
... |
... |
function rg_repo_list_query($db, $url, $sql) |
433 |
423 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
434 |
424 |
|
|
435 |
425 |
rg_prof_end("repo_list_query"); |
rg_prof_end("repo_list_query"); |
436 |
|
|
|
437 |
426 |
return rg_template_table("repo/list", $d, array()); |
return rg_template_table("repo/list", $d, array()); |
438 |
427 |
} |
} |
439 |
428 |
|
|
|
... |
... |
function rg_repo_rights_set($db, $ri, $uid, $rights) |
587 |
576 |
/* |
/* |
588 |
577 |
* List rights for a repo |
* List rights for a repo |
589 |
578 |
*/ |
*/ |
590 |
|
function rg_repo_rights_list($db, $ri, $url) |
|
|
579 |
|
function rg_repo_rights_load($db, $ri) |
591 |
580 |
{ |
{ |
592 |
|
rg_log("rg_repo_rights_list: repo_id=" . $ri['repo_id'] . " url=$url"); |
|
|
581 |
|
rg_log("rg_repo_rights_load: repo_id=" . $ri['repo_id']); |
593 |
582 |
|
|
594 |
|
$r = rg_rights_list($db, "repo", $ri['repo_id'], $url); |
|
|
583 |
|
$r = rg_rights_load($db, "repo", $ri['repo_id']); |
595 |
584 |
if ($r === FALSE) { |
if ($r === FALSE) { |
596 |
585 |
rg_repo_set_error("Cannot list rights (" . rg_rights_error() . ")"); |
rg_repo_set_error("Cannot list rights (" . rg_rights_error() . ")"); |
597 |
586 |
return FALSE; |
return FALSE; |
File inc/rights.inc.php changed (mode: 100644) (index dd6adbf..ca76c1a) |
... |
... |
function rg_rights_get($db, $type, $obj_id, $uid) |
155 |
155 |
return $ret; |
return $ret; |
156 |
156 |
} |
} |
157 |
157 |
|
|
158 |
|
$sql = "SELECT rights FROM rights" |
|
|
158 |
|
$sql = "SELECT itime, rights FROM rights" |
159 |
159 |
. " WHERE type = '$type'" |
. " WHERE type = '$type'" |
160 |
160 |
. " AND uid = $uid" |
. " AND uid = $uid" |
161 |
161 |
. " AND obj_id = $obj_id" |
. " AND obj_id = $obj_id" |
|
... |
... |
function rg_rights_get($db, $type, $obj_id, $uid) |
173 |
173 |
$row = rg_sql_fetch_array($res); |
$row = rg_sql_fetch_array($res); |
174 |
174 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
175 |
175 |
if ($rows > 0) { |
if ($rows > 0) { |
|
176 |
|
$ret['itime'] = $row['itime']; |
176 |
177 |
$ret['rights'] = $row['rights']; |
$ret['rights'] = $row['rights']; |
177 |
178 |
$ret['exists'] = 1; |
$ret['exists'] = 1; |
178 |
179 |
} |
} |
|
... |
... |
function rg_rights_set($db, $type, $obj_id, $uid, $rights) |
226 |
227 |
} |
} |
227 |
228 |
|
|
228 |
229 |
/* |
/* |
229 |
|
* List rights for a repo |
|
|
230 |
|
* Returns an array with the rights |
230 |
231 |
*/ |
*/ |
231 |
|
function rg_rights_list($db, $type, $obj_id, $url) |
|
|
232 |
|
function rg_rights_load($db, $type, $obj_id) |
232 |
233 |
{ |
{ |
233 |
234 |
global $rg_rights; |
global $rg_rights; |
234 |
235 |
|
|
235 |
|
rg_log("rg_rights_list: type=$type obj_id=$obj_id url=$url"); |
|
|
236 |
|
rg_prof_start("rights_list"); |
|
237 |
|
rg_log("rg_rights_list: type=$type obj_id=$obj_id"); |
|
238 |
|
|
|
239 |
|
$ret = FALSE; |
|
240 |
|
do { |
|
241 |
|
$sql = "SELECT * FROM rights" |
|
242 |
|
. " WHERE type = '$type'" |
|
243 |
|
. " AND obj_id = $obj_id"; |
|
244 |
|
$res = rg_sql_query($db, $sql); |
|
245 |
|
if ($res === FALSE) { |
|
246 |
|
rg_rights_set_error("cannot get info (" . rg_sql_error() . ")!"); |
|
247 |
|
break; |
|
248 |
|
} |
236 |
249 |
|
|
237 |
|
$ret = ""; |
|
|
250 |
|
$ret = array(); |
|
251 |
|
while (($row = rg_sql_fetch_array($res))) { |
|
252 |
|
$row['username'] = "?"; |
|
253 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
254 |
|
if ($_ui['exists'] == 1) |
|
255 |
|
$row['username'] = $_ui['username']; |
238 |
256 |
|
|
239 |
|
$sql = "SELECT * FROM rights WHERE type = '$type' AND obj_id = $obj_id"; |
|
240 |
|
$res = rg_sql_query($db, $sql); |
|
241 |
|
if ($res === FALSE) { |
|
242 |
|
rg_rights_set_error("cannot get info (" . rg_sql_error() . ")!"); |
|
243 |
|
return FALSE; |
|
244 |
|
} |
|
|
257 |
|
$_r = rg_rights_text($type, $row['rights']); |
|
258 |
|
$row['rights_text'] = implode(", ", $_r); |
245 |
259 |
|
|
246 |
|
$ret .= "<table>\n"; |
|
247 |
|
$ret .= "<tr>\n"; |
|
248 |
|
$ret .= " <th>User</th>\n"; |
|
249 |
|
$ret .= " <th>Rights</th>\n"; |
|
250 |
|
$ret .= " <th>Operations</th>\n"; |
|
251 |
|
$ret .= "</tr>\n"; |
|
252 |
|
while (($row = rg_sql_fetch_array($res))) { |
|
253 |
|
$ret .= "<tr>\n"; |
|
254 |
|
|
|
255 |
|
$_u = $row['uid']; |
|
256 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
257 |
|
if ($_ui['exists'] == 1) |
|
258 |
|
$_u = $_ui['username']; |
|
259 |
|
|
|
260 |
|
$ret .= " <td>" . $_u . "</td>\n"; |
|
261 |
|
|
|
262 |
|
$_r = rg_rights_text($type, $row['rights']); |
|
263 |
|
$_r = implode("<br />\n", $_r); |
|
264 |
|
$ret .= " <td>" . $_r . "</td>\n"; |
|
265 |
|
|
|
266 |
|
// operations |
|
267 |
|
// remove |
|
268 |
|
$ret .= " <td>"; |
|
269 |
|
$ret .= " <div class=\"menu\">"; |
|
270 |
|
$ret .= " <ul>"; |
|
271 |
|
$v = $row['uid']; |
|
272 |
|
$ret .= "<li><a href=\"$url?remove_uid=$v\">Remove</a></li>\n"; |
|
273 |
|
$ret .= "<li><a href=\"$url?edit_uid=$v\">Edit</a></li>\n"; |
|
274 |
|
$ret .= " </ul>"; |
|
275 |
|
$ret .= " </div>"; |
|
276 |
|
$ret .= " </td>"; |
|
277 |
|
$ret .= "</tr>\n"; |
|
278 |
|
} |
|
279 |
|
$ret .= "</table>\n"; |
|
280 |
|
rg_sql_free_result($res); |
|
|
260 |
|
$row['itime_text'] = gmdate("Y-m-d H:i", $row['itime']); |
|
261 |
|
|
|
262 |
|
// To avoid confusion |
|
263 |
|
$row['right_uid'] = $row['uid']; |
|
264 |
|
unset($row['uid']); |
|
265 |
|
|
|
266 |
|
$ret[] = $row; |
|
267 |
|
} |
|
268 |
|
rg_sql_free_result($res); |
|
269 |
|
} while (0); |
281 |
270 |
|
|
|
271 |
|
rg_prof_end("rights_list"); |
282 |
272 |
return $ret; |
return $ret; |
283 |
273 |
} |
} |
284 |
274 |
|
|
File inc/user/repo-page.php changed (mode: 100644) (index a9ef6ab..0e16ec4) |
2 |
2 |
rg_log("/inc/user/repo-page"); |
rg_log("/inc/user/repo-page"); |
3 |
3 |
|
|
4 |
4 |
$_repo_page = ""; |
$_repo_page = ""; |
|
5 |
|
$user_more = $more; |
5 |
6 |
|
|
6 |
7 |
if (rg_user_ok($rr['user']) !== TRUE) { |
if (rg_user_ok($rr['user']) !== TRUE) { |
7 |
8 |
$_repo_page .= "Invalid user!"; |
$_repo_page .= "Invalid user!"; |
|
... |
... |
if ($ui === FALSE) { |
42 |
43 |
// TODO: should we test against $ri?! |
// TODO: should we test against $ri?! |
43 |
44 |
$can_admin = (rg_repo_allow($db, $ri, $rg_ui, "A") === TRUE) ? 1 : 0; |
$can_admin = (rg_repo_allow($db, $ri, $rg_ui, "A") === TRUE) ? 1 : 0; |
44 |
45 |
|
|
45 |
|
$_more = array( |
|
|
46 |
|
$user_more = array( |
46 |
47 |
"owner" => $rr['user'], |
"owner" => $rr['user'], |
47 |
48 |
"url_user" => rg_re_userpage($ui), |
"url_user" => rg_re_userpage($ui), |
48 |
49 |
"url_repo" => rg_re_repopage($ui, $rr['repo']), |
"url_repo" => rg_re_repopage($ui, $rr['repo']), |
|
... |
... |
$_more = array( |
50 |
51 |
"git" => rg_re_repo_git($rr), |
"git" => rg_re_repo_git($rr), |
51 |
52 |
"can_admin" => $can_admin |
"can_admin" => $can_admin |
52 |
53 |
); |
); |
53 |
|
$_more = array_merge($_more, $ri); |
|
54 |
|
$_more['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights'])); |
|
55 |
|
$_more['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']); |
|
56 |
|
$_more['max_users'] = $ri['max_users'] == 0 ? "unlimited" : rg_1000($ri['max_users']); |
|
57 |
|
$_more['hints'] = ""; |
|
|
54 |
|
$user_more = array_merge($user_more, $ri); |
|
55 |
|
$user_more['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights'])); |
|
56 |
|
$user_more['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']); |
|
57 |
|
$user_more['max_users'] = $ri['max_users'] == 0 ? "unlimited" : rg_1000($ri['max_users']); |
|
58 |
|
$user_more['hints'] = ""; |
58 |
59 |
|
|
59 |
60 |
$repo_dir = rg_repo_name2base($rr) . $rr['repo'] . ".git"; |
$repo_dir = rg_repo_name2base($rr) . $rr['repo'] . ".git"; |
60 |
61 |
rg_log("repo_dir=$repo_dir"); |
rg_log("repo_dir=$repo_dir"); |
|
... |
... |
putenv("GIT_DIR=$repo_dir"); |
64 |
65 |
if (empty($subop)) |
if (empty($subop)) |
65 |
66 |
$subop = "source"; |
$subop = "source"; |
66 |
67 |
|
|
67 |
|
$_more['repo_body'] = ""; |
|
68 |
|
$_more['repo_right'] = ""; |
|
69 |
|
$_more['branches_and_tags'] = ""; |
|
|
68 |
|
$user_more['repo_body'] = ""; |
|
69 |
|
$user_more['repo_right'] = ""; |
|
70 |
|
$user_more['branches_and_tags'] = ""; |
70 |
71 |
$_repo_body = ""; |
$_repo_body = ""; |
71 |
72 |
$_repo_right = ""; |
$_repo_right = ""; |
72 |
73 |
|
|
73 |
74 |
// build urls list |
// build urls list |
74 |
75 |
$urls = array(); |
$urls = array(); |
75 |
76 |
if ($rg_ssh_port != 0) |
if ($rg_ssh_port != 0) |
76 |
|
$urls[]['HTML:url'] = '<a href="' . $_more['ssh'] . '">' . $_more['ssh'] . '</a>'; |
|
|
77 |
|
$urls[]['HTML:url'] = '<a href="' . $user_more['ssh'] . '">' . $user_more['ssh'] . '</a>'; |
77 |
78 |
if ($rg_git_port != 0) |
if ($rg_git_port != 0) |
78 |
|
$urls[]['HTML:url'] = '<a href="' . $_more['git'] . '">' . $_more['git'] . '</a>'; |
|
79 |
|
$_more['HTML:urls'] = rg_template_table("repo/urls", $urls, $_more); |
|
|
79 |
|
$urls[]['HTML:url'] = '<a href="' . $user_more['git'] . '">' . $user_more['git'] . '</a>'; |
|
80 |
|
$user_more['HTML:urls'] = rg_template_table("repo/urls", $urls, $user_more); |
80 |
81 |
|
|
81 |
82 |
if (strcmp($subop, "admin") == 0) { |
if (strcmp($subop, "admin") == 0) { |
82 |
83 |
if ($can_admin != 1) |
if ($can_admin != 1) |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
89 |
90 |
|
|
90 |
91 |
$type_ref = rg_git_parse_ref($paras); |
$type_ref = rg_git_parse_ref($paras); |
91 |
92 |
$ref = $type_ref['ref_path']; |
$ref = $type_ref['ref_path']; |
92 |
|
$_more = array_merge($_more, $type_ref); |
|
|
93 |
|
$user_more = array_merge($user_more, $type_ref); |
93 |
94 |
|
|
94 |
|
$bt = rg_git_branches_and_tags($repo_dir, $_more['url_repo'], |
|
|
95 |
|
$bt = rg_git_branches_and_tags($repo_dir, $user_more['url_repo'], |
95 |
96 |
$type_ref['ref_url']); |
$type_ref['ref_url']); |
96 |
|
rg_log("DEBUG: _more: " . rg_array2string($_more)); |
|
97 |
|
$_more = array_merge($_more, $bt); |
|
|
97 |
|
rg_log("DEBUG: user_more: " . rg_array2string($user_more)); |
|
98 |
|
$user_more = array_merge($user_more, $bt); |
98 |
99 |
|
|
99 |
100 |
$hints = array(); |
$hints = array(); |
100 |
101 |
if ($rg_ssh_port != 0) |
if ($rg_ssh_port != 0) |
101 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_ssh.html", $_more); |
|
|
102 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_ssh.html", $user_more); |
102 |
103 |
if ($rg_git_port != 0) |
if ($rg_git_port != 0) |
103 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_git.html", $_more); |
|
|
104 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_git.html", $user_more); |
104 |
105 |
if (rg_rights_allow($ri['default_rights'], "H")) // anonymous push? |
if (rg_rights_allow($ri['default_rights'], "H")) // anonymous push? |
105 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $_more); |
|
|
106 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $user_more); |
106 |
107 |
rg_log("DEBUG: hints1: " . rg_array2string($hints)); |
rg_log("DEBUG: hints1: " . rg_array2string($hints)); |
107 |
|
$_more['HTML:hints'] = rg_template_table("hints/list", $hints, $_more); |
|
108 |
|
rg_log("DEBUG: hints: " . $_more['HTML:hints']); |
|
|
108 |
|
$user_more['HTML:hints'] = rg_template_table("hints/list", $hints, $user_more); |
|
109 |
|
rg_log("DEBUG: hints: " . $user_more['HTML:hints']); |
109 |
110 |
|
|
110 |
|
$_repo_body .= rg_template("repo/source.html", $_more); |
|
|
111 |
|
$_repo_body .= rg_template("repo/source.html", $user_more); |
111 |
112 |
|
|
112 |
113 |
rg_log("DEBUG: subop=[$subop]"); |
rg_log("DEBUG: subop=[$subop]"); |
113 |
114 |
if (strcmp($subop, "tree") == 0) { |
if (strcmp($subop, "tree") == 0) { |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
116 |
117 |
if (strcmp($type, "blob") == 0) { |
if (strcmp($type, "blob") == 0) { |
117 |
118 |
// find hash of blob |
// find hash of blob |
118 |
119 |
$_path = implode("/", $paras); |
$_path = implode("/", $paras); |
119 |
|
$_more['path'] = "/" . $_path; |
|
|
120 |
|
$user_more['path'] = "/" . $_path; |
120 |
121 |
$_tree = rg_git_ls_tree($ref, $_path); |
$_tree = rg_git_ls_tree($ref, $_path); |
121 |
122 |
if ($_tree === FALSE) { |
if ($_tree === FALSE) { |
122 |
123 |
$_repo_body .= "Invalid path!"; |
$_repo_body .= "Invalid path!"; |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
130 |
131 |
); |
); |
131 |
132 |
$blob = array_merge($blob, $_content); |
$blob = array_merge($blob, $_content); |
132 |
133 |
$_repo_body .= rg_template("repo/blob.html", |
$_repo_body .= rg_template("repo/blob.html", |
133 |
|
array_merge($blob, $_more)); |
|
|
134 |
|
array_merge($blob, $user_more)); |
134 |
135 |
} |
} |
135 |
136 |
} else if (strcmp($type, "tree") == 0) { |
} else if (strcmp($type, "tree") == 0) { |
136 |
137 |
// find treeish of dir |
// find treeish of dir |
137 |
138 |
$_path = implode("/", $paras); |
$_path = implode("/", $paras); |
138 |
|
$_more['path'] = "/" . $_path; |
|
|
139 |
|
$user_more['path'] = "/" . $_path; |
139 |
140 |
$_tree = rg_git_ls_tree($ref, $_path); |
$_tree = rg_git_ls_tree($ref, $_path); |
140 |
141 |
if ($_tree === FALSE) { |
if ($_tree === FALSE) { |
141 |
142 |
$_repo_body .= "Invalid path!"; |
$_repo_body .= "Invalid path!"; |
142 |
143 |
} else { |
} else { |
143 |
144 |
$_hash = $_tree[0]['ref']; |
$_hash = $_tree[0]['ref']; |
144 |
145 |
$_tree = rg_git_ls_tree($_hash, ""); |
$_tree = rg_git_ls_tree($_hash, ""); |
145 |
|
$_repo_body .= rg_template_table("repo/tree", $_tree, $_more); |
|
|
146 |
|
$_repo_body .= rg_template_table("repo/tree", $_tree, $user_more); |
146 |
147 |
} |
} |
147 |
148 |
} else { // default is to show root tree |
} else { // default is to show root tree |
148 |
|
$_more['path'] = ""; |
|
|
149 |
|
$user_more['path'] = ""; |
149 |
150 |
$_tree = rg_git_ls_tree($ref, ""); |
$_tree = rg_git_ls_tree($ref, ""); |
150 |
|
$_repo_body .= rg_template_table("repo/tree", $_tree, $_more); |
|
|
151 |
|
$_repo_body .= rg_template_table("repo/tree", $_tree, $user_more); |
151 |
152 |
} |
} |
152 |
153 |
} else { // log is default |
} else { // log is default |
153 |
154 |
// show the log |
// show the log |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
157 |
158 |
$_repo_body .= "Error generating log!"; |
$_repo_body .= "Error generating log!"; |
158 |
159 |
// TODO: rg_internal_error? |
// TODO: rg_internal_error? |
159 |
160 |
} else if (empty($log)) { |
} else if (empty($log)) { |
160 |
|
$_repo_body .= rg_template("repo/not_init.html", $_more); |
|
|
161 |
|
$_repo_body .= rg_template("repo/not_init.html", $user_more); |
161 |
162 |
} else { |
} else { |
162 |
163 |
//rg_log("DEBUG: log: " . print_r($log, TRUE)); |
//rg_log("DEBUG: log: " . print_r($log, TRUE)); |
163 |
164 |
$_repo_body .= rg_git_log_template($log, |
$_repo_body .= rg_git_log_template($log, |
164 |
|
"repo/log", $_more); |
|
|
165 |
|
"repo/log", $user_more); |
165 |
166 |
} |
} |
166 |
167 |
|
|
167 |
168 |
$type = array_shift($paras); |
$type = array_shift($paras); |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
190 |
191 |
$_repo_body .= rg_git_diff($log[0]['patches'], "repo/diff.html"); |
$_repo_body .= rg_git_diff($log[0]['patches'], "repo/diff.html"); |
191 |
192 |
} |
} |
192 |
193 |
} |
} |
193 |
|
$_repo_right = rg_template("repo/source_r.html", $_more); |
|
|
194 |
|
$_repo_right = rg_template("repo/source_r.html", $user_more); |
194 |
195 |
} else if (strcmp($subop, "bug") == 0) { |
} else if (strcmp($subop, "bug") == 0) { |
195 |
196 |
include($INC . "/user/repo/bug/main.php"); |
include($INC . "/user/repo/bug/main.php"); |
196 |
|
$_repo_body .= rg_template("repo/bug/main.html", $_more); |
|
|
197 |
|
$_repo_body .= rg_template("repo/bug/main.html", $user_more); |
197 |
198 |
} else if (strcmp($subop, "stats") == 0) { |
} else if (strcmp($subop, "stats") == 0) { |
198 |
|
$_repo_body .= rg_template("repo/stats.html", $_more); |
|
|
199 |
|
$_repo_body .= rg_template("repo/stats.html", $user_more); |
199 |
200 |
} else if (strcmp($subop, "mr") == 0) { |
} else if (strcmp($subop, "mr") == 0) { |
200 |
201 |
if (empty($paras[0])) { |
if (empty($paras[0])) { |
201 |
|
$_repo_body .= rg_template("repo/mrs.html", $_more); |
|
|
202 |
|
$_repo_body .= rg_template("repo/mrs.html", $user_more); |
202 |
203 |
|
|
203 |
204 |
$r = rg_mr_load($db, $ri['repo_id'], 20); |
$r = rg_mr_load($db, $ri['repo_id'], 20); |
204 |
205 |
if ($r === FALSE) { |
if ($r === FALSE) { |
205 |
206 |
$_repo_body .= "Error getting merge request list (" |
$_repo_body .= "Error getting merge request list (" |
206 |
207 |
. rg_mr_error() . ")."; |
. rg_mr_error() . ")."; |
207 |
208 |
} else { |
} else { |
208 |
|
$_repo_body .= rg_template_table("repo/mr/list", $r, $_more); |
|
|
209 |
|
$_repo_body .= rg_template_table("repo/mr/list", $r, $user_more); |
209 |
210 |
} |
} |
210 |
211 |
} else { |
} else { |
211 |
212 |
$mr = preg_replace('/[^0-9a-zA-Z_]/', '', $paras[0]); |
$mr = preg_replace('/[^0-9a-zA-Z_]/', '', $paras[0]); |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
222 |
223 |
break; |
break; |
223 |
224 |
} |
} |
224 |
225 |
|
|
225 |
|
$mri['HTML:diff'] = rg_git_log_template($_log, "repo/log", $_more); |
|
226 |
|
$_repo_body .= rg_template("repo/mr/page.html", $mri, $_more); |
|
|
226 |
|
$mri['HTML:diff'] = rg_git_log_template($_log, "repo/log", $user_more); |
|
227 |
|
$_repo_body .= rg_template("repo/mr/page.html", $mri, $user_more); |
227 |
228 |
} while (0); |
} while (0); |
228 |
229 |
} |
} |
229 |
230 |
} |
} |
230 |
231 |
|
|
231 |
|
$_more['HTML:repo_body'] = $_repo_body; |
|
232 |
|
$_more['HTML:repo_right'] = $_repo_right; |
|
233 |
|
$_repo_page = rg_template("repo/main.html", $_more); |
|
|
232 |
|
$user_more['HTML:repo_body'] = $_repo_body; |
|
233 |
|
$user_more['HTML:repo_right'] = $_repo_right; |
|
234 |
|
$_repo_page = rg_template("repo/main.html", $user_more); |
234 |
235 |
?> |
?> |
File inc/user/repo/bug/main.php changed (mode: 100644) (index 71fdb4d..43696d4) |
1 |
1 |
<?php |
<?php |
2 |
2 |
rg_log("/inc/user/repo/bug/main"); |
rg_log("/inc/user/repo/bug/main"); |
3 |
3 |
|
|
|
4 |
|
$repo_bug_more = $repo_admin_more; |
4 |
5 |
$_bug_body = ""; |
$_bug_body = ""; |
5 |
6 |
|
|
6 |
|
$_more['can_save'] = $rg_ui['uid'] > 0 ? 1 : 0; |
|
|
7 |
|
$repo_bug_more['can_save'] = $rg_ui['uid'] > 0 ? 1 : 0; |
7 |
8 |
|
|
8 |
9 |
$_op = empty($paras) ? "list" : array_shift($paras); |
$_op = empty($paras) ? "list" : array_shift($paras); |
9 |
10 |
switch ($_op) { |
switch ($_op) { |
|
... |
... |
case 'list': /* list */ |
41 |
42 |
$_bug_body .= "Error: cannot load all searches!"; // TODO |
$_bug_body .= "Error: cannot load all searches!"; // TODO |
42 |
43 |
} else { |
} else { |
43 |
44 |
$_bug_body .= rg_template_table("repo/bug/search/list", |
$_bug_body .= rg_template_table("repo/bug/search/list", |
44 |
|
$r, $_more); |
|
|
45 |
|
$r, $repo_bug_more); |
45 |
46 |
} |
} |
46 |
47 |
|
|
47 |
48 |
$filter = rg_bug_search_load($db, $ri['repo_id'], $rg_ui['uid'], $_search); |
$filter = rg_bug_search_load($db, $ri['repo_id'], $rg_ui['uid'], $_search); |
|
... |
... |
case 'list': /* list */ |
51 |
52 |
} |
} |
52 |
53 |
|
|
53 |
54 |
if (isset($filter['name'])) |
if (isset($filter['name'])) |
54 |
|
$_more['search_name'] = $filter['name']; |
|
|
55 |
|
$repo_bug_more['search_name'] = $filter['name']; |
55 |
56 |
|
|
56 |
|
$r = rg_bug_search($db, $_more['url_repo'], $ri['repo_id'], |
|
|
57 |
|
$r = rg_bug_search($db, $repo_bug_more['url_repo'], $ri['repo_id'], |
57 |
58 |
$rg_ui['uid'], $filter); |
$rg_ui['uid'], $filter); |
58 |
59 |
if ($r === FALSE) |
if ($r === FALSE) |
59 |
60 |
$_bug_body .= "Error: Cannot search bugs!"; // TODO: do something OK here! |
$_bug_body .= "Error: Cannot search bugs!"; // TODO: do something OK here! |
|
... |
... |
case 'list': /* list */ |
62 |
63 |
|
|
63 |
64 |
// Show remove for custom search |
// Show remove for custom search |
64 |
65 |
if (isset($filter['standard']) && ($filter['standard'] == 0)) { |
if (isset($filter['standard']) && ($filter['standard'] == 0)) { |
65 |
|
$_remove_more = $_more; |
|
|
66 |
|
$_remove_more = $repo_bug_more; |
66 |
67 |
$_remove_more['rg_action'] = $_url . "/list/" . $filter['name']; |
$_remove_more['rg_action'] = $_url . "/list/" . $filter['name']; |
67 |
68 |
$_remove_more['rg_form_token'] = rg_token_get($db, $sid); |
$_remove_more['rg_form_token'] = rg_token_get($db, $sid); |
68 |
69 |
$_remove_more['search_remove_errmsg'] = ""; |
$_remove_more['search_remove_errmsg'] = ""; |
|
... |
... |
default: // go directly to a bug |
76 |
77 |
if ($bug_id == 0) { |
if ($bug_id == 0) { |
77 |
78 |
rg_log("BAD, invalid op=$_op!"); |
rg_log("BAD, invalid op=$_op!"); |
78 |
79 |
} else { |
} else { |
79 |
|
include($INC . "/user/repo/bug/show.php"); |
|
|
80 |
|
include($INC . "/user/repo/bug/show/show.php"); |
80 |
81 |
$_bug_body .= $_bug_show; |
$_bug_body .= $_bug_show; |
81 |
82 |
} |
} |
82 |
83 |
} |
} |
83 |
84 |
|
|
84 |
|
$_more['HTML:bug_body'] = $_bug_body; |
|
|
85 |
|
$repo_bug_more['HTML:bug_body'] = $_bug_body; |
85 |
86 |
?> |
?> |
File inc/user/repo/bug/show/show.php renamed from inc/user/repo/bug/show.php (similarity 52%) (mode: 100644) (index 18b1972..7d06a6e) |
1 |
1 |
<?php |
<?php |
2 |
2 |
rg_log("/inc/user/repo/bug/show"); |
rg_log("/inc/user/repo/bug/show"); |
3 |
3 |
|
|
|
4 |
|
$repo_bug_show_more = $repo_bug_more; |
4 |
5 |
$_bug_show = ""; |
$_bug_show = ""; |
5 |
6 |
|
|
6 |
|
$_my_more = $_more; |
|
7 |
|
$_my_more['bug_id'] = $bug_id; |
|
|
7 |
|
$repo_bug_show_more['bug_id'] = $bug_id; |
8 |
8 |
|
|
9 |
9 |
$ibug = rg_bug_info($db, $ri['repo_id'], $bug_id); |
$ibug = rg_bug_info($db, $ri['repo_id'], $bug_id); |
10 |
10 |
if ($ibug === FALSE) |
if ($ibug === FALSE) |
11 |
11 |
rg_fatal("Cannot lookup bug!"); |
rg_fatal("Cannot lookup bug!"); |
12 |
12 |
if ($ibug['exists'] != 1) { |
if ($ibug['exists'] != 1) { |
13 |
|
$_bug_body .= rg_template("repo/bug/not_found.html", $_my_more); |
|
|
13 |
|
$_bug_body .= rg_template("repo/bug/not_found.html", $repo_bug_show_more); |
14 |
14 |
return; |
return; |
15 |
15 |
} |
} |
16 |
16 |
|
|
17 |
|
$_my_more = array_merge($_my_more, $ibug); |
|
|
17 |
|
$repo_bug_show_more = array_merge($repo_bug_show_more, $ibug); |
18 |
18 |
|
|
19 |
19 |
// insert? |
// insert? |
20 |
20 |
$doit = rg_var_uint("doit"); |
$doit = rg_var_uint("doit"); |
21 |
21 |
$note_errmsg = array(); |
$note_errmsg = array(); |
22 |
22 |
if ($doit == 0) { |
if ($doit == 0) { |
23 |
23 |
// default values |
// default values |
24 |
|
$_my_more['note'] = ""; |
|
|
24 |
|
$repo_bug_show_more['note'] = ""; |
25 |
25 |
} else { |
} else { |
26 |
26 |
do { |
do { |
27 |
27 |
$token = rg_var_str("token"); |
$token = rg_var_str("token"); |
|
... |
... |
if ($doit == 0) { |
47 |
47 |
} |
} |
48 |
48 |
|
|
49 |
49 |
// prepare form for other note |
// prepare form for other note |
50 |
|
$_my_more['note'] = ""; |
|
|
50 |
|
$repo_bug_show_more['note'] = ""; |
51 |
51 |
} while (0); |
} while (0); |
52 |
52 |
} |
} |
53 |
53 |
|
|
54 |
54 |
// load labels |
// load labels |
55 |
55 |
$labels = rg_bug_label_get($db, $ri['repo_id'], $bug_id); |
$labels = rg_bug_label_get($db, $ri['repo_id'], $bug_id); |
56 |
56 |
if ($labels === FALSE) |
if ($labels === FALSE) |
57 |
|
$_my_more['HTML:labels'] = "Cannot load labels!"; |
|
|
57 |
|
$repo_bug_show_more['HTML:labels'] = "Cannot load labels!"; |
58 |
58 |
else |
else |
59 |
|
$_my_more['HTML:labels'] = rg_bug_label_html($db, $ri['repo_id'], $bug_id); |
|
|
59 |
|
$repo_bug_show_more['HTML:labels'] = rg_bug_label_html($db, $ri['repo_id'], $bug_id); |
60 |
60 |
|
|
61 |
61 |
// load notes |
// load notes |
62 |
62 |
$notes = rg_bug_note_list($db, $ri['repo_id'], $bug_id, 0); |
$notes = rg_bug_note_list($db, $ri['repo_id'], $bug_id, 0); |
63 |
63 |
if ($notes === FALSE) |
if ($notes === FALSE) |
64 |
|
$_my_more['HTML:notes'] = "Cannot load notes!"; |
|
|
64 |
|
$repo_bug_show_more['HTML:notes'] = "Cannot load notes!"; |
65 |
65 |
else |
else |
66 |
|
$_my_more['HTML:notes'] = rg_template_table("repo/bug/list_note", $notes, $_my_more); |
|
|
66 |
|
$repo_bug_show_more['HTML:notes'] = rg_template_table("repo/bug/list_note", $notes, $repo_bug_show_more); |
67 |
67 |
|
|
68 |
68 |
// add note form |
// add note form |
69 |
|
$_my_more['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg); |
|
|
69 |
|
$repo_bug_show_more['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg); |
70 |
70 |
|
|
71 |
|
$_my_more['rg_action'] = rg_re_post($cop); |
|
72 |
|
$_my_more['rg_form_token'] = rg_token_get($db, $sid); |
|
73 |
|
$_my_more['HTML:note_add'] = rg_template("repo/bug/note_add.html", $_my_more); |
|
|
71 |
|
$repo_bug_show_more['rg_action'] = rg_re_post($cop); |
|
72 |
|
$repo_bug_show_more['rg_form_token'] = rg_token_get($db, $sid); |
|
73 |
|
$repo_bug_show_more['HTML:note_add'] = rg_template("repo/bug/note_add.html", $repo_bug_show_more); |
74 |
74 |
|
|
75 |
|
$_bug_show .= rg_template("repo/bug/show.html", $_my_more); |
|
|
75 |
|
$_bug_show .= rg_template("repo/bug/show.html", $repo_bug_show_more); |
76 |
76 |
?> |
?> |