Commit 4726e87f5ee0be33911e0ae9b9d3348343001c0b

Authored by Neil Blakey-Milner
1 parent 54b8ba2d

Allow Units to be created with their homes anywhere in the folder

hierarchy.

Submitted by:	Stefano Ciancio (sciancio)
SF Tracker:	1182024


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3281 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/unitmanagement/Unit.inc
@@ -30,12 +30,14 @@ class Unit extends KTEntity { @@ -30,12 +30,14 @@ class Unit extends KTEntity {
30 var $iId; 30 var $iId;
31 /** unit's name */ 31 /** unit's name */
32 var $sName; 32 var $sName;
  33 + /** folder's id */
  34 + var $iFolderID;
33 35
34 -  
35 - function Unit($sNewName) { 36 + function Unit($sNewName, $iNewFolderID=1) {
36 //object has not been created in database yet 37 //object has not been created in database yet
37 $this->iId = -1; 38 $this->iId = -1;
38 $this->sName = $sNewName; 39 $this->sName = $sNewName;
  40 + $this->iFolderID = $iNewFolderID;
39 } 41 }
40 42
41 /** 43 /**
@@ -93,7 +95,7 @@ class Unit extends KTEntity { @@ -93,7 +95,7 @@ class Unit extends KTEntity {
93 95
94 // create a new unit root folder 96 // create a new unit root folder
95 // FIXME: lookup the organisation for this unit and use the appropriate folder id for the org root folder 97 // FIXME: lookup the organisation for this unit and use the appropriate folder id for the org root folder
96 - $oFolder = new Folder($this->sName, $this->sName . " Unit Root Folder", 1, $_SESSION["userID"], $this->iId); 98 + $oFolder = new Folder($this->sName, $this->sName . " Unit Root Folder", $this->iFolderID, $_SESSION["userID"], $this->iId);
97 if (!$oFolder->exists()) { 99 if (!$oFolder->exists()) {
98 if ($oFolder->create()) { 100 if ($oFolder->create()) {
99 if (PhysicalFolderManagement::createFolder(Folder::getFolderPath($oFolder->getID()))) { 101 if (PhysicalFolderManagement::createFolder(Folder::getFolderPath($oFolder->getID()))) {
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitBL.php
@@ -46,15 +46,17 @@ if (checkSession()) { @@ -46,15 +46,17 @@ if (checkSession()) {
46 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 46 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
47 $oPatternCustom = & new PatternCustom(); 47 $oPatternCustom = & new PatternCustom();
48 48
49 - if (isset($fForStore)) {  
50 - if($fUnitName != "" and $fOrgID != "") { 49 + if (isset($fFolderID)) {
  50 +
  51 + if (isset($fForStore)) {
  52 + if($fUnitName != "" and $fOrgID != "" and $fFolderID != "") {
51 // #2944 a folder will be created for this unit, so check if there is already a folder with the name 53 // #2944 a folder will be created for this unit, so check if there is already a folder with the name
52 // of the unit before creating the unit 54 // of the unit before creating the unit
53 - $oFolder = new Folder($fUnitName, $fUnitName . " " . _("Unit Root Folder"), 1, $_SESSION["userID"], 0); 55 + $oFolder = new Folder($fUnitName, $fUnitName . " " . _("Unit Root Folder"), $fFolderID, $_SESSION["userID"], 0);
54 if (!$oFolder->exists()) { 56 if (!$oFolder->exists()) {
55 57
56 - $oUnit = new Unit($fUnitName);  
57 - 58 + $oUnit = new Unit($fUnitName, $fFolderID);
  59 +
58 // if creation is successfull..get the unit id 60 // if creation is successfull..get the unit id
59 if ($oUnit->create()) { 61 if ($oUnit->create()) {
60 $unitID = $oUnit->getID(); 62 $unitID = $oUnit->getID();
@@ -82,11 +84,13 @@ if (checkSession()) { @@ -82,11 +84,13 @@ if (checkSession()) {
82 } else { 84 } else {
83 // display add unit page 85 // display add unit page
84 $oPatternCustom->setHtml(getAddPage()); 86 $oPatternCustom->setHtml(getAddPage());
  87 + $oPatternCustom->addHtml(renderBrowsePage($fFolderID));
85 $main->setHasRequiredFields(true); 88 $main->setHasRequiredFields(true);
86 - $main->setFormAction($_SERVER["PHP_SELF"]. "?fForStore=1"); 89 + $main->setFormAction($_SERVER["PHP_SELF"]. "?fForStore=1&fFolderID=$fFolderID");
87 90
88 } 91 }
89 $main->setCentralPayload($oPatternCustom); 92 $main->setCentralPayload($oPatternCustom);
90 $main->render(); 93 $main->render();
  94 + }
91 } 95 }
92 ?> 96 ?>
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/addUnitUI.inc
@@ -86,7 +86,7 @@ function getAddPageFail($sMessage) { @@ -86,7 +86,7 @@ function getAddPageFail($sMessage) {
86 $sToRender .= "<tr></tr>\n"; 86 $sToRender .= "<tr></tr>\n";
87 $sToRender .= "<tr></tr>\n"; 87 $sToRender .= "<tr></tr>\n";
88 $sToRender .= "<tr>\n"; 88 $sToRender .= "<tr>\n";
89 - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=addUnit\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n"; 89 + $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=addUnit&fFolderID=1\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n";
90 $sToRender .= "</tr>\n"; 90 $sToRender .= "</tr>\n";
91 $sToRender .= "</table>\n"; 91 $sToRender .= "</table>\n";
92 92
@@ -144,4 +144,23 @@ function getOrgDisplay() { @@ -144,4 +144,23 @@ function getOrgDisplay() {
144 // $oPatternListBox = & new PatternListBox($default->organisations_table, "name", "id", "fOrgID"); 144 // $oPatternListBox = & new PatternListBox($default->organisations_table, "name", "id", "fOrgID");
145 // return $oPatternListBox->render(); 145 // return $oPatternListBox->render();
146 } 146 }
  147 +
  148 +
  149 +function renderBrowsePage($fFolderID) {
  150 + global $default;
  151 + $sToRender = "<table border=\"0\">\n";
  152 + $sToRender .= "<tr>\n";
  153 + $sToRender .= "\t<td>" . renderFolderPath($fFolderID, generateControllerUrl("addUnit", "", false)) . "</td>\n";
  154 + $sToRender .= "</tr>\n";
  155 + $sToRender .= "</table>\n";
  156 + $sToRender .= "<table border=\"0\">\n";
  157 + $sToRender .= "<tr>\n";
  158 + $sToRender .= "\t<td>" . renderFolderList($fFolderID, generateControllerUrl("addUnit", "", false)) . "<td>\n";
  159 +
  160 + $sToRender .= "</tr>\n";
  161 + $sToRender .= "</table><br>\n";
  162 +
  163 + return $sToRender;
  164 +}
  165 +
147 ?> 166 ?>
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsUI.inc
@@ -69,7 +69,8 @@ function getPage($iOrganisationID) { @@ -69,7 +69,8 @@ function getPage($iOrganisationID) {
69 global $default; 69 global $default;
70 $sToRender .= renderHeading(_("Unit Management")); 70 $sToRender .= renderHeading(_("Unit Management"));
71 71
72 - $sToRender .= getAddLink("addUnit", _("Add A Unit")); 72 + $sToRender .= getAddLink("addUnit&fFolderID=1", _("Add A Unit"));
  73 +
73 //$sToRender .= getOrganisationDisplay($iOrganisationID); 74 //$sToRender .= getOrganisationDisplay($iOrganisationID);
74 $sToRender .= getUnits($iOrganisationID); 75 $sToRender .= getUnits($iOrganisationID);
75 return $sToRender; 76 return $sToRender;