1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #4041 from turbo124/v2

Improve update process
This commit is contained in:
David Bomba 2020-09-07 20:05:39 +10:00 committed by GitHub
commit ca34e77530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 106 additions and 78 deletions

View File

@ -30,7 +30,7 @@ jobs:
MULTI_DB_ENABLED: false MULTI_DB_ENABLED: false
NINJA_LICENSE: 123456 NINJA_LICENSE: 123456
TRAVIS: true TRAVIS: true
MAIL_DRIVER: log MAIL_MAILER: log
services: services:
mariadb: mariadb:

View File

@ -51,49 +51,62 @@ class PostUpdate extends Command
\Log::error("I wasn't able to optimize."); \Log::error("I wasn't able to optimize.");
} }
$composer_data = [ // Composer\Factory::getHomeDir() method
'url' => 'https://getcomposer.org/composer.phar', // needs COMPOSER_HOME environment variable set
'dir' => __DIR__.'/.code', putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer');
'bin' => __DIR__.'/.code/composer.phar',
'json' => __DIR__.'/.code/composer.json',
'conf' => [
'autoload' => [
'psr-4' => [
'' => 'local/',
],
],
],
];
if (! is_dir($composer_data['dir'])) { // call `composer install` command programmatically
mkdir($composer_data['dir'], 0777, true); $input = new ArrayInput(array('command' => 'install'));
} $application = new Application();
$application->setAutoExit(false);
$out = $application->run($input);
if (! is_dir("{$composer_data['dir']}/local")) { print_r($out);
mkdir("{$composer_data['dir']}/local", 0777, true); echo "Done.";
}
copy($composer_data['url'], $composer_data['bin']); // $composer_data = [
require_once "phar://{$composer_data['bin']}/src/bootstrap.php"; // 'url' => 'https://getcomposer.org/composer.phar',
// 'dir' => __DIR__.'/.code',
// 'bin' => __DIR__.'/.code/composer.phar',
// 'json' => __DIR__.'/.code/composer.json',
// 'conf' => [
// 'autoload' => [
// 'psr-4' => [
// '' => 'local/',
// ],
// ],
// ],
// ];
$conf_json = json_encode($composer_data['conf'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // if (! is_dir($composer_data['dir'])) {
file_put_contents($composer_data['json'], $conf_json); // mkdir($composer_data['dir'], 0777, true);
chdir($composer_data['dir']); // }
putenv("COMPOSER_HOME={$composer_data['dir']}");
putenv('OSTYPE=OS400');
$app = new \Composer\Console\Application();
$factory = new \Composer\Factory(); // if (! is_dir("{$composer_data['dir']}/local")) {
$output = $factory->createOutput(); // mkdir("{$composer_data['dir']}/local", 0777, true);
// }
$input = new \Symfony\Component\Console\Input\ArrayInput([ // copy($composer_data['url'], $composer_data['bin']);
'command' => 'install', // require_once "phar://{$composer_data['bin']}/src/bootstrap.php";
]);
$input->setInteractive(false);
echo '<pre>';
$cmdret = $app->doRun($input, $output);
echo 'end!';
\Log::error(print_r($cmdret, 1)); // $conf_json = json_encode($composer_data['conf'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
// file_put_contents($composer_data['json'], $conf_json);
// chdir($composer_data['dir']);
// putenv("COMPOSER_HOME={$composer_data['dir']}");
// putenv('OSTYPE=OS400');
// $app = new \Composer\Console\Application();
// $factory = new \Composer\Factory();
// $output = $factory->createOutput();
// $input = new \Symfony\Component\Console\Input\ArrayInput([
// 'command' => 'install',
// ]);
// $input->setInteractive(false);
// echo '<pre>';
// $cmdret = $app->doRun($input, $output);
// echo 'end!';
// \Log::error(print_r($cmdret, 1));
} }
} }

View File

@ -33,17 +33,18 @@ class EntityViewController extends Controller
$key = $entity_type.'_id'; $key = $entity_type.'_id';
$invitation = $invitation_entity::whereRaw('BINARY `key`= ?', [$invitation_key])->firstOrFail(); $invitation = $invitation_entity::whereRaw('BINARY `key`= ?', [$invitation_key])
->with('contact.client')
->firstOrFail();
$contact = $invitation->contact; $contact = $invitation->contact;
$client = $contact->client;
$entity = $invitation->{$entity_type};
if (is_null($contact->password) || empty($contact->password)) { if (is_null($contact->password) || empty($contact->password)) {
return redirect("/client/password/reset?email={$contact->email}"); return redirect("/client/password/reset?email={$contact->email}");
} }
$entity_class = sprintf('App\\Models\\%s', ucfirst($entity_type));
$entity = $entity_class::findOrFail($invitation->{$key});
if ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) { if ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
session()->flash("{$entity_type}_VIEW_{$entity->hashed_id}", true); session()->flash("{$entity_type}_VIEW_{$entity->hashed_id}", true);
} }

View File

