Commit a3d0278dcdd87e08fad3ba8b348427c80a71bf39

Authored by michael
1 parent 2bbfabf2

#2725- don't allow the deletion of the Category document field


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2332 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/removeDocFieldBL.php
@@ -27,25 +27,30 @@ if (checkSession()) { @@ -27,25 +27,30 @@ if (checkSession()) {
27 if (isset($fDocFieldID)) { 27 if (isset($fDocFieldID)) {
28 $oDocField = DocumentField::get($fDocFieldID); 28 $oDocField = DocumentField::get($fDocFieldID);
29 if ($oDocField) { 29 if ($oDocField) {
30 -  
31 - // check if the document field is mapped to a document type first  
32 - $aDocumentTypes = $oDocField->getDocumentTypes();  
33 - if (count($aDocumentTypes) > 0) {  
34 - // display status message- can't delete  
35 - $oPatternCustom->setHtml(getFieldMappedPage($oDocField->getName(), $aDocumentTypes));  
36 - } else {  
37 - // perform the deletion  
38 - if (isset($fForDelete)) {  
39 - if ($oDocField->delete()) {  
40 - $oPatternCustom->setHtml(getDeleteSuccessPage()); 30 + // check if we're trying to delete the category field
  31 + if ($oDocField->getName() != "Category") {
  32 + // check if the document field is mapped to a document type first
  33 + $aDocumentTypes = $oDocField->getDocumentTypes();
  34 + if (count($aDocumentTypes) > 0) {
  35 + // display status message- can't delete
  36 + $oPatternCustom->setHtml(getFieldMappedPage($oDocField->getName(), $aDocumentTypes));
  37 + } else {
  38 + // perform the deletion
  39 + if (isset($fForDelete)) {
  40 + if ($oDocField->delete()) {
  41 + $oPatternCustom->setHtml(getDeleteSuccessPage());
  42 + } else {
  43 + $oPatternCustom->setHtml(getDeleteFailPage());
  44 + }
41 } else { 45 } else {
42 - $oPatternCustom->setHtml(getDeleteFailPage()); 46 + // delete confirmation page
  47 + $oPatternCustom->setHtml(getDeletePage($fDocFieldID));
  48 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForDelete=1");
43 } 49 }
44 - } else {  
45 - // delete confirmation page  
46 - $oPatternCustom->setHtml(getDeletePage($fDocFieldID));  
47 - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForDelete=1");  
48 } 50 }
  51 + } else {
  52 + // couldn't retrieve document field from db
  53 + $oPatternCustom->setHtml(getStatusPage("Read-only document field", "The 'Category' document field cannot be deleted."));
49 } 54 }
50 } else { 55 } else {
51 // couldn't retrieve document field from db 56 // couldn't retrieve document field from db