From 4e55f88542424d72b6d9c79e4e507e1b09956503 Mon Sep 17 00:00:00 2001
From: Megan
Date: Fri, 13 Mar 2009 13:16:30 +0200
Subject: [PATCH] Added static signatures on document actions and bulk actions In progress.
---
plugins/ktcore/KTDocumentActions.php | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
plugins/ktcore/document/Rename.php | 35 ++++++++++++++++++++++++-----------
plugins/ktcore/document/edit.php | 33 +++++++++++++++++++++++++++++++++
plugins/ktstandard/KTDocumentLinks.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---------
templates/ktcore/action/rename.smarty | 4 ++--
templates/ktcore/workflow/documentWorkflow.smarty | 20 ++++++++++----------
templates/ktstandard/action/document_links.smarty | 18 +++++++++++++++---
templates/ktstandard/action/link.smarty | 4 ++--
templates/ktstandard/action/link_external.smarty | 4 ++--
9 files changed, 316 insertions(+), 70 deletions(-)
diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php
index 4c30ee1..e5c3ff9 100644
--- a/plugins/ktcore/KTDocumentActions.php
+++ b/plugins/ktcore/KTDocumentActions.php
@@ -1016,20 +1016,52 @@ class KTDocumentDeleteAction extends KTDocumentAction {
'submit_label' => _kt('Delete Document'),
'context' => &$this,
));
- $oForm->setWidgets(array(
- array('ktcore.widgets.reason', array(
+
+ // Electronic Signature if enabled
+ global $default;
+ if($default->enableESignatures){
+ $widgets[] = array('ktcore.widgets.info', array(
+ 'label' => _kt('This action requires authentication'),
+ 'description' => _kt('Please provide your user credentials as confirmation of this action.'),
+ 'name' => 'info'
+ ));
+ $widgets[] = array('ktcore.widgets.string', array(
+ 'label' => _kt('Username'),
+ 'name' => 'sign_username',
+ 'required' => true
+ ));
+ $widgets[] = array('ktcore.widgets.password', array(
+ 'label' => _kt('Password'),
+ 'name' => 'sign_password',
+ 'required' => true
+ ));
+ }
+
+ $widgets[] = array('ktcore.widgets.reason', array(
'label' => _kt('Reason'),
'description' => _kt('Please specify why you are deleting this document. Please bear in mind that you can use a maximum of 250 characters.'),
'name' => 'reason',
- )),
- ));
- $oForm->setValidators(array(
- array('ktcore.validators.string', array(
+ ));
+
+ $oForm->setWidgets($widgets);
+
+ $validators[] = array('ktcore.validators.string', array(
'test' => 'reason',
'max_length' => 250,
'output' => 'reason',
- )),
- ));
+ ));
+
+ if($default->enableESignatures){
+ $validators[] = array('electonic.signatures.validators.authenticate', array(
+ 'object_id' => $this->oDocument->iId,
+ 'type' => 'document',
+ 'action' => 'ktcore.transactions.delete',
+ 'test' => 'info',
+ 'output' => 'info'
+ ));
+ }
+
+ $oForm->setValidators($validators);
return $oForm;
}
@@ -1144,35 +1176,67 @@ class KTDocumentMoveAction extends KTDocumentAction {
* This is still not the most elegant solution.
*/
- $oForm->setWidgets(array(
- array('ktcore.widgets.foldercollection', array(
+ $widgets[] = array('ktcore.widgets.foldercollection', array(
'label' => _kt('Target Folder'),
'description' => _kt('Use the folder collection and path below select the folder into which you wish to move the document.'),
'required' => true,
'name' => 'browse',
- 'folder_id' => $this->oDocument->getFolderID(),
- )),
- array('ktcore.widgets.reason', array(
+ 'folder_id' => $this->oDocument->getFolderID()
+ ));
+
+
+ // Electronic Signature if enabled
+ global $default;
+ if($default->enableESignatures){
+ $widgets[] = array('ktcore.widgets.info', array(
+ 'label' => _kt('This action requires authentication'),
+ 'description' => _kt('Please provide your user credentials as confirmation of this action.'),
+ 'name' => 'info'
+ ));
+ $widgets[] = array('ktcore.widgets.string', array(
+ 'label' => _kt('Username'),
+ 'name' => 'sign_username',
+ 'required' => true
+ ));
+ $widgets[] = array('ktcore.widgets.password', array(
+ 'label' => _kt('Password'),
+ 'name' => 'sign_password',
+ 'required' => true
+ ));
+ }
+
+
+ $widgets[] = array('ktcore.widgets.reason', array(
'label' => _kt('Reason'),
'description' => _kt('Please specify why you are moving this document. Bear in mind that you can use a maximum of 250 characters.'),
'name' => 'reason',
- )),
));
+ $oForm->setWidgets($widgets);
- $oForm->setValidators(array(
- array('ktcore.validators.string', array(
+ $validators[] = array('ktcore.validators.string', array(
'test' => 'reason',
'max_length' => 250,
'output' => 'reason',
- )),
- array('ktcore.validators.entity', array(
+ ));
+ $validators[] = array('ktcore.validators.entity', array(
'class' => 'Folder',
'test' => 'browse',
'output' => 'browse',
- )),
));
+ if($default->enableESignatures){
+ $validators[] = array('electonic.signatures.validators.authenticate', array(
+ 'object_id' => $this->oDocument->iId,
+ 'type' => 'document',
+ 'action' => 'ktcore.transactions.move',
+ 'test' => 'info',
+ 'output' => 'info'
+ ));
+ }
+
+ $oForm->setValidators($validators);
+
// here's the ugly bit.
$err = $oForm->getErrors();
@@ -1565,20 +1629,52 @@ class KTDocumentArchiveAction extends KTDocumentAction {
'submit_label' => _kt('Archive Document'),
'context' => &$this,
));
- $oForm->setWidgets(array(
- array('ktcore.widgets.reason', array(
+
+ // Electronic Signature if enabled
+ global $default;
+ if($default->enableESignatures){
+ $widgets[] = array('ktcore.widgets.info', array(
+ 'label' => _kt('This action requires authentication'),
+ 'description' => _kt('Please provide your user credentials as confirmation of this action.'),
+ 'name' => 'info'
+ ));
+ $widgets[] = array('ktcore.widgets.string', array(
+ 'label' => _kt('Username'),
+ 'name' => 'sign_username',
+ 'required' => true
+ ));
+ $widgets[] = array('ktcore.widgets.password', array(
+ 'label' => _kt('Password'),
+ 'name' => 'sign_password',
+ 'required' => true
+ ));
+ }
+
+ $widgets[] = array('ktcore.widgets.reason', array(
'label' => _kt('Reason'),
'description' => _kt('Please specify why you are archiving this document. Please bear in mind that you can use a maximum of 250 characters.'),
'name' => 'reason',
- )),
- ));
- $oForm->setValidators(array(
- array('ktcore.validators.string', array(
+ ));
+
+ $oForm->setWidgets($widgets);
+
+ $validators[] = array('ktcore.validators.string', array(
'test' => 'reason',
'max_length' => 250,
'output' => 'reason',
- )),
- ));
+ ));
+
+ if($default->enableESignatures){
+ $validators[] = array('electonic.signatures.validators.authenticate', array(
+ 'object_id' => $this->oDocument->iId,
+ 'type' => 'document',
+ 'action' => 'ktcore.transactions.archive',
+ 'test' => 'info',
+ 'output' => 'info'
+ ));
+ }
+
+ $oForm->setValidators($validators);
return $oForm;
}
@@ -1710,6 +1806,22 @@ class KTDocumentWorkflowAction extends KTDocumentAction {
}
}
+ // Add an electronic signature
+ global $default;
+ if($default->enableESignatures){
+ $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
+ $heading = _kt('You are attempting to modify the document workflow');
+ $submit['type'] = 'button';
+ $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.modify_workflow', 'document', 'start_workflow_form', 'submit', {$this->oDocument->iId});";
+
+ $heading2 = _kt('You are attempting to transition the document workflow');
+ $submit2['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading2}', 'ktcore.transactions.transition_workflow', 'document', 'transition_wf_form', 'submit', {$this->oDocument->iId});";
+ }else{
+ $submit['type'] = 'submit';
+ $submit['onclick'] = '';
+ $submit2['onclick'] = '';
+ }
+
$aTemplateData = array(
'oDocument' => $oDocument,
'oWorkflow' => $oWorkflow,
@@ -1719,6 +1831,8 @@ class KTDocumentWorkflowAction extends KTDocumentAction {
'transition_fields' => $transition_fields,
'bHasPerm' => $bHasPerm,
'bIsCheckedOut' => $bIsCheckedOut,
+ 'submit' => $submit,
+ 'submit2' => $submit2
);
return $oTemplate->render($aTemplateData);
}
@@ -1779,14 +1893,37 @@ class KTDocumentWorkflowAction extends KTDocumentAction {
'fail_action' => 'quicktransition',
'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument),
));
- $oForm->setWidgets(array(
- array('ktcore.widgets.reason', array(
+
+ // Electronic Signature if enabled
+ global $default;
+ if($default->enableESignatures){
+ $widgets[] = array('ktcore.widgets.info', array(
+ 'label' => _kt('This action requires authentication'),
+ 'description' => _kt('Please provide your user credentials as confirmation of this action.'),
+ 'name' => 'info'
+ ));
+ $widgets[] = array('ktcore.widgets.string', array(
+ 'label' => _kt('Username'),
+ 'name' => 'sign_username',
+ 'required' => true
+ ));
+ $widgets[] = array('ktcore.widgets.password', array(
+ 'label' => _kt('Password'),
+ 'name' => 'sign_password',
+ 'required' => true
+ ));
+ }
+
+
+ $widgets[] = array('ktcore.widgets.reason', array(
'label' => _kt('Reason'),
'description' => _kt('Specify your reason for performing this action.'),
'important_description' => _kt('Please bear in mind that you can use a maximum of 250 characters.'),
'name' => 'reason',
- )),
- ));
+ ));
+
+ $oForm->setWidgets($widgets);
+
$oForm->setValidators(array(
array('ktcore.validators.string', array(
'test' => 'reason',
@@ -1794,6 +1931,17 @@ class KTDocumentWorkflowAction extends KTDocumentAction {
'output' => 'reason',
)),
));
+
+ if($default->enableESignatures){
+ $oForm->addValidator(array('electonic.signatures.validators.authenticate', array(
+ 'object_id' => $this->oDocument->iId,
+ 'type' => 'document',
+ 'action' => 'ktcore.transactions.transition_workflow',
+ 'test' => 'info',
+ 'output' => 'info'
+ )));
+ }
+
}
return $oForm;
diff --git a/plugins/ktcore/document/Rename.php b/plugins/ktcore/document/Rename.php
index 2789b88..67959f1 100644
--- a/plugins/ktcore/document/Rename.php
+++ b/plugins/ktcore/document/Rename.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008, 2009 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -86,9 +86,22 @@ class KTDocumentRenameAction extends KTDocumentAction {
$fields[] = new KTStaticTextWidget(_kt('Current file name'), _kt('The current file name is shown below:'), 'oldfilename', $this->oDocument->getFileName(), $this->oPage, false);
$fields[] = new KTStringWidget(_kt('New file name'), _kt('The name to which the current file should be renamed.'), 'filename', $this->oDocument->getFileName(), $this->oPage, true);
+ // Add an electronic signature
+ global $default;
+ if($default->enableESignatures){
+ $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
+ $heading = _kt('You are attempting to rename the document');
+ $submit['type'] = 'button';
+ $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.rename', 'document', 'document_rename_form', 'submit', {$this->oDocument->iId});";
+ }else{
+ $submit['type'] = 'submit';
+ $submit['onclick'] = '';
+ }
+
$oTemplate->setData(array(
'context' => &$this,
'fields' => $fields,
+ 'submit' => $submit
));
return $oTemplate->render();
}
@@ -103,7 +116,7 @@ class KTDocumentRenameAction extends KTDocumentAction {
);
$this->oValidator->validateString($sFilename, $aOptions);
$this->oValidator->validateIllegalCharacters($sFilename, $aOptions);
-
+
$res = KTDocumentUtil::rename($this->oDocument, $sFilename, $this->oUser);
if (PEAR::isError($res)) {
$_SESSION['KTErrorMessage'][] = $res->getMessage();
@@ -111,7 +124,7 @@ class KTDocumentRenameAction extends KTDocumentAction {
} else {
$_SESSION['KTInfoMessage'][] = sprintf(_kt('Document "%s" renamed.'),$this->oDocument->getName());
}
-
+
controllerRedirect('viewDocument', sprintf('fDocumentId=%d', $this->oDocument->getId()));
exit(0);
}
diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php
index 5f0e997..b840acf 100644
--- a/plugins/ktcore/document/edit.php
+++ b/plugins/ktcore/document/edit.php
@@ -120,6 +120,39 @@ class KTDocumentEditAction extends KTDocumentAction {
$validators = kt_array_merge($validators, $oFReg->validatorsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument));
}
+ // Electronic Signature if enabled
+ global $default;
+ if($default->enableESignatures){
+ $widgets[] = array('ktcore.widgets.info', array(
+ 'label' => _kt('This action requires authentication'),
+ 'description' => _kt('Please provide your user credentials as confirmation of this action.'),
+ 'name' => 'info'
+ ));
+ $widgets[] = array('ktcore.widgets.string', array(
+ 'label' => _kt('Username'),
+ 'name' => 'sign_username',
+ 'required' => true
+ ));
+ $widgets[] = array('ktcore.widgets.password', array(
+ 'label' => _kt('Password'),
+ 'name' => 'sign_password',
+ 'required' => true
+ ));
+ $widgets[] = array('ktcore.widgets.reason', array(
+ 'label' => _kt('Reason'),
+ 'name' => 'reason',
+ 'required' => true
+ ));
+
+ $validators[] = array('electonic.signatures.validators.authenticate', array(
+ 'object_id' => $this->oDocument->iId,
+ 'type' => 'document',
+ 'action' => 'ktcore.transactions.edit_metadata',
+ 'test' => 'info',
+ 'output' => 'info'
+ ));
+ }
+
$oForm->setWidgets($widgets);
$oForm->setValidators($validators);
diff --git a/plugins/ktstandard/KTDocumentLinks.php b/plugins/ktstandard/KTDocumentLinks.php
index ea29fe1..05114ab 100644
--- a/plugins/ktstandard/KTDocumentLinks.php
+++ b/plugins/ktstandard/KTDocumentLinks.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008, 2009 KnowledgeTree Inc.
* Portions copyright The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
+ * must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
* Contributor( s): ______________________________________
*
@@ -179,6 +179,16 @@ class KTDocumentLinkAction extends KTDocumentAction {
$oReadPermission =& KTPermission::getByName('ktcore.permissions.read');
$oWritePermission =& KTPermission::getByName('ktcore.permissions.write');
+ // Add an electronic signature
+ global $default;
+ if($default->enableESignatures){
+ $signatures = true;
+ $submit['sUrl'] = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
+ $submit['heading'] = _kt('You are attempting to delete a document link');
+ }else{
+ $signatures = false;
+ }
+
$aTemplateData = array(
'context' => $this,
'iDocId' => $iDocId,
@@ -187,6 +197,8 @@ class KTDocumentLinkAction extends KTDocumentAction {
'links_to' => DocumentLink::getLinksToDocument($iDocId),
'read_permission' => KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oReadPermission, $this->oDocument),
'write_permission' => KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oWritePermission, $this->oDocument),
+ 'submit' => $submit,
+ 'signatures' => $signatures
);
return $oTemplate->render($aTemplateData);
@@ -251,6 +263,20 @@ class KTDocumentLinkAction extends KTDocumentAction {
$aURLParams['action'] = 'new';
$aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams);
+
+ // Add an electronic signature
+ global $default;
+ if($default->enableESignatures){
+ $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
+ $heading = _kt('You are attempting to add a document link');
+ $submit['type'] = 'button';
+ $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.add_link', 'document', 'document_add_link_form', 'submit', {$oParentDocument->iId});";
+ }else{
+ $submit['type'] = 'submit';
+ $submit['onclick'] = '';
+ }
+
+
$aTemplateData = array(
'context' => $this,
'folder' => $oFolder,
@@ -258,6 +284,7 @@ class KTDocumentLinkAction extends KTDocumentAction {
'breadcrumbs' => $aBreadcrumbs,
'collection' => $collection,
'link_types' => LinkType::getList("id > 0"),
+ 'submit' => $submit
);
$oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link');
@@ -278,10 +305,23 @@ class KTDocumentLinkAction extends KTDocumentAction {
$oParentDocument =& $this->oDocument;
$iParentId = $oParentDocument->getId();
+ // Add an electronic signature
+ global $default;
+ if($default->enableESignatures){
+ $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
+ $heading = _kt('You are attempting to add an external document link');
+ $submit['type'] = 'button';
+ $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.add_external_link', 'document', 'document_add_ext_link_form', 'submit', {$oParentDocument->iId});";
+ }else{
+ $submit['type'] = 'submit';
+ $submit['onclick'] = '';
+ }
+
$aTemplateData = array(
'context' => $this,
'iDocId' => $iParentId,
'link_types' => LinkType::getList("id > 0"),
+ 'submit' => $submit
);
$oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link_external');
diff --git a/templates/ktcore/action/rename.smarty b/templates/ktcore/action/rename.smarty
index 9341fad..a7b5ac0 100644
--- a/templates/ktcore/action/rename.smarty
+++ b/templates/ktcore/action/rename.smarty
@@ -6,7 +6,7 @@ name (not the document title) for a document.{/i18n}
{assign var=iDocumentId value=$context->oDocument->getId()}
{capture assign=link}{"viewDocument"|generateControllerUrl:"fDocumentId=$iDocumentId"}{/capture}
-
@@ -52,19 +52,19 @@
{/if}
{if $aWorkflows}
{if $bHasPerm}
-
diff --git a/templates/ktstandard/action/document_links.smarty b/templates/ktstandard/action/document_links.smarty
index f99a044..5a28146 100644
--- a/templates/ktstandard/action/document_links.smarty
+++ b/templates/ktstandard/action/document_links.smarty
@@ -29,7 +29,11 @@
|
{if $write_permission}
- {i18n}Delete{/i18n}
+ {if $signatures}
+ {i18n}Delete{/i18n}
+ {else}
+ {i18n}Delete{/i18n}
+ {/if}
{else}
{/if}
@@ -50,7 +54,11 @@
|
|
{if $write_permission}
- {i18n}Delete{/i18n}
+ {if $signatures}
+ {i18n}Delete{/i18n}
+ {else}
+ {i18n}Delete{/i18n}
+ {/if}
{else}
{/if}
@@ -71,7 +79,11 @@
|
|
{if $write_permission}
- {i18n}Delete{/i18n}
+ {if $signatures}
+ {i18n}Delete{/i18n}
+ {else}
+ {i18n}Delete{/i18n}
+ {/if}
{else}
{/if}
diff --git a/templates/ktstandard/action/link.smarty b/templates/ktstandard/action/link.smarty
index d453fae..1380e76 100644
--- a/templates/ktstandard/action/link.smarty
+++ b/templates/ktstandard/action/link.smarty
@@ -13,12 +13,12 @@
{/if}
{/foreach}
-
{else}
diff --git a/templates/ktstandard/action/link_external.smarty b/templates/ktstandard/action/link_external.smarty
index 823aa55..777740f 100644
--- a/templates/ktstandard/action/link_external.smarty
+++ b/templates/ktstandard/action/link_external.smarty
@@ -5,7 +5,7 @@
{i18n}Enter the URL to the external document or site.{/i18n}
-
{else}
--
libgit2 0.21.4
|