1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Contains class AccountStatus. |
4
|
|
|
* |
5
|
|
|
* PHP version 5.4 |
6
|
|
|
* |
7
|
|
|
* LICENSE: |
8
|
|
|
* This file is part of Yet Another Php Eve Api Library also know as Yapeal |
9
|
|
|
* which can be used to access the Eve Online API data and place it into a |
10
|
|
|
* database. |
11
|
|
|
* Copyright (C) 2016 Michael Cummings |
12
|
|
|
* |
13
|
|
|
* This program is free software: you can redistribute it and/or modify it |
14
|
|
|
* under the terms of the GNU Lesser General Public License as published by the |
15
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your |
16
|
|
|
* option) any later version. |
17
|
|
|
* |
18
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
19
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
21
|
|
|
* for more details. |
22
|
|
|
* |
23
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
24
|
|
|
* along with this program. If not, see |
25
|
|
|
* <http://www.gnu.org/licenses/>. |
26
|
|
|
* |
27
|
|
|
* You should be able to find a copy of this license in the LICENSE.md file. A |
28
|
|
|
* copy of the GNU GPL should also be available in the GNU-GPL.md file. |
29
|
|
|
* |
30
|
|
|
* @copyright 2016 Michael Cummings |
31
|
|
|
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL |
32
|
|
|
* @author Michael Cummings <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
namespace Yapeal\EveApi\Account; |
35
|
|
|
|
36
|
|
|
use Yapeal\Log\Logger; |
37
|
|
|
use Yapeal\Sql\PreserverTrait; |
38
|
|
|
use Yapeal\Xml\EveApiPreserverInterface; |
39
|
|
|
use Yapeal\Xml\EveApiReadWriteInterface; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Class AccountStatus |
43
|
|
|
*/ |
44
|
|
|
class AccountStatus extends AccountSection implements EveApiPreserverInterface |
45
|
|
|
{ |
46
|
|
|
use PreserverTrait; |
47
|
|
|
|
48
|
|
|
/** @noinspection MagicMethodsValidityInspection */ |
49
|
|
|
/** |
50
|
|
|
* Constructor |
51
|
|
|
*/ |
52
|
|
|
public function __construct() |
53
|
|
|
{ |
54
|
|
|
$this->mask = 33554432; |
55
|
|
|
$this->preserveTos = [ |
56
|
|
|
'preserveToAccountStatus', |
57
|
|
|
'preserveToMultiCharacterTraining', |
58
|
|
|
'preserveToOffers' |
59
|
|
|
]; |
60
|
|
|
} |
61
|
|
|
/** |
62
|
|
|
* @param EveApiReadWriteInterface $data |
63
|
|
|
* |
64
|
|
|
* @return self Fluent interface. |
65
|
|
|
* @throws \LogicException |
66
|
|
|
*/ |
67
|
|
|
protected function preserveToAccountStatus(EveApiReadWriteInterface $data) |
68
|
|
|
{ |
69
|
|
|
$tableName = 'accountAccountStatus'; |
70
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
71
|
|
|
$sql = $this->getCsq() |
72
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
73
|
|
|
$this->getYem() |
74
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, $sql); |
75
|
|
|
$this->getPdo() |
76
|
|
|
->exec($sql); |
77
|
|
|
$columnDefaults = [ |
78
|
|
|
'createDate' => '1970-01-01 00:00:01', |
79
|
|
|
'logonCount' => null, |
80
|
|
|
'logonMinutes' => null, |
81
|
|
|
'ownerID' => $ownerID, |
82
|
|
|
'paidUntil' => '1970-01-01 00:00:01' |
83
|
|
|
]; |
84
|
|
|
$xPath = '//result/child::*[not(*|@*|self::dataTime)]'; |
85
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
86
|
|
|
$this->valuesPreserveData($elements, $columnDefaults, $tableName); |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
/** |
90
|
|
|
* @param EveApiReadWriteInterface $data |
91
|
|
|
* |
92
|
|
|
* @return self Fluent interface. |
93
|
|
|
* @throws \LogicException |
94
|
|
|
*/ |
95
|
|
|
protected function preserveToMultiCharacterTraining(EveApiReadWriteInterface $data) |
96
|
|
|
{ |
97
|
|
|
$tableName = 'accountMultiCharacterTraining'; |
98
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
99
|
|
|
$sql = $this->getCsq() |
100
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
101
|
|
|
$this->getYem() |
102
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, $sql); |
103
|
|
|
$this->getPdo() |
104
|
|
|
->exec($sql); |
105
|
|
|
$columnDefaults = [ |
106
|
|
|
'ownerID' => $ownerID, |
107
|
|
|
'trainingEnd' => null |
108
|
|
|
]; |
109
|
|
|
$xPath = '//multiCharacterTraining/row'; |
110
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
111
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
/** |
115
|
|
|
* @param EveApiReadWriteInterface $data |
116
|
|
|
* |
117
|
|
|
* @return self Fluent interface. |
118
|
|
|
* @throws \LogicException |
119
|
|
|
*/ |
120
|
|
|
protected function preserveToOffers(EveApiReadWriteInterface $data) |
121
|
|
|
{ |
122
|
|
|
$tableName = 'accountOffers'; |
123
|
|
|
$ownerID = $this->extractOwnerID($data->getEveApiArguments()); |
124
|
|
|
$sql = $this->getCsq() |
125
|
|
|
->getDeleteFromTableWithOwnerID($tableName, $ownerID); |
126
|
|
|
$this->getYem() |
127
|
|
|
->triggerLogEvent('Yapeal.Log.log', Logger::DEBUG, $sql); |
128
|
|
|
$this->getPdo() |
129
|
|
|
->exec($sql); |
130
|
|
|
$columnDefaults = [ |
131
|
|
|
'keyID' => $ownerID, |
132
|
|
|
'offerID' => null, |
133
|
|
|
'offeredDate' => null, |
134
|
|
|
'from' => null, |
135
|
|
|
'to' => null, |
136
|
|
|
'ISK' => null |
137
|
|
|
]; |
138
|
|
|
$xPath = '//Offers/row'; |
139
|
|
|
$elements = (new \SimpleXMLElement($data->getEveApiXml()))->xpath($xPath); |
140
|
|
|
$this->attributePreserveData($elements, $columnDefaults, $tableName); |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|