Skip to content

Commit

Permalink
Merge pull request #195 from uplink42/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
uplink42 authored Jul 10, 2017
2 parents 5e8e409 + f4adedd commit a913b8d
Show file tree
Hide file tree
Showing 47 changed files with 1,664 additions and 693 deletions.
50 changes: 25 additions & 25 deletions application/controllers/Apikeymanagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ public function __construct()

/**
* Loads the api key management page
* @param string $character_id
* @return void
* @param string $character_id
* @return void
*/
public function index($character_id)
{
settype($character_id, 'int');
if ($this->enforce($character_id, $this->user_id)) {
$this->Log->addEntry("visit " . $this->page, $this->user_id);
$aggregate = $this->aggregate;
$data = $this->loadViewDependencies($character_id, $this->user_id, $aggregate);
$chars = $data['chars'];
$aggregate = $this->aggregate;
$data = $this->loadViewDependencies($character_id, $this->user_id, $aggregate);
$chars = $data['chars'];
$data['selected'] = "apikey";

$data['layout']['page_title'] = "API Key Management";
$data['layout']['icon'] = "fa fa-users";
$data['layout']['page_aggregate'] = false;

$data['view'] = 'main/apimanagement_v';
$data['view'] = 'main/apimanagement_v';
$this->twig->display('main/_template_v', $data);
}
}
Expand All @@ -56,23 +56,23 @@ public function getCharacters()

