Commit 3b006136d6caaa4a316a4f9f1efb9032f5aab651

Authored by michael
1 parent c5099a0f

refactored pattern and webtemplate usage


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2167 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php
1 <?php 1 <?php
2 /** 2 /**
3 * $Id$ 3 * $Id$
  4 + *
4 * Contains the business logic required to build the document view page. 5 * Contains the business logic required to build the document view page.
5 * Will use documentViewUI.php for HTML 6 * Will use documentViewUI.php for HTML
6 * 7 *
@@ -13,7 +14,6 @@ @@ -13,7 +14,6 @@
13 * o fBeginCollaboration - the user selected the 'Begin Collaboration' button 14 * o fBeginCollaboration - the user selected the 'Begin Collaboration' button
14 * o fFireSubscription - the document has been modified, and a subscription alert must be fired 15 * o fFireSubscription - the document has been modified, and a subscription alert must be fired
15 * 16 *
16 - *  
17 * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa 17 * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
18 * @date 21 January 2003 18 * @date 21 January 2003
19 * @package presentation.lookAndFeel.knowledgeTree.documentManager 19 * @package presentation.lookAndFeel.knowledgeTree.documentManager
@@ -50,6 +50,7 @@ require_once(&quot;$default-&gt;fileSystemRoot/lib/visualpatterns/PatternListBox.inc&quot;); @@ -50,6 +50,7 @@ require_once(&quot;$default-&gt;fileSystemRoot/lib/visualpatterns/PatternListBox.inc&quot;);
50 require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); 50 require_once("$default->fileSystemRoot/lib/web/WebDocument.inc");
51 51
52 require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc"); 52 require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc");
  53 +require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc");
53 54
54 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/restoreArchivedDocumentUI.inc"); 55 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/restoreArchivedDocumentUI.inc");
55 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); 56 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc");
@@ -58,20 +59,17 @@ require_once(&quot;$default-&gt;fileSystemRoot/presentation/lookAndFeel/knowledgeTree/fo @@ -58,20 +59,17 @@ require_once(&quot;$default-&gt;fileSystemRoot/presentation/lookAndFeel/knowledgeTree/fo
58 require_once("$default->fileSystemRoot/presentation/Html.inc"); 59 require_once("$default->fileSystemRoot/presentation/Html.inc");
59 60
60 if (checkSession()) { 61 if (checkSession()) {
  62 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  63 + $oPatternCustom = & new PatternCustom();
61 if (isset($fDocumentID)) { 64 if (isset($fDocumentID)) {
  65 + $oDocument = & Document::get($fDocumentID);
62 if (isset($fCollaborationEdit) && Permission::userHasDocumentWritePermission($fDocumentID)) { 66 if (isset($fCollaborationEdit) && Permission::userHasDocumentWritePermission($fDocumentID)) {
63 //return value from collaborationBL.php. User attempted to edt 67 //return value from collaborationBL.php. User attempted to edt
64 //a step in the document collaboration process that is currently being 68 //a step in the document collaboration process that is currently being
65 //executed 69 //executed
66 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
67 -  
68 - $oDocument = & Document::get($fDocumentID);  
69 - $oPatternCustom = & new PatternCustom();  
70 - $oPatternCustom->setHtml(getEditPage($oDocument));  
71 - $main->setCentralPayload($oPatternCustom); 70 + $oPatternCustom->setHtml(getPage($oDocument, true));
72 $main->setErrorMessage("You cannot edit a document collaboration step that is completed or currently underway"); 71 $main->setErrorMessage("You cannot edit a document collaboration step that is completed or currently underway");
73 $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID()); 72 $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID());
74 - $main->render();  
75 } else if (isset($fForInlineView) && Permission::userHasDocumentReadPermission($fDocumentID)) { 73 } else if (isset($fForInlineView) && Permission::userHasDocumentReadPermission($fDocumentID)) {
76 $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW); 74 $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW);
77 $oDocumentTransaction->create(); 75 $oDocumentTransaction->create();
@@ -90,10 +88,8 @@ if (checkSession()) { @@ -90,10 +88,8 @@ if (checkSession()) {
90 PhysicalDocumentManager::downloadPhysicalDocument($fDocumentID); 88 PhysicalDocumentManager::downloadPhysicalDocument($fDocumentID);
91 } 89 }
92 } else if (isset($fBeginCollaboration) && Permission::userHasDocumentWritePermission($fDocumentID)) { 90 } else if (isset($fBeginCollaboration) && Permission::userHasDocumentWritePermission($fDocumentID)) {
93 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
94 //begin the collaboration process 91 //begin the collaboration process
95 //first ensure that all steps in the collaboration process are assigned 92 //first ensure that all steps in the collaboration process are assigned
96 - $oDocument = Document::get($fDocumentID);  
97 $aFolderCollaboration = FolderCollaboration::getList("WHERE folder_id = " . $oDocument->getFolderID()); 93 $aFolderCollaboration = FolderCollaboration::getList("WHERE folder_id = " . $oDocument->getFolderID());
98 if (count($aFolderCollaboration) > 0) { 94 if (count($aFolderCollaboration) > 0) {
99 //if the the folder has collaboration steps set up 95 //if the the folder has collaboration steps set up
@@ -105,49 +101,26 @@ if (checkSession()) { @@ -105,49 +101,26 @@ if (checkSession()) {
105 //DocumentCollaboration::resetDocumentCollaborationSteps($fDocumentID); 101 //DocumentCollaboration::resetDocumentCollaborationSteps($fDocumentID);
106 102
107 $oDocument->beginCollaborationProcess(); 103 $oDocument->beginCollaborationProcess();
108 - $oPatternCustom = & new PatternCustom();  
109 - $oPatternCustom->setHtml(getEditPage($oDocument));  
110 - $main->setCentralPayload($oPatternCustom); 104 + $oPatternCustom->setHtml(getPage($oDocument, true));
111 $main->setErrorMessage("Document collaboration successfully started"); 105 $main->setErrorMessage("Document collaboration successfully started");
112 - $main->render();  
113 } else { 106 } else {
114 //not all the roles have actual users assigned to them, so we must assign the 107 //not all the roles have actual users assigned to them, so we must assign the
115 //default users and then proceed 108 //default users and then proceed
116 109
117 FolderUserRole::createDefaultFolderUserRoles($oDocument); 110 FolderUserRole::createDefaultFolderUserRoles($oDocument);
118 -  
119 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
120 -  
121 $oDocument->beginCollaborationProcess(); 111 $oDocument->beginCollaborationProcess();
122 - $oPatternCustom = & new PatternCustom();  
123 - $oPatternCustom->setHtml(getEditPage($oDocument));  
124 - $main->setCentralPayload($oPatternCustom); 112 + $oPatternCustom->setHtml(getPage($oDocument, true));
125 $main->setErrorMessage("Document collaboration successfully started"); 113 $main->setErrorMessage("Document collaboration successfully started");
126 - $main->render();  
127 -  
128 -  
129 - /*$oPatternCustom = & new PatternCustom();  
130 - $oPatternCustom->setHtml(getEditPage($oDocument));  
131 - $main->setCentralPayload($oPatternCustom);  
132 - $main->setErrorMessage("Document collaboration not started. Not all steps in the process have been assigned");  
133 - $main->render();*/  
134 } 114 }
135 } else { 115 } else {
136 //the folder has no collaboration set up yet, so we can't start document collaboration 116 //the folder has no collaboration set up yet, so we can't start document collaboration
137 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
138 - $oPatternCustom = & new PatternCustom();  
139 - $oPatternCustom->setHtml(getEditPage($oDocument));  
140 - $main->setCentralPayload($oPatternCustom); 117 + $oPatternCustom->setHtml(getPage($oDocument, true));
141 $main->setErrorMessage("The collaboration steps for the folder must be set up before collaboration can begin"); 118 $main->setErrorMessage("The collaboration steps for the folder must be set up before collaboration can begin");
142 - $main->render();  
143 } 119 }
144 } else if ((isset($fCollaborationStepComplete)) && (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($fDocumentID))) { 120 } else if ((isset($fCollaborationStepComplete)) && (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($fDocumentID))) {
145 //the user has signled that they have completed their step in the collaboration process 121 //the user has signled that they have completed their step in the collaboration process
146 if (DocumentCollaboration::isLastStepInCollaborationProcess($fDocumentID)) { 122 if (DocumentCollaboration::isLastStepInCollaborationProcess($fDocumentID)) {
147 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
148 //the last step in the collaboration process has been performed- email the document creator 123 //the last step in the collaboration process has been performed- email the document creator
149 -  
150 - $oDocument = Document::get($fDocumentID);  
151 $oDocument->endCollaborationProcess(); 124 $oDocument->endCollaborationProcess();
152 125
153 // on the last collaboration step- trigger a major revision 126 // on the last collaboration step- trigger a major revision
@@ -164,27 +137,18 @@ if (checkSession()) { @@ -164,27 +137,18 @@ if (checkSession()) {
164 $oEmail->send($oUser->getEmail(), "Document collaboration complete", $sBody); 137 $oEmail->send($oUser->getEmail(), "Document collaboration complete", $sBody);
165 138
166 //possibly set the document up for web publishing???? 139 //possibly set the document up for web publishing????
167 - $oPatternCustom = & new PatternCustom();  
168 - $oPatternCustom->setHtml(getEditPage($oDocument));  
169 - $main->setCentralPayload($oPatternCustom); 140 + $oPatternCustom->setHtml(getPage($oDocument, true));
170 $main->setErrorMessage("Document collaboration complete. The document initiator has been notified"); 141 $main->setErrorMessage("Document collaboration complete. The document initiator has been notified");
171 - $main->render();  
172 142
173 } else { 143 } else {
174 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
175 //start the next steps if all criteria are met 144 //start the next steps if all criteria are met
176 DocumentCollaboration::beginNextStepInCollaborationProcess($fDocumentID, $_SESSION["userID"]); 145 DocumentCollaboration::beginNextStepInCollaborationProcess($fDocumentID, $_SESSION["userID"]);
177 - $oDocument = Document::get($fDocumentID);  
178 - $oPatternCustom = & new PatternCustom();  
179 - $oPatternCustom->setHtml(getEditPage($oDocument));  
180 - $main->setCentralPayload($oPatternCustom); 146 + $oPatternCustom->setHtml(getPage($oDocument, true));
181 $main->setErrorMessage("The next steps in the collaboration process have been started"); 147 $main->setErrorMessage("The next steps in the collaboration process have been started");
182 - $main->render();  
183 } 148 }
184 } else if ((isset($fForPublish)) && (!DocumentCollaboration::documentIsPendingWebPublishing($fDocumentID))) { 149 } else if ((isset($fForPublish)) && (!DocumentCollaboration::documentIsPendingWebPublishing($fDocumentID))) {
185 if ($fSubmit) { 150 if ($fSubmit) {
186 // user wishes to publish document 151 // user wishes to publish document
187 - $oDocument = Document::get($fDocumentID);  
188 $aWebDocument = WebDocument::getList("document_id = $fDocumentID"); 152 $aWebDocument = WebDocument::getList("document_id = $fDocumentID");
189 $oWebDocument = $aWebDocument[0]; 153 $oWebDocument = $aWebDocument[0];
190 154
@@ -199,50 +163,33 @@ if (checkSession()) { @@ -199,50 +163,33 @@ if (checkSession()) {
199 } 163 }
200 164
201 if ($oWebDocument->update()) { 165 if ($oWebDocument->update()) {
202 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
203 $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE); 166 $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE);
204 $oDocumentTransaction->create(); 167 $oDocumentTransaction->create();
205 - $oDocument = Document::get($fDocumentID);  
206 if ((strlen($fWebSiteID) > 0) && (strlen($fComment) > 0)) { 168 if ((strlen($fWebSiteID) > 0) && (strlen($fComment) > 0)) {
207 DocumentCollaboration::notifyWebMaster($fDocumentID, $fComment); 169 DocumentCollaboration::notifyWebMaster($fDocumentID, $fComment);
208 } 170 }
209 - $oPatternCustom = & new PatternCustom();  
210 - $oPatternCustom->setHtml(getEditPage($oDocument));  
211 - $main->setCentralPayload($oPatternCustom); 171 + $oPatternCustom->setHtml(getPage($oDocument, true));
212 if ((strlen($fWebSiteID) > 0) && (strlen($fComment) > 0)) { 172 if ((strlen($fWebSiteID) > 0) && (strlen($fComment) > 0)) {
213 $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified"); 173 $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified");
214 } else { 174 } else {
215 $main->setErrorMessage("The document has been published"); 175 $main->setErrorMessage("The document has been published");
216 } 176 }
217 - $main->render();  
218 -  
219 } else { 177 } else {
220 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
221 - $oDocument = Document::get($fDocumentID);  
222 - $oPatternCustom = & new PatternCustom();  
223 - $oPatternCustom->setHtml(getEditPage($oDocument));  
224 - $main->setCentralPayload($oPatternCustom); 178 + $oPatternCustom->setHtml(getPage($oDocument, false));
225 $main->setErrorMessage("An error occured while attempting to update the document for publishing"); 179 $main->setErrorMessage("An error occured while attempting to update the document for publishing");
226 - $main->render();  
227 } 180 }
228 } else { 181 } else {
229 // prompt for the website to publish to 182 // prompt for the website to publish to
230 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
231 - $oDocument = Document::get($fDocumentID);  
232 - $oPatternCustom = & new PatternCustom();  
233 $oPatternCustom->setHtml(getWebPublishPage($oDocument)); 183 $oPatternCustom->setHtml(getWebPublishPage($oDocument));
234 - $main->setCentralPayload($oPatternCustom);  
235 $main->setFormAction($_SERVER['PHP_SELF']); 184 $main->setFormAction($_SERVER['PHP_SELF']);
236 - $main->render(); 185 + //$main->setDHTMLScrolling(false);
  186 + //$main->setOnLoadJavaScript("switchDiv('documentData')");
237 } 187 }
238 188
239 } else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) { 189 } else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) {
240 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
241 - require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc");  
242 -  
243 - $oDocument = & Document::get($fDocumentID);  
244 - 190 +
245 // check subscription flag 191 // check subscription flag
  192 + // ??
246 if (isset($fFireSubscription)) { 193 if (isset($fFireSubscription)) {
247 // fire subscription alerts for the modified document 194 // fire subscription alerts for the modified document
248 $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"), 195 $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"),
@@ -252,12 +199,11 @@ if (checkSession()) { @@ -252,12 +199,11 @@ if (checkSession()) {
252 $default->log->info("viewBL.php fired $count subscription alerts for modified document $fFolderName"); 199 $default->log->info("viewBL.php fired $count subscription alerts for modified document $fFolderName");
253 } 200 }
254 201
255 - $oPatternCustom = & new PatternCustom();  
256 if ($oDocument->isLive()) { 202 if ($oDocument->isLive()) {
257 if (Permission::userHasDocumentWritePermission($fDocumentID)) { 203 if (Permission::userHasDocumentWritePermission($fDocumentID)) {
258 - $oPatternCustom->setHtml(getEditPage($oDocument)); 204 + $oPatternCustom->setHtml(getPage($oDocument, true));
259 } else if (Permission::userHasDocumentReadPermission($fDocumentID)) { 205 } else if (Permission::userHasDocumentReadPermission($fDocumentID)) {
260 - $oPatternCustom->setHtml(getViewPage($oDocument)); 206 + $oPatternCustom->setHtml(getPage($oDocument, false));
261 } 207 }
262 } else if ($oDocument->isArchived()) { 208 } else if ($oDocument->isArchived()) {
263 $main->setErrorMessage("This document has been archived."); 209 $main->setErrorMessage("This document has been archived.");
@@ -273,29 +219,23 @@ if (checkSession()) { @@ -273,29 +219,23 @@ if (checkSession()) {
273 $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n"); 219 $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
274 $main->setErrorMessage("The document you have chosen no longer exists in the DMS."); 220 $main->setErrorMessage("The document you have chosen no longer exists in the DMS.");
275 } 221 }
276 - $main->setCentralPayload($oPatternCustom); 222 + $main->setDHTMLScrolling(false);
  223 + $main->setOnLoadJavaScript("switchDiv('documentData')");
277 $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID()); 224 $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID());
278 - $main->render();  
279 } else { 225 } else {
280 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
281 -  
282 - $oPatternCustom = & new PatternCustom();  
283 - $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n"); 226 + if ($oDocument) {
  227 + $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
  228 + } else {
  229 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
  230 + }
284 $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."); 231 $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.");
285 - $main->setCentralPayload($oPatternCustom);  
286 - $main->render();  
287 } 232 }
288 } else { 233 } else {
289 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 234 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
290 -  
291 - $oPatternCustom = & new PatternCustom();  
292 - $oPatternCustom->setHtml(""); 235 + $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
293 $main->setErrorMessage("You have not chosen a document to view"); 236 $main->setErrorMessage("You have not chosen a document to view");
294 - $main->setCentralPayload($oPatternCustom);  
295 - $main->render();  
296 } 237 }
  238 + $main->setCentralPayload($oPatternCustom);
  239 + $main->render();
297 } 240 }
298 -  
299 -?>  
300 -  
301 - 241 +?>
302 \ No newline at end of file 242 \ No newline at end of file