}
 }
 if (!errors()) {
     $prj = project_get_by_id($id_prj);
     if (!$prj) {
         sql_do('ROLLBACK');
         append_error('Unable to retrieve the created project, please contact the administrator.');
     }
 }
 // on place un admin/owner
 if (!errors()) {
     $prj->add_admin($me->get_id_user(), 1);
 }
 // on crée une branche ...
 if (!errors()) {
     $id_branch = branch_new('main', $prj->get_id_prj());
     if (!$id_branch) {
         sql_do('ROLLBACK');
         append_error('Unable to create the default branch, please contact the administrator.');
     }
 }
 // ... par défaut
 if (!errors()) {
     $prj->set_default_branch($id_branch);
     $prj->write();
 }
 if (!errors()) {
     sql_do('COMMIT');
     http_redir('/project/view.php?id_prj=' . $id_prj);
 } else {
     sql_do('ROLLBACK');
Example #2
0
    append_error_exit('You must be logged to add a new branch.');
}
$id_prj = empty($_GET['id_prj']) ? 0 : $_GET['id_prj'];
if (!$id_prj) {
    append_error_exit('You have to specify a project.');
}
$prj = project_get_by_id($id_prj);
if (!$prj) {
    append_error_exit('Invalid project number #' . $id_prj . '.');
}
if (!$prj->is_admin($me->get_id_user())) {
    append_error_exit('Sorry, you are not an admin for this project.');
}
// ADDING A BRANCH
if (!empty($_GET['name_branch'])) {
    $id_branch = branch_new($_GET['name_branch'], $prj->get_id_prj());
    $branch = branch_get_by_id($id_branch);
    if (!$branch) {
        append_error('Unable to create a new branch');
    }
    if (!errors()) {
        http_redir('/project/view.php?id_branch=' . $branch->get_id_branch());
    }
}
?>



<?php 
// OUTPUT
header_box("Igoan :: Adding a new branch to a project");