Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/nuance/storage/NuanceQueue.php
12256 views
1
<?php
2
3
final class NuanceQueue
4
extends NuanceDAO
5
implements
6
PhabricatorPolicyInterface,
7
PhabricatorApplicationTransactionInterface {
8
9
protected $name;
10
protected $mailKey;
11
protected $viewPolicy;
12
protected $editPolicy;
13
14
protected function getConfiguration() {
15
return array(
16
self::CONFIG_AUX_PHID => true,
17
self::CONFIG_COLUMN_SCHEMA => array(
18
'name' => 'text255?',
19
'mailKey' => 'bytes20',
20
),
21
) + parent::getConfiguration();
22
}
23
24
public function generatePHID() {
25
return PhabricatorPHID::generateNewPHID(
26
NuanceQueuePHIDType::TYPECONST);
27
}
28
29
public static function initializeNewQueue() {
30
return id(new self())
31
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
32
->setEditPolicy(PhabricatorPolicies::POLICY_USER);
33
}
34
35
public function save() {
36
if (!$this->getMailKey()) {
37
$this->setMailKey(Filesystem::readRandomCharacters(20));
38
}
39
return parent::save();
40
}
41
42
public function getURI() {
43
return '/nuance/queue/view/'.$this->getID().'/';
44
}
45
46
public function getWorkURI() {
47
return '/nuance/queue/work/'.$this->getID().'/';
48
}
49
50
51
/* -( PhabricatorPolicyInterface )----------------------------------------- */
52
53
54
public function getCapabilities() {
55
return array(
56
PhabricatorPolicyCapability::CAN_VIEW,
57
PhabricatorPolicyCapability::CAN_EDIT,
58
);
59
}
60
61
public function getPolicy($capability) {
62
switch ($capability) {
63
case PhabricatorPolicyCapability::CAN_VIEW:
64
return $this->getViewPolicy();
65
case PhabricatorPolicyCapability::CAN_EDIT:
66
return $this->getEditPolicy();
67
}
68
}
69
70
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
71
return false;
72
}
73
74
75
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
76
77
78
public function getApplicationTransactionEditor() {
79
return new NuanceQueueEditor();
80
}
81
82
public function getApplicationTransactionTemplate() {
83
return new NuanceQueueTransaction();
84
}
85
86
}
87
88