637cd93429e340caaceacb72ba620a411e8c5b2d
bernd First draft of gitolite-mod...

bernd authored 12 years ago

1) <?php
2) require_role(ROLE_SYSTEMUSER);
3) 
4) include('git.php');
5) 
6) if ($_GET['action'] == 'newuser') {
bernd Fürs erste feature-complete

bernd authored 12 years ago

7)   check_form_token('git_newkey');
bernd First draft of gitolite-mod...

bernd authored 12 years ago

8)   $handle = $_POST['handle'];
9)   if ($handle == '') {
10)     system_failure("Leere Benutzerbezeichnung!");
11)   }
12)   $users = list_users();
13)   if (in_array($handle, $users)) {
14)     system_failure("Ein Benutzer mit diesem Namen existiert bereits.");
15)   }
16)   newkey($_POST['pubkey'], $handle);
17)   if (! $debugmode)
18)     header('Location: git');
19)   die();
20) } elseif ($_GET['action'] == 'newkey') {
bernd Fürs erste feature-complete

bernd authored 12 years ago

21)   check_form_token('git_newkey');
bernd First draft of gitolite-mod...

bernd authored 12 years ago

22)   $handle = $_POST['handle'];
23)   if ($handle == '') {
24)     system_failure("Leere Benutzerbezeichnung!");
25)   }
26)   newkey($_POST['pubkey'], $handle);
27)   if (! $debugmode)
28)     header('Location: git');
29)   die();
bernd Fürs erste feature-complete

bernd authored 12 years ago

30) } elseif ($_GET['action'] == 'newrepo' || $_GET['action'] == 'editrepo') {
31)   check_form_token('git_edit');
32)   $permissions = array();
33)   $users = list_users();
34)   foreach ($users as $u) {  
35)     if (isset($_POST[$u])) {
36)       switch ($_POST[$u]) {
37)         case 'rwplus': $permissions[$u] = 'RW+';
38)           break;
39)         case 'rw': $permissions[$u] = 'RW';
40)           break;
41)         case 'r': $permissions[$u] = 'R';
42)           break;
43)       }
44)     }
45)   }
46)   save_repo($_POST['repo'], $permissions);
47)   if (! $debugmode)
48)     header('Location: git');
49)   die();
50)