Skip to content

Commit

Permalink
first login fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Praesidiarius committed Mar 15, 2020
1 parent 988f08e commit 4695eda
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "onePlace User Module",
"type": "oneplace-module",
"license": "BSD-3-Clause",
"version": "1.0.22",
"version": "1.0.23",
"keywords": [
"laminas",
"mvc",
Expand Down
61 changes: 61 additions & 0 deletions src/Controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,67 @@ public function loginAction()
}
}

# Check if it is first login
$aTabs = CoreController::$aCoreTables['form-tab']->select();
if(count($aTabs) == 0) {
$aBaseTabs = CoreController::$aCoreTables['core-form-tab']->select([]);
if(count($aBaseTabs) > 0) {
$iSortID = 0;
foreach($aBaseTabs as $oTab) {
CoreController::$aCoreTables['form-tab']->insert([
'user_idfs' => $oUser->getID(),
'tab_idfs' => $oTab->Tab_ID,
'sort_id' => $iSortID,
]);
$iSortID++;
}
}
}

# Check if it is first login
$aFields = CoreController::$aCoreTables['form-field']->select();
if(count($aFields) == 0) {
$aBaseFields = CoreController::$aCoreTables['core-form-field']->select([]);
if(count($aBaseFields) > 0) {
$iSortID = 0;
foreach($aBaseFields as $oField) {
CoreController::$aCoreTables['form-field']->insert([
'user_idfs' => $oUser->getID(),
'field_idfs' => $oField->Field_ID,
'sort_id' => $iSortID,
]);
$iSortID++;
}
}
}

# Check if it is first login
$aList = CoreController::$aCoreTables['table-col']->select();
if(count($aFields) == 0) {
$aBaseLists = CoreController::$aCoreTables['table-index']->select();
if(count($aBaseLists) > 0) {
foreach($aBaseLists as $oList) {
$aListFields = CoreController::$aCoreTables['core-form-field']->select(['form' => $oList->form]);
if(count($aListFields) > 0) {
$iSortID = 0;
foreach($aListFields as $oListField) {
if($iSortID == 5) {
break;
}
CoreController::$aCoreTables['table-col']->insert([
'user_idfs' => $oUser->getID(),
'tbl_name' => $oList->table_name,
'field_idfs' => $oListField->Field_ID,
'sortID' => $iSortID,
'width' => 'col-m-2',
]);
$iSortID++;
}
}
}
}
}

# Add XP for successful login
$oUser->addXP('login');

Expand Down
2 changes: 1 addition & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Module
*
* @since 1.0.0
*/
const VERSION = '1.0.22';
const VERSION = '1.0.23';

/**
* Load module config file
Expand Down

0 comments on commit 4695eda

Please sign in to comment.