1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Legalpad - add "no one" signature type

Summary: Fixes T7294. This lets legalpad store other documents that don't need signatures but conceptually belong in legalpad.

Test Plan: made a document with signature type "no one" and it saved. viewed the document and noted no signing UI was present.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7294

Differential Revision: https://secure.phabricator.com/D11788
This commit is contained in:
Bob Trahan 2015-02-17 11:45:20 -08:00
parent e946e7cebc
commit 733a9c40ee
3 changed files with 122 additions and 93 deletions

View file

@ -97,8 +97,8 @@ final class LegalpadDocumentEditController extends LegalpadController {
if (!$user->getIsAdmin()) {
$errors[] = pht('Only admins may require signature.');
}
$corp = LegalpadDocument::SIGNATURE_TYPE_CORPORATION;
if ($v_signature_type == $corp) {
$individual = LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL;
if ($v_signature_type != $individual) {
$errors[] = pht(
'Only documents with signature type "individual" may require '.
'signing to use Phabricator.');
@ -147,6 +147,7 @@ final class LegalpadDocumentEditController extends LegalpadController {
->setValue($v_signature_type)
->setOptions(LegalpadDocument::getSignatureTypeMap()));
$show_require = true;
$caption = pht('Applies only to documents individuals sign.');
} else {
$form->appendChild(
id(new AphrontFormMarkupControl())
@ -154,6 +155,7 @@ final class LegalpadDocumentEditController extends LegalpadController {
->setValue($document->getSignatureTypeName()));
$individual = LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL;
$show_require = $document->getSignatureType() == $individual;
$caption = null;
}
if ($show_require) {
@ -166,9 +168,9 @@ final class LegalpadDocumentEditController extends LegalpadController {
'requireSignature',
'requireSignature',
pht(
'Should signing this document be required to use Phabricator? '.
'Applies to invidivuals only.'),
$v_require_signature));
'Should signing this document be required to use Phabricator?'),
$v_require_signature)
->setCaption($caption));
}
$form

View file

@ -26,11 +26,19 @@ final class LegalpadDocumentSignController extends LegalpadController {
$type_individual = LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL;
$is_individual = ($document->getSignatureType() == $type_individual);
if ($is_individual) {
switch ($document->getSignatureType()) {
case LegalpadDocument::SIGNATURE_TYPE_NONE:
// nothing to sign means this should be true
$has_signed = true;
// this is a status UI element
$signed_status = null;
break;
case LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL:
if ($signer_phid) {
// TODO: This is odd and should probably be adjusted after grey/external
// accounts work better, but use the omnipotent viewer to check for a
// signature so we can pick up anonymous/grey signatures.
// TODO: This is odd and should probably be adjusted after
// grey/external accounts work better, but use the omnipotent
// viewer to check for a signature so we can pick up
// anonymous/grey signatures.
$signature = id(new LegalpadDocumentSignatureQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
@ -98,7 +106,10 @@ final class LegalpadDocumentSignController extends LegalpadController {
'email' => true,
'agree' => true,
);
} else {
$signature->setSignatureData($signature_data);
break;
case LegalpadDocument::SIGNATURE_TYPE_CORPORATION:
$signature = id(new LegalpadDocumentSignature())
->setDocumentPHID($document->getPHID())
->setDocumentVersion($document->getVersions());
@ -125,9 +136,9 @@ final class LegalpadDocumentSignController extends LegalpadController {
'contact.name' => true,
'email' => true,
);
}
$signature->setSignatureData($signature_data);
break;
}
$errors = array();
if ($request->isFormOrHisecPost() && !$has_signed) {
@ -256,9 +267,17 @@ final class LegalpadDocumentSignController extends LegalpadController {
$signature,
$field_errors);
switch ($document->getSignatureType()) {
case LegalpadDocument::SIGNATURE_TYPE_NONE:
$subheader = null;
break;
case LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL:
case LegalpadDocument::SIGNATURE_TYPE_CORPORATION:
$subheader = id(new PHUIHeaderView())
->setHeader(pht('Agree and Sign Document'))
->setBleedHeader(true);
break;
}
$content->appendChild(
array(
@ -292,6 +311,8 @@ final class LegalpadDocumentSignController extends LegalpadController {
$signature_data = array();
switch ($document->getSignatureType()) {
case LegalpadDocument::SIGNATURE_TYPE_NONE:
break;
case LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL:
if ($viewer->isLoggedIn()) {
$signer_phid = $viewer->getPHID();
@ -348,6 +369,9 @@ final class LegalpadDocumentSignController extends LegalpadController {
$signature_type = $document->getSignatureType();
switch ($signature_type) {
case LegalpadDocument::SIGNATURE_TYPE_NONE:
// bail out of here quick
return;
case LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL:
$this->buildIndividualSignatureForm(
$form,

View file

@ -20,6 +20,7 @@ final class LegalpadDocument extends LegalpadDAO
protected $preamble;
protected $requireSignature;
const SIGNATURE_TYPE_NONE = 'none';
const SIGNATURE_TYPE_INDIVIDUAL = 'user';
const SIGNATURE_TYPE_CORPORATION = 'corp';
@ -134,6 +135,7 @@ final class LegalpadDocument extends LegalpadDAO
return array(
self::SIGNATURE_TYPE_INDIVIDUAL => pht('Individuals'),
self::SIGNATURE_TYPE_CORPORATION => pht('Corporations'),
self::SIGNATURE_TYPE_NONE => pht('No One'),
);
}
@ -145,6 +147,7 @@ final class LegalpadDocument extends LegalpadDAO
public function getSignatureTypeIcon() {
$type = $this->getSignatureType();
$map = array(
self::SIGNATURE_TYPE_NONE => '',
self::SIGNATURE_TYPE_INDIVIDUAL => 'fa-user grey',
self::SIGNATURE_TYPE_CORPORATION => 'fa-building-o grey',
);