Bessere Handhabung öffentlich abrufbarer Repositories
bernd

bernd commited on 2011-12-21 16:51:53
Zeige 3 geänderte Dateien mit 25 Einfügungen und 4 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@2095 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -11,6 +11,15 @@ $users = list_users();
11 11
 $action = '';
12 12
 $form = '';
13 13
 
14
+html_header("<script type=\"text/javascript\">
15
+  function showDescription( ) {
16
+    var do_it = (document.getElementById('gitweb').checked == false);
17
+    var inputfield = document.getElementById('description');
18
+    inputfield.disabled = do_it;
19
+    }
20
+</script>
21
+");
22
+
14 23
 if (isset($_GET['repo']) && isset($repos[$_GET['repo']])) {
15 24
   $action = 'editrepo';
16 25
   title("Zugriff auf GIT-Repository ändern");
... ...
@@ -43,8 +52,9 @@ foreach ($users as $user) {
43 52
 }
44 53
 $checked = (isset($_GET['repo']) && isset($repos[$_GET['repo']]) && isset($repos[$_GET['repo']]['users']['gitweb']) && $repos[$_GET['repo']]['users']['gitweb'] == 'R') ? ' checked="checked"' : '';
45 54
 $description = (isset($_GET['repo']) && isset($repos[$_GET['repo']])) ? $repos[$_GET['repo']]['description'] : '';
46
-$form .= '<p><input type="checkbox" name="gitweb" id="gitweb" value="r"'.$checked.' /> <label for="gitweb">Öffentlicher Lesezugriff via gitweb</label><br />
47
-<label for="description">Beschreibung des Repository:</label> <input type="text" name="description" id="description" value="'.$description.'" /></p>';
55
+$disabled = $checked ? '' : ' disabled="disabled"';
56
+$form .= '<p><input type="checkbox" name="gitweb" id="gitweb" value="r"'.$checked.' onclick="showDescription()" /> <label for="gitweb">Öffentlicher Lesezugriff via gitweb</label><br />
57
+<label for="description">Beschreibung des Repository:</label> <input type="text" name="description" id="description" value="'.$description.'"'.$disabled.' /></p>';
48 58
 $form .= '</td></tr></table>';
49 59
 $form .= '<p><input type="submit" value="Speichern" /></p>';
50 60
 
... ...
@@ -21,8 +21,17 @@ if (count($repos) == 0) {
21 21
 foreach ($repos as $repo => $settings) {
22 22
   $description = $settings['description'] ? '<br /><em>"'.$settings['description'].'"</em>' : '';
23 23
   $url = get_git_url($repo);
24
-  output("<div><p><strong>{$repo}</strong> ".internal_link('edit', icon_edit('Zugriffsrechte bearbeiten'), 'repo='.$repo)." ".internal_link('delete', icon_delete('Repository löschen'), 'repo='.$repo)."{$description}<br />{$url}</p><ul>");
24
+  $public = isset($settings['users']['gitweb']) && $settings['users']['gitweb'] == 'R';
25
+  $public_string = '';
26
+  if ($public) {
27
+    $public_url = 'http://git.schokokeks.org/'.$repo.'.git';
28
+    $public_string = '(Öffentlich abrufbar über <a href="'.$public_url.'">'.$public_url.'</a>)';
29
+  }
30
+  output("<div><p><strong>{$repo}</strong> ".internal_link('edit', icon_edit('Zugriffsrechte bearbeiten'), 'repo='.$repo)." ".internal_link('delete', icon_delete('Repository löschen'), 'repo='.$repo)."{$description}<br />{$url} {$public_string}</p><ul>");
25 31
   foreach ($settings['users'] as $user => $rights) {
32
+    if ($user == 'gitweb') {
33
+      continue;
34
+    }
26 35
     $grant = '';
27 36
     switch ($rights) {
28 37
       case 'R': $grant = 'Lesezugriff';
... ...
@@ -45,8 +45,10 @@ if ($_GET['action'] == 'newuser') {
45 45
   }
46 46
   if ($_POST['gitweb'] == 'r') {
47 47
     $permissions['gitweb'] = 'R';
48
-  }
49 48
     $description = $_POST['description'];
49
+  } else {
50
+    $description = NULL;
51
+  }
50 52
   save_repo($_POST['repo'], $permissions, $description);
51 53
   if (! $debugmode)
52 54
     header('Location: git');
53 55