diff --git a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitBL.php b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitBL.php index 002f300..a1b3d69 100644 --- a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitBL.php +++ b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitBL.php @@ -45,24 +45,33 @@ if (checkSession()) { if (isset($fForStore)) { if($fUnitName != "" and $fOrgID != "") { - $oUnit = new Unit($fUnitName); - - // if creation is successfull..get the unit id - if ($oUnit->create()) { - $unitID = $oUnit->getID(); - $oUnitOrg = new UnitOrganisationLink($unitID,$fOrgID); - - if($oUnitOrg->create()) { - // if successfull print out success message - $oPatternCustom->setHtml(getAddPageSuccess()); - } else { - // if fail print out fail message - $oPatternCustom->setHtml(getAddToOrgFail()); - } - } else { - // if fail print out fail message - $oPatternCustom->setHtml(getAddPageFail()); - } + // #2944 a folder will be created for this unit, so check if there is already a folder with the name + // of the unit before creating the unit + $oFolder = new Folder($fUnitName, $fUnitName . " Unit Root Folder", 1, $_SESSION["userID"], 0); + if (!$oFolder->exists()) { + + $oUnit = new Unit($fUnitName); + + // if creation is successfull..get the unit id + if ($oUnit->create()) { + $unitID = $oUnit->getID(); + $oUnitOrg = new UnitOrganisationLink($unitID,$fOrgID); + + if($oUnitOrg->create()) { + // if successfull print out success message + $oPatternCustom->setHtml(getAddPageSuccess()); + } else { + // if fail print out fail message + $oPatternCustom->setHtml(getAddToOrgFail()); + } + } else { + // if fail print out fail message + $oPatternCustom->setHtml(getAddPageFail("The Unit was not added. Unit Name Already exists!")); + } + } else { + // #2944 failed with duplicate folder error message + $oPatternCustom->setHtml(getAddPageFail("The folder $fUnitName already exists, please rename folder before creating this unit.")); + } } else { $oPatternCustom->setHtml(getPageFail()); } diff --git a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitUI.inc b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitUI.inc index 8bab619..c852889 100644 --- a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitUI.inc @@ -75,14 +75,14 @@ function getAddPageSuccess() { } // if edition is successful print out failure page -function getAddPageFail() { +function getAddPageFail($sMessage) { global $default; $sToRender .= renderHeading("Add Unit"); $sToRender .= "
| Addition Unsuccessful |
| The Unit was not added. Unit Name Already exists! |
| $sMessage |