public function buildCustomEditFields(PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { $viewer = $engine->getViewer(); $editor = $object->getApplicationTransactionEditor(); $types = $editor->getTransactionTypesForObject($object); $types = array_fuse($types); $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($object)->execute(); $map = array(PhabricatorTransactions::TYPE_VIEW_POLICY => array('key' => 'policy.view', 'aliases' => array('view'), 'capability' => PhabricatorPolicyCapability::CAN_VIEW, 'label' => pht('View Policy'), 'description' => pht('Controls who can view the object.'), 'edit' => 'view'), PhabricatorTransactions::TYPE_EDIT_POLICY => array('key' => 'policy.edit', 'aliases' => array('edit'), 'capability' => PhabricatorPolicyCapability::CAN_EDIT, 'label' => pht('Edit Policy'), 'description' => pht('Controls who can edit the object.'), 'edit' => 'edit'), PhabricatorTransactions::TYPE_JOIN_POLICY => array('key' => 'policy.join', 'aliases' => array('join'), 'capability' => PhabricatorPolicyCapability::CAN_JOIN, 'label' => pht('Join Policy'), 'description' => pht('Controls who can join the object.'), 'edit' => 'join')); $fields = array(); foreach ($map as $type => $spec) { if (empty($types[$type])) { continue; } $capability = $spec['capability']; $key = $spec['key']; $aliases = $spec['aliases']; $label = $spec['label']; $description = $spec['description']; $edit = $spec['edit']; $policy_field = id(new PhabricatorPolicyEditField())->setKey($key)->setLabel($label)->setDescription($description)->setAliases($aliases)->setIsCopyable(true)->setCapability($capability)->setPolicies($policies)->setTransactionType($type)->setEditTypeKey($edit)->setValue($object->getPolicy($capability)); $fields[] = $policy_field; if (!$object instanceof PhabricatorSpacesInterface) { if ($capability == PhabricatorPolicyCapability::CAN_VIEW) { $type_space = PhabricatorTransactions::TYPE_SPACE; if (isset($types[$type_space])) { $space_field = id(new PhabricatorSpaceEditField())->setKey('spacePHID')->setLabel(pht('Space'))->setEditTypeKey('space')->setDescription(pht('Shifts the object in the Spaces application.'))->setIsCopyable(true)->setIsReorderable(false)->setAliases(array('space', 'policy.space'))->setTransactionType($type_space)->setValue($object->getSpacePHID()); $fields[] = $space_field; $policy_field->setSpaceField($space_field); } } } } return $fields; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $subscriber_phids = id(new PhabricatorObjectListQuery())->setViewer($viewer)->setAllowedTypes(array(PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorProjectProjectPHIDType::TYPECONST))->setObjectList(implode(' ', $argv))->setAllowPartialResults(true)->execute(); $xactions = array(); $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('+' => array_fuse($subscriber_phids))); return $xactions; }
/** * Build and configure an Editor to publish these transactions. */ private function buildEditor(PhabricatorApplicationTransactionInterface $object) { $data = $this->getTaskData(); $daemon_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_DAEMON, array()); $viewer = PhabricatorUser::getOmnipotentUser(); $editor = $object->getApplicationTransactionEditor()->setActor($viewer)->setContentSource($daemon_source)->setActingAsPHID(idx($data, 'actorPHID'))->loadWorkerState(idx($data, 'state', array())); return $editor; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $project_phids = id(new PhabricatorObjectListQuery())->setViewer($viewer)->setAllowedTypes(array(PhabricatorProjectProjectPHIDType::TYPECONST))->setObjectList(implode(' ', $argv))->setAllowPartialResults(true)->execute(); $xactions = array(); $type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_project)->setNewValue(array('+' => array_fuse($project_phids))); return $xactions; }
public function supportsObject(PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { $xaction = $object->getApplicationTransactionTemplate(); try { $comment = $xaction->getApplicationTransactionCommentObject(); } catch (PhutilMethodNotImplementedException $ex) { $comment = null; } return (bool) $comment; }
public function buildCustomEditFields(PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { $subscribers_type = PhabricatorTransactions::TYPE_SUBSCRIBERS; $object_phid = $object->getPHID(); if ($object_phid) { $sub_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($object_phid); } else { $sub_phids = array(); } $subscribers_field = id(new PhabricatorSubscribersEditField())->setKey('subscriberPHIDs')->setLabel(pht('Subscribers'))->setEditTypeKey('subscribers')->setDescription(pht('Manage subscribers.'))->setAliases(array('subscriber', 'subscribers'))->setIsCopyable(true)->setUseEdgeTransactions(true)->setEdgeTransactionDescriptions(pht('Add subscribers.'), pht('Remove subscribers.'), pht('Set subscribers, overwriting current value.'))->setCommentActionLabel(pht('Change Subscribers'))->setTransactionType($subscribers_type)->setValue($sub_phids); return array($subscribers_field); }
public function buildCustomEditFields(PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { $edge_type = PhabricatorTransactions::TYPE_EDGE; $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $object_phid = $object->getPHID(); if ($object_phid) { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($object_phid, $project_edge_type); $project_phids = array_reverse($project_phids); } else { $project_phids = array(); } $projects_field = id(new PhabricatorProjectsEditField())->setKey('projectPHIDs')->setLabel(pht('Projects'))->setEditTypeKey('projects')->setDescription(pht('Add or remove associated projects.'))->setAliases(array('project', 'projects'))->setIsCopyable(true)->setUseEdgeTransactions(true)->setEdgeTransactionDescriptions(pht('Add projects.'), pht('Remove projects.'), pht('Set associated projects, overwriting current value.'))->setCommentActionLabel(pht('Change Projects'))->setTransactionType($edge_type)->setMetadataValue('edge:type', $project_edge_type)->setValue($project_phids); return array($projects_field); }
public static final function newQueryForObject(PhabricatorApplicationTransactionInterface $object) { $xaction = $object->getApplicationTransactionTemplate(); $target_class = get_class($xaction); $queries = id(new PhutilClassMapQuery())->setAncestorClass(__CLASS__)->execute(); foreach ($queries as $query) { $query_xaction = $query->getTemplateApplicationTransaction(); $query_class = get_class($query_xaction); if ($query_class === $target_class) { return id(clone $query); } } return null; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $xactions = array(); $assign_to = head($argv); if ($assign_to) { $assign_user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withUsernames(array($assign_to))->executeOne(); if ($assign_user) { $assign_phid = $assign_user->getPHID(); } } // Treat bad "!assign" like "!claim". if (!$assign_phid) { $assign_phid = $viewer->getPHID(); } $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(ManiphestTransaction::TYPE_OWNER)->setNewValue($assign_phid); return $xactions; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $target = phutil_utf8_strtolower(implode(' ', $argv)); $yes_values = $this->getYesValues(); $no_values = $this->getNoValues(); if (in_array($target, $yes_values)) { $rsvp = PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE; } else { if (in_array($target, $no_values)) { $rsvp = PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE; } else { return array(); } } $xactions = array(); $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType($rsvp)->setNewValue(true); return $xactions; }
public function buildCustomEditFields(PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { $edge_type = PhabricatorTransactions::TYPE_EDGE; $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $object_phid = $object->getPHID(); if ($object_phid) { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($object_phid, $project_edge_type); $project_phids = array_reverse($project_phids); } else { $project_phids = array(); } $projects_field = id(new PhabricatorProjectsEditField())->setKey('projectPHIDs')->setLabel(pht('Tags'))->setEditTypeKey('projects')->setAliases(array('project', 'projects', 'tag', 'tags'))->setIsCopyable(true)->setUseEdgeTransactions(true)->setCommentActionLabel(pht('Change Project Tags'))->setCommentActionOrder(8000)->setDescription(pht('Select project tags for the object.'))->setTransactionType($edge_type)->setMetadataValue('edge:type', $project_edge_type)->setValue($project_phids); $projects_field->setViewer($engine->getViewer()); $edit_add = $projects_field->getConduitEditType('projects.add')->setConduitDescription(pht('Add project tags.')); $edit_set = $projects_field->getConduitEditType('projects.set')->setConduitDescription(pht('Set project tags, overwriting current value.')); $edit_rem = $projects_field->getConduitEditType('projects.remove')->setConduitDescription(pht('Remove project tags.')); return array($projects_field); }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $xactions = array(); $target = phutil_utf8_strtolower(head($argv)); $priority = null; $keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap(); foreach ($keywords as $key => $words) { foreach ($words as $word) { if ($word == $target) { $priority = $key; break; } } } if ($priority === null) { return array(); } $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)->setNewValue($priority); return $xactions; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING; $status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED; $xactions = array(); $target = phutil_utf8_strtolower(implode(' ', $argv)); $rsvp = null; $yes_values = $this->getYesValues(); $no_values = $this->getNoValues(); if (in_array($target, $yes_values)) { $rsvp = $status_attending; } else { if (in_array($target, $no_values)) { $rsvp = $status_declined; } else { $rsvp = null; } } if ($rsvp === null) { return array(); } $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(PhabricatorCalendarEventTransaction::TYPE_INVITE)->setNewValue(array($viewer->getPHID() => $rsvp)); return $xactions; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $xactions = array(); $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(DifferentialTransaction::TYPE_ACTION)->setNewValue($this->getAction()); return $xactions; }
protected function buildTransactionTimeline(PhabricatorApplicationTransactionInterface $object, PhabricatorApplicationTransactionQuery $query, PhabricatorMarkupEngine $engine = null, $render_data = array()) { $viewer = $this->getRequest()->getUser(); $xaction = $object->getApplicationTransactionTemplate(); $view = $xaction->getApplicationTransactionViewObject(); $pager = id(new AphrontCursorPagerView())->readFromRequest($this->getRequest())->setURI(new PhutilURI('/transactions/showolder/' . $object->getPHID() . '/')); $xactions = $query->setViewer($viewer)->withObjectPHIDs(array($object->getPHID()))->needComments(true)->executeWithCursorPager($pager); $xactions = array_reverse($xactions); if ($engine) { foreach ($xactions as $xaction) { if ($xaction->getComment()) { $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); } } $engine->process(); $view->setMarkupEngine($engine); } $timeline = $view->setUser($viewer)->setObjectPHID($object->getPHID())->setTransactions($xactions)->setPager($pager)->setRenderData($render_data)->setQuoteTargetID($this->getRequest()->getStr('quoteTargetID'))->setQuoteRef($this->getRequest()->getStr('quoteRef')); $object->willRenderTimeline($timeline, $this->getRequest()); return $timeline; }
public function getXactionsforColumn(PhabricatorApplicationTransactionInterface $column) { $xactions = $this->xquery->setViewer($this->viewer)->withObjectPHIDs(array($column->getPHID()))->needComments(true)->setReversePaging(false)->execute(); $xactions = array_reverse($xactions); return $xactions; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $xactions = array(); $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(ManiphestTransaction::TYPE_STATUS)->setNewValue(ManiphestTaskStatus::getDefaultClosedStatus()); return $xactions; }
public function buildTransactions(PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $xactions = array(); $xactions[] = $object->getApplicationTransactionTemplate()->setTransactionType(ManiphestTransaction::TYPE_OWNER)->setNewValue($viewer->getPHID()); return $xactions; }