Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/storage/PhabricatorDashboardPortal.php
12242 views
1
<?php
2
3
final class PhabricatorDashboardPortal
4
extends PhabricatorDashboardDAO
5
implements
6
PhabricatorApplicationTransactionInterface,
7
PhabricatorPolicyInterface,
8
PhabricatorDestructibleInterface,
9
PhabricatorProjectInterface,
10
PhabricatorFulltextInterface,
11
PhabricatorFerretInterface {
12
13
protected $name;
14
protected $viewPolicy;
15
protected $editPolicy;
16
protected $status;
17
protected $properties = array();
18
19
public static function initializeNewPortal() {
20
return id(new self())
21
->setName('')
22
->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())
23
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
24
->setStatus(PhabricatorDashboardPortalStatus::STATUS_ACTIVE);
25
}
26
27
protected function getConfiguration() {
28
return array(
29
self::CONFIG_AUX_PHID => true,
30
self::CONFIG_SERIALIZATION => array(
31
'properties' => self::SERIALIZATION_JSON,
32
),
33
self::CONFIG_COLUMN_SCHEMA => array(
34
'name' => 'text255',
35
'status' => 'text32',
36
),
37
) + parent::getConfiguration();
38
}
39
40
public function getPHIDType() {
41
return PhabricatorDashboardPortalPHIDType::TYPECONST;
42
}
43
44
public function getPortalProperty($key, $default = null) {
45
return idx($this->properties, $key, $default);
46
}
47
48
public function setPortalProperty($key, $value) {
49
$this->properties[$key] = $value;
50
return $this;
51
}
52
53
public function getObjectName() {
54
return pht('Portal %d', $this->getID());
55
}
56
57
public function getURI() {
58
return '/portal/view/'.$this->getID().'/';
59
}
60
61
public function isArchived() {
62
$status_archived = PhabricatorDashboardPortalStatus::STATUS_ARCHIVED;
63
return ($this->getStatus() === $status_archived);
64
}
65
66
67
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
68
69
70
public function getApplicationTransactionEditor() {
71
return new PhabricatorDashboardPortalEditor();
72
}
73
74
public function getApplicationTransactionTemplate() {
75
return new PhabricatorDashboardPortalTransaction();
76
}
77
78
79
/* -( PhabricatorPolicyInterface )----------------------------------------- */
80
81
82
public function getCapabilities() {
83
return array(
84
PhabricatorPolicyCapability::CAN_VIEW,
85
PhabricatorPolicyCapability::CAN_EDIT,
86
);
87
}
88
89
public function getPolicy($capability) {
90
switch ($capability) {
91
case PhabricatorPolicyCapability::CAN_VIEW:
92
return $this->getViewPolicy();
93
case PhabricatorPolicyCapability::CAN_EDIT:
94
return $this->getEditPolicy();
95
}
96
}
97
98
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
99
return false;
100
}
101
102
103
/* -( PhabricatorDestructibleInterface )----------------------------------- */
104
105
106
public function destroyObjectPermanently(
107
PhabricatorDestructionEngine $engine) {
108
$this->delete();
109
}
110
111
/* -( PhabricatorFulltextInterface )--------------------------------------- */
112
113
public function newFulltextEngine() {
114
return new PhabricatorDashboardPortalFulltextEngine();
115
}
116
117
/* -( PhabricatorFerretInterface )----------------------------------------- */
118
119
public function newFerretEngine() {
120
return new PhabricatorDashboardPortalFerretEngine();
121
}
122
123
}
124
125