viewBL.php
10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* documentViewUI.php
* Contains the business logic required to build the document view page.
* Will use documentViewUI.php for HTML
*
* Expected form varaibles:
* o $fDocumentID - Primary key of document to view
*
* Optional form variables:
* o fCollaborationEdit - the user attempted to edit a collaboration step that is currently active
* o fForDownload - the user is attempting to download the document
* o fBeginCollaboration - the user selected the 'Begin Collaboration' button
* o fFireSubscription - the document has been modified, and a subscription alert must be fired
*
*
* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
* @date 21 January 2003
* @package presentation.lookAndFeel.knowledgeTree.documentManager
*/
require_once("../../../../config/dmsDefaults.php");
require_once("$default->fileSystemRoot/lib/security/permission.inc");
require_once("$default->fileSystemRoot/lib/email/Email.inc");
require_once("$default->fileSystemRoot/lib/users/User.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/FolderUserRole.inc");
require_once("$default->fileSystemRoot/lib/roles/Role.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc");
require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc");
require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc");
require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
require_once("$default->fileSystemRoot/presentation/Html.inc");
if (checkSession()) {
if (isset($fDocumentID)) {
if (isset($fCollaborationEdit) && Permission::userHasDocumentWritePermission($fDocumentID)) {
//return value from collaborationBL.php. User attempted to edt
//a step in the document collaboration process that is currently being
//executed
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oDocument = & Document::get($fDocumentID);
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getEditPage($oDocument));
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("You cannot edit a document collaboration step that is completed or currently underway");
$main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID());
$main->render();
} else if (isset($fForInlineView) && Permission::userHasDocumentReadPermission($fDocumentID)) {
$oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", DOWNLOAD);
$oDocumentTransaction->create();
PhysicalDocumentManager::inlineViewPhysicalDocument($fDocumentID);
} else if (isset($fForDownload) && Permission::userHasDocumentReadPermission($fDocumentID)) {
//if the user has document read permission, perform the download
$oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document downloaded", DOWNLOAD);
$oDocumentTransaction->create();
PhysicalDocumentManager::downloadPhysicalDocument($fDocumentID);
} else if (isset($fBeginCollaboration) && Permission::userHasDocumentWritePermission($fDocumentID)) {
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
//begin the collaboration process
//first ensure that all steps in the collaboration process are assigned
$oDocument = Document::get($fDocumentID);
$aFolderCollaboration = FolderCollaboration::getList("WHERE folder_id = " . $oDocument->getFolderID());
if (count($aFolderCollaboration) > 0) {
//if the the folder has collaboration steps set up
$aFolderUserRoles = FolderUserRole::getList("WHERE document_id = " . $fDocumentID);
if (count($aFolderCollaboration) == count($aFolderUserRoles)) {
//if all the roles have been assigned we can start the collaboration process
$oDocument->beginCollaborationProcess();
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getEditPage($oDocument));
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("Document collaboration successfully started");
$main->render();
} else {
//not all the roles have users assigned to them, so display an error message
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getEditPage($oDocument));
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("Document collaboration not started. Not all steps in the process have been assigned");
$main->render();
}
} else {
//the folder has no collaboration set up yet, so we can't start document collaboration
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getEditPage($oDocument));
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("The collaboration steps for the folder must be set up before collaboration can begin");
$main->render();
}
} else if (isset($fCollaborationStepComplete)) {
//the user has signled that they have completed their step in the collaboration process
if (Document::isLastStepInCollaborationProcess($fDocumentID)) {
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
//the last step in the collaboration process has been performed
//reset all the steps and email the document creator
Document::resetDocumentCollaborationSteps($fDocumentID);
$oDocument = Document::get($fDocumentID);
$oUser = User::get($oDocument->getCreatorID());
$sBody = $oUser->getUserName() . ", the collaboration process for the document, '<a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\">" . $oDocument->getName() . "</a>', has been completed. ";
$oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);
$oEmail->send($oUser->getEmail(), "Document collaboration complete", $sBody, $default->owl_email_from, $default->owl_email_fromname);
//possibly set the document up for web publishing????
$oDocument = Document::get($fDocumentID);
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getEditPage($oDocument));
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("Document collaboration complete. The document initiator has been notified");
$main->render();
} else {
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
//start the next steps if all criteria are met
Document::beginNextStepInCollaborationProcess($fDocumentID, $_SESSION["userID"]);
$oDocument = Document::get($fDocumentID);
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getEditPage($oDocument));
$main->setCentralPayload($oPatternCustom);
$main->setErrorMessage("The next steps in the collaboration process have been started");
$main->render();
}
} else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) {
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc");
$oDocument = & Document::get($fDocumentID);
// check subscription flag
if (isset($fFireSubscription)) {
// fire subscription alerts for the modified document
$count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"),
SubscriptionConstants::subscriptionType("DocumentSubscription"),
array( "modifiedDocumentName" => $oDocument->getName()));
$default->log->info("viewBL.php fired $count subscription alerts for modified document $fFolderName");
}
$oPatternCustom = & new PatternCustom();
if (Permission::userHasDocumentWritePermission($fDocumentID)) {
$oPatternCustom->setHtml(getEditPage($oDocument));
} else if (Permission::userHasDocumentReadPermission($fDocumentID)) {
$oPatternCustom->setHtml(getViewPage($oDocument));
}
$main->setCentralPayload($oPatternCustom);
$main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID());
$main->render();
} else {
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml("");
$main->setErrorMessage("Either you do not have permission to view this document, or the document you have chosen no longer exists on the file system.");
$main->setCentralPayload($oPatternCustom);
$main->render();
}
} else {
require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml("");
$main->setErrorMessage("You have not chosen a document to view");
$main->setCentralPayload($oPatternCustom);
$main->render();
}
}
?>