modules/gitolite/save.php
97b6f432
 <?php
 require_role(ROLE_SYSTEMUSER);
 
57a56c8c
 $section = 'git_git';
97b6f432
 include('git.php');
 
 if ($_GET['action'] == 'newuser') {
637cd934
   check_form_token('git_newkey');
97b6f432
   $handle = $_POST['handle'];
   if ($handle == '') {
     system_failure("Leere Benutzerbezeichnung!");
   }
   $users = list_users();
   if (in_array($handle, $users)) {
     system_failure("Ein Benutzer mit diesem Namen existiert bereits.");
   }
   newkey($_POST['pubkey'], $handle);
   if (! $debugmode)
     header('Location: git');
   die();
 } elseif ($_GET['action'] == 'newkey') {
637cd934
   check_form_token('git_newkey');
97b6f432
   $handle = $_POST['handle'];
   if ($handle == '') {
     system_failure("Leere Benutzerbezeichnung!");
   }
   newkey($_POST['pubkey'], $handle);
   if (! $debugmode)
     header('Location: git');
   die();
637cd934
 } elseif ($_GET['action'] == 'newrepo' || $_GET['action'] == 'editrepo') {
   check_form_token('git_edit');
   $permissions = array();
   $users = list_users();
   foreach ($users as $u) {  
     if (isset($_POST[$u])) {
       switch ($_POST[$u]) {
         case 'rwplus': $permissions[$u] = 'RW+';
           break;
         case 'rw': $permissions[$u] = 'RW';
           break;
         case 'r': $permissions[$u] = 'R';
           break;
       }
     }
   }
18f96a11
   if (isset($_POST['gitweb']) && ($_POST['gitweb'] == 'r')) {
ff794853
     $permissions['gitweb'] = 'R';
57a56c8c
     $permissions['daemon'] = 'R';
b6b0e8e5
     $description = $_POST['description'];
   } else {
     $description = NULL;
ff794853
   }
   save_repo($_POST['repo'], $permissions, $description);
637cd934
   if (! $debugmode)
     header('Location: git');
   die();
   
97b6f432
 }