Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15197374
D7983.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D7983.diff
View Options
Index: src/applications/legalpad/controller/LegalpadDocumentEditController.php
===================================================================
--- src/applications/legalpad/controller/LegalpadDocumentEditController.php
+++ src/applications/legalpad/controller/LegalpadDocumentEditController.php
@@ -23,6 +23,7 @@
->setCreatorPHID($user->getPHID())
->setContributorCount(0)
->setRecentContributorPHIDs(array())
+ ->attachSignatures(array())
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy(PhabricatorPolicies::POLICY_USER);
$body = id(new LegalpadDocumentBody())
@@ -37,6 +38,7 @@
$document = id(new LegalpadDocumentQuery())
->setViewer($user)
->needDocumentBodies(true)
+ ->needSignatures(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -147,6 +149,7 @@
->setPolicies($policies)
->setName('can_edit'));
+ $crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
$submit = new AphrontFormSubmitControl();
if ($is_create) {
$submit->setValue(pht('Create Document'));
@@ -158,6 +161,17 @@
$this->getApplicationURI('view/'.$document->getID()));
$title = pht('Update Document');
$short = pht('Update');
+ $signatures = $document->getSignatures();
+ if ($signatures) {
+ $form->appendInstructions(pht(
+ 'Warning: there are %d signature(s) already for this document. '.
+ 'Updating the title or text will invalidate these signatures and '.
+ 'users will need to sign again. Proceed carefully.',
+ count($signatures)));
+ }
+ $crumbs->addTextCrumb(
+ $document->getMonogram(),
+ $this->getApplicationURI('view/'.$document->getID()));
}
$form
@@ -168,10 +182,8 @@
->setFormErrors($errors)
->setForm($form);
- $crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
$crumbs->addTextCrumb($short);
-
$preview = id(new PHUIRemarkupPreviewPanel())
->setHeader(pht('Document Preview'))
->setPreviewURI($this->getApplicationURI('document/preview/'))
Index: src/applications/legalpad/controller/LegalpadDocumentViewController.php
===================================================================
--- src/applications/legalpad/controller/LegalpadDocumentViewController.php
+++ src/applications/legalpad/controller/LegalpadDocumentViewController.php
@@ -82,7 +82,7 @@
$crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
$crumbs->setActionList($actions);
$crumbs->addTextCrumb(
- 'L'.$document->getID(),
+ $document->getMonogram(),
$this->getApplicationURI('view/'.$document->getID()));
$object_box = id(new PHUIObjectBoxView())
@@ -140,6 +140,12 @@
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('like')
+ ->setName(pht('Sign Document'))
+ ->setHref('/'.$document->getMonogram()));
+
return $actions;
}
Index: src/applications/legalpad/query/LegalpadDocumentQuery.php
===================================================================
--- src/applications/legalpad/query/LegalpadDocumentQuery.php
+++ src/applications/legalpad/query/LegalpadDocumentQuery.php
@@ -16,6 +16,7 @@
private $needDocumentBodies;
private $needContributors;
+ private $needSignatures;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -52,6 +53,11 @@
return $this;
}
+ public function needSignatures($need_signatures) {
+ $this->needSignatures = $need_signatures;
+ return $this;
+ }
+
public function withDateCreatedBefore($date_created_before) {
$this->dateCreatedBefore = $date_created_before;
return $this;
@@ -102,6 +108,7 @@
}
}
}
+
if ($this->needDocumentBodies) {
$documents = $this->loadDocumentBodies($documents);
}
@@ -110,6 +117,10 @@
$documents = $this->loadContributors($documents);
}
+ if ($this->needSignatures) {
+ $documents = $this->loadSignatures($documents);
+ }
+
return $documents;
}
@@ -208,6 +219,28 @@
return $documents;
}
+ private function loadSignatures(array $documents) {
+ $document_map = mpull($documents, null, 'getPHID');
+
+ $signatures = id(new LegalpadDocumentSignature())
+ ->loadAllWhere(
+ 'documentPHID IN (%Ls)',
+ array_keys($document_map));
+ $signatures = mgroup($signatures, 'getDocumentPHID');
+
+ foreach ($documents as $document) {
+ $sigs = idx($signatures, $document->getPHID());
+ foreach ($sigs as $index => $sig) {
+ if ($sig->getDocumentVersion() != $document->getVersions()) {
+ unset($sigs[$index]);
+ }
+ }
+ $document->attachSignatures($sigs);
+ }
+
+ return $documents;
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorApplicationLegalpad';
}
Index: src/applications/legalpad/storage/LegalpadDocument.php
===================================================================
--- src/applications/legalpad/storage/LegalpadDocument.php
+++ src/applications/legalpad/storage/LegalpadDocument.php
@@ -21,6 +21,7 @@
private $documentBody = self::ATTACHABLE;
private $contributors = self::ATTACHABLE;
+ private $signatures = self::ATTACHABLE;
public function getConfiguration() {
return array(
@@ -54,6 +55,15 @@
return $this;
}
+ public function getSignatures() {
+ return $this->assertAttached($this->signatures);
+ }
+
+ public function attachSignatures(array $signatures) {
+ $this->signatures = $signatures;
+ return $this;
+ }
+
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
Index: src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
===================================================================
--- src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
+++ src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
@@ -815,7 +815,18 @@
'%d Users Need Approval',
),
+ 'Warning: there are %d signature(s) already for this document. '.
+ 'Updating the title or text will invalidate these signatures and users '.
+ 'will need to sign again. Proceed carefully.' => array(
+ 'Warning: there is %d signature already for this document. '.
+ 'Updating the title or text will invalidate this signature and the '.
+ 'user will need to sign again. Proceed carefully.',
+ 'Warning: there are %d signatures already for this document. '.
+ 'Updating the title or text will invalidate these signatures and '.
+ 'users will need to sign again. Proceed carefully.',
+ ),
+
);
}
-}
+ }
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 23, 11:00 PM (14 h, 4 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7187977
Default Alt Text
D7983.diff (6 KB)
Attached To
Mode
D7983: Legalpad - a few rough edges smoothed...
Attached
Detach File
Event Timeline
Log In to Comment