Example #1
0
function create_project(&$response)
{
    $Name = $_REQUEST['project']['Name'];
    // Remove any potentially problematic characters.
    $Name = preg_replace("/[^a-zA-Z0-9\\s+-._]/", '', $Name);
    // Make sure that a project with this name does not already exist.
    $Project = new Project();
    if ($Project->ExistsByName($Name)) {
        $response['error'] = "Project '{$Name}' already exists.";
        http_response_code(400);
        return;
    }
    // Create the project.
    $Project->Name = $Name;
    populate_project($Project);
    $Project->InitialSetup();
    // Add the current user to this project.
    global $userid;
    if ($userid != 1) {
        // Global admin is already added, so no need to do it again.
        $User->Id = $userid;
        $UserProject = new UserProject();
        $UserProject->ProjectId = $Project->Id;
        $UserProject->Role = 2;
        $UserProject->EmailType = 3;
        // receive all emails
        $User->AddProject($UserProject);
    }
    $response['projectcreated'] = 1;
    $response['project'] = $Project->ConvertToJSON();
    http_response_code(200);
}
Example #2
0
 function stripHTTP($url)
 {
     $pos = strpos($url, "http://");
     if ($pos !== FALSE) {
         return substr($url, 7);
     }
     return $url;
 }
 // If we should create the tables
 @($Submit = $_POST["Submit"]);
 if ($Submit) {
     // Remove any slashes, etc...
     $Name = stripslashes_if_gpc_magic_quotes($_POST["name"]);
     $Name = preg_replace("/[^a-zA-Z0-9\\s+-._]/", "", $Name);
     // Check that the name are different
     if (!$Project->ExistsByName($Name)) {
         $Project->Name = $Name;
         $Project->Description = stripslashes_if_gpc_magic_quotes($_POST["description"]);
         $Project->HomeUrl = stripHTTP(stripslashes_if_gpc_magic_quotes($_POST["homeURL"]));
         $Project->CvsUrl = stripHTTP(stripslashes_if_gpc_magic_quotes($_POST["cvsURL"]));
         $Project->BugTrackerUrl = stripslashes_if_gpc_magic_quotes($_POST["bugURL"]);
         $Project->BugTrackerFileUrl = stripslashes_if_gpc_magic_quotes($_POST["bugFileURL"]);
         $Project->DocumentationUrl = stripHTTP(stripslashes_if_gpc_magic_quotes($_POST["docURL"]));
         $Project->TestingDataUrl = stripHTTP(stripslashes_if_gpc_magic_quotes($_POST["testingDataUrl"]));
         @($Public = $_POST["public"]);
         if (!isset($Public)) {
             $Public = 0;
         }
         $Project->CoverageThreshold = stripslashes_if_gpc_magic_quotes($_POST["coverageThreshold"]);
         $Project->NightlyTime = stripslashes_if_gpc_magic_quotes($_POST["nightlyTime"]);
         $Project->GoogleTracker = stripslashes_if_gpc_magic_quotes($_POST["googleTracker"]);