Skip to content

Commit e6165c4

Browse files
committed
Merge branch 'master' of github.com:dandart/projectchaplin
Conflicts: composer.lock
2 parents fee59b5 + 363865f commit e6165c4

28 files changed

+1489
-201
lines changed

application/Bootstrap.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,6 @@ protected function _initRoutes()
152152
protected function _initSession()
153153
{
154154
$configSessions = Chaplin_Config_Sessions::getInstance();
155-
$configServers = Chaplin_Config_Servers::getInstance();
156-
if ($configServers->getRedisSettings()) {
157-
$strRegistryKey = $configServers->getRedisSettings()->registrykey;
158-
$intTimeout = (int)$configServers->getRedisSettings()->timeout;
159-
$arrServers = $configServers->getRedisSettings()->servers->toArray();
160-
$redis = new Redis();
161-
$strHost = $arrServers[0]['host'];
162-
$strPort = $arrServers[0]['port'];
163-
$redis->connect($strHost, $strPort, $intTimeout);
164-
Zend_Registry::set($strRegistryKey, $redis);
165-
}
166155
if (!is_null($configSessions->getSaveHandler())) {
167156
Zend_Session::setSaveHandler($configSessions->getSaveHandler());
168157
}

application/modules/admin/Bootstrap.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,21 @@ protected function _initModuleAutoloader()
3535
protected function _initAcl()
3636
{
3737
$acl = Zend_Registry::get('acl');
38-
{
39-
$acl->add(new Zend_Acl_Resource('admin/events'));
40-
$acl->add(new Zend_Acl_Resource('admin/import'));
41-
$acl->add(new Zend_Acl_Resource('admin/node'));
42-
$acl->add(new Zend_Acl_Resource('admin/nodestatus'));
43-
$acl->add(new Zend_Acl_Resource('admin/error'));
44-
$acl->add(new Zend_Acl_Resource('admin/user'));
45-
46-
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_MINION, 'admin/events');
47-
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/import');
48-
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/node');
49-
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GUEST, 'admin/nodestatus');
50-
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/error');
51-
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/user');
52-
}
38+
39+
$acl->add(new Zend_Acl_Resource('admin/events'));
40+
$acl->add(new Zend_Acl_Resource('admin/import'));
41+
$acl->add(new Zend_Acl_Resource('admin/node'));
42+
$acl->add(new Zend_Acl_Resource('admin/nodestatus'));
43+
$acl->add(new Zend_Acl_Resource('admin/error'));
44+
$acl->add(new Zend_Acl_Resource('admin/user'));
45+
$acl->add(new Zend_Acl_Resource('admin/setup'));
46+
47+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GUEST, 'admin/setup');
48+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_MINION, 'admin/events');
49+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/import');
50+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/node');
51+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GUEST, 'admin/nodestatus');
52+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/error');
53+
$acl->allow(Chaplin_Model_User_Helper_UserType::TYPE_GOD, 'admin/user');
5354
}
5455
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
/**
3+
* This file is part of Project Chaplin.
4+
*
5+
* Project Chaplin is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Project Chaplin is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with Project Chaplin. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* @package Project Chaplin
19+
* @author Dan Dart
20+
* @copyright 2012-2013 Project Chaplin
21+
* @license http://www.gnu.org/licenses/agpl-3.0.html GNU AGPL 3.0
22+
* @version git
23+
* @link https://github.com/dandart/projectchaplin
24+
**/
25+
class Admin_SetupController extends Zend_Controller_Action
26+
{
27+
public function init()
28+
{
29+
parent::init();
30+
if (file_exists(APPLICATION_PATH.'/../config/chaplin.ini')) {
31+
return $this->_redirect('/');
32+
}
33+
$this->_helper->_layout->setLayout('plain');
34+
}
35+
36+
public function indexAction()
37+
{
38+
39+
}
40+
41+
public function sqltestAction()
42+
{
43+
$arrPost = $this->_request->getPost();
44+
$strAdapter = isset($arrPost['adapter'])?$arrPost['adapter']:null;
45+
$arrParams = isset($arrPost['params'])?$arrPost['params']:array();
46+
47+
$this->_helper->layout()->disableLayout();
48+
$this->_helper->viewRenderer->setNoRender(true);
49+
50+
try {
51+
$adapter = Zend_Db::factory($strAdapter, $arrParams);
52+
// Make sure we get a PDO instance that tries to connect
53+
$adapter->prepare('SELECT');
54+
echo 'DB Connect Success!';
55+
} catch (Exception $e) {
56+
echo 'DB Connect failed! Reason: '.$e->getMessage();
57+
}
58+
}
59+
60+
public function amqptestAction()
61+
{
62+
$this->_helper->layout()->disableLayout();
63+
$this->_helper->viewRenderer->setNoRender(true);
64+
65+
try {
66+
$amqp = new Amqp\Connection($this->_request->getPost());
67+
$amqp->connect();
68+
echo 'AMQP connection success!';
69+
} catch (Exception $e) {
70+
echo 'Sorry - the connection failed...';
71+
}
72+
}
73+
74+
public function smtptestAction()
75+
{
76+
$this->_helper->layout()->disableLayout();
77+
$this->_helper->viewRenderer->setNoRender(true);
78+
$arrSmtp = $this->_request->getPost();
79+
$transport = new Zend_Mail_Transport_Smtp(
80+
$arrSmtp['host'],
81+
$arrSmtp['options']
82+
);
83+
84+
// No SMTP tests exist atm
85+
}
86+
87+
public function writeAction()
88+
{
89+
$this->_helper->layout()->disableLayout();
90+
$this->_helper->viewRenderer->setNoRender(true);
91+
$arrPost = array(
92+
'default' => $this->_request->getPost(),
93+
'production' => array(),
94+
'staging' => array(),
95+
'development' => array()
96+
);
97+
98+
$schemaSql = file_get_contents(APPLICATION_PATH . '/../sql/schema.sql');
99+
100+
$arrDefault = $arrPost['default'];
101+
102+
if (!isset($arrDefault['sql'])) {
103+
echo 'No SQL settings exist.';
104+
exit;
105+
}
106+
107+
$arrSql = $arrDefault['sql'];
108+
109+
$strAdapter = isset($arrSql['adapter'])?$arrSql['adapter']:null;
110+
if (is_null($strAdapter)) {
111+
echo 'Did you forget to choose an adapter?';
112+
exit;
113+
}
114+
$arrParams = isset($arrSql['params'])?$arrSql['params']:array();
115+
116+
try {
117+
$adapter = Zend_Db::factory($strAdapter, $arrParams);
118+
$adapter->getConnection()->exec($schemaSql);
119+
} catch (Exception $e) {
120+
echo 'Error writing DB. Please refresh and try again.';
121+
exit();
122+
}
123+
124+
$config = new Zend_Config($arrPost, true);
125+
$config->setExtend('production', 'default');
126+
$config->setExtend('staging', 'production');
127+
$config->setExtend('development', 'production');
128+
129+
$iniWriter = new Zend_Config_Writer_Ini();
130+
$iniWriter->setConfig($config);
131+
try {
132+
$iniWriter->write(APPLICATION_PATH.'/../config/chaplin.ini');
133+
echo 'File successfully written.';
134+
} catch (Exception $e) {
135+
echo '; Could not write file. Please copy and insert the following into the file /config/chaplin.ini'.PHP_EOL;
136+
echo $iniWriter->render();
137+
}
138+
}
139+
}

0 commit comments

Comments
 (0)