Working on self host setup page

This commit is contained in:
Hillel Coren 2014-12-01 21:43:59 +02:00
parent e0aad0e248
commit 6b519f6833
4 changed files with 62 additions and 31 deletions

View File

@ -872,7 +872,14 @@ class AccountController extends \BaseController {
$user->registered = true;
$user->amend();
if (Utils::isNinja())
{
$this->userMailer->sendConfirmation($user);
}
else
{
//$this->accountRepo->registerUser($user);
}
$activities = Activity::scope()->get();
foreach ($activities as $activity)

View File

@ -42,7 +42,7 @@ class AppController extends BaseController {
$database = Input::get('database');
$dbType = $database['default'];
$database[$dbType] = $database['type'];
unset($database['type']);
//unset($database['type']);
$mail = Input::get('mail');
$email = $mail['username'];
@ -64,6 +64,11 @@ class AppController extends BaseController {
return Redirect::to('/setup')->withInput();
}
$content = "<?php return 'production';";
$fp = fopen(base_path() . "/bootstrap/environment.php" , 'w');
fwrite($fp, $content);
fclose($fp);
$configDir = app_path() . '/config/production';
if (!file_exists($configDir))
{
@ -94,7 +99,7 @@ class AppController extends BaseController {
$user->amend();
//Auth::login($user, true);
//self::register($user);
//$this->accountRepo->registerUser($user);
return Redirect::to('/invoices/create');
}
@ -150,27 +155,6 @@ class AppController extends BaseController {
}
}
private function register($user)
{
$url = NINJA_APP_URL . '/signup/register';
$data = '';
$fields = [
'first_name' => urlencode($user->first_name),
'last_name' => urlencode($user->last_name),
'email' => urlencode($user->email)
];
foreach($fields as $key=>$value) { $data .= $key.'='.$value.'&'; }
rtrim($data, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
}
public function install()
{
if (!Utils::isNinja() && !Utils::isDatabaseSetup()) {

View File

@ -222,4 +222,25 @@ class AccountRepository
return $client;
}
public function registerUser($user)
{
$url = NINJA_APP_URL . '/signup/register';
$data = '';
$fields = [
'first_name' => urlencode($user->first_name),
'last_name' => urlencode($user->last_name),
'email' => urlencode($user->email)
];
foreach($fields as $key=>$value) { $data .= $key.'='.$value.'&'; }
rtrim($data, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
}
}

View File

@ -17,6 +17,8 @@
<div class="jumbotron">
<h2>Invoice Ninja Setup</h2>
If you need help you can either post to our <a href="https://groups.google.com/forum/#!forum/invoiceninja" target="_blank">Google Group</a>
or email us at <a href="mailto:contact@invoiceninja.com" target="_blank">contact@invoiceninja.com</a>.
<p>
<pre>-- Commands to create a MySQL database and user
CREATE SCHEMA `ninja` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
@ -24,11 +26,20 @@ CREATE USER 'ninja'@'localhost' IDENTIFIED BY 'ninja';
GRANT ALL PRIVILEGES ON `ninja`.* TO 'ninja'@'localhost';
FLUSH PRIVILEGES;</pre>
</p>
If you need help you can either post to our <a href="https://groups.google.com/forum/#!forum/invoiceninja" target="_blank">Google Group</a>
or email us at <a href="mailto:contact@invoiceninja.com" target="_blank">contact@invoiceninja.com</a>.
</div>
{{ Former::open() }}
{{ Former::open()->rules([
'app[url]' => 'required',
'database[type][host]' => 'required',
'database[type][database]' => 'required',
'database[type][username]' => 'required',
'database[type][password]' => 'required',
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email',
'password' => 'required',
'terms_checkbox' => 'required'
]) }}
<div class="panel panel-default">
<div class="panel-heading">
@ -48,7 +59,7 @@ FLUSH PRIVILEGES;</pre>
{{ Former::text('database[type][host]')->label('Host')->value('localhost') }}
{{ Former::text('database[type][database]')->label('Database')->value('ninja') }}
{{ Former::text('database[type][username]')->label('Username')->value('ninja') }}
{{ Former::text('database[type][password]')->label('Password')->value('ninja') }}
{{ Former::password('database[type][password]')->label('Password')->value('ninja') }}
{{ Former::actions( Button::normal('Test connection', ['onclick' => 'testDatabase()']), '&nbsp;&nbsp;<span id="dbTestResult"/>' ) }}
</div>
</div>
@ -65,7 +76,7 @@ FLUSH PRIVILEGES;</pre>
{{ Former::select('mail[encryption]')->label('Encryption')->options(['tls' => 'TLS', 'ssl' => 'SSL']) }}
{{ Former::text('mail[from][name]')->label('From Name') }}
{{ Former::text('mail[username]')->label('Email') }}
{{ Former::text('mail[password]')->label('Password') }}
{{ Former::password('mail[password]')->label('Password') }}
{{ Former::actions( Button::normal('Send test email', ['onclick' => 'testMail()']), '&nbsp;&nbsp;<span id="mailTestResult"/>' ) }}
</div>
</div>
@ -83,6 +94,7 @@ FLUSH PRIVILEGES;</pre>
</div>
</div>
{{ Former::checkbox('terms_checkbox')->label(' ')->text(trans('texts.agree_to_terms', ['terms' => '<a href="'.NINJA_APP_URL.'/terms" target="_blank">'.trans('texts.terms_of_service').'</a>'])) }}
{{ Former::actions( Button::submit_lg('Submit') ) }}
{{ Former::close() }}
@ -108,6 +120,13 @@ FLUSH PRIVILEGES;</pre>
});
}
// http://stackoverflow.com/questions/585396/how-to-prevent-enter-keypress-to-submit-a-web-form
$("form").bind("keypress", function (e) {
if (e.keyCode == 13) {
return false;
}
});
</script>
</body>