mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-11 08:06:13 +01:00
0e7a5623e3
Summary: Ref T12335. See that task for discussion. Here are the behavioral changes: - Statuses can be flagged with `locked`, which means that tasks in that status are locked to further discussion and interaction. - A new "CAN_INTERACT" permission facilitates this. For most objects, "CAN_INTERACT" is just the same as "CAN_VIEW". - For tasks, "CAN_INTERACT" is everyone if the status is a normal status, and no one if the status is a locked status. - If a user doesn't have "Interact" permission: - They can not submit the comment form. - The comment form is replaced with text indicating "This thing is locked.". - The "Edit" workflow prompts them. This is a mixture of advisory and hard policy checks but sholuld represent a reasonable starting point. Test Plan: Created a new "Locked" status, locked a task. Couldn't comment, saw lock warning, saw lock prompt on edit. Unlocked a task. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12335 Differential Revision: https://secure.phabricator.com/D17453
66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
<?php
|
|
|
|
abstract class PhabricatorEditEngineLock
|
|
extends Phobject {
|
|
|
|
private $viewer;
|
|
private $object;
|
|
|
|
final public function setViewer(PhabricatorUser $viewer) {
|
|
$this->viewer = $viewer;
|
|
return $this;
|
|
}
|
|
|
|
final public function getViewer() {
|
|
return $this->viewer;
|
|
}
|
|
|
|
final public function setObject($object) {
|
|
$this->object = $object;
|
|
return $this;
|
|
}
|
|
|
|
final public function getObject() {
|
|
return $this->object;
|
|
}
|
|
|
|
public function willPromptUserForLockOverrideWithDialog(
|
|
AphrontDialogView $dialog) {
|
|
|
|
return $dialog
|
|
->setTitle(pht('Edit Locked Object'))
|
|
->appendParagraph(pht('This object is locked. Edit it anyway?'))
|
|
->addSubmitButton(pht('Override Lock'));
|
|
}
|
|
|
|
public function willBlockUserInteractionWithDialog(
|
|
AphrontDialogView $dialog) {
|
|
|
|
return $dialog
|
|
->setTitle(pht('Object Locked'))
|
|
->appendParagraph(
|
|
pht('You can not interact with this object because it is locked.'));
|
|
}
|
|
|
|
public function getLockedObjectDisplayText() {
|
|
return pht('This object has been locked.');
|
|
}
|
|
|
|
public static function newForObject(
|
|
PhabricatorUser $viewer,
|
|
$object) {
|
|
|
|
if ($object instanceof PhabricatorEditEngineLockableInterface) {
|
|
$lock = $object->newEditEngineLock();
|
|
} else {
|
|
$lock = new PhabricatorEditEngineDefaultLock();
|
|
}
|
|
|
|
return $lock
|
|
->setViewer($viewer)
|
|
->setObject($object);
|
|
}
|
|
|
|
|
|
|
|
}
|