Refactoring to support updated b8framework.
This commit is contained in:
parent
aff5b1886e
commit
67386df9ef
20 changed files with 140 additions and 79 deletions
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class BitbucketController extends b8\Controller
|
||||
class BitbucketController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class BuildController extends b8\Controller
|
||||
class BuildController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
|
@ -32,11 +32,8 @@ class BuildController extends b8\Controller
|
|||
public function view($buildId)
|
||||
{
|
||||
$build = $this->_buildStore->getById($buildId);
|
||||
$view = new b8\View('Build');
|
||||
$view->build = $build;
|
||||
$view->data = $this->getBuildData($buildId);
|
||||
|
||||
return $view->render();
|
||||
$this->view->build = $build;
|
||||
$this->view->data = $this->getBuildData($buildId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class BuildStatusController extends b8\Controller
|
||||
class BuildStatusController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class GithubController extends b8\Controller
|
||||
class GithubController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use b8;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class IndexController extends b8\Controller
|
||||
class IndexController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
|
@ -31,11 +31,10 @@ class IndexController extends b8\Controller
|
|||
public function index()
|
||||
{
|
||||
$projects = $this->_projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
|
||||
$view = new b8\View('Index');
|
||||
$view->builds = $this->getLatestBuildsHtml();
|
||||
$view->projects = $projects['items'];
|
||||
$this->view->builds = $this->getLatestBuildsHtml();
|
||||
$this->view->projects = $projects['items'];
|
||||
|
||||
return $view->render();
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
namespace PHPCI\Controller;
|
||||
|
||||
use b8;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Model\Project;
|
||||
use b8;
|
||||
use b8\Controller;
|
||||
use b8\Store;
|
||||
use b8\Form;
|
||||
use b8\Registry;
|
||||
|
||||
|
|
@ -21,12 +23,12 @@ use b8\Registry;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class ProjectController extends b8\Controller
|
||||
class ProjectController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->_buildStore = b8\Store\Factory::getStore('Build');
|
||||
$this->_projectStore = b8\Store\Factory::getStore('Project');
|
||||
$this->_buildStore = Store\Factory::getStore('Build');
|
||||
$this->_projectStore = Store\Factory::getStore('Project');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,13 +40,12 @@ class ProjectController extends b8\Controller
|
|||
$page = $this->getParam('p', 1);
|
||||
$builds = $this->getLatestBuildsHtml($projectId, (($page - 1) * 10));
|
||||
|
||||
$view = new b8\View('Project');
|
||||
$view->builds = $builds[0];
|
||||
$view->total = $builds[1];
|
||||
$view->project = $project;
|
||||
$view->page = $page;
|
||||
$this->view->builds = $builds[0];
|
||||
$this->view->total = $builds[1];
|
||||
$this->view->project = $project;
|
||||
$this->view->page = $page;
|
||||
|
||||
return $view->render();
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +70,7 @@ class ProjectController extends b8\Controller
|
|||
*/
|
||||
public function delete($projectId)
|
||||
{
|
||||
if (!Registry::getInstance()->get('user')->getIsAdmin()) {
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
|
|
@ -107,11 +108,11 @@ class ProjectController extends b8\Controller
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
if (!Registry::getInstance()->get('user')->getIsAdmin()) {
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
$method = Registry::getInstance()->get('requestMethod');
|
||||
$method = $this->request->getMethod();
|
||||
$this->handleGithubResponse();
|
||||
|
||||
if ($method == 'POST') {
|
||||
|
|
@ -199,11 +200,11 @@ class ProjectController extends b8\Controller
|
|||
*/
|
||||
public function edit($projectId)
|
||||
{
|
||||
if (!Registry::getInstance()->get('user')->getIsAdmin()) {
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
$method = Registry::getInstance()->get('requestMethod');
|
||||
$method = $this->request->getMethod();
|
||||
$project = $this->_projectStore->getById($projectId);
|
||||
|
||||
if ($method == 'POST') {
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@ use b8;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class SessionController extends b8\Controller
|
||||
class SessionController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->response->disableLayout();
|
||||
$this->_userStore = b8\Store\Factory::getStore('User');
|
||||
}
|
||||
|
||||
|
|
@ -28,10 +29,10 @@ class SessionController extends b8\Controller
|
|||
* Handles user login (form and processing)
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if (b8\Registry::getInstance()->get('requestMethod') == 'POST') {
|
||||
{
|
||||
if ($this->request->getMethod() == 'POST') {
|
||||
$user = $this->_userStore->getByEmail($this->getParam('email'));
|
||||
|
||||
|
||||
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
||||
$_SESSION['user_id'] = $user->getId();
|
||||
header('Location: ' . PHPCI_URL);
|
||||
|
|
@ -60,9 +61,9 @@ class SessionController extends b8\Controller
|
|||
$pwd->setClass('btn-success');
|
||||
$form->addField($pwd);
|
||||
|
||||
$view = new b8\View('Login');
|
||||
$view->form = $form->render();
|
||||
die($view->render());
|
||||
$this->view->form = $form->render();
|
||||
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use b8\Form;
|
|||
* @package PHPCI
|
||||
* @subpackage Web
|
||||
*/
|
||||
class UserController extends b8\Controller
|
||||
class UserController extends \PHPCI\Controller
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
|
@ -33,10 +33,9 @@ class UserController extends b8\Controller
|
|||
public function index()
|
||||
{
|
||||
$users = $this->_userStore->getWhere(array(), 1000, 0, array(), array('email' => 'ASC'));
|
||||
$view = new b8\View('User');
|
||||
$view->users = $users;
|
||||
$this->view->users = $users;
|
||||
|
||||
return $view->render();
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -44,11 +43,11 @@ class UserController extends b8\Controller
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
if (!Registry::getInstance()->get('user')->getIsAdmin()) {
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
$method = Registry::getInstance()->get('requestMethod');
|
||||
$method = $this->request->getMethod();
|
||||
|
||||
if ($method == 'POST') {
|
||||
$values = $this->getParams();
|
||||
|
|
@ -85,11 +84,11 @@ class UserController extends b8\Controller
|
|||
*/
|
||||
public function edit($userId)
|
||||
{
|
||||
if (!Registry::getInstance()->get('user')->getIsAdmin()) {
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
$method = Registry::getInstance()->get('requestMethod');
|
||||
$method = $this->request->getMethod();
|
||||
$user = $this->_userStore->getById($userId);
|
||||
|
||||
if ($method == 'POST') {
|
||||
|
|
@ -172,7 +171,7 @@ class UserController extends b8\Controller
|
|||
*/
|
||||
public function delete($userId)
|
||||
{
|
||||
if (!Registry::getInstance()->get('user')->getIsAdmin()) {
|
||||
if (!$_SESSION['user']->getIsAdmin()) {
|
||||
throw new \Exception('You do not have permission to do that.');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue