Commit 1b8c4e103a1f240a68e62868815122eec4a4f140
1 parent
42aefd94
fix for KTS-387: cannot make a generic fieldset type-specific, and vice versa.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5698 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
20 additions
and
4 deletions
plugins/ktcore/admin/documentFields.php
| @@ -103,6 +103,8 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | @@ -103,6 +103,8 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | ||
| 103 | $editFieldset[] = new KTStringWidget(_kt('Name'), _kt('A human-readable name, used in add and edit forms.'), 'name',$oFieldset->getName(), $this->oPage, true); | 103 | $editFieldset[] = new KTStringWidget(_kt('Name'), _kt('A human-readable name, used in add and edit forms.'), 'name',$oFieldset->getName(), $this->oPage, true); |
| 104 | $editFieldset[] = new KTStringWidget(_kt('Namespace'), _kt('Every fieldset needs to have a system name (used internally by the document management system). For fieldsets which you create, this is automatically created by the system, but for fieldsets created by plugins, this controls how the fieldset works.'), 'namespace', $oFieldset->getNamespace(), $this->oPage, true); | 104 | $editFieldset[] = new KTStringWidget(_kt('Namespace'), _kt('Every fieldset needs to have a system name (used internally by the document management system). For fieldsets which you create, this is automatically created by the system, but for fieldsets created by plugins, this controls how the fieldset works.'), 'namespace', $oFieldset->getNamespace(), $this->oPage, true); |
| 105 | $editFieldset[] = new KTTextWidget(_kt('Description'), _kt('A brief description of the information stored in this fieldset.'), 'description', $oFieldset->getDescription(), $this->oPage, true); | 105 | $editFieldset[] = new KTTextWidget(_kt('Description'), _kt('A brief description of the information stored in this fieldset.'), 'description', $oFieldset->getDescription(), $this->oPage, true); |
| 106 | + $editFieldset[] = new KTCheckboxWidget(_kt('Generic'), _kt('Whether this fieldset applies to all documents, or only those directly associated with it. Note that changing this setting will cause the fieldset to be removed from document types which are related to it.'), 'generic', $oFieldset->getIsGeneric(), $this->oPage, false); | ||
| 107 | + | ||
| 106 | $createFields = array(); | 108 | $createFields = array(); |
| 107 | $createFields[] = new KTStringWidget(_kt('Name'), _kt('A human-readable name, used in add and edit forms.'), 'name',null, $this->oPage, true); | 109 | $createFields[] = new KTStringWidget(_kt('Name'), _kt('A human-readable name, used in add and edit forms.'), 'name',null, $this->oPage, true); |
| 108 | $createFields[] = new KTTextWidget(_kt('Description'), _kt('A brief description of the information stored in this field.'), 'description', null, $this->oPage, true); | 110 | $createFields[] = new KTTextWidget(_kt('Description'), _kt('A brief description of the information stored in this field.'), 'description', null, $this->oPage, true); |
| @@ -159,9 +161,27 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | @@ -159,9 +161,27 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | ||
| 159 | $aErrorOptions['message'] = sprintf(_kt("The field '%s' is a required field"), _kt("Description")); | 161 | $aErrorOptions['message'] = sprintf(_kt("The field '%s' is a required field"), _kt("Description")); |
| 160 | $sDescription = $this->oValidator->validateString($_REQUEST['description'], $aErrorOptions); | 162 | $sDescription = $this->oValidator->validateString($_REQUEST['description'], $aErrorOptions); |
| 161 | 163 | ||
| 164 | + $bGeneric = KTUtil::arrayGet($_REQUEST, 'generic', false); | ||
| 165 | + if ($bGeneric !== false) { $bGeneric = true; } | ||
| 166 | + | ||
| 167 | + $this->startTransaction(); | ||
| 168 | + | ||
| 169 | + if ($bGeneric != $oFieldset->getIsGeneric) { | ||
| 170 | + // delink it from all doctypes. | ||
| 171 | + $aTypes = $oFieldset->getAssociatedTypes(); | ||
| 172 | + foreach ($aTypes as $oType) { | ||
| 173 | + $res = KTMetadataUtil::removeSetsFromDocumentType($oType, $oFieldset->getId()); | ||
| 174 | + if (PEAR::isError($res)) { | ||
| 175 | + $this->errorRedirectTo('edit', _kt('Could not save fieldset changes'), 'fFieldsetId=' . $oFieldset->getId()); | ||
| 176 | + exit(0); | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 162 | $oFieldset->setName($sName); | 181 | $oFieldset->setName($sName); |
| 163 | $oFieldset->setNamespace($sNamespace); | 182 | $oFieldset->setNamespace($sNamespace); |
| 164 | $oFieldset->setDescription($sDescription); | 183 | $oFieldset->setDescription($sDescription); |
| 184 | + $oFieldset->setIsGeneric($bGeneric); | ||
| 165 | $res = $oFieldset->update(); | 185 | $res = $oFieldset->update(); |
| 166 | if (PEAR::isError($res) || ($res === false)) { | 186 | if (PEAR::isError($res) || ($res === false)) { |
| 167 | $this->errorRedirectTo('edit', _kt('Could not save fieldset changes'), 'fFieldsetId=' . $oFieldset->getId()); | 187 | $this->errorRedirectTo('edit', _kt('Could not save fieldset changes'), 'fFieldsetId=' . $oFieldset->getId()); |
templates/ktcore/documenttypes/list.smarty
| @@ -77,10 +77,6 @@ its details, or use the enable/disable buttons to change its availability state. | @@ -77,10 +77,6 @@ its details, or use the enable/disable buttons to change its availability state. | ||
| 77 | {/if} | 77 | {/if} |
| 78 | </td> | 78 | </td> |
| 79 | 79 | ||
| 80 | -<td> | ||
| 81 | - <span class="descriptiveText">{$context->getFieldsetsForType($oDocumentType)}</span> | ||
| 82 | -</td> | ||
| 83 | - | ||
| 84 | </tr> | 80 | </tr> |
| 85 | </tbody> | 81 | </tbody> |
| 86 | {/foreach} | 82 | {/foreach} |