public static function project_new() { $postVars = array(); foreach ($_POST['newProjectContainer'] as $name => $value) { if (isset($value['value'])) { $postVars[$name] = $value['value']; } } // // Check for mandatory attributes // if (!isset($postVars['title']) || empty($postVars['title']) || !isset($postVars['scmConnectorType']) || empty($postVars['scmConnectorType']) || !isset($postVars['scmRemoteRepository']) || empty($postVars['scmRemoteRepository'])) { // // TODO: Error notification!!! // SystemEvent::raise(SystemEvent::DEBUG, "Project creation failed, required attributes were empty.", __METHOD__); echo json_encode(array('success' => false, 'error' => 'Missing required attributes. Make sure all attributes not marked as optional are filled.')); exit; } else { $GLOBALS['project'] = null; $project = new Project(); $project->setTitle($postVars['title']); $project->setReleaseLabel($postVars['releaseLabel']); $project->setScmConnectorType($postVars['scmConnectorType']); $project->setScmRemoteRepository($postVars['scmRemoteRepository']); $project->setScmUsername($postVars['scmUsername']); $project->setScmPassword($postVars['scmPassword']); $project->addToUsers($GLOBALS['user'], Access::OWNER); if (!$project->init()) { SystemEvent::raise(SystemEvent::ERROR, "Could not initialize project. Try again later.", __METHOD__); echo json_encode(array('success' => false, 'error' => 'The project was created but could not be initialized. Please check the logs and/or try the first build manually.')); exit; } $GLOBALS['project'] = $project; $GLOBALS['project']->log("Project created.", $GLOBALS['user']->getUsername()); echo json_encode(array('success' => true, 'error' => 'Project successfully created, taking you back to your dashboard. Stand by...')); exit; } }