Skip to content

Commit

Permalink
GH-230 Move effects to their own function
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Jul 3, 2022
1 parent 4660d8f commit 85e022c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 34 deletions.
1 change: 1 addition & 0 deletions modules/overview/_includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$includePath = $_EnginePath . 'modules/overview/';

include($includePath . './screens/FirstLogin/FirstLogin.screen.php');
include($includePath . './screens/FirstLogin/FirstLogin.utils.php');
include($includePath . './screens/FirstLogin/utils/effects/createUserDevLogDump.effect.php');
include($includePath . './screens/FirstLogin/utils/effects/handleProxyDetection.effect.php');
include($includePath . './screens/FirstLogin/utils/effects/handleReferralMultiAccountDetection.effect.php');
Expand Down
36 changes: 2 additions & 34 deletions modules/overview/screens/FirstLogin/FirstLogin.screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace UniEngine\Engine\Modules\Overview\Screens\FirstLogin;

use UniEngine\Engine\Modules\Overview;
use UniEngine\Engine\Modules\Overview\Screens\FirstLogin;

/**
* @param array $params
Expand All @@ -17,43 +17,11 @@ function render($props) {

includeLang('firstlogin');

// Run effects
Overview\Screens\FirstLogin\Utils\Effects\updateUserOnFirstLogin([
'userId' => $user['id'],
'currentTimestamp' => $currentTimestamp,
]);

if ($user['referred'] > 0) {
$referringUserWithTasksData = Overview\Screens\FirstLogin\Utils\Helpers\getReferrerTasksData([
'referredById' => $user['referred'],
]);

Overview\Screens\FirstLogin\Utils\Effects\triggerUserReferralTask([
'referringUserWithTasksData' => &$referringUserWithTasksData,
]);
Overview\Screens\FirstLogin\Utils\Effects\handleReferralMultiAccountDetection([
'user' => &$user,
'referredById' => $user['referred'],
'referringUserWithTasksData' => &$referringUserWithTasksData,
'currentTimestamp' => $currentTimestamp,
]);
}

// Check, if this IP is Proxy
Overview\Screens\FirstLogin\Utils\Effects\handleProxyDetection([
FirstLogin\runEffects([
'user' => &$user,
'currentTimestamp' => $currentTimestamp,
]);

// TODO: move this to utils
// Give Free ProAccount for 7 days
// doquery("INSERT INTO {{table}} VALUES (NULL, {$user['id']}, UNIX_TIMESTAMP(), 0, 0, 11, 0);", 'premium_free');

Overview\Screens\FirstLogin\Utils\Effects\createUserDevLogDump([
'userId' => $user['id'],
]);

// Render the screen
$_DontShowMenus = true;

$screenTitle = $_Lang['FirstLogin_Title'];
Expand Down
52 changes: 52 additions & 0 deletions modules/overview/screens/FirstLogin/FirstLogin.utils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace UniEngine\Engine\Modules\Overview\Screens\FirstLogin;

use UniEngine\Engine\Modules\Overview\Screens\FirstLogin;

/**
* @param array $params
* @param arrayRef $params['user']
* @param number $params['currentTimestamp']
*/
function runEffects($props) {
$user = &$props['user'];
$currentTimestamp = $props['currentTimestamp'];

FirstLogin\Utils\Effects\updateUserOnFirstLogin([
'userId' => $user['id'],
'currentTimestamp' => $currentTimestamp,
]);

if ($user['referred'] > 0) {
$referringUserWithTasksData = FirstLogin\Utils\Helpers\getReferrerTasksData([
'referredById' => $user['referred'],
]);

FirstLogin\Utils\Effects\triggerUserReferralTask([
'referringUserWithTasksData' => &$referringUserWithTasksData,
]);
FirstLogin\Utils\Effects\handleReferralMultiAccountDetection([
'user' => &$user,
'referredById' => $user['referred'],
'referringUserWithTasksData' => &$referringUserWithTasksData,
'currentTimestamp' => $currentTimestamp,
]);
}

// Check, if this IP is Proxy
FirstLogin\Utils\Effects\handleProxyDetection([
'user' => &$user,
'currentTimestamp' => $currentTimestamp,
]);

// TODO: move this to utils
// Give Free ProAccount for 7 days
// doquery("INSERT INTO {{table}} VALUES (NULL, {$user['id']}, UNIX_TIMESTAMP(), 0, 0, 11, 0);", 'premium_free');

FirstLogin\Utils\Effects\createUserDevLogDump([
'userId' => $user['id'],
]);
}

?>

0 comments on commit 85e022c

Please sign in to comment.