@ -37,29 +37,34 @@ class InvitationController extends Controller
$entity_obj = 'App\Models\\'.ucfirst($entity).'Invitation'; $entity_obj = 'App\Models\\'.ucfirst($entity).'Invitation';
$invitation = $entity_obj::whereRaw('BINARY `key`= ?', [$invitation_key])->first(); $invitation = $entity_obj::whereRaw('BINARY `key`= ?', [$invitation_key])
->with('contact.client')
->firstOrFail();
if ($invitation) { /* Return early if we have the correct client_hash embedded */
if ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
$this->middleware('auth:contact');
} else {
auth()->guard('contact')->login($invitation->contact, true);
}
if (! request()->has('silent') && ! $invitation->viewed_date) { if(request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) {
// if (!request()->has('silent')) { auth()->guard('contact')->login($invitation->contact, true);
$invitation->markViewed();
event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars()));
$this->fireEntityViewedEvent($invitation, $entity);
}
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
} else {
abort(404);
} }
else if ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
$this->middleware('auth:contact');
}
else {
auth()->guard('contact')->login($invitation->contact, true);
}
if (auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed();
event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars()));
$this->fireEntityViewedEvent($invitation, $entity);
}
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
} }
private function fireEntityViewedEvent($invitation, $entity_string) private function fireEntityViewedEvent($invitation, $entity_string)

View File

@ -29,8 +29,8 @@ class Kernel extends HttpKernel
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class, \App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class, //\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\Cors::class, \App\Http\Middleware\Cors::class,
]; ];

View File

@ -31,10 +31,12 @@ class QueryLogging
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, Closure $next)
{ {
$timeStart = microtime(true);
// Enable query logging for development // Enable query logging for development
if (config('ninja.app_env') != 'production') { if (config('ninja.app_env') != 'production') {
DB::enableQueryLog(); DB::enableQueryLog();
$timeStart = microtime(true);
} }
$response = $next($request); $response = $next($request);

View File

@ -111,7 +111,7 @@ class CreateInvoicePdf implements ShouldQueue
//todo - move this to the client creation stage so we don't keep hitting this unnecessarily //todo - move this to the client creation stage so we don't keep hitting this unnecessarily
Storage::makeDirectory($path, 0775); Storage::makeDirectory($path, 0775);
info($maker->getCompiledHTML(true)); //info($maker->getCompiledHTML(true));
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true)); $pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));

View File

@ -262,6 +262,13 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment
{ {
$payment_meta = new \stdClass;
$payment_meta->exp_month = 'xx';
$payment_meta->exp_year = 'xx';
$payment_meta->brand = 'PayPal';
$payment_meta->last4 = 'xxxx';
$payment_meta->type = GatewayType::PAYPAL;
$payment = parent::createPayment($data, $status); $payment = parent::createPayment($data, $status);
$client_contact = $this->getContact(); $client_contact = $this->getContact();
@ -271,6 +278,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
$payment->type_id = PaymentType::PAYPAL; $payment->type_id = PaymentType::PAYPAL;
$payment->transaction_reference = $data['PAYMENTINFO_0_TRANSACTIONID']; $payment->transaction_reference = $data['PAYMENTINFO_0_TRANSACTIONID'];
$payment->client_contact_id = $client_contact_id; $payment->client_contact_id = $client_contact_id;
$payment->meta = $payment_meta;
$payment->save(); $payment->save();
return $payment; return $payment;

21
composer.lock generated
View File

@ -1541,16 +1541,16 @@
}, },
{ {
"name": "egulias/email-validator", "name": "egulias/email-validator",
"version": "2.1.19", "version": "2.1.20",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/egulias/EmailValidator.git", "url": "https://github.com/egulias/EmailValidator.git",
"reference": "840d5603eb84cc81a6a0382adac3293e57c1c64c" "reference": "f46887bc48db66c7f38f668eb7d6ae54583617ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/840d5603eb84cc81a6a0382adac3293e57c1c64c", "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/f46887bc48db66c7f38f668eb7d6ae54583617ff",
"reference": "840d5603eb84cc81a6a0382adac3293e57c1c64c", "reference": "f46887bc48db66c7f38f668eb7d6ae54583617ff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1595,7 +1595,7 @@
"validation", "validation",
"validator" "validator"
], ],
"time": "2020-08-08T21:28:19+00:00" "time": "2020-09-06T13:44:32+00:00"
}, },
{ {
"name": "fedeisas/laravel-mail-css-inliner", "name": "fedeisas/laravel-mail-css-inliner",
@ -4364,16 +4364,16 @@
}, },
{ {
"name": "opis/closure", "name": "opis/closure",
"version": "3.5.6", "version": "3.5.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/opis/closure.git", "url": "https://github.com/opis/closure.git",
"reference": "e8d34df855b0a0549a300cb8cb4db472556e8aa9" "reference": "4531e53afe2fc660403e76fb7644e95998bff7bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/opis/closure/zipball/e8d34df855b0a0549a300cb8cb4db472556e8aa9", "url": "https://api.github.com/repos/opis/closure/zipball/4531e53afe2fc660403e76fb7644e95998bff7bf",
"reference": "e8d34df855b0a0549a300cb8cb4db472556e8aa9", "reference": "4531e53afe2fc660403e76fb7644e95998bff7bf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4421,7 +4421,7 @@
"serialization", "serialization",
"serialize" "serialize"
], ],
"time": "2020-08-11T08:46:50+00:00" "time": "2020-09-06T17:02:15+00:00"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
@ -11053,7 +11053,6 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"abandoned": true,
"time": "2019-09-17T06:23:10+00:00" "time": "2019-09-17T06:23:10+00:00"
}, },
{ {

View File

@ -13,7 +13,7 @@ return [
| |
*/ */
'default' => env('FILESYSTEM_DRIVER', 'local'), 'default' => env('FILESYSTEM_DRIVER', 'public'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------