Commit d3b12e42d57f5330368606a5b2d09ebed372be9f

Authored by Neil Blakey-Milner
1 parent e951c807

Allow for metadata to be enabled or disabled, and add some getBy*

functions for ease of use.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3907 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/MetaData.inc
... ... @@ -34,12 +34,15 @@ class MetaData extends KTEntity {
34 34 var $sName;
35 35 /** _if_ this field is a tree, which node in said tree is this one's parent. */
36 36 var $iTreeParent;
  37 + var $bDisabled = false;
37 38  
  39 + var $_bUsePearError = true;
38 40 var $_aFieldToSelect = array(
39 41 'iId' => 'id',
40 42 'iDocFieldId' => 'document_field_id',
41 43 'sName' => 'name',
42 44 'iTreeParent' => 'treeorg_parent',
  45 + 'bDisabled' => 'disabled',
43 46 );
44 47  
45 48 /**
... ... @@ -63,6 +66,8 @@ class MetaData extends KTEntity {
63 66 function setDocFieldId($iNewValue) { $this->iDocFieldId = $iNewValue; }
64 67 function getTreeParent() { return $this->iTreeParent; }
65 68 function setTreeParent($iNewValue) { $this->iTreeParent = $iNewValue; }
  69 + function getDisabled() { return $this->bDisabled; }
  70 + function setDisabled($bNewValue) { $this->bDisabled = $bNewValue; }
66 71  
67 72 function _table () {
68 73 global $default;
... ... @@ -125,6 +130,77 @@ class MetaData extends KTEntity {
125 130 ));
126 131 }
127 132  
  133 + function getValuesByDocumentField($oDocumentField) {
  134 + if (is_object($oDocumentField)) {
  135 + $iDocumentFieldId = $oDocumentField->getId();
  136 + } else {
  137 + $iDocumentFieldId = $oDocumentField;
  138 + }
  139 + return KTEntityUtil::getByDict('MetaData', array(
  140 + 'document_field_id' => $iDocumentFieldId,
  141 + ), array(
  142 + 'multi' => 'true',
  143 + 'ids' => true,
  144 + 'idfield' => 'name',
  145 + ));
  146 + }
  147 +
  148 + function getEnabledByDocumentField($oDocumentField) {
  149 + if (is_object($oDocumentField)) {
  150 + $iDocumentFieldId = $oDocumentField->getId();
  151 + } else {
  152 + $iDocumentFieldId = $oDocumentField;
  153 + }
  154 + return KTEntityUtil::getByDict('MetaData', array(
  155 + 'document_field_id' => $iDocumentFieldId,
  156 + 'disabled' => false,
  157 + ), array(
  158 + 'multi' => 'true'
  159 + ));
  160 + }
  161 +
  162 + function getDisabledByDocumentField($oDocumentField) {
  163 + $iDocumentFieldId = KTUtil::getId($oDocumentField);
  164 + return KTEntityUtil::getByDict('MetaData', array(
  165 + 'document_field_id' => $iDocumentFieldId,
  166 + 'disabled' => true,
  167 + ), array(
  168 + 'multi' => true,
  169 + ));
  170 + }
  171 +
  172 + function getEnabledValuesByDocumentField($oDocumentField) {
  173 + $iDocumentFieldId = KTUtil::getId($oDocumentField);
  174 + return KTEntityUtil::getByDict('MetaData', array(
  175 + 'document_field_id' => $iDocumentFieldId,
  176 + 'disabled' => false,
  177 + ), array(
  178 + 'multi' => 'true',
  179 + 'ids' => true,
  180 + 'idfield' => 'name',
  181 + ));
  182 + }
  183 +
  184 + function getDisabledValuesByDocumentField($oDocumentField) {
  185 + $iDocumentFieldId = KTUtil::getId($oDocumentField);
  186 + return KTEntityUtil::getByDict('MetaData', array(
  187 + 'document_field_id' => $iDocumentFieldId,
  188 + 'disabled' => true,
  189 + ), array(
  190 + 'multi' => 'true',
  191 + 'ids' => true,
  192 + 'idfield' => 'name',
  193 + ));
  194 + }
  195 +
  196 + function getByValueAndDocumentField($sValue, $oDocumentField) {
  197 + $iDocumentFieldId = KTUtil::getId($oDocumentField);
  198 + return KTEntityUtil::getByDict('MetaData', array(
  199 + 'document_field_id' => $iDocumentFieldId,
  200 + 'name' => $sValue,
  201 + ));
  202 + }
  203 +
128 204 function &createFromArray($aData) {
129 205 return KTEntityUtil::createFromArray('MetaData', $aData);
130 206 }
... ...