Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F115451069
PonderAnswerEditor.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jun 1, 02:32
Size
3 KB
Mime Type
text/x-php
Expires
Tue, Jun 3, 02:32 (2 d)
Engine
blob
Format
Raw Data
Handle
26492118
Attached To
rPH Phabricator
PonderAnswerEditor.php
View Options
<?php
final
class
PonderAnswerEditor
extends
PonderEditor
{
public
function
getEditorObjectsDescription
()
{
return
pht
(
'Ponder Answers'
);
}
public
function
getTransactionTypes
()
{
$types
=
parent
::
getTransactionTypes
();
$types
[]
=
PhabricatorTransactions
::
TYPE_COMMENT
;
$types
[]
=
PonderAnswerTransaction
::
TYPE_CONTENT
;
$types
[]
=
PonderAnswerTransaction
::
TYPE_QUESTION_ID
;
return
$types
;
}
protected
function
getCustomTransactionOldValue
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PonderAnswerTransaction
::
TYPE_CONTENT
:
return
$object
->
getContent
();
case
PonderAnswerTransaction
::
TYPE_QUESTION_ID
:
return
$object
->
getQuestionID
();
}
}
protected
function
getCustomTransactionNewValue
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PonderAnswerTransaction
::
TYPE_CONTENT
:
case
PonderAnswerTransaction
::
TYPE_QUESTION_ID
:
return
$xaction
->
getNewValue
();
}
}
protected
function
applyCustomInternalTransaction
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
PonderAnswerTransaction
::
TYPE_CONTENT
:
$object
->
setContent
(
$xaction
->
getNewValue
());
break
;
case
PonderAnswerTransaction
::
TYPE_QUESTION_ID
:
$object
->
setQuestionID
(
$xaction
->
getNewValue
());
break
;
}
}
protected
function
applyCustomExternalTransaction
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
return
;
}
protected
function
mergeTransactions
(
PhabricatorApplicationTransaction
$u
,
PhabricatorApplicationTransaction
$v
)
{
$type
=
$u
->
getTransactionType
();
switch
(
$type
)
{
case
PonderAnswerTransaction
::
TYPE_CONTENT
:
return
$v
;
}
return
parent
::
mergeTransactions
(
$u
,
$v
);
}
protected
function
shouldSendMail
(
PhabricatorLiskDAO
$object
,
array
$xactions
)
{
return
true
;
}
protected
function
buildReplyHandler
(
PhabricatorLiskDAO
$object
)
{
$question
=
$object
->
getQuestion
();
return
id
(
new
PonderQuestionReplyHandler
())
->
setMailReceiver
(
$question
);
}
protected
function
buildMailTemplate
(
PhabricatorLiskDAO
$object
)
{
$question
=
$object
->
getQuestion
();
return
parent
::
buildMailTemplate
(
$question
);
}
protected
function
buildMailBody
(
PhabricatorLiskDAO
$object
,
array
$xactions
)
{
$body
=
parent
::
buildMailBody
(
$object
,
$xactions
);
// If the user just gave the answer, add the answer text.
foreach
(
$xactions
as
$xaction
)
{
$type
=
$xaction
->
getTransactionType
();
$new
=
$xaction
->
getNewValue
();
if
(
$type
==
PonderAnswerTransaction
::
TYPE_CONTENT
)
{
$body
->
addRawSection
(
$new
);
}
}
$body
->
addLinkSection
(
pht
(
'ANSWER DETAIL'
),
PhabricatorEnv
::
getProductionURI
(
$object
->
getURI
()));
return
$body
;
}
}
Event Timeline
Log In to Comment