Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/controller/PhabricatorPeopleLogViewController.php
12256 views
1
<?php
2
3
final class PhabricatorPeopleLogViewController
4
extends PhabricatorPeopleController {
5
6
public function shouldRequireAdmin() {
7
return false;
8
}
9
10
public function handleRequest(AphrontRequest $request) {
11
$viewer = $this->getViewer();
12
$id = $request->getURIData('id');
13
14
$log = id(new PhabricatorPeopleLogQuery())
15
->setViewer($viewer)
16
->withIDs(array($id))
17
->executeOne();
18
if (!$log) {
19
return new Aphront404Response();
20
}
21
22
$logs_uri = $this->getApplicationURI('logs/');
23
24
$crumbs = $this->buildApplicationCrumbs()
25
->addTextCrumb(pht('Activity Logs'), $logs_uri)
26
->addTextCrumb($log->getObjectName())
27
->setBorder(true);
28
29
$header = $this->buildHeaderView($log);
30
$properties = $this->buildPropertiesView($log);
31
32
$view = id(new PHUITwoColumnView())
33
->setHeader($header)
34
->addPropertySection(pht('Details'), $properties);
35
36
return $this->newPage()
37
->setCrumbs($crumbs)
38
->setTitle($log->getObjectName())
39
->appendChild($view);
40
}
41
42
private function buildHeaderView(PhabricatorUserLog $log) {
43
$viewer = $this->getViewer();
44
45
$view = id(new PHUIHeaderView())
46
->setViewer($viewer)
47
->setHeader($log->getObjectName());
48
49
return $view;
50
}
51
52
private function buildPropertiesView(PhabricatorUserLog $log) {
53
$viewer = $this->getViewer();
54
55
$view = id(new PHUIPropertyListView())
56
->setViewer($viewer);
57
58
$type_map = PhabricatorUserLogType::getAllLogTypes();
59
$type_map = mpull($type_map, 'getLogTypeName', 'getLogTypeKey');
60
61
$action = $log->getAction();
62
$type_name = idx($type_map, $action, $action);
63
64
$view->addProperty(pht('Event Type'), $type_name);
65
66
$view->addProperty(
67
pht('Event Date'),
68
phabricator_datetime($log->getDateCreated(), $viewer));
69
70
$actor_phid = $log->getActorPHID();
71
if ($actor_phid) {
72
$view->addProperty(
73
pht('Acting User'),
74
$viewer->renderHandle($actor_phid));
75
}
76
77
$user_phid = $log->getUserPHID();
78
if ($user_phid) {
79
$view->addProperty(
80
pht('Affected User'),
81
$viewer->renderHandle($user_phid));
82
}
83
84
$remote_address = $log->getRemoteAddressForViewer($viewer);
85
if ($remote_address !== null) {
86
$view->addProperty(pht('Remote Address'), $remote_address);
87
}
88
89
return $view;
90
}
91
92
}
93
94