Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/conpherence/conduit/ConpherenceCreateThreadConduitAPIMethod.php
12256 views
1
<?php
2
3
final class ConpherenceCreateThreadConduitAPIMethod
4
extends ConpherenceConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'conpherence.createthread';
8
}
9
10
public function getMethodDescription() {
11
return pht('Create a new conpherence thread.');
12
}
13
14
public function getMethodStatus() {
15
return self::METHOD_STATUS_FROZEN;
16
}
17
18
public function getMethodStatusDescription() {
19
return pht(
20
'This method is frozen and will eventually be deprecated. New code '.
21
'should use "conpherence.edit" instead.');
22
}
23
24
protected function defineParamTypes() {
25
return array(
26
'title' => 'required string',
27
'topic' => 'optional string',
28
'message' => 'optional string',
29
'participantPHIDs' => 'required list<phids>',
30
);
31
}
32
33
protected function defineReturnType() {
34
return 'nonempty dict';
35
}
36
37
protected function defineErrorTypes() {
38
return array(
39
'ERR_EMPTY_PARTICIPANT_PHIDS' => pht(
40
'You must specify participant phids.'),
41
'ERR_EMPTY_TITLE' => pht(
42
'You must specify a title.'),
43
);
44
}
45
46
protected function execute(ConduitAPIRequest $request) {
47
$participant_phids = $request->getValue('participantPHIDs', array());
48
$message = $request->getValue('message');
49
$title = $request->getValue('title');
50
$topic = $request->getValue('topic');
51
52
list($errors, $conpherence) = ConpherenceEditor::createThread(
53
$request->getUser(),
54
$participant_phids,
55
$title,
56
$message,
57
$request->newContentSource(),
58
$topic);
59
60
if ($errors) {
61
foreach ($errors as $error_code) {
62
switch ($error_code) {
63
case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
64
throw new ConduitException('ERR_EMPTY_PARTICIPANT_PHIDS');
65
break;
66
}
67
}
68
}
69
70
return array(
71
'conpherenceID' => $conpherence->getID(),
72
'conpherencePHID' => $conpherence->getPHID(),
73
'conpherenceURI' => $this->getConpherenceURI($conpherence),
74
);
75
}
76
77
}
78
79