Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Apr 23, 2018
2 parents b7a1c2c + 110fde3 commit 29d206b
Show file tree
Hide file tree
Showing 1,320 changed files with 114,524 additions and 102,856 deletions.
1 change: 1 addition & 0 deletions .htaccess
Expand Up @@ -2,6 +2,7 @@
Options -Indexes

RewriteEngine On
RewriteBase /

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} ^(.*)
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -15,7 +15,7 @@ services:

before_script:
- cp .travis/env.travis.php env.php
- composer install --no-interaction --verbose
- composer install --dev --no-interaction --verbose

script:
- php artisan database:create --reset
Expand Down
27 changes: 27 additions & 0 deletions .travis/Formatting.xml
@@ -0,0 +1,27 @@
<code_scheme name="PHPVMS" version="173">
<option name="RIGHT_MARGIN" value="100" />
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
<option name="ALIGN_CLASS_CONSTANTS" value="true" />
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
</PHPCodeStyleSettings>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JAVA">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JSON">
<indentOptions>
<option name="INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="PHP">
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
</codeStyleSettings>
</code_scheme>
19 changes: 18 additions & 1 deletion .travis/deploy_script.sh
Expand Up @@ -30,18 +30,23 @@ if [ "$TRAVIS" = "true" ]; then

make clean

# Clean up the dependencies to only remove the dev packages
#rm -rf vendor
#composer install --no-interaction --no-dev

rm -rf env.php config.php
find ./vendor -type d -name ".git" -print0 | xargs rm -rf
find . -type d -name "sass-cache" -print0 | xargs rm -rf

# clear any app specific stuff that might have been loaded in
find storage/app/public -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf {} +
find storage/app -mindepth 1 -not -name '.gitignore' -not -name public -print0 -exec rm -rf {} +
find storage/app -mindepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf {} +

# Remove any development files
rm -rf .sass-cache
rm -rf .idea phpvms.iml .travis .dpl
rm -rf .phpstorm.meta.php _ide_helper.php phpunit.xml Procfile
rm -f phpstan.neon

# remove large sized files
rm -rf .git
Expand All @@ -63,5 +68,17 @@ if [ "$TRAVIS" = "true" ]; then
mv "/tmp/$TAR_NAME" "/tmp/$TAR_NAME.sha256" .
artifacts upload --target-paths "/" $TAR_NAME $TRAVIS_BUILD_DIR/VERSION $TAR_NAME.sha256

# Upload the version for a tagged release. Move to a version file in different
# tags. Within phpVMS, we have an option of which version to track in the admin
if test "$TRAVIS_TAG"; then
echo "uploading release version file"
cp "$TRAVIS_BUILD_DIR/VERSION" release_version
artifacts upload --target-paths "/" release_version
else
echo "uploading ${TRAVIS_BRANCH}_version file"
cp $TRAVIS_BUILD_DIR/VERSION ${TRAVIS_BRANCH}_version
artifacts upload --target-paths "/" ${TRAVIS_BRANCH}_version
fi

curl -X POST --data "{\"content\": \"A new build is available at http://downloads.phpvms.net/$TAR_NAME ($VERSION)\"}" -H "Content-Type: application/json" $DISCORD_WEBHOOK_URL
fi
23 changes: 23 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,26 @@
## Alpha 3

!! Please do a complete reinstall, with a new database

