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