1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00
phorge-phorge/src/applications/project/controller/PhabricatorProjectLockController.php
epriestley 6b1b21c999 Move member/watch actions to "Members/Watchers" page
Summary:
Ref T10054. This tries to make the members page a bit more consistent and provide hints to users about subproject/milestone membership rules. In particular:

  - You now join, leave, watch, unwatch, add and remove members, and lock and unlock membership from the members screen.
  - We now explain the membership rule for the project on this screen. There are currently four rules:
    - Normal Project: Join/leave normally.
    - Parent Project: Uses subprojects to determine members.
    - Milestone: Uses parent project to determine members.
    - Locked: Membership is locked.
    - (Future) Imported from LDAP/other external sources: Membership is determined by something else.

Test Plan: {F1064878}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10054

Differential Revision: https://secure.phabricator.com/D15059
2016-01-19 19:37:27 -08:00

85 lines
2.3 KiB
PHP

<?php
final class PhabricatorProjectLockController
extends PhabricatorProjectController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$this->requireApplicationCapability(
ProjectCanLockProjectsCapability::CAPABILITY);
$id = $request->getURIData('id');
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$project) {
return new Aphront404Response();
}
$done_uri = "/project/members/{$id}/";
if (!$project->supportsEditMembers()) {
return $this->newDialog()
->setTitle(pht('Membership Immutable'))
->appendChild(
pht('This project does not support editing membership.'))
->addCancelButton($done_uri);
}
$is_locked = $project->getIsMembershipLocked();
if ($request->isFormPost()) {
$xactions = array();
if ($is_locked) {
$new_value = 0;
} else {
$new_value = 1;
}
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectTransaction::TYPE_LOCKED)
->setNewValue($new_value);
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true)
->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
if ($project->getIsMembershipLocked()) {
$title = pht('Unlock Project');
$body = pht(
'If you unlock this project, members will be free to leave.');
$button = pht('Unlock Project');
} else {
$title = pht('Lock Project');
$body = pht(
'If you lock this project, members will be prevented from '.
'leaving it.');
$button = pht('Lock Project');
}
return $this->newDialog()
->setTitle($title)
->appendParagraph($body)
->addSubmitbutton($button)
->addCancelButton($done_uri);
}
}