/**
* Remove a character from an account
* @param int $character_id_r
* @return string json
* @param int $character_id_r
* @return string json
*/
public function removeCharacter(int $character_id_r)
{
$this->load->model('ValidateRequest');
if ($this->ValidateRequest->checkCharacterBelong($character_id_r, $this->user_id)) {
if($this->ApiKeyManagement_model->removeCharacterProcess($character_id_r)) {
if ($this->ApiKeyManagement_model->removeCharacterProcess($character_id_r)) {
$notice = "success";
$msg = Msg::CHARACTER_REMOVE_SUCCESS;
$msg = Msg::CHARACTER_REMOVE_SUCCESS;
} else {
$notice = "error";
$msg = Msg::CHARACTER_REMOVE_ERROR;
$msg = Msg::CHARACTER_REMOVE_ERROR;
}
} else {
$notice = "error";
$msg = Msg::INVALID_REQUEST;
$msg = Msg::INVALID_REQUEST;
}

$data = array("notice" => $notice, "message" => $msg);
Expand All @@ -81,14 +81,14 @@ public function removeCharacter(int $character_id_r)

/**
* Adds a character or set of characters to an account
* @return string json
* @return string json
*/
public function addCharacters()
{
$this->load->model('common/ValidateRequest', 'validate');
$result = $this->validate->validateAPI($this->keyid, $this->vcode);

if($result) {
if ($result) {
$notice = "error";
$msg = $result;
$data = array("notice" => $notice, "message" => $msg);
Expand All @@ -103,11 +103,11 @@ public function addCharacters()

/**
* Add characters to account - step 2
* @param int $apikey
* @param string $vcode
* @param string|null $char1
* @param string|null $char2
* @param string|null $char3
* @param int $apikey
* @param string $vcode
* @param string|null $char1
* @param string|null $char2
* @param string|null $char3
* @return string json
*/
public function addCharactersStep(int $apikey, string $vcode, string $char1 = null, string $char2 = null, string $char3 = null)
Expand All @@ -117,25 +117,25 @@ public function addCharactersStep(int $apikey, string $vcode, string $char1 = nu
$char2 ? array_push($chars, $char2) : '';
$char3 ? array_push($chars, $char3) : '';

if(count($chars) != 0) {
if (count($chars) != 0) {
$this->load->model('register_model', 'reg');
if($this->reg->verifyCharacters($chars, $apikey, $vcode)) {
if ($this->reg->verifyCharacters($chars, $apikey, $vcode)) {
$create_error = $this->ApiKeyManagement_model->addCharacters($chars, $apikey, $vcode, $this->user_id);
//add characters
if (!$create_error) {
$notice = "success";
$msg = Msg::CHARACTER_CREATE_SUCCESS;
$msg = Msg::CHARACTER_CREATE_SUCCESS;
} else {
$notice = "error";
$msg = $create_error;
$msg = $create_error;
}
} else {
$notice = "error";
$msg = Msg::CHARACTER_ACCOUNT_MISMATCH;
$msg = Msg::CHARACTER_ACCOUNT_MISMATCH;
}
} else {
$notice = "error";
$msg = Msg::NO_CHARACTER_SELECTED;
$msg = Msg::NO_CHARACTER_SELECTED;
}

$data = array("notice" => $notice, "message" => $msg);
Expand Down
15 changes: 7 additions & 8 deletions application/controllers/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public function __construct()

/**
* Loads the assets page
* @param int $character_id
* @param int|integer $region_id
* @return void
* @param int $character_id
* @param int|integer $region_id
* @return void
*/
public function index($character_id, $region_id = 0) : void
public function index($character_id, $region_id = 0): void
{
if ($this->enforce($character_id, $this->user_id)) {
$this->Log->addEntry("visit " . $this->page, $this->user_id);
Expand All @@ -39,7 +39,7 @@ public function index($character_id, $region_id = 0) : void

$asset_totals = $this->assets->getRegionData($chars);
$region_name = $this->assets->getRegionName($region_id);

if ($region_name != "All") {
$data['current_asset_value'] = isset($asset_totals[$region_name]) ? $asset_totals[$region_name][0]['total_value'] : 0;
} else {
Expand All @@ -56,17 +56,16 @@ public function index($character_id, $region_id = 0) : void
$data['layout']['icon'] = "pe-7s-plugin";
$data['layout']['page_aggregate'] = true;

$data['view'] = 'main/assets_v';
$data['view'] = 'main/assets_v';
$this->twig->display('main/_template_v', $data);
}
}


public function getAssetsTable(int $character_id, bool $aggr)
{
$region_id = $_REQUEST['region_id'] ?? null;
$params = ['region_id' => $region_id, 'defs' => $_REQUEST];

echo $this->buildData($character_id, $aggr, 'getAssetsList', 'Assets_model', $params);
echo $this->buildData($character_id, $aggr, 'getAssetsList', 'Assets_model', $params);
}
}
22 changes: 11 additions & 11 deletions application/controllers/Citadeltax.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public function __construct()

/**
* Loads the Citadel tax page
* @param int $character_id
* @return void
* @param int $character_id
* @return void
*/
public function index($character_id) : void
public function index($character_id): void
{
if ($this->enforce($character_id, $user_id = $this->user_id)) {
$this->Log->addEntry("visit " . $this->page, $this->user_id);
Expand All @@ -51,7 +51,7 @@ public function index($character_id) : void
* Returns Citadels autocomplete results
* @return string json
*/
public function searchCitadels() : void
public function searchCitadels(): void
{
$input = $_REQUEST['term'];
$result = $this->CitadelTax_model->queryCitadels($input);
Expand All @@ -62,7 +62,7 @@ public function searchCitadels() : void
* Validates and adds a tax to a certain citadel
* @return string json
*/
public function addTax() : void
public function addTax(): void
{
$citadel_id = $this->CitadelTax_model->getCitadelID($this->citadel);
if ($citadel_id) {
Expand All @@ -88,21 +88,21 @@ public function addTax() : void

/**
* Returns the citadel tax list for a user
* @param int $character_id
* @return string json
* @param int $character_id
* @return string json
*/
public function getTaxList(int $character_id) : void
public function getTaxList(int $character_id): void
{
echo json_encode($this->CitadelTax_model->taxList($character_id));
}

/**
* Removes a citadel tax entry
* @param int $character_id
* @param int $tax_id
* @return string json
* @param int $tax_id
* @return string json
*/
public function removeTax(int $character_id, int $tax_id) : void
public function removeTax(int $character_id, int $tax_id): void
{
if ($this->ValidateRequest->checkCitadelOwnership($character_id, $tax_id)) {
if ($this->CitadelTax_model->removeTax($tax_id)) {
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/Contracts.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public function __construct()
}

if (isset($_REQUEST['new'])) {
$this->new = (int)$_REQUEST['new'];
$this->new = (int) $_REQUEST['new'];
};
}

/**
* Loads the contracts page
* @param int $character_id
* @return void
* @param int $character_id
* @return void
*/
public function index($character_id) : void
public function index($character_id): void
{
if ($this->enforce($character_id, $user_id = $this->user_id)) {
$this->Log->addEntry("visit " . $this->page, $this->user_id);
Expand Down
39 changes: 18 additions & 21 deletions application/controllers/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

final class Dashboard extends MY_Controller
{

public function __construct()
{
parent::__construct();
Expand All @@ -12,13 +11,13 @@ public function __construct()
$this->load->model('Dashboard_model', 'dashboard');
}

/**
* Loads the dashboard page
* @param int $character_id
* @param int|integer $interval
* @return void
*/
public function index($character_id, $interval = 1) : void
/**
* Loads the dashboard page
* @param int $character_id
* @param int|integer $interval
* @return void
*/
public function index($character_id, int $interval = 1): void
{
if ($interval > 7) {
$interval = 7;
Expand All @@ -30,8 +29,8 @@ public function index($character_id, $interval = 1) : void
$data = $this->loadViewDependencies($character_id, $this->user_id, $aggregate);
$chars = $data['chars'];

$data['selected'] = "dashboard";
$data['interval'] = $interval;
$data['selected'] = "dashboard";
$data['interval'] = $interval;
$data['week_profits'] = $this->dashboard->getWeekProfits($chars);
$data['new_info'] = $this->dashboard->getNewInfo($chars);
$data['profits_trends'] = $this->dashboard->getTotalProfitsTrends($chars);
Expand All @@ -45,21 +44,19 @@ public function index($character_id, $interval = 1) : void
}
}


public function getPieChart(int $character_id, bool $aggr = false) : void
public function getPieChart(int $character_id, bool $aggr = false): void
{
$params = [];
echo $this->buildData($character_id, $aggr, 'getPieChartData', 'Dashboard_model', $params);
echo $this->buildData($character_id, $aggr, 'getPieChartData', 'Dashboard_model', $params);
}


public function getProfitTable(int $character_id, int $interval = 3, bool $aggr = false) : void
public function getProfitTable(int $character_id, int $interval = 3, bool $aggr = false): void
{
$params = ['interval' => $interval,
'user_id' => $this->user_id,
'defs' => $_REQUEST
];
echo $this->buildData($character_id, $aggr, 'getProfits', 'Dashboard_model', $params);
'user_id' => $this->user_id,
'defs' => $_REQUEST,
];

echo $this->buildData($character_id, $aggr, 'getProfits', 'Dashboard_model', $params);
}
}
}
6 changes: 3 additions & 3 deletions application/controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public function __construct()
* Loads the homepage
* @return void
*/
public function index() : void
public function index(): void
{
$data = ["view" => "home/home_v", "stats" => $this->Home_model->getStats()];
$this->load->view('home/_template');
}

/**
* Returns the website stats
* @return string json
* @return string json
*/
public function getAll() : void
public function getAll(): void
{
$data = $this->Home_model->getStats();
echo json_encode($data);
Expand Down
Loading

0 comments on commit a913b8d

Please sign in to comment.