Skip to content

Commit e3062db

Browse files
committed
[WIP] Domain log archives
1 parent 452efc5 commit e3062db

3 files changed

Lines changed: 375 additions & 0 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
namespace Claroline\LogBundle\Entity\Archive;
4+
5+
use Claroline\LogBundle\Entity\AbstractLog;
6+
use Claroline\LogBundle\Entity\FunctionalLog;
7+
use Doctrine\ORM\Mapping as ORM;
8+
9+
/**
10+
* @ORM\Entity
11+
* @ORM\Table(null)
12+
*/
13+
class FunctionalLogArchive extends AbstractLog
14+
{
15+
/**
16+
* @var string|null
17+
* @ORM\Column(type="int", nullable=true)
18+
*/
19+
private $userId;
20+
21+
/**
22+
* @var string|null
23+
* @ORM\Column(type="string", nullable=true)
24+
*/
25+
private $userUuid;
26+
27+
/**
28+
* @var string|null
29+
* @ORM\Column(type="string", nullable=true)
30+
*/
31+
private $userUsername;
32+
33+
/**
34+
* @var string|null
35+
* @ORM\Column(type="string", nullable=true)
36+
*/
37+
private $workspaceUuid;
38+
39+
/**
40+
* @var string|null
41+
* @ORM\Column(type="string", nullable=true)
42+
*/
43+
private $resourceUuid;
44+
45+
public static function fromFunctionalLog(FunctionalLog $functionalLog)
46+
{
47+
$user = $functionalLog->getUser();
48+
$workspace = $functionalLog->getWorkspace();
49+
$resource = $functionalLog->getResource();
50+
51+
$archive = new self();
52+
$archive->setUserId($user->getId());
53+
$archive->setUserUuid($user->getUuid());
54+
$archive->setUserUsername($user->getUsername());
55+
$archive->setResourceUuid($resource ? $resource->getUuid() : null);
56+
$archive->setWorkspaceUuid($workspace ? $workspace->getUuid() : null);
57+
58+
$archive->setDate($functionalLog->getDate());
59+
$archive->setDetails($functionalLog->getDetails());
60+
$archive->setEvent($functionalLog->getEvent());
61+
62+
return $archive;
63+
}
64+
65+
public function getUserId(): ?int
66+
{
67+
return $this->userId;
68+
}
69+
70+
public function setUserId(?int $userId): void
71+
{
72+
$this->userId = $userId;
73+
}
74+
75+
public function getUserUuid(): ?string
76+
{
77+
return $this->userUuid;
78+
}
79+
80+
public function setUserUuid(?string $userUuid): void
81+
{
82+
$this->userUuid = $userUuid;
83+
}
84+
85+
public function getUserUsername(): ?string
86+
{
87+
return $this->userUsername;
88+
}
89+
90+
public function setUserUsername(?string $userUsername): void
91+
{
92+
$this->userUsername = $userUsername;
93+
}
94+
95+
public function getWorkspaceUuid(): ?string
96+
{
97+
return $this->workspaceUuid;
98+
}
99+
100+
public function setWorkspaceUuid(?string $workspaceUuid): void
101+
{
102+
$this->workspaceUuid = $workspaceUuid;
103+
}
104+
105+
public function getResourceUuid(): ?string
106+
{
107+
return $this->resourceUuid;
108+
}
109+
110+
public function setResourceUuid(?string $resourceUuid): void
111+
{
112+
$this->resourceUuid = $resourceUuid;
113+
}
114+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
namespace Claroline\LogBundle\Entity\Archive;
4+
5+
use Claroline\LogBundle\Entity\AbstractLog;
6+
use Claroline\LogBundle\Entity\MessageLog;
7+
use Doctrine\ORM\Mapping as ORM;
8+
9+
/**
10+
* @ORM\Entity
11+
* @ORM\Table(null)
12+
*/
13+
class MessageLogArchive extends AbstractLog
14+
{
15+
/**
16+
* @var int|null
17+
* @ORM\Column(type="integer", nullable=true)
18+
*/
19+
private $senderId;
20+
21+
/**
22+
* @var string|null
23+
* @ORM\Column(type="string", nullable=true)
24+
*/
25+
private $senderUuid;
26+
27+
/**
28+
* @var string|null
29+
* @ORM\Column(type="string", nullable=true)
30+
*/
31+
private $senderUsername;
32+
33+
/**
34+
* @var int|null
35+
* @ORM\Column(type="integer", nullable=true)
36+
*/
37+
private $receiverId;
38+
39+
/**
40+
* @var string|null
41+
* @ORM\Column(type="string", nullable=true)
42+
*/
43+
private $receiverUuid;
44+
45+
/**
46+
* @var string|null
47+
* @ORM\Column(type="string")
48+
*/
49+
private $receiverUsername;
50+
51+
public static function fromMessageLog(MessageLog $messageLog)
52+
{
53+
$sender = $messageLog->getSender();
54+
$receiver = $messageLog->getReceiver();
55+
56+
$archive = new self();
57+
$archive->setDate($messageLog->getDate());
58+
$archive->setDetails($messageLog->getDetails());
59+
$archive->setEvent($messageLog->getEvent());
60+
$archive->setSenderId($sender->getId());
61+
$archive->setSenderUuid($sender->getUuid());
62+
$archive->setSenderUsername($sender->getUsername());
63+
$archive->setReceiverId($receiver->getId());
64+
$archive->setReceiverUuid($receiver->getUuid());
65+
$archive->setReceiverUsername($receiver->getUsername());
66+
67+
return $archive;
68+
}
69+
70+
public function getSenderId(): ?int
71+
{
72+
return $this->senderId;
73+
}
74+
75+
public function setSenderId(?int $senderId): void
76+
{
77+
$this->senderId = $senderId;
78+
}
79+
80+
public function getSenderUuid(): ?string
81+
{
82+
return $this->senderUuid;
83+
}
84+
85+
public function setSenderUuid(?string $senderUuid): void
86+
{
87+
$this->senderUuid = $senderUuid;
88+
}
89+
90+
public function getSenderUsername(): ?string
91+
{
92+
return $this->senderUsername;
93+
}
94+
95+
public function setSenderUsername(?string $senderUsername): void
96+
{
97+
$this->senderUsername = $senderUsername;
98+
}
99+
100+
public function getReceiverId(): ?int
101+
{
102+
return $this->receiverId;
103+
}
104+
105+
public function setReceiverId(?int $receiverId): void
106+
{
107+
$this->receiverId = $receiverId;
108+
}
109+
110+
public function getReceiverUuid(): ?string
111+
{
112+
return $this->receiverUuid;
113+
}
114+
115+
public function setReceiverUuid(?string $receiverUuid): void
116+
{
117+
$this->receiverUuid = $receiverUuid;
118+
}
119+
120+
public function getReceiverUsername(): ?string
121+
{
122+
return $this->receiverUsername;
123+
}
124+
125+
public function setReceiverUsername(?string $receiverUsername): void
126+
{
127+
$this->receiverUsername = $receiverUsername;
128+
}
129+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
namespace Claroline\LogBundle\Entity\Archive;
4+
5+
use Claroline\LogBundle\Entity\AbstractLog;
6+
use Claroline\LogBundle\Entity\SecurityLog;
7+
use Doctrine\ORM\Mapping as ORM;
8+
9+
/**
10+
* @ORM\Entity
11+
* @ORM\Table(null)
12+
*/
13+
class SecurityLogArchive extends AbstractLog
14+
{
15+
/**
16+
* @var int|null
17+
* @ORM\Column(type="integer", nullable=true)
18+
*/
19+
private $doerId;
20+
21+
/**
22+
* @var string|null
23+
* @ORM\Column(type="string", nullable=true)
24+
*/
25+
private $doerUuid;
26+
27+
/**
28+
* @var string|null
29+
* @ORM\Column(type="string", nullable=true)
30+
*/
31+
private $doerUsername;
32+
33+
/**
34+
* @var string|null
35+
* @ORM\Column(type="string", nullable=true)
36+
*/
37+
private $doerIp;
38+
39+
/**
40+
* @var string|null
41+
* @ORM\Column(type="string", nullable=true)
42+
*/
43+
private $doerCountry;
44+
45+
/**
46+
* @var string|null
47+
* @ORM\Column(type="string", nullable=true)
48+
*/
49+
private $doerCity;
50+
51+
public static function fromSecurityLog(SecurityLog $securityLog): self
52+
{
53+
$doer = $securityLog->getDoer();
54+
55+
$archive = new self();
56+
$archive->setEvent($securityLog->getEvent());
57+
$archive->setDetails($securityLog->getDetails());
58+
$archive->setDate($securityLog->getDate());
59+
60+
if ($doer) {
61+
$archive->setDoerId($doer->getId());
62+
$archive->setDoerUuid($doer->getUuid());
63+
$archive->setDoerUsername($doer->getUsername());
64+
}
65+
66+
$archive->setDoerIp($securityLog->getDoerIp());
67+
$archive->setDoerCountry($securityLog->getCountry());
68+
$archive->setDoerCity($securityLog->getCity());
69+
70+
return $archive;
71+
}
72+
73+
public function getDoerId(): ?int
74+
{
75+
return $this->doerId;
76+
}
77+
78+
public function setDoerId(?int $doerId): void
79+
{
80+
$this->doerId = $doerId;
81+
}
82+
83+
public function getDoerUuid(): ?string
84+
{
85+
return $this->doerUuid;
86+
}
87+
88+
public function setDoerUuid(?string $doerUuid): void
89+
{
90+
$this->doerUuid = $doerUuid;
91+
}
92+
93+
public function getDoerUsername(): string
94+
{
95+
return $this->doerUsername;
96+
}
97+
98+
public function setDoerUsername(?string $doerUsername): void
99+
{
100+
$this->doerUsername = $doerUsername;
101+
}
102+
103+
public function getDoerIp(): ?string
104+
{
105+
return $this->doerIp;
106+
}
107+
108+
public function setDoerIp(?string $doerIp): void
109+
{
110+
$this->doerIp = $doerIp;
111+
}
112+
113+
public function getDoerCountry(): ?string
114+
{
115+
return $this->doerCountry;
116+
}
117+
118+
public function setDoerCountry(?string $doerCountry): void
119+
{
120+
$this->doerCountry = $doerCountry;
121+
}
122+
123+
public function getDoerCity(): ?string
124+
{
125+
return $this->doerCity;
126+
}
127+
128+
public function setDoerCity(?string $doerCity): void
129+
{
130+
$this->doerCity = $doerCity;
131+
}
132+
}

0 commit comments

Comments
 (0)