protected function expandTransactions(PhabricatorLiskDAO $object, array $xactions)
 {
     $results = parent::expandTransactions($object, $xactions);
     $is_unassigned = $object->getOwnerPHID() === null;
     $any_assign = false;
     foreach ($xactions as $xaction) {
         if ($xaction->getTransactionType() == ManiphestTransaction::TYPE_OWNER) {
             $any_assign = true;
             break;
         }
     }
     $is_open = !$object->isClosed();
     $new_status = null;
     foreach ($xactions as $xaction) {
         switch ($xaction->getTransactionType()) {
             case ManiphestTransaction::TYPE_STATUS:
                 $new_status = $xaction->getNewValue();
                 break;
         }
     }
     if ($new_status === null) {
         $is_closing = false;
     } else {
         $is_closing = ManiphestTaskStatus::isClosedStatus($new_status);
     }
     // If the task is not assigned, not being assigned, currently open, and
     // being closed, try to assign the actor as the owner.
     if ($is_unassigned && !$any_assign && $is_open && $is_closing) {
         // Don't assign the actor if they aren't a real user.
         $actor = $this->getActor();
         $actor_phid = $actor->getPHID();
         if ($actor_phid) {
             $results[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_OWNER)->setNewValue($actor_phid);
         }
     }
     return $results;
 }
 protected function expandTransactions(PhabricatorLiskDAO $object, array $xactions)
 {
     $actor = $this->getActor();
     $actor_phid = $actor->getPHID();
     $results = parent::expandTransactions($object, $xactions);
     $is_unassigned = $object->getOwnerPHID() === null;
     $any_assign = false;
     foreach ($xactions as $xaction) {
         if ($xaction->getTransactionType() == ManiphestTransaction::TYPE_OWNER) {
             $any_assign = true;
             break;
         }
     }
     $is_open = !$object->isClosed();
     $new_status = null;
     foreach ($xactions as $xaction) {
         switch ($xaction->getTransactionType()) {
             case ManiphestTransaction::TYPE_STATUS:
                 $new_status = $xaction->getNewValue();
                 break;
         }
     }
     if ($new_status === null) {
         $is_closing = false;
     } else {
         $is_closing = ManiphestTaskStatus::isClosedStatus($new_status);
     }
     // If the task is not assigned, not being assigned, currently open, and
     // being closed, try to assign the actor as the owner.
     if ($is_unassigned && !$any_assign && $is_open && $is_closing) {
         $is_claim = ManiphestTaskStatus::isClaimStatus($new_status);
         // Don't assign the actor if they aren't a real user.
         // Don't claim the task if the status is configured to not claim.
         if ($actor_phid && $is_claim) {
             $results[] = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_OWNER)->setNewValue($actor_phid);
         }
     }
     // Automatically subscribe the author when they create a task.
     if ($this->getIsNewObject()) {
         if ($actor_phid) {
             $results[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('+' => array($actor_phid => $actor_phid)));
         }
     }
     return $results;
 }
 protected function expandTransactions(PhabricatorLiskDAO $object, array $xactions)
 {
     $actor = $this->getActor();
     $actor_phid = $actor->getPHID();
     $results = parent::expandTransactions($object, $xactions);
     // Automatically add the author as a member when they create a project
     // if they're using the web interface.
     $content_source = $this->getContentSource();
     $source_web = PhabricatorContentSource::SOURCE_WEB;
     $is_web = $content_source->getSource() === $source_web;
     if ($this->getIsNewObject() && $is_web) {
         if ($actor_phid) {
             $type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
             $results[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue(array('+' => array($actor_phid => $actor_phid)));
         }
     }
     $is_milestone = $object->isMilestone();
     foreach ($xactions as $xaction) {
         switch ($xaction->getTransactionType()) {
             case PhabricatorProjectTransaction::TYPE_MILESTONE:
                 if ($xaction->getNewValue() !== null) {
                     $is_milestone = true;
                 }
                 break;
         }
     }
     $this->setIsMilestone($is_milestone);
     return $results;
 }
 protected function expandTransactions(PhabricatorLiskDAO $object, array $xactions)
 {
     $actor = $this->getActor();
     $actor_phid = $actor->getPHID();
     $results = parent::expandTransactions($object, $xactions);
     $is_milestone = $object->isMilestone();
     foreach ($xactions as $xaction) {
         switch ($xaction->getTransactionType()) {
             case PhabricatorProjectTransaction::TYPE_MILESTONE:
                 if ($xaction->getNewValue() !== null) {
                     $is_milestone = true;
                 }
                 break;
         }
     }
     $this->setIsMilestone($is_milestone);
     return $results;
 }