Commit 4dbf601bdf084ff46c7c6c84b983801125bea277
1 parent
9fdd2ae0
added check for the folder having a default document type
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1691 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
45 additions
and
31 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
| @@ -31,40 +31,53 @@ if (checkSession()) { | @@ -31,40 +31,53 @@ if (checkSession()) { | ||
| 31 | //user has permission to add document to this folder | 31 | //user has permission to add document to this folder |
| 32 | if (isset($fForStore)) { | 32 | if (isset($fForStore)) { |
| 33 | //user wants to store a document | 33 | //user wants to store a document |
| 34 | + | ||
| 35 | + // check that the folder has a default document type | ||
| 36 | + if (Folder::getDefaultFolderDocumentType($fFolderID)) { | ||
| 34 | //make sure the user actually selected a file first | 37 | //make sure the user actually selected a file first |
| 35 | - if (strlen($_FILES['fFile']['name']) > 0) { | ||
| 36 | - //if the user selected a file to upload | ||
| 37 | - //create the document in the database | ||
| 38 | - $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID); | ||
| 39 | - if (!(Document::documentExists($oDocument->getFileName(), $oDocument->getFolderID()))) { | ||
| 40 | - if ($oDocument->create()) { | ||
| 41 | - //if the document was successfully created in the db, then store it on the file system | ||
| 42 | - if (PhysicalDocumentManager::uploadPhysicalDocument($oDocument, $fFolderID, "None", $_FILES['fFile']['tmp_name'])) { | ||
| 43 | - //create the web document link | ||
| 44 | - $oWebDocument = & new WebDocument($oDocument->getID(), -1, 1, NOT_PUBLISHED, getCurrentDateTime()); | ||
| 45 | - $oWebDocument->create(); | ||
| 46 | - //create the document transaction record | ||
| 47 | - $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), "Document created", CREATE); | ||
| 48 | - $oDocumentTransaction->create(); | ||
| 49 | - | ||
| 50 | - // fire subscription alerts for the new document | ||
| 51 | - $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), | ||
| 52 | - SubscriptionConstants::subscriptionType("FolderSubscription"), | ||
| 53 | - array( "newDocumentName" => $oDocument->getName(), | ||
| 54 | - "folderName" => Folder::getFolderName($fFolderID))); | ||
| 55 | - $default->log->info("addDocumentBL.php fired $count subscription alerts for new document " . $oDocument->getName()); | ||
| 56 | - | ||
| 57 | - //redirect to the document view page | ||
| 58 | - redirect("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID(). "&fFirstEdit=1"); | 38 | + if (strlen($_FILES['fFile']['name']) > 0) { |
| 39 | + //if the user selected a file to upload | ||
| 40 | + //create the document in the database | ||
| 41 | + $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID); | ||
| 42 | + if (!(Document::documentExists($oDocument->getFileName(), $oDocument->getFolderID()))) { | ||
| 43 | + if ($oDocument->create()) { | ||
| 44 | + //if the document was successfully created in the db, then store it on the file system | ||
| 45 | + if (PhysicalDocumentManager::uploadPhysicalDocument($oDocument, $fFolderID, "None", $_FILES['fFile']['tmp_name'])) { | ||
| 46 | + //create the web document link | ||
| 47 | + $oWebDocument = & new WebDocument($oDocument->getID(), -1, 1, NOT_PUBLISHED, getCurrentDateTime()); | ||
| 48 | + $oWebDocument->create(); | ||
| 49 | + //create the document transaction record | ||
| 50 | + $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), "Document created", CREATE); | ||
| 51 | + $oDocumentTransaction->create(); | ||
| 52 | + | ||
| 53 | + // fire subscription alerts for the new document | ||
| 54 | + $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), | ||
| 55 | + SubscriptionConstants::subscriptionType("FolderSubscription"), | ||
| 56 | + array( "newDocumentName" => $oDocument->getName(), | ||
| 57 | + "folderName" => Folder::getFolderName($fFolderID))); | ||
| 58 | + $default->log->info("addDocumentBL.php fired $count subscription alerts for new document " . $oDocument->getName()); | ||
| 59 | + | ||
| 60 | + //redirect to the document view page | ||
| 61 | + redirect("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID(). "&fFirstEdit=1"); | ||
| 62 | + } else { | ||
| 63 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 64 | + $oDocument->delete(); | ||
| 65 | + $oPatternCustom = & new PatternCustom(); | ||
| 66 | + $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | ||
| 67 | + $main->setCentralPayload($oPatternCustom); | ||
| 68 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | ||
| 69 | + $main->setFormEncType("multipart/form-data"); | ||
| 70 | + $main->setErrorMessage("An error occured while storing the document on the file system"); | ||
| 71 | + $main->render(); | ||
| 72 | + } | ||
| 59 | } else { | 73 | } else { |
| 60 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 74 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 61 | - $oDocument->delete(); | ||
| 62 | $oPatternCustom = & new PatternCustom(); | 75 | $oPatternCustom = & new PatternCustom(); |
| 63 | $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 76 | $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); |
| 64 | $main->setCentralPayload($oPatternCustom); | 77 | $main->setCentralPayload($oPatternCustom); |
| 65 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | 78 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); |
| 66 | $main->setFormEncType("multipart/form-data"); | 79 | $main->setFormEncType("multipart/form-data"); |
| 67 | - $main->setErrorMessage("An error occured while storing the document on the file system"); | 80 | + $main->setErrorMessage("An error occured while storing the document in the database"); |
| 68 | $main->render(); | 81 | $main->render(); |
| 69 | } | 82 | } |
| 70 | } else { | 83 | } else { |
| @@ -74,7 +87,7 @@ if (checkSession()) { | @@ -74,7 +87,7 @@ if (checkSession()) { | ||
| 74 | $main->setCentralPayload($oPatternCustom); | 87 | $main->setCentralPayload($oPatternCustom); |
| 75 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | 88 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); |
| 76 | $main->setFormEncType("multipart/form-data"); | 89 | $main->setFormEncType("multipart/form-data"); |
| 77 | - $main->setErrorMessage("An error occured while storing the document in the database"); | 90 | + $main->setErrorMessage("A document with this file name already exists in this folder"); |
| 78 | $main->render(); | 91 | $main->render(); |
| 79 | } | 92 | } |
| 80 | } else { | 93 | } else { |
| @@ -84,19 +97,20 @@ if (checkSession()) { | @@ -84,19 +97,20 @@ if (checkSession()) { | ||
| 84 | $main->setCentralPayload($oPatternCustom); | 97 | $main->setCentralPayload($oPatternCustom); |
| 85 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | 98 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); |
| 86 | $main->setFormEncType("multipart/form-data"); | 99 | $main->setFormEncType("multipart/form-data"); |
| 87 | - $main->setErrorMessage("A document with this file name already exists in this folder"); | 100 | + $main->setErrorMessage("Please select a document by first clicking on 'Browse'. Then click 'Add'"); |
| 88 | $main->render(); | 101 | $main->render(); |
| 89 | } | 102 | } |
| 90 | } else { | 103 | } else { |
| 104 | + // the folder doesn't have a default document type | ||
| 91 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 105 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 92 | $oPatternCustom = & new PatternCustom(); | 106 | $oPatternCustom = & new PatternCustom(); |
| 93 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID)); | 107 | + $oPatternCustom->setHtml(getBrowsePage($fFolderID)); |
| 94 | $main->setCentralPayload($oPatternCustom); | 108 | $main->setCentralPayload($oPatternCustom); |
| 95 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | 109 | $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); |
| 96 | $main->setFormEncType("multipart/form-data"); | 110 | $main->setFormEncType("multipart/form-data"); |
| 97 | - $main->setErrorMessage("Please select a document by first clicking on 'Browse'. Then click 'Add'"); | 111 | + $main->setErrorMessage("The folder you're attempting to add the document to doesn't have a default document type.<br>Please correct this and try again.</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>"); |
| 98 | $main->render(); | 112 | $main->render(); |
| 99 | - } | 113 | + } |
| 100 | 114 | ||
| 101 | } else { | 115 | } else { |
| 102 | //we're still just browsing | 116 | //we're still just browsing |