Skip to content

Commit

Permalink
Merge pull request #43 from exodus4d/develop
Browse files Browse the repository at this point in the history
v0.0.12
  • Loading branch information
exodus4d committed Oct 6, 2015
2 parents 2e98c98 + 8d315ad commit 633b817
Show file tree
Hide file tree
Showing 50 changed files with 1,237 additions and 105 deletions.
21 changes: 8 additions & 13 deletions app/main/controller/api/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function updateData($f3){
$responseTTL = $f3->get('PATHFINDER.TIMER.UPDATE_SERVER_MAP.DELAY') / 1000;
$mapData = (array)$f3->get('POST.mapData');

$user = $this->_getUser();
$user = $this->_getUser(0);
$return = (object) [];
$return->error = [];

Expand All @@ -342,12 +342,11 @@ public function updateData($f3){

$cacheKey = 'user_map_data_' . $activeCharacter->id;

// if there is any system/connection change data submitted -> clear cache
if(!empty($mapData)){
$f3->clear($cacheKey);
}

if($f3->exists($cacheKey) === false ){
// if there is any system/connection change data submitted -> save new data
if(
$f3->exists($cacheKey) === false ||
!empty($mapData)
){

// get current map data ========================================================
$maps = $user->getMaps();
Expand Down Expand Up @@ -377,7 +376,6 @@ public function updateData($f3){

// map changes expected =============================================


// loop current user maps and check for changes
foreach($maps as $map){

Expand Down Expand Up @@ -443,10 +441,7 @@ public function updateData($f3){

// format map Data for return
$return->mapData = self::getFormattedMapData($maps);

if(count($return->mapData) > 0){
$f3->set($cacheKey, $return, $responseTTL);
}
$f3->set($cacheKey, $return, $responseTTL);
}else{
// get from cache
$return = $f3->get($cacheKey);
Expand Down Expand Up @@ -500,7 +495,7 @@ public function updateUserData($f3){
$return = (object) [];
$return->error = [];

$user = $this->_getUser();
$user = $this->_getUser(0);

if($user){

Expand Down
29 changes: 21 additions & 8 deletions app/main/controller/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,34 @@ public function showError($f3){
}

if($f3->get('AJAX')){
// error on ajax call
header('Content-type: application/json');

// error on ajax call
$errorData = [
'status' => $f3->get('ERROR.status'),
'code' => $f3->get('ERROR.code'),
'text' => $f3->get('ERROR.text')
];
$return = (object) [];
$error = (object) [];
$error->type = 'error';
$error->code = $f3->get('ERROR.code');
$error->status = $f3->get('ERROR.status');
$error->message = $f3->get('ERROR.text');

// append stack trace for greater debug level
if( $f3->get('DEBUG') === 3){
$errorData['trace'] = $f3->get('ERROR.trace');
$error->trace = $f3->get('ERROR.trace');
}

echo json_encode($errorData);
// check if error is a PDO Exception
if(strpos(strtolower( $f3->get('ERROR.text') ), 'duplicate') !== false){
preg_match_all('/\'([^\']+)\'/', $f3->get('ERROR.text'), $matches, PREG_SET_ORDER);

if(count($matches) === 2){
$error->field = $matches[1][1];
$error->message = 'Value "' . $matches[0][1] . '" already exists';
}
}

$return->error[] = $error;

echo json_encode($return);
}else{
echo $f3->get('ERROR.text');
}
Expand Down
27 changes: 17 additions & 10 deletions app/main/model/usermodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function beforeInsertEvent(){
* @return array|FALSE
*/
public function getByName($name){
return $this->getByForeignKey('name', $name);
return $this->getByForeignKey('name', $name, [], 0);
}

/**
Expand Down Expand Up @@ -281,10 +281,11 @@ public function setMainCharacterId($characterId = 0){
$userCharacter->save();
}

// set random main character
if(! $mainSet ){
$userCharacters[0]->setMain(1);
$userCharacters[0]->save();
// set first character as "main"
if( !$mainSet ){
$userCharacter = reset($userCharacters);
$userCharacter->setMain(1);
$userCharacter->save();
}
}
}
Expand All @@ -299,21 +300,27 @@ public function getUserCharacters(){

$this->filter('apis', ['active = ?', 1]);

// if a user has multiple API keys saved for ONE character,
// skip double characters!
$userCharacters = [];

if($this->apis){
$this->apis->rewind();
while($this->apis->valid()){

$this->apis->current()->filter('userCharacters', ['active = ?', 1]);

if($this->apis->current()->userCharacters){
$this->apis->current()->userCharacters->rewind();
while($this->apis->current()->userCharacters->valid()){
$userCharacters[] = $this->apis->current()->userCharacters->current();

$tempCharacterId = $this->apis->current()->userCharacters->current()->characterId->get('id');
if( !isset($userCharacters[ $tempCharacterId ]) ){
$userCharacters[ $tempCharacterId ] = $this->apis->current()->userCharacters->current();
}
$this->apis->current()->userCharacters->next();
}
}

$this->apis->next();
}
}
Expand Down Expand Up @@ -347,17 +354,17 @@ public function getMainUserCharacter(){
public function getActiveUserCharacter(){
$activeUserCharacter = null;

$apiController = Controller\CcpApiController::getIGBHeaderData();
$headerData = Controller\CcpApiController::getIGBHeaderData();

// check if IGB Data is available
if( !empty($apiController->values) ){
if( !empty($headerData->values) ){
// search for the active character by IGB Header Data

$this->filter('userCharacters',
[
'active = :active AND characterId = :characterId',
':active' => 1,
':characterId' => intval($apiController->values['charid'])
':characterId' => intval($headerData->values['charid'])
],
['limit' => 1]
);
Expand Down
6 changes: 3 additions & 3 deletions app/pathfinder.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[PATHFINDER]
NAME = "PATHFINDER"
; installed version (used for CSS/JS cache busting)
VERSION = "v0.0.11"
VERSION = "v0.0.12"
; contact information (DO NOT CHANGE)
CONTACT = "https://github.com/exodus4d"
; source code (DO NOT CHANGE)
Expand Down Expand Up @@ -92,7 +92,7 @@ STATUS = 1
MSG_DISABLED = "User registration is currently not allowed"

; use the invite system e.g. beta testing. A "registration key" is required (0=disabled, 1=enabled)
INVITE = 1
INVITE = 0

; the limit of registration keys. Increase it to hand out more keys
INVITE_LIMIT = 50
Expand All @@ -119,7 +119,7 @@ CONSTELLATION_SYSTEMS = 2592000
; ======================================================================================================
[PATHFINDER.TIMER]
; login time (minutes)
LOGGED = 120
LOGGED = 240

; double click timer (ms)
DBL_CLICK = 250
Expand Down
1 change: 0 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ gulp.task('watch', function(tag) {

/**
* Production task for deployment.
* Triggered by Maven Plugin.
* $ gulp production --tag v0.0.9
* WARNING: DO NOT REMOVE THIS TASK!!!
*/
Expand Down
1 change: 1 addition & 0 deletions js/app/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ define([
mode: 'popup',
type: 'text',
name: 'alias',
emptytext: system.data('name'),
title: 'System alias',
placement: 'top',
onblur: 'submit',
Expand Down
3 changes: 3 additions & 0 deletions js/app/mappage.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ define([
$(document).setProgramStatus('online');

if(data.mapData.length === 0){
// clear all existing maps
mapModule.clearMapModule();

// no map data available -> show "new map" dialog
$(document).trigger('pf:menuShowMapSettings', {tab: 'new'});
}else{
Expand Down
23 changes: 23 additions & 0 deletions js/app/module_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,29 @@ define([
return deletedTabName;
};

/**
* clear all active maps
*/
$.fn.clearMapModule = function(){

var mapModuleElement = $(this);

var tabMapElement = $('#' + config.mapTabElementId);

if(tabMapElement.length > 0){
var tabElements = mapModuleElement.getMapTabElements();

for(var i = 0; i < tabElements.length; i++){
var tabElement = $(tabElements[i]);
var mapId = tabElement.data('map-id');

if(mapId > 0){
tabMapElement.deleteTab(mapId);
}
}
}
};

/**
* load/update map module into element (all maps)
* @param mapData
Expand Down
23 changes: 5 additions & 18 deletions js/app/ui/dialog/account_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,11 @@ define([
if(jqXHR.responseText){
var errorObj = $.parseJSON(jqXHR.responseText);

if(errorObj.text !== undefined){
// DB error

if(errorObj.text.match('Duplicate')){
// duplicate DB key

var fieldName = 'name';
if(errorObj.text.match( fieldName )){
// name exist
form.showFormMessage([{type: 'error', message: 'Username already exists', field: fieldName}]);
}

fieldName = 'email';
if(errorObj.text.match( fieldName )){
// email exist
form.showFormMessage([{type: 'error', message: 'Email already exists', field: fieldName}]);
}
}
if(
errorObj.error &&
errorObj.error.length > 0
){
form.showFormMessage(errorObj.error);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions js/app/ui/form_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ define([
}

var markup = '<div class="clearfix">';
markup += '<div class="col-sm-6 pf-select-item-anchor">' + data.text + '</div>';
markup += '<div class="col-sm-5 pf-select-item-anchor">' + data.text + '</div>';
markup += '<div class="col-sm-2 text-right ' + data.effectClass + '">';
markup += '<i class="fa fa-fw fa-square ' + hideEffectClass + '"></i>';
markup += '</div>';
markup += '<div class="col-sm-2 text-right ' + data.secClass + '">' + data.security + '</div>';
markup += '<div class="col-sm-2 text-right ' + data.trueSecClass + '">' + data.trueSec + '</div></div>';
markup += '<div class="col-sm-3 text-right ' + data.trueSecClass + '">' + data.trueSec + '</div></div>';

return markup;
}
Expand Down
Loading

0 comments on commit 633b817

Please sign in to comment.