Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890920
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/legalpad/xaction/LegalpadDocumentRequireSignatureTransaction.php b/src/applications/legalpad/xaction/LegalpadDocumentRequireSignatureTransaction.php
index 3819f38a70..9932baab80 100644
--- a/src/applications/legalpad/xaction/LegalpadDocumentRequireSignatureTransaction.php
+++ b/src/applications/legalpad/xaction/LegalpadDocumentRequireSignatureTransaction.php
@@ -1,72 +1,83 @@
<?php
final class LegalpadDocumentRequireSignatureTransaction
extends LegalpadDocumentTransactionType {
const TRANSACTIONTYPE = 'legalpad:require-signature';
public function generateOldValue($object) {
return (int)$object->getRequireSignature();
}
public function applyInternalEffects($object, $value) {
$object->setRequireSignature((int)$value);
}
public function applyExternalEffects($object, $value) {
if ($value) {
$session = new PhabricatorAuthSession();
queryfx(
$session->establishConnection('w'),
'UPDATE %T SET signedLegalpadDocuments = 0',
$session->getTableName());
}
}
public function getTitle() {
$new = $this->getNewValue();
if ($new) {
return pht(
'%s set the document to require signatures.',
$this->renderAuthor());
} else {
return pht(
'%s set the document to not require signatures.',
$this->renderAuthor());
}
}
public function getTitleForFeed() {
$new = $this->getNewValue();
if ($new) {
return pht(
'%s set the document %s to require signatures.',
$this->renderAuthor(),
$this->renderObject());
} else {
return pht(
'%s set the document %s to not require signatures.',
$this->renderAuthor(),
$this->renderObject());
}
}
public function validateTransactions($object, array $xactions) {
$errors = array();
- $is_admin = $this->getActor()->getIsAdmin();
+ $old = (bool)$object->getRequireSignature();
+ foreach ($xactions as $xaction) {
+ $new = (bool)$xaction->getNewValue();
- if (!$is_admin) {
- $errors[] = $this->newInvalidError(
- pht('Only admins may require signature.'));
+ if ($old === $new) {
+ continue;
+ }
+
+ $is_admin = $this->getActor()->getIsAdmin();
+ if (!$is_admin) {
+ $errors[] = $this->newInvalidError(
+ pht(
+ 'Only administrators may change whether a document '.
+ 'requires a signature.'),
+ $xaction);
+ }
}
return $errors;
}
public function getIcon() {
return 'fa-pencil-square';
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 14:21 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125440
Default Alt Text
(2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment