diff --git a/plugins/ktcore/KTAssist.php b/plugins/ktcore/KTAssist.php
index abd47e9..2a6af9a 100644
--- a/plugins/ktcore/KTAssist.php
+++ b/plugins/ktcore/KTAssist.php
@@ -7,31 +7,31 @@
* Document Management Made Simple
* Copyright (C) 2008 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): ______________________________________
*
@@ -187,7 +187,7 @@ class KTAssistNotification extends KTNotificationHandler {
$oTemplate =& $oTemplating->loadTemplate('ktcore/assist/assist_notification');
$oDoc = Document::get($oKTNotification->getIntData1());
- $isBroken = (PEAR::isError($oDoc) || ($oDoc->getStatusID() != LIVE));
+ $isBroken = (PEAR::isError($oDoc) || ($oDoc->getStatusID() != LIVE && $oDoc->getStatusID() != ARCHIVED));
$oTemplate->setData(array(
'context' => $this,
@@ -211,10 +211,14 @@ class KTAssistNotification extends KTNotificationHandler {
}
function notify_main() {
+ $this->aBreadcrumbs = array(array('action' => 'dashboard', 'name' => _kt('Dashboard')));
+ $this->oPage->setBreadcrumbDetails(_kt('Help request'));
+
$oTemplating =& KTTemplating::getSingleton();
$oKTNotification =& $this->oNotification;
$oDoc = Document::get($oKTNotification->getIntData1());
$isBroken = (PEAR::isError($oDoc) || ($oDoc->getStatusID() != LIVE));
+ $isArchived = ($oDoc->getStatusID() == ARCHIVED)? true : false;
$oTemplate =& $oTemplating->loadTemplate('ktcore/assist/assist_notification_details');
$oTemplate->setData(array(
@@ -227,7 +231,8 @@ class KTAssistNotification extends KTNotificationHandler {
'details' => $oKTNotification->getTextData1(),
'document' => $oDoc,
'is_broken' => $isBroken,
-
+ 'is_archived' => $isArchived,
+
));
return $oTemplate->render();
}
@@ -244,6 +249,70 @@ class KTAssistNotification extends KTNotificationHandler {
// $this->oNotification->delete(); // clear the alert.
exit(redirect($url));
}
+
+ function notify_restore() {
+ $iDocId = $this->oNotification->getIntData1();
+ $res = $this->restore($iDocId);
+ if(PEAR::isError($res) || !$res){
+ $msg = _kt('Document could not be restored');
+ if($res){
+ $msg .= ': '.$res->getMessage();
+ }
+ $this->addErrorMessage($msg);
+ }else{
+ $this->addInfoMessage(_kt('The document has been successfully restored.'));
+ }
+
+ $notify_id = $_REQUEST['id'];
+ $url = KTUtil::ktLink("notify.php", '', "id=$notify_id");
+ exit(redirect($url));
+ }
+
+ function restore($iDocId) {
+ // Get the document object
+ $oDoc = Document::get($iDocId);
+
+ if (PEAR::isError($oDoc) || ($oDoc === false)) {
+ return $oDoc;
+ }
+
+ $this->startTransaction();
+ $iRestoreFolder = $oDoc->getRestoreFolderId();
+ $oFolder = Folder::get($iRestoreFolder);
+
+ // move to root if parent no longer exists.
+ if (PEAR::isError($oFolder)) {
+ $oDoc->setFolderId(1);
+ $oFolder = Folder::get(1);
+ } else {
+ $oDoc->setFolderId($iRestoreFolder);
+ }
+
+ $oStorage = KTStorageManagerUtil::getSingleton();
+
+ if ($oStorage->restore($oDoc)) {
+ $oDoc = Document::get($iDocId); // storage path has changed for most recent object...
+ $oDoc->setStatusId(LIVE);
+ $oDoc->setPermissionObjectId($oFolder->getPermissionObjectId());
+ $res = $oDoc->update();
+
+ if (PEAR::isError($res) || ($res == false)) {
+ return $res;
+ }
+
+ $res = KTPermissionUtil::updatePermissionLookup($oDoc);
+
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+
+ // create a doc-transaction.
+ $oTransaction = new DocumentTransaction($oDoc, sprintf(_kt("Restored from deleted state by %s"), $this->oUser->getName()), 'ktcore.transactions.update');
+ $oTransaction->create();
+ }
+ $this->commitTransaction();
+ return true;
+ }
}
?>
diff --git a/templates/ktcore/assist/assist_notification.smarty b/templates/ktcore/assist/assist_notification.smarty
index 5ebc91e..7612be0 100644
--- a/templates/ktcore/assist/assist_notification.smarty
+++ b/templates/ktcore/assist/assist_notification.smarty
@@ -15,7 +15,7 @@
{i18n}Clear Alert{/i18n}
+ class="ktAction ktInline ktDelete" style="position: relative;" >
{i18n}Clear Alert{/i18n}
diff --git a/templates/ktcore/assist/assist_notification_details.smarty b/templates/ktcore/assist/assist_notification_details.smarty
index befd3e4..f25164e 100644
--- a/templates/ktcore/assist/assist_notification_details.smarty
+++ b/templates/ktcore/assist/assist_notification_details.smarty
@@ -1,25 +1,27 @@
-
+
Request Assistance
+
{i18n arg_name=$document_name|sanitize arg_state=$state_name arg_user=$actor->getName()}A
user, #user#, has requested help on the document #name#, and you are
the owner or an admin of this document.{/i18n}
-
-- {i18n}Subject{/i18n}
-- {$subject|sanitize}
-- {i18n}Details{/i18n}
-- {$details|sanitize}
-
+{i18n}Subject{/i18n}
{$subject|sanitize}
+{i18n}Details{/i18n}
+{$details|sanitize}
-
+
{i18n}Clear Alert{/i18n}
+ class="ktAction ktInline ktDelete" style="position: relative;" >
{i18n}Clear Alert{/i18n}
diff --git a/view.php b/view.php
index 2bb77ba..d8b77ba 100644
--- a/view.php
+++ b/view.php
@@ -6,31 +6,31 @@
* Document Management Made Simple
* Copyright (C) 2008 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): ______________________________________
*/
@@ -128,7 +128,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
if (!KTBrowseUtil::inAdminMode($this->oUser, $oDocument->getFolderId())) {
if ($oDocument->getStatusID() == ARCHIVED) {
$this->oPage->addError(_kt('This document has been archived. Please contact the system administrator to have it restored if it is still needed.'));
- return $this->do_error();
+ return $this->do_request($oDocument);
} else if ($oDocument->getStatusID() == DELETED) {
$this->oPage->addError(_kt('This document has been deleted. Please contact the system administrator to have it restored if it is still needed.'));
return $this->do_error();
@@ -396,6 +396,73 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
return ' '; // don't actually do anything.
}
+ function do_request($oDocument) {
+ // Display form for sending a request through the the sys admin to unarchive the document
+ // name, document, request, submit
+
+ $oForm = new KTForm;
+ $oForm->setOptions(array(
+ 'label' => _kt('Request restoration of document'),
+ 'submit_label' => _kt('Send request'),
+ 'identifier' => '',
+ 'cancel_url' => KTBrowseUtil::getUrlForFolder($oFolder),
+ 'fail_action' => 'main',
+ 'context' => $this,
+ ));
+
+ $oForm->addWidget(
+ array('ktcore.widgets.text', array(
+ 'label' => _kt('Reason'),
+ 'name' => 'reason',
+ 'required' => true,
+ ))
+ );
+
+ $data = isset($_REQUEST['data']) ? $_REQUEST['data'] : array();
+
+ $iFolderId = $oDocument->getFolderID();
+ $oFolder = Folder::get($iFolderId);
+ $sFolderUrl = KTBrowseUtil::getUrlForFolder($oFolder);
+
+ if(!empty($data)){
+ $res = $oForm->validate();
+ if (!empty($res['errors'])) {
+ return $oForm->handleError('', $aError);
+ }
+
+ $aAdminGroups = Group::getAdministratorGroups();
+ if(!PEAR::isError($aAdminGroups) && !empty($aAdminGroups)){
+ foreach ($aAdminGroups as $oGroup) {
+ $aGroupUsers = $oGroup->getMembers();
+
+ // ensure unique users
+ foreach ($aGroupUsers as $oUser){
+ $aUsers[$oUser->getId()] = $oUser;
+ }
+ }
+
+ $sSubject = _kt('Request for an archived document to be restored');
+ $sDetails = $data['reason'];
+
+ // Send request
+ foreach ($aUsers as $oU) {
+ if (!PEAR::isError($oU)) {
+ include_once(KT_DIR.'/plugins/ktcore/KTAssist.php');
+ KTAssistNotification::newNotificationForDocument($oDocument, $oU, $this->oUser, $sSubject, $sDetails);
+ }
+ }
+
+ // Redirect to folder
+ $this->addInfoMessage(_kt('The System Administrators have been notified of your request.'));
+ redirect($sFolderUrl);
+ exit();
+ }
+ }
+
+ return $oForm->renderPage(_kt('Archived document request') . ': '.$oDocument->getName());
+ }
+
+
function getUserForId($iUserId) {
$u = User::get($iUserId);