Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/editor/PonderQuestionEditor.php
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public function getTransactionTypes() { | ||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; | $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; | ||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; | $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; | ||||
$types[] = PhabricatorTransactions::TYPE_SPACE; | $types[] = PhabricatorTransactions::TYPE_SPACE; | ||||
$types[] = PonderQuestionTransaction::TYPE_TITLE; | $types[] = PonderQuestionTransaction::TYPE_TITLE; | ||||
$types[] = PonderQuestionTransaction::TYPE_CONTENT; | $types[] = PonderQuestionTransaction::TYPE_CONTENT; | ||||
$types[] = PonderQuestionTransaction::TYPE_ANSWERS; | $types[] = PonderQuestionTransaction::TYPE_ANSWERS; | ||||
$types[] = PonderQuestionTransaction::TYPE_STATUS; | $types[] = PonderQuestionTransaction::TYPE_STATUS; | ||||
$types[] = PonderQuestionTransaction::TYPE_ANSWERWIKI; | |||||
return $types; | return $types; | ||||
} | } | ||||
protected function getCustomTransactionOldValue( | protected function getCustomTransactionOldValue( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
case PonderQuestionTransaction::TYPE_TITLE: | case PonderQuestionTransaction::TYPE_TITLE: | ||||
return $object->getTitle(); | return $object->getTitle(); | ||||
case PonderQuestionTransaction::TYPE_CONTENT: | case PonderQuestionTransaction::TYPE_CONTENT: | ||||
return $object->getContent(); | return $object->getContent(); | ||||
case PonderQuestionTransaction::TYPE_ANSWERS: | case PonderQuestionTransaction::TYPE_ANSWERS: | ||||
return mpull($object->getAnswers(), 'getPHID'); | return mpull($object->getAnswers(), 'getPHID'); | ||||
case PonderQuestionTransaction::TYPE_STATUS: | case PonderQuestionTransaction::TYPE_STATUS: | ||||
return $object->getStatus(); | return $object->getStatus(); | ||||
case PonderQuestionTransaction::TYPE_ANSWERWIKI: | |||||
return $object->getAnswerWiki(); | |||||
} | } | ||||
} | } | ||||
protected function getCustomTransactionNewValue( | protected function getCustomTransactionNewValue( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
case PonderQuestionTransaction::TYPE_TITLE: | case PonderQuestionTransaction::TYPE_TITLE: | ||||
case PonderQuestionTransaction::TYPE_CONTENT: | case PonderQuestionTransaction::TYPE_CONTENT: | ||||
case PonderQuestionTransaction::TYPE_STATUS: | case PonderQuestionTransaction::TYPE_STATUS: | ||||
case PonderQuestionTransaction::TYPE_ANSWERWIKI: | |||||
return $xaction->getNewValue(); | return $xaction->getNewValue(); | ||||
case PonderQuestionTransaction::TYPE_ANSWERS: | case PonderQuestionTransaction::TYPE_ANSWERS: | ||||
$raw_new_value = $xaction->getNewValue(); | $raw_new_value = $xaction->getNewValue(); | ||||
$new_value = array(); | $new_value = array(); | ||||
foreach ($raw_new_value as $key => $answers) { | foreach ($raw_new_value as $key => $answers) { | ||||
$phids = array(); | $phids = array(); | ||||
foreach ($answers as $answer) { | foreach ($answers as $answer) { | ||||
$obj = idx($answer, 'answer'); | $obj = idx($answer, 'answer'); | ||||
Show All 18 Lines | switch ($xaction->getTransactionType()) { | ||||
$object->setTitle($xaction->getNewValue()); | $object->setTitle($xaction->getNewValue()); | ||||
break; | break; | ||||
case PonderQuestionTransaction::TYPE_CONTENT: | case PonderQuestionTransaction::TYPE_CONTENT: | ||||
$object->setContent($xaction->getNewValue()); | $object->setContent($xaction->getNewValue()); | ||||
break; | break; | ||||
case PonderQuestionTransaction::TYPE_STATUS: | case PonderQuestionTransaction::TYPE_STATUS: | ||||
$object->setStatus($xaction->getNewValue()); | $object->setStatus($xaction->getNewValue()); | ||||
break; | break; | ||||
case PonderQuestionTransaction::TYPE_ANSWERWIKI: | |||||
$object->setAnswerWiki($xaction->getNewValue()); | |||||
break; | |||||
case PonderQuestionTransaction::TYPE_ANSWERS: | case PonderQuestionTransaction::TYPE_ANSWERS: | ||||
$old = $xaction->getOldValue(); | $old = $xaction->getOldValue(); | ||||
$new = $xaction->getNewValue(); | $new = $xaction->getNewValue(); | ||||
$add = array_diff_key($new, $old); | $add = array_diff_key($new, $old); | ||||
$rem = array_diff_key($old, $new); | $rem = array_diff_key($old, $new); | ||||
$count = $object->getAnswerCount(); | $count = $object->getAnswerCount(); | ||||
Show All 15 Lines | protected function mergeTransactions( | ||||
PhabricatorApplicationTransaction $u, | PhabricatorApplicationTransaction $u, | ||||
PhabricatorApplicationTransaction $v) { | PhabricatorApplicationTransaction $v) { | ||||
$type = $u->getTransactionType(); | $type = $u->getTransactionType(); | ||||
switch ($type) { | switch ($type) { | ||||
case PonderQuestionTransaction::TYPE_TITLE: | case PonderQuestionTransaction::TYPE_TITLE: | ||||
case PonderQuestionTransaction::TYPE_CONTENT: | case PonderQuestionTransaction::TYPE_CONTENT: | ||||
case PonderQuestionTransaction::TYPE_STATUS: | case PonderQuestionTransaction::TYPE_STATUS: | ||||
case PonderQuestionTransaction::TYPE_ANSWERWIKI: | |||||
return $v; | return $v; | ||||
} | } | ||||
return parent::mergeTransactions($u, $v); | return parent::mergeTransactions($u, $v); | ||||
} | } | ||||
protected function supportsSearch() { | protected function supportsSearch() { | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |