c208bd906b3991555db11b9229846c4601ca408c
bernd First draft of gitolite-mod...

bernd authored 13 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
5) Written 2008-2012 by schokokeks.org Hosting, namely
6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
16) 
bernd First draft of gitolite-mod...

bernd authored 13 years ago

17) require_role(ROLE_SYSTEMUSER);
18) 
19) include("git.php");
20) 
21) $section = 'git_git';
22) 
bernd Fürs erste feature-complete

bernd authored 13 years ago

23) $repos = list_repos();
24) $users = list_users();
bernd First draft of gitolite-mod...

bernd authored 13 years ago

25) 
bernd Fürs erste feature-complete

bernd authored 13 years ago

26) $action = '';
27) $form = '';
28) 
bernd Bessere Handhabung öffentli...

bernd authored 13 years ago

29) html_header("<script type=\"text/javascript\">
30)   function showDescription( ) {
31)     var do_it = (document.getElementById('gitweb').checked == false);
32)     var inputfield = document.getElementById('description');
33)     inputfield.disabled = do_it;
34)     }
35) </script>
36) ");
37) 
bernd Fürs erste feature-complete

bernd authored 13 years ago

38) if (isset($_GET['repo']) && isset($repos[$_GET['repo']])) {
39)   $action = 'editrepo';
40)   title("Zugriff auf GIT-Repository ändern");
41)   output("<p>Legen Sie hier fest, welche Berechtigungen für welche SSH-Keys gelten sollen.</p>");
42)   $form .= '<table><tr><td>Name des Repository</td><td><input type="hidden" name="repo" value="'.filter_input_general($_GET['repo']).'" />'.filter_input_general($_GET['repo']).'</td></tr>';
43) } else {
44)   $action = 'newrepo';
45)   title("Neues GIT-Repository anlegen");
46)   output("<p>Geben Sie einen Namen für das neue Repository an und legen Sie fest, welche Berechtigungen für welche SSH-Keys gelten sollen.</p>");
47)   $form .= '<table><tr><td><label for="repo">Name des Repository</label></td><td><input type="text" id="repo" name="repo" /></td></tr>';
48) }
49) 
50) $form .= '<tr><td>Berechtigungen</td><td>';
51) foreach ($users as $user) {
52)   $r = $rw = $rwplus = '';
53)   if (isset($_GET['repo']) && isset($repos[$_GET['repo']])) {
bernd Setze Berechtigung für gitw...

bernd authored 13 years ago

54)     $permissions = $repos[$_GET['repo']]['users'];
55)     if (isset($permissions[$user])) {
56)       switch ($permissions[$user]) {
bernd Fürs erste feature-complete

bernd authored 13 years ago

57)         case 'RW+': $rwplus = ' selected="selected"';
58)                     break;
59)         case 'RW': $rw = ' selected="selected"';
60)                    break;
61)         case 'R': $r = ' selected="selected"';
62)                   break;
63)       }
64)     }
65)   }
bernd Setze Berechtigung für gitw...

bernd authored 13 years ago

66)   $form .= '<p>'.$user.': <select name="'.$user.'"><option value="-">Zugriff verweigern</option><option value="r"'.$r.'>Lesezugriff erlauben</option><option value="rw"'.$rw.'>Lese- und Schreibzugriff</option><option value="rwplus"'.$rwplus.'>erweiterter Lese- und Schreibzugriff (inkl. &quot;rewind&quot;)</option></select></p>';
bernd Fürs erste feature-complete

bernd authored 13 years ago

67) }
bernd Setze Berechtigung für gitw...

bernd authored 13 years ago

68) $checked = (isset($_GET['repo']) && isset($repos[$_GET['repo']]) && isset($repos[$_GET['repo']]['users']['gitweb']) && $repos[$_GET['repo']]['users']['gitweb'] == 'R') ? ' checked="checked"' : '';
69) $description = (isset($_GET['repo']) && isset($repos[$_GET['repo']])) ? $repos[$_GET['repo']]['description'] : '';
bernd Bessere Handhabung öffentli...

bernd authored 13 years ago

70) $disabled = $checked ? '' : ' disabled="disabled"';
71) $form .= '<p><input type="checkbox" name="gitweb" id="gitweb" value="r"'.$checked.' onclick="showDescription()" /> <label for="gitweb">Öffentlicher Lesezugriff via gitweb</label><br />
72) <label for="description">Beschreibung des Repository:</label> <input type="text" name="description" id="description" value="'.$description.'"'.$disabled.' /></p>';
bernd Fürs erste feature-complete

bernd authored 13 years ago

73) $form .= '</td></tr></table>';
74) $form .= '<p><input type="submit" value="Speichern" /></p>';
75) 
76) output(html_form('git_edit', 'save', 'action='.$action, $form));