Various bits of cleanup, should hopefully fix the build

This commit is contained in:
Dan Cryer 2014-07-11 14:29:27 +00:00
parent 52f45a38bf
commit 8b0261417a
4 changed files with 40 additions and 53 deletions

View file

@ -71,4 +71,11 @@ class Controller extends \b8\Controller
return $this->response;
}
protected function requireAdmin()
{
if (!$_SESSION['user']->getIsAdmin()) {
throw new ForbiddenException('You do not have permission to do that.');
}
}
}

View file

@ -152,10 +152,7 @@ class ProjectController extends \PHPCI\Controller
public function add()
{
$this->config->set('page_title', 'Add Project');
if (!$_SESSION['user']->getIsAdmin()) {
throw new ForbiddenException('You do not have permission to do that.');
}
$this->requireAdmin();
$method = $this->request->getMethod();
@ -181,8 +178,13 @@ class ProjectController extends \PHPCI\Controller
$view->key = $pub;
return $view->render();
} else {
return $this->addProject($form);
}
}
protected function addProject(Form $form)
{
$values = $form->getValues();
$matches = array();
@ -291,69 +293,48 @@ class ProjectController extends \PHPCI\Controller
'hg' => 'Mercurial',
);
$field = new Form\Element\Select('type');
$field->setRequired(true);
$field = Form\Element\Select::create('type', 'Where is your project hosted?', true);
$field->setPattern('^(github|bitbucket|gitlab|remote|local|hg)');
$field->setOptions($options);
$field->setLabel('Where is your project hosted?');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field->setClass('form-control')->setContainerClass('form-group');
$form->addField($field);
$container = new Form\ControlGroup('github-container');
$container->setClass('github-container');
$field = new Form\Element\Select('github');
$field->setLabel('Choose a Github repository:');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field = Form\Element\Select::create('github', 'Choose a Github repository:', false);
$field->setClass('form-control')->setContainerClass('form-group');
$container->addField($field);
$form->addField($container);
$field = new Form\Element\Text('reference');
$field->setRequired(true);
$field = Form\Element\Text::create('reference', 'Repository Name / URL (Remote) or Path (Local)', true);
$field->setValidator($this->getReferenceValidator($values));
$field->setLabel('Repository Name / URL (Remote) or Path (Local)');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field->setClass('form-control')->setContainerClass('form-group');
$form->addField($field);
$field = new Form\Element\Text('branch');
$field->setRequired(true);
$field->setValidator($this->getReferenceValidator($values));
$field->setLabel('Branch name');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field = Form\Element\Text::create('title', 'Project Title', true);
$field->setClass('form-control')->setContainerClass('form-group');
$form->addField($field);
$field = new Form\Element\Text('title');
$field->setRequired(true);
$field->setLabel('Project Title');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$form->addField($field);
$field = new Form\Element\TextArea('key');
$field->setRequired(false);
$field->setLabel('Private key to use to access repository (leave blank for local and/or anonymous remotes)');
$field->setClass('form-control');
$field->setContainerClass('form-group');
$title = 'Private key to use to access repository (leave blank for local and/or anonymous remotes)';
$field = Form\Element\TextArea::create('key', $title, false);
$field->setClass('form-control')->setContainerClass('form-group');
$field->setRows(6);
$form->addField($field);
$field = new Form\Element\TextArea('build_config');
$field->setRequired(false);
$label = 'PHPCI build config for this project (if you cannot add a phpci.yml file in the project repository)';
$field->setLabel($label);
$field->setClass('form-control');
$field->setContainerClass('form-group');
$field = Form\Element\TextArea::create('build_config', $label, false);
$field->setClass('form-control')->setContainerClass('form-group');
$field->setRows(6);
$form->addField($field);
$field = new Form\Element\Checkbox('allow_public_status');
$field->setRequired(false);
$field->setLabel('Enable public status page and image for this project?');
$field = Form\Element\Text::create('branch', 'Default branch name', true);
$field->setValidator($this->getReferenceValidator($values));
$field->setClass('form-control')->setContainerClass('form-group')->setValue('master');
$form->addField($field);
$label = 'Enable public status page and image for this project?';
$field = Form\Element\Checkbox::create('allow_public_status', $label, false);
$field->setContainerClass('form-group');
$field->setCheckedValue(1);
$field->setValue(1);

View file

@ -37,7 +37,7 @@ class Github
$http = new HttpClient('https://api.github.com');
$res = $http->get($url, $params);
foreach ($res['body'] as $key => $item) {
foreach ($res['body'] as $item) {
$results[] = $item;

13
composer.lock generated
View file

@ -1,23 +1,22 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "6f9eb9a5f893e600062aa7810ed06257",
"packages": [
{
"name": "block8/b8framework",
"version": "1.1.5",
"version": "1.1.7",
"source": {
"type": "git",
"url": "https://github.com/Block8/b8framework.git",
"reference": "2ae699b8b6a28752e9eebbd43c518fdc80a9d322"
"reference": "27c435a7cec78257851d860fa320e1973b164992"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Block8/b8framework/zipball/2ae699b8b6a28752e9eebbd43c518fdc80a9d322",
"reference": "2ae699b8b6a28752e9eebbd43c518fdc80a9d322",
"url": "https://api.github.com/repos/Block8/b8framework/zipball/27c435a7cec78257851d860fa320e1973b164992",
"reference": "27c435a7cec78257851d860fa320e1973b164992",
"shasum": ""
},
"require": {
@ -51,7 +50,7 @@
"mvc",
"php"
],
"time": "2014-05-13 09:41:11"
"time": "2014-07-11 14:24:08"
},
{
"name": "ircmaxell/password-compat",