Skip to content

Commit

Permalink
Jobs are now user-configurable
Browse files Browse the repository at this point in the history
Not every installation has the same jobs as everyone else. Also updates the documentation for customizations
  • Loading branch information
nfreader committed Dec 3, 2018
1 parent 38cf560 commit 2b6942a
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -4,4 +4,5 @@
composer.lock
src/conf/servers.json
src/conf/ranks.json
src/conf/alert.html*
src/conf/alert.html*
composer.lock
12 changes: 8 additions & 4 deletions Readme.md
Expand Up @@ -16,20 +16,24 @@
2. Clone this repo into the document root you specified in step 1.
3. Run `composer update` and `composer dump-autoload -o`.
4. Copy `.env.example` to `.env` and adjust your settings accordingly.
5. Copy `src/conf/example-servers.json` to `src/conf/servers.json` and customize your settings accordingly.
6. Copy `src/conf/example-ranks.json` to `src/conf/ranks.json` and customize your settings accordingly. Icons are from [FontAwesome](https://fontawesome.com/icons?d=gallery&m=free).

### Second Database (Alt DB)
Some data, when parsed, can be saved to a second database. To enable this function:

1. Make sure the `ALT_DB_*` variables are set in your `.env`. See `.env.example` for details.
2. Initialize the second database using the table structure defined in `sql/alt_db.sql`.


## Updating
1. Run `git pull`.
2. Run `composer update` and `composer dump-autoload -o`.
3. (Maybe) Remove the twig cache at `tmp/twig`.

### Second Database (Alt DB)
1. Apply any updates specified in `sql/sqlchangelog.md`.
1. Apply any updates specified in `sql/sqlchangelog.md`.

##Customizations
There are several files you can edit in order to tailor Statbus to your codebase:

- `src/conf/servers.json` can be used to map server information. At the minimum, you must specify a server port and name. See `src/conf/example-servers.json`.
- `src/conf/ranks.json` holds the definitions for admin rank badge colors and icons. See `src/conf/example-ranks.json` for examples. The icon field sources icons from [FontAwsome](https://fontawesome.com/icons?d=gallery&s=solid&m=free). You only need the name of the icon, the part after `fa-`.
- `src/conf/jobs.json` can be used to customize what jobs are looked at for querying role_time data (as seen on `/me`). You should copy `src/conf/example-jobs.json` into your `jobs.json` and add or remove jobs from that listing.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -17,7 +17,8 @@
"kevinrob/guzzle-cache-middleware": "^3.2",
"league/flysystem": "^1.0",
"doctrine/cache": "^1.7",
"slim/csrf": "^0.8.3"
"slim/csrf": "^0.8.3",
"sensiolabs/security-checker": "^5.0"
},
"autoload": {
"psr-4": {
Expand Down
241 changes: 240 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion index.php
Expand Up @@ -31,6 +31,11 @@
if(file_exists(__DIR__ . '/src/conf/ranks.json')){
$settings['settings']['statbus']['ranks'] = json_decode(file_get_contents(__DIR__ . '/src/conf/ranks.json'), true);
}

if(file_exists(__DIR__ . '/src/conf/jobs.json')){
$settings['settings']['statbus']['jobs'] = json_decode(file_get_contents(__DIR__ . '/src/conf/jobs.json'), true);
}

if ($settings['settings']['refresh_key'] == filter_input(INPUT_GET,'refresh', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)){
exec("rm -rf ".__DIR__."/tmp/twig");
print("Twig cache has been cleared");
Expand All @@ -45,7 +50,6 @@

// Register routes
require __DIR__ . '/src/routes.php';

// Run app
$app->run();

6 changes: 4 additions & 2 deletions src/Statbus/Controllers/PlayerController.php
Expand Up @@ -10,7 +10,8 @@ class PlayerController Extends Controller {

public function __construct(ContainerInterface $container) {
parent::__construct($container);
$this->playerModel = new Player($this->container->get('settings')['statbus']);
$this->sb = $this->container->get('settings')['statbus'];
$this->playerModel = new Player($this->sb);
$dbConn = $this->container->get('settings')['database']['alt'];
$this->alt_db = (new DBController($dbConn))->db;
}
Expand Down Expand Up @@ -81,10 +82,11 @@ public function getPlayerByIP(int $IP){
}

public function getRoleData($ckey) {
$jobs = "('".implode("','",$this->sb['jobs'])."')";
return json_encode($this->DB->run("SELECT job, minutes
FROM tbl_role_time
WHERE ckey = ?
AND tbl_role_time.job IN ('Assistant','Scientist','Shaft Miner','Station Engineer','Cyborg','Medical Doctor','Security Officer','Roboticist','Cargo Technician','Botanist','Chemist','AI','Cook','Atmospheric Technician','Janitor','Clown','Captain','Bartender','Head of Personnel','Quartermaster','Chaplain','Geneticist','Chief Engineer','Research Director','Mime','Lawyer','Detective','Chief Medical Officer','Head of Security','Virologist','Librarian','Warden')
AND tbl_role_time.job IN $jobs
ORDER BY job ASC", $ckey));
}

Expand Down
35 changes: 35 additions & 0 deletions src/conf/Statbus.php
Expand Up @@ -88,5 +88,40 @@
'Very Ragin\' Bullshit Mages'=>'cloud-sun',
'Vigilante Gang War'=>'',
'Wizard'=>'hat-wizard'
],
'jobs' => [
'AI',
'Assistant',
'Atmospheric Technician',
'Bartender',
'Botanist',
'Captain',
'Cargo Technician',
'Chaplain',
'Chemist',
'Chief Engineer',
'Chief Medical Officer',
'Clown',
'Cook',
'Curator',
'Cyborg',
'Detective',
'Geneticist',
'Head of Personnel',
'Head of Security',
'Janitor',
'Lawyer',
'Librarian',
'Medical Doctor',
'Mime',
'Quartermaster',
'Research Director',
'Roboticist',
'Scientist',
'Security Officer',
'Shaft Miner',
'Station Engineer',
'Virologist',
'Warden'
]
];

0 comments on commit 2b6942a

Please sign in to comment.