Commit 25b5d0ef3ecc1519fbb403391ae8ec80aaf12498
1 parent
100cfe22
#2944 added check for existing folder and appropriate error message.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2788 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
29 additions
and
20 deletions
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitBL.php
| ... | ... | @@ -45,24 +45,33 @@ if (checkSession()) { |
| 45 | 45 | |
| 46 | 46 | if (isset($fForStore)) { |
| 47 | 47 | if($fUnitName != "" and $fOrgID != "") { |
| 48 | - $oUnit = new Unit($fUnitName); | |
| 49 | - | |
| 50 | - // if creation is successfull..get the unit id | |
| 51 | - if ($oUnit->create()) { | |
| 52 | - $unitID = $oUnit->getID(); | |
| 53 | - $oUnitOrg = new UnitOrganisationLink($unitID,$fOrgID); | |
| 54 | - | |
| 55 | - if($oUnitOrg->create()) { | |
| 56 | - // if successfull print out success message | |
| 57 | - $oPatternCustom->setHtml(getAddPageSuccess()); | |
| 58 | - } else { | |
| 59 | - // if fail print out fail message | |
| 60 | - $oPatternCustom->setHtml(getAddToOrgFail()); | |
| 61 | - } | |
| 62 | - } else { | |
| 63 | - // if fail print out fail message | |
| 64 | - $oPatternCustom->setHtml(getAddPageFail()); | |
| 65 | - } | |
| 48 | + // #2944 a folder will be created for this unit, so check if there is already a folder with the name | |
| 49 | + // of the unit before creating the unit | |
| 50 | + $oFolder = new Folder($fUnitName, $fUnitName . " Unit Root Folder", 1, $_SESSION["userID"], 0); | |
| 51 | + if (!$oFolder->exists()) { | |
| 52 | + | |
| 53 | + $oUnit = new Unit($fUnitName); | |
| 54 | + | |
| 55 | + // if creation is successfull..get the unit id | |
| 56 | + if ($oUnit->create()) { | |
| 57 | + $unitID = $oUnit->getID(); | |
| 58 | + $oUnitOrg = new UnitOrganisationLink($unitID,$fOrgID); | |
| 59 | + | |
| 60 | + if($oUnitOrg->create()) { | |
| 61 | + // if successfull print out success message | |
| 62 | + $oPatternCustom->setHtml(getAddPageSuccess()); | |
| 63 | + } else { | |
| 64 | + // if fail print out fail message | |
| 65 | + $oPatternCustom->setHtml(getAddToOrgFail()); | |
| 66 | + } | |
| 67 | + } else { | |
| 68 | + // if fail print out fail message | |
| 69 | + $oPatternCustom->setHtml(getAddPageFail("The Unit was not added. Unit Name Already exists!")); | |
| 70 | + } | |
| 71 | + } else { | |
| 72 | + // #2944 failed with duplicate folder error message | |
| 73 | + $oPatternCustom->setHtml(getAddPageFail("The folder $fUnitName already exists, please rename folder before creating this unit.")); | |
| 74 | + } | |
| 66 | 75 | } else { |
| 67 | 76 | $oPatternCustom->setHtml(getPageFail()); |
| 68 | 77 | } | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitUI.inc
| ... | ... | @@ -75,14 +75,14 @@ function getAddPageSuccess() { |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // if edition is successful print out failure page |
| 78 | -function getAddPageFail() { | |
| 78 | +function getAddPageFail($sMessage) { | |
| 79 | 79 | global $default; |
| 80 | 80 | |
| 81 | 81 | $sToRender .= renderHeading("Add Unit"); |
| 82 | 82 | $sToRender .= "<table>\n"; |
| 83 | 83 | $sToRender .= "<tr><td><b>Addition Unsuccessful</b></td></tr>\n"; |
| 84 | 84 | $sToRender .= "<tr></tr>\n"; |
| 85 | - $sToRender .= "<tr><td>The Unit was not added. Unit Name Already exists!</td></tr>\n"; | |
| 85 | + $sToRender .= "<tr><td>$sMessage</td></tr>\n"; | |
| 86 | 86 | $sToRender .= "<tr></tr>\n"; |
| 87 | 87 | $sToRender .= "<tr></tr>\n"; |
| 88 | 88 | $sToRender .= "<tr>\n"; | ... | ... |