Commit 9769384f9528a8f33156c3486a9816c4cf1b9df8
1 parent
888d57f4
Make sure that document fieldsets can't be renamed to the name of an
existing fieldset. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5080 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
22 additions
and
6 deletions
plugins/ktcore/admin/documentFields.php
| @@ -115,11 +115,25 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | @@ -115,11 +115,25 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | ||
| 115 | 115 | ||
| 116 | // {{{ edit_object | 116 | // {{{ edit_object |
| 117 | function do_editobject() { | 117 | function do_editobject() { |
| 118 | - | ||
| 119 | - $oFieldset =& KTFieldset::get($_REQUEST['fFieldsetId']); | ||
| 120 | - $oFieldset->setName($_REQUEST['name']); | ||
| 121 | - $oFieldset->setNamespace($_REQUEST['namespace']); | ||
| 122 | - $oFieldset->setDescription($_REQUEST['description']); | 118 | + $aErrorOptions = array( |
| 119 | + 'redirect_to' => array('main'), | ||
| 120 | + ); | ||
| 121 | + $oFieldset =& $this->oValidator->validateFieldset($_REQUEST['fFieldsetId'], $aErrorOptions); | ||
| 122 | + $aErrorOptions = array( | ||
| 123 | + 'redirect_to' => array('edit', sprintf('fFieldsetId=%d', $oFieldset->getId())), | ||
| 124 | + ); | ||
| 125 | + $aErrorOptions['empty_message'] = _("No name was given for the fieldset"); | ||
| 126 | + $aErrorOptions['duplicate_message'] = _("A fieldset with that name already exists"); | ||
| 127 | + $aErrorOptions['rename'] = $oFieldset->getId(); | ||
| 128 | + $sName = $this->oValidator->validateEntityName("KTFieldset", $_REQUEST['name'], $aErrorOptions); | ||
| 129 | + $aErrorOptions['message'] = sprintf(_("The field '%s' is a required field"), _("Namespace")); | ||
| 130 | + $sNamespace = $this->oValidator->validateString($_REQUEST['namespace'], $aErrorOptions); | ||
| 131 | + $aErrorOptions['message'] = sprintf(_("The field '%s' is a required field"), _("Description")); | ||
| 132 | + $sDescription = $this->oValidator->validateString($_REQUEST['description'], $aErrorOptions); | ||
| 133 | + | ||
| 134 | + $oFieldset->setName($sName); | ||
| 135 | + $oFieldset->setNamespace($sNamespace); | ||
| 136 | + $oFieldset->setDescription($sDescription); | ||
| 123 | $res = $oFieldset->update(); | 137 | $res = $oFieldset->update(); |
| 124 | if (PEAR::isError($res) || ($res === false)) { | 138 | if (PEAR::isError($res) || ($res === false)) { |
| 125 | $this->errorRedirectTo('edit', _('Could not save fieldset changes'), 'fFieldsetId=' . $oFieldset->getId()); | 139 | $this->errorRedirectTo('edit', _('Could not save fieldset changes'), 'fFieldsetId=' . $oFieldset->getId()); |
| @@ -154,7 +168,9 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | @@ -154,7 +168,9 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { | ||
| 154 | } | 168 | } |
| 155 | 169 | ||
| 156 | // basic validation | 170 | // basic validation |
| 157 | - $sName = $this->oValidator->validateEntityName("KTFieldset", "fieldset", KTUtil::arrayGet($_REQUEST, 'name'), $aErrorOptions); | 171 | + $aErrorOptions['empty_message'] = _("No name was given for the fieldset"); |
| 172 | + $aErrorOptions['duplicate_message'] = _("A fieldset with that name already exists"); | ||
| 173 | + $sName = $this->oValidator->validateEntityName("KTFieldset", $_REQUEST['name'], $aErrorOptions); | ||
| 158 | 174 | ||
| 159 | $sDescription = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'description'), | 175 | $sDescription = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'description'), |
| 160 | KTUtil::meldOptions($aErrorOptions, array('message' => "You must provide a description"))); | 176 | KTUtil::meldOptions($aErrorOptions, array('message' => "You must provide a description"))); |