catching permission error

This commit is contained in:
Jimmy Cleuren 2013-11-18 22:47:44 +01:00
parent 2b9302f9fc
commit 8c127d692c
2 changed files with 17 additions and 3 deletions

View file

@ -53,9 +53,16 @@ class SettingsController extends Controller
$this->settings['phpci']['github']['id'] = $this->getParam('githubid', ''); $this->settings['phpci']['github']['id'] = $this->getParam('githubid', '');
$this->settings['phpci']['github']['secret'] = $this->getParam('githubsecret', ''); $this->settings['phpci']['github']['secret'] = $this->getParam('githubsecret', '');
$this->storeSettings(); $error = $this->storeSettings();
if($error)
{
header('Location: ' . PHPCI_URL . 'settings?saved=2');
}
else
{
header('Location: ' . PHPCI_URL . 'settings?saved=1'); header('Location: ' . PHPCI_URL . 'settings?saved=1');
}
die; die;
} }
@ -94,6 +101,7 @@ class SettingsController extends Controller
$dumper = new Dumper(); $dumper = new Dumper();
$yaml = $dumper->dump($this->settings); $yaml = $dumper->dump($this->settings);
file_put_contents(APPLICATION_PATH . 'PHPCI/config.yml', $yaml); file_put_contents(APPLICATION_PATH . 'PHPCI/config.yml', $yaml);
if(error_get_last()) return error_get_last()['message'];
} }
protected function getGithubForm() protected function getGithubForm()

View file

@ -1,9 +1,15 @@
<?php if (isset($_GET['saved'])): ?> <?php if (isset($_GET['saved']) && $_GET['saved'] == 1): ?>
<p class="alert alert-success" style="margin-bottom: 20px;"> <p class="alert alert-success" style="margin-bottom: 20px;">
Your settings have been saved. Your settings have been saved.
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php if (isset($_GET['saved']) && $_GET['saved'] == 2): ?>
<p class="alert alert-danger" style="margin-bottom: 20px;">
Your settings could not be saved, maybe check the permissions of config.yml?
</p>
<?php endif; ?>
<?php if (isset($_GET['linked']) && $_GET['linked'] == 1): ?> <?php if (isset($_GET['linked']) && $_GET['linked'] == 1): ?>
<p class="alert alert-success" style="margin-bottom: 20px;"> <p class="alert alert-success" style="margin-bottom: 20px;">
Your Github account has been linked. Your Github account has been linked.