You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The purpose of this is twofold:
* Allow players to navigate their main/multi accounts without
having to log in and out.
* Synchronize things between the two accounts when it doesn't
make sense to have two values (i.e. e-mail address, user
preferences, bans, etc.).
Add a new table `account_link_login`, which associates a `login_id`
(the new primary key replacing `account_id` in the `account` table)
with an `account_id` (the primary key of `account_link_login`).
Each "login" (`account`) can be associated with multiple "accounts"
(`account_link_login`).
This is a little confusing, since ideally the `account` table would
be renamed `login` (or similar), but we are probably a bit too heavily
invested in the original infrastructure to completely change it now.
We provide a way on the "Play Game" page to switch to/create multis,
including an option to link an existing account as a multi.
Adds two helper methods to SmrAccount:
* getLinkedAccountList - finds all accounts associated with login
* getLinkedAccount - returns an account if it is associated with login
* Return an array of account_ids associated with this login.
1315
+
* We assume that each login has only MAX_LINKED_ACCOUNTS accounts and
1316
+
* that the smallest ID (created first) is the primary account_id.
1317
+
*/
1318
+
publicfunctiongetLinkedAccountList() {
1319
+
$this->db->query('SELECT account_id FROM account_link_login WHERE login_id='.$this->db->escapeNumber($this->getLoginID()).' ORDER BY account_id ASC LIMIT '.$this->db->escapeNumber(self::MAX_LINKED_ACCOUNTS));
1320
+
$result = array();
1321
+
while ($this->db->nextRecord()) {
1322
+
$name = count($result) == 0 ? 'Main' : 'Multi';
1323
+
$result[$this->db->getInt('account_id')] = $name;
1324
+
}
1325
+
return$result;
1326
+
}
1327
+
1328
+
/**
1329
+
* Returns another account that is linked to this login.
1330
+
*/
1331
+
publicfunctiongetLinkedAccount($accountID) {
1332
+
if ($accountID == $this->getAccountID()) {
1333
+
return$this;
1334
+
}
1335
+
$linkedAccounts = $this->getLinkedAccountList();
1336
+
if (isset($linkedAccounts[$accountID])) {
1337
+
return$this::getAccount($accountID);
1338
+
} else {
1339
+
thrownewException('No linked account with ID: ' . $accountID);
0 commit comments