Commit b714ef17b766ea84b06e10cb146fb27e17e1d89a
1 parent
5ef1f834
KTS-1686
"Fieldsets should not be deleted, but flagged instead. " Fixed. Reviewed By: Kevin git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6388 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
7 changed files
with
25 additions
and
7 deletions
lib/database/dbutil.inc
| @@ -218,6 +218,15 @@ class DBUtil { | @@ -218,6 +218,15 @@ class DBUtil { | ||
| 218 | $aParams = array($iId); | 218 | $aParams = array($iId); |
| 219 | return DBUtil::runQuery(array($sQuery, $aParams), $db); | 219 | return DBUtil::runQuery(array($sQuery, $aParams), $db); |
| 220 | } | 220 | } |
| 221 | + | ||
| 222 | + function deReference($sTable, $iId, $db = null) { | ||
| 223 | + global $default; | ||
| 224 | + // $default->log->debug('AutoDelete called for table ' . $sTable . ' with id ' . $iId); | ||
| 225 | + $db =& DBUtil::getDB(); | ||
| 226 | + $sQuery = "UPDATE " . $sTable . " SET disabled = true WHERE id = ?"; | ||
| 227 | + $aParams = array($iId); | ||
| 228 | + return DBUtil::runQuery(array($sQuery, $aParams), $db); | ||
| 229 | + } | ||
| 221 | 230 | ||
| 222 | function &whereDelete($sTable, $aWhereFieldValues, $db = null) { | 231 | function &whereDelete($sTable, $aWhereFieldValues, $db = null) { |
| 223 | global $default; | 232 | global $default; |
lib/ktentity.inc
| @@ -161,13 +161,17 @@ class KTEntity { | @@ -161,13 +161,17 @@ class KTEntity { | ||
| 161 | * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"] | 161 | * @return boolean true on successful deletion, false otherwise and set $_SESSION["errorMessage"] |
| 162 | * | 162 | * |
| 163 | */ | 163 | */ |
| 164 | - function delete() { | 164 | + function delete($dereference = null) { |
| 165 | $group = sprintf("%s/%s", get_class($this), 'id'); | 165 | $group = sprintf("%s/%s", get_class($this), 'id'); |
| 166 | $oCache =& KTCache::getSingleton(); | 166 | $oCache =& KTCache::getSingleton(); |
| 167 | $oCache->remove($group, $this->iId); | 167 | $oCache->remove($group, $this->iId); |
| 168 | $this->clearCachedGroups(); | 168 | $this->clearCachedGroups(); |
| 169 | if ($this->iId >= 0) { | 169 | if ($this->iId >= 0) { |
| 170 | - $res = DBUtil::autoDelete($this->_table(), $this->iId); | 170 | + if($dereference = 'true'){ |
| 171 | + $res = DBUtil::deReference($this->_table(), $this->iId); | ||
| 172 | + }else{ | ||
| 173 | + $res = DBUtil::autoDelete($this->_table(), $this->iId); | ||
| 174 | + } | ||
| 171 | if (PEAR::isError($res)) { | 175 | if (PEAR::isError($res)) { |
| 172 | if ($this->_bUsePearError === false) { | 176 | if ($this->_bUsePearError === false) { |
| 173 | $_SESSION['errorMessage'] = $res->toString(); | 177 | $_SESSION['errorMessage'] = $res->toString(); |
lib/metadata/fieldset.inc.php
| @@ -158,6 +158,7 @@ class KTFieldset extends KTEntity { | @@ -158,6 +158,7 @@ class KTFieldset extends KTEntity { | ||
| 158 | )); | 158 | )); |
| 159 | return KTEntityUtil::getByDict('KTFieldset', array( | 159 | return KTEntityUtil::getByDict('KTFieldset', array( |
| 160 | 'is_generic' => false, | 160 | 'is_generic' => false, |
| 161 | + 'disabled' => false, | ||
| 161 | ), $aOptions); | 162 | ), $aOptions); |
| 162 | } | 163 | } |
| 163 | 164 | ||
| @@ -168,6 +169,7 @@ class KTFieldset extends KTEntity { | @@ -168,6 +169,7 @@ class KTFieldset extends KTEntity { | ||
| 168 | ); | 169 | ); |
| 169 | return KTEntityUtil::getByDict('KTFieldset', array( | 170 | return KTEntityUtil::getByDict('KTFieldset', array( |
| 170 | 'is_generic' => true, | 171 | 'is_generic' => true, |
| 172 | + 'disabled' => false, | ||
| 171 | ), $aOptions); | 173 | ), $aOptions); |
| 172 | } | 174 | } |
| 173 | 175 | ||
| @@ -231,12 +233,14 @@ class KTFieldset extends KTEntity { | @@ -231,12 +233,14 @@ class KTFieldset extends KTEntity { | ||
| 231 | function &getByNamespace($sNamespace) { | 233 | function &getByNamespace($sNamespace) { |
| 232 | return KTEntityUtil::getByDict('KTFieldset', array( | 234 | return KTEntityUtil::getByDict('KTFieldset', array( |
| 233 | 'namespace' => $sNamespace, | 235 | 'namespace' => $sNamespace, |
| 236 | + 'disabled' => false, | ||
| 234 | )); | 237 | )); |
| 235 | } | 238 | } |
| 236 | 239 | ||
| 237 | function &getByName($sName) { | 240 | function &getByName($sName) { |
| 238 | return KTEntityUtil::getByDict('KTFieldset', array( | 241 | return KTEntityUtil::getByDict('KTFieldset', array( |
| 239 | 'name' => $sName, | 242 | 'name' => $sName, |
| 243 | + 'disabled' => false, | ||
| 240 | )); | 244 | )); |
| 241 | } | 245 | } |
| 242 | } | 246 | } |
lib/metadata/metadatautil.inc.php
| @@ -684,7 +684,8 @@ class KTMetadataUtil { | @@ -684,7 +684,8 @@ class KTMetadataUtil { | ||
| 684 | "FROM $default->document_metadata_version_table AS DM INNER JOIN document_fields_link AS DFL ON DM.id = DFL.metadata_version_id " . | 684 | "FROM $default->document_metadata_version_table AS DM INNER JOIN document_fields_link AS DFL ON DM.id = DFL.metadata_version_id " . |
| 685 | "INNER JOIN $default->document_fields_table AS DF ON DF.ID = DFL.document_field_id " . | 685 | "INNER JOIN $default->document_fields_table AS DF ON DF.ID = DFL.document_field_id " . |
| 686 | "INNER JOIN $default->fieldsets_table AS F ON F.id = DF.parent_fieldset " . | 686 | "INNER JOIN $default->fieldsets_table AS F ON F.id = DF.parent_fieldset " . |
| 687 | - "WHERE DM.id = ?"; | 687 | + "WHERE DM.id = ?" . |
| 688 | + "AND F.disabled = false"; | ||
| 688 | $aParam = array($iMetadataVersionId); | 689 | $aParam = array($iMetadataVersionId); |
| 689 | $aDocumentFieldsetIds = DBUtil::getResultArrayKey(array($sQuery, $aParam), 'fieldset_id'); | 690 | $aDocumentFieldsetIds = DBUtil::getResultArrayKey(array($sQuery, $aParam), 'fieldset_id'); |
| 690 | 691 |
lib/upgrades/UpgradeFunctions.inc.php
| @@ -785,7 +785,7 @@ class UpgradeFunctions { | @@ -785,7 +785,7 @@ class UpgradeFunctions { | ||
| 785 | '-12' => 'ktcore.criteria.searchabletext', | 785 | '-12' => 'ktcore.criteria.searchabletext', |
| 786 | '-11' => 'ktcore.criteria.transactiontext'); | 786 | '-11' => 'ktcore.criteria.transactiontext'); |
| 787 | 787 | ||
| 788 | - $aFieldsets =& KTFieldset::getList(); | 788 | + $aFieldsets =& KTFieldset::getList('disabled != true'); |
| 789 | foreach($aFieldsets as $oFieldset) { | 789 | foreach($aFieldsets as $oFieldset) { |
| 790 | $aFields =& DocumentField::getByFieldset($oFieldset); | 790 | $aFields =& DocumentField::getByFieldset($oFieldset); |
| 791 | foreach($aFields as $oField) { | 791 | foreach($aFields as $oField) { |
plugins/ktcore/admin/documentFieldsv2.php
| @@ -54,7 +54,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | @@ -54,7 +54,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | ||
| 54 | 54 | ||
| 55 | $oTemplate->setData(array( | 55 | $oTemplate->setData(array( |
| 56 | 'context' => $this, | 56 | 'context' => $this, |
| 57 | - 'fieldsets' => KTFieldset::getList(), | 57 | + 'fieldsets' => KTFieldset::getList('disabled != true'), |
| 58 | )); | 58 | )); |
| 59 | return $oTemplate; | 59 | return $oTemplate; |
| 60 | } | 60 | } |
| @@ -270,7 +270,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | @@ -270,7 +270,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | ||
| 270 | 270 | ||
| 271 | function do_delete() { | 271 | function do_delete() { |
| 272 | $this->startTransaction(); | 272 | $this->startTransaction(); |
| 273 | - $res = $this->oFieldset->delete(); | 273 | + $res = $this->oFieldset->delete('true'); |
| 274 | $this->oValidator->notErrorFalse($res, array( | 274 | $this->oValidator->notErrorFalse($res, array( |
| 275 | 'redirect_to' => array('main', ''), | 275 | 'redirect_to' => array('main', ''), |
| 276 | 'message' => _kt('Could not delete fieldset'), | 276 | 'message' => _kt('Could not delete fieldset'), |
plugins/ktcore/admin/manageConditionals.php
| @@ -52,7 +52,7 @@ class ManageConditionalDispatcher extends KTAdminDispatcher { | @@ -52,7 +52,7 @@ class ManageConditionalDispatcher extends KTAdminDispatcher { | ||
| 52 | 52 | ||
| 53 | function do_main() { | 53 | function do_main() { |
| 54 | 54 | ||
| 55 | - $aFieldsets = KTFieldset::getList("is_conditional = 1"); | 55 | + $aFieldsets = KTFieldset::getList("is_conditional = 1 AND disabled != true"); |
| 56 | $oTemplating =& KTTemplating::getSingleton(); | 56 | $oTemplating =& KTTemplating::getSingleton(); |
| 57 | 57 | ||
| 58 | $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/conditional/select_fieldset"); | 58 | $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/conditional/select_fieldset"); |