- Finances! The finance portions have been implemented, you can [read about them here](http://docs.phpvms.net/concepts/finances)
- Awards! Added the award plugin system. [see docs](http://docs.phpvms.net/customizing/awards)
- Import/Export in admin panel for aircraft, airports, expenses, fares, flights and subfleets
- Changed theme system to using [laravel-theme](https://github.com/igaster/laravel-theme), there are changes to making theming much simpler with much more flexibility.
- Added cron task for background tasks
- Expanded on flight types to match IATA SIMM format
- Added subfleet `cost_block_hour`
- Fixed several security vulnerabilities (thanks magicflyer!)
- Fuel units changed to lbs/kgs [#193](https://github.com/nabeelio/phpvms/issues/193)
- Airports can be restricted to only hubs on registration/user profile
- Cleaned up a lot unused icons and files [#195](https://github.com/nabeelio/phpvms/issues/195)
- Rank restrictions for PIREPs are respected [#170](https://github.com/nabeelio/phpvms/issues/170)
- API: Added the ability to get/update/delete user bids [#172](https://github.com/nabeelio/phpvms/issues/172)
- API: Added `block_time` parameter for PIREP prefile/update/file calls
- API: Added `block_on_time` and `block_off_time` for PIREP prefile/update/file calls
- Artisan: Added a `phpvms:csv-import [table] [file]` to import from CSV
- Artisan: Added a `phpvms:yaml-export [tables]` to export tables to YAML files which can be re-imported using `phpvms:yaml-import`
- Numerous bug fixes

## Alpha 2 (2018-02-23, v7.0.0-alpha2)

!! Please do a full reinstall, with recreating the database
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Expand Up @@ -36,8 +36,7 @@ build:
# This is to build all the stylesheets, etc
.PHONY: build-assets
build-assets:
npm update
npm run dev
yarn run dev

.PHONY: install
install: build
Expand All @@ -53,16 +52,16 @@ update: build
@echo "Done!"

.PHONY: reset
reset: clean
reset: cleanapp/Models/Traits/JournalTrait.php
@php $(COMPOSER) dump-autoload
@make reload-db

.PHONY: reload-db
reload-db:
@php artisan database:create --reset
@php artisan migrate:fresh --seed
@php artisan phpvms:import app/Database/seeds/sample.yml
@php artisan phpvms:import app/Database/seeds/acars.yml
@php artisan phpvms:yaml-import app/Database/seeds/sample.yml
@php artisan phpvms:yaml-import app/Database/seeds/acars.yml
#php artisan phpvms:navdata

.PHONY: tests
Expand All @@ -73,6 +72,10 @@ test:
#php artisan database:create --reset
vendor/bin/phpunit --debug --verbose

.PHONY:
phpstan:
vendor/bin/phpstan analyse -c phpstan.neon -v --level 2 app

.PHONY: replay-acars
replay-acars:
#@php artisan phpvms:replay AAL10,AAL3113,BAW172,DAL988,FIN6,MSR986 --manual
Expand Down
47 changes: 47 additions & 0 deletions app/Awards/PilotFlightAwards.php
@@ -0,0 +1,47 @@
<?php

namespace App\Awards;

use App\Interfaces\Award;

/**
* Simple example of an awards class, where you can apply an award when a user
* has 100 flights. All award classes need to extend the AwardInterface
* @package App\Awards
*/
class PilotFlightAwards extends Award
{
/**
* Set the name of this award class to make it easier to see when
* assigning to a specific award
* @var string
*/
public $name = 'Pilot Flights';

/**
* The description to show under the parameters field, so the admin knows
* what the parameter actually controls. You can leave this blank if there
* isn't a parameter.
* @var string
*/
public $param_description = 'The number of flights at which to give this award';

/**
* If the user has over N flights, then we can give them this award. This method
* only needs to return a true or false of whether it should be awarded or not.
*
* If no parameter is passed in, just default it to 100. You should check if there
* is a parameter or not. You can call it whatever you want, since that would make
* sense with the $param_description.
* @param int|null $number_of_flights The parameters passed in from the UI
* @return bool
*/
public function check($number_of_flights = null): bool
{
if (!$number_of_flights) {
$number_of_flights = 100;
}

return $this->user->flights >= $number_of_flights;
}
}
3 changes: 1 addition & 2 deletions app/Bootstrap/LoadConfiguration.php
Expand Up @@ -23,8 +23,7 @@ class LoadConfiguration extends \Illuminate\Foundation\Bootstrap\LoadConfigurati
* Load the configuration items from all of the files.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Contracts\Config\Repository $repository
* @return void
* @param \Illuminate\Contracts\Config\Repository $repository
* @throws \Exception
*/
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository)
Expand Down
65 changes: 0 additions & 65 deletions app/Console/BaseCommand.php

This file was deleted.

102 changes: 102 additions & 0 deletions app/Console/Command.php
@@ -0,0 +1,102 @@
<?php

namespace App\Console;

use Log;
use Symfony\Component\Process\Process;

/**
* Class BaseCommand
* @package App\Console
*/
abstract class Command extends \Illuminate\Console\Command
{
/**
* @return mixed
*/
abstract public function handle();

/**
* Splice the logger and replace the active handlers with
* the handlers from the "cron" stack in config/logging.php
*
* Close out any of the existing handlers so we don't leave
* file descriptors leaking around
*
* @param string $channel_name Channel name to grab the handlers from
*/
public function redirectLoggingToStdout($channel_name): void
{
$logger = app(\Illuminate\Log\Logger::class);

// Close the existing loggers
try {
$handlers = $logger->getHandlers();
foreach ($handlers as $handler) {
$handler->close();
}
} catch (\Exception $e) {
$this->error('Error closing handlers: '.$e->getMessage());
}

// Open the handlers for the channel name,
// and then set them to the main logger
try {
$logger->setHandlers(
Log::channel($channel_name)->getHandlers()
);
} catch (\Exception $e) {
$this->error('Couldn\'t splice the logger: '.$e->getMessage());
}
}

/**
* Streaming file reader
* @param $filename
* @return \Generator
*/
public function readFile($filename): ?\Generator
{
$fp = fopen($filename, 'rb');
while (($line = fgets($fp)) !== false) {
$line = rtrim($line, "\r\n");
if ($line[0] === ';') {
continue;
}

yield $line;
}

fclose($fp);
}

/**
* @param $cmd
* @param bool $return
* @return string
* @throws \Symfony\Component\Process\Exception\RuntimeException
* @throws \Symfony\Component\Process\Exception\LogicException
*/
public function runCommand($cmd, $return = false, $verbose = true): string
{
if (\is_array($cmd)) {
$cmd = join(' ', $cmd);
}

if ($verbose) {
$this->info('Running "'.$cmd.'"');
}

$val = '';
$process = new Process($cmd);
$process->run(function ($type, $buffer) use ($return, &$val) {
if ($return) {
$val .= $buffer;
} else {
echo $buffer;
}
});

return $val;
}
}

0 comments on commit 29d206b

Please sign in to comment.