[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/project/controller/ -> PhabricatorProjectArchiveController.php (source)

   1  <?php
   2  
   3  final class PhabricatorProjectArchiveController
   4    extends PhabricatorProjectController {
   5  
   6    private $id;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->id = $data['id'];
  10    }
  11  
  12    public function processRequest() {
  13      $request = $this->getRequest();
  14      $viewer = $request->getUser();
  15  
  16      $project = id(new PhabricatorProjectQuery())
  17        ->setViewer($viewer)
  18        ->withIDs(array($this->id))
  19        ->requireCapabilities(
  20          array(
  21            PhabricatorPolicyCapability::CAN_VIEW,
  22            PhabricatorPolicyCapability::CAN_EDIT,
  23          ))
  24        ->executeOne();
  25      if (!$project) {
  26        return new Aphront404Response();
  27      }
  28  
  29      $edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
  30  
  31      if ($request->isFormPost()) {
  32        if ($project->isArchived()) {
  33          $new_status = PhabricatorProjectStatus::STATUS_ACTIVE;
  34        } else {
  35          $new_status = PhabricatorProjectStatus::STATUS_ARCHIVED;
  36        }
  37  
  38        $xactions = array();
  39  
  40        $xactions[] = id(new PhabricatorProjectTransaction())
  41          ->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
  42          ->setNewValue($new_status);
  43  
  44        id(new PhabricatorProjectTransactionEditor())
  45          ->setActor($viewer)
  46          ->setContentSourceFromRequest($request)
  47          ->setContinueOnNoEffect(true)
  48          ->setContinueOnMissingFields(true)
  49          ->applyTransactions($project, $xactions);
  50  
  51        return id(new AphrontRedirectResponse())->setURI($edit_uri);
  52      }
  53  
  54      if ($project->isArchived()) {
  55        $title = pht('Really unarchive project?');
  56        $body = pht('This project will become active again.');
  57        $button = pht('Unarchive Project');
  58      } else {
  59        $title = pht('Really archive project?');
  60        $body = pht('This project will be moved to the archive.');
  61        $button = pht('Archive Project');
  62      }
  63  
  64      $dialog = id(new AphrontDialogView())
  65        ->setUser($viewer)
  66        ->setTitle($title)
  67        ->appendChild($body)
  68        ->addCancelButton($edit_uri)
  69        ->addSubmitButton($button);
  70  
  71      return id(new AphrontDialogResponse())->setDialog($dialog);
  72    }
  73  
  74  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1