Commit b23cac3297a5241d180d8216d39ba1acd62004d8

Authored by megan_w
1 parent d6027be1

KTC-189

"Deleting a fieldset does not remove all instances of itself and existing field and document type associations"
Fixed. On deleting the fieldset it checks for any document type associations and removes them.

KTS-2487
"Deleting an assigned fieldset causes a fatal error"
Fixed. Removing the document type associations fixes the error on viewing the document.

Committed by: Megan Watson
Reviewed by: Jonathan Byrne



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7599 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/admin/documentFieldsv2.php
@@ -6,32 +6,32 @@ @@ -6,32 +6,32 @@
6 * KnowledgeTree Open Source Edition 6 * KnowledgeTree Open Source Edition
7 * Document Management Made Simple 7 * Document Management Made Simple
8 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited 8 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
9 - * 9 + *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
12 * Free Software Foundation. 12 * Free Software Foundation.
13 - * 13 + *
14 * This program is distributed in the hope that it will be useful, but WITHOUT 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details. 17 * details.
18 - * 18 + *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 - * 21 + *
22 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, 22 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
23 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. 23 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
24 - * 24 + *
25 * The interactive user interfaces in modified source and object code versions 25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under 26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU General Public License version 3. 27 * Section 5 of the GNU General Public License version 3.
28 - * 28 + *
29 * In accordance with Section 7(b) of the GNU General Public License version 3, 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by 30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33 - * must display the words "Powered by KnowledgeTree" and retain the original  
34 - * copyright notice. 33 + * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * copyright notice.
35 * Contributor( s): ______________________________________ 35 * Contributor( s): ______________________________________
36 * 36 *
37 */ 37 */
@@ -49,7 +49,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -49,7 +49,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
49 function predispatch() { 49 function predispatch() {
50 $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Field Management')); 50 $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Field Management'));
51 $this->persistParams(array('fFieldsetId')); 51 $this->persistParams(array('fFieldsetId'));
52 - 52 +
53 $this->oFieldset = KTFieldset::get(KTUtil::arrayGet($_REQUEST, 'fFieldsetId')); 53 $this->oFieldset = KTFieldset::get(KTUtil::arrayGet($_REQUEST, 'fFieldsetId'));
54 if (PEAR::isError($this->oFieldset)) { 54 if (PEAR::isError($this->oFieldset)) {
55 $this->oFieldset = null; 55 $this->oFieldset = null;
@@ -63,7 +63,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -63,7 +63,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
63 63
64 function do_main () { 64 function do_main () {
65 $oTemplate =& $this->oValidator->validateTemplate('ktcore/metadata/admin/list'); 65 $oTemplate =& $this->oValidator->validateTemplate('ktcore/metadata/admin/list');
66 - 66 +
67 $oTemplate->setData(array( 67 $oTemplate->setData(array(
68 'context' => $this, 68 'context' => $this,
69 'fieldsets' => KTFieldset::getList('disabled != true'), 69 'fieldsets' => KTFieldset::getList('disabled != true'),
@@ -80,10 +80,10 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -80,10 +80,10 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
80 'cancel_action' => 'main', 80 'cancel_action' => 'main',
81 'fail_action' => 'newfieldset', 81 'fail_action' => 'newfieldset',
82 'action' => 'create', 82 'action' => 'create',
83 - 'context' => $this, 83 + 'context' => $this,
84 )); 84 ));
85 -  
86 - 85 +
  86 +
87 // construct the widget set. 87 // construct the widget set.
88 // we use a slight variation here, because "type" is only present in certain circumstances. 88 // we use a slight variation here, because "type" is only present in certain circumstances.
89 $widgets = array( 89 $widgets = array(
@@ -98,16 +98,16 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -98,16 +98,16 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
98 'name' => 'description', 98 'name' => 'description',
99 'required' => true, 99 'required' => true,
100 'description' => _kt("In order to ensure that the data that users enter is useful, it is essential that you provide a good example."), 100 'description' => _kt("In order to ensure that the data that users enter is useful, it is essential that you provide a good example."),
101 - )), 101 + )),
102 ); 102 );
103 if ($this->bHaveConditional) { 103 if ($this->bHaveConditional) {
104 - 104 +
105 // FIXME get this from some external source. 105 // FIXME get this from some external source.
106 $type_vocab = array( 106 $type_vocab = array(
107 'normal' => _kt("Normal"), 107 'normal' => _kt("Normal"),
108 - 'conditional' => _kt("Conditional"), 108 + 'conditional' => _kt("Conditional"),
109 ); 109 );
110 - 110 +
111 $widgets[] = array('ktcore.widgets.selection', array( 111 $widgets[] = array('ktcore.widgets.selection', array(
112 'label' => _kt("Fieldset Type"), 112 'label' => _kt("Fieldset Type"),
113 'use_simple' => false, 113 'use_simple' => false,
@@ -119,20 +119,20 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -119,20 +119,20 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
119 'vocab' => $type_vocab, 119 'vocab' => $type_vocab,
120 )); 120 ));
121 } 121 }
122 - 122 +
123 $widgets[] = array('ktcore.widgets.boolean',array( 123 $widgets[] = array('ktcore.widgets.boolean',array(
124 'label' => _kt("Generic"), 124 'label' => _kt("Generic"),
125 'name' => 'generic', 125 'name' => 'generic',
126 'description' => _kt("A generic fieldset is one that is available for every document by default. These fieldsets will be available for users to edit and add for every document in the document management system."), 126 'description' => _kt("A generic fieldset is one that is available for every document by default. These fieldsets will be available for users to edit and add for every document in the document management system."),
127 )); 127 ));
128 - 128 +
129 $oForm->setWidgets($widgets); 129 $oForm->setWidgets($widgets);
130 - 130 +
131 // similarly, we construct validators here. 131 // similarly, we construct validators here.
132 $validators = array( 132 $validators = array(
133 array('ktcore.validators.string', array( 133 array('ktcore.validators.string', array(
134 'test' => 'name', 134 'test' => 'name',
135 - 'output' => 'name', 135 + 'output' => 'name',
136 )), 136 )),
137 array('ktcore.validators.string', array( 137 array('ktcore.validators.string', array(
138 'test' => 'description', 138 'test' => 'description',
@@ -143,65 +143,65 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -143,65 +143,65 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
143 'output' => 'generic', 143 'output' => 'generic',
144 )), 144 )),
145 ); 145 );
146 - 146 +
147 if ($this->bHaveConditional) { 147 if ($this->bHaveConditional) {
148 $validators[] = array('ktcore.validators.string', array( 148 $validators[] = array('ktcore.validators.string', array(
149 'test' => 'fieldset_type', 149 'test' => 'fieldset_type',
150 'output' => 'fieldset_type', 150 'output' => 'fieldset_type',
151 )); 151 ));
152 } 152 }
153 - 153 +
154 $oForm->setValidators($validators); 154 $oForm->setValidators($validators);
155 - 155 +
156 return $oForm; 156 return $oForm;
157 } 157 }
158 158
159 function do_newfieldset() { 159 function do_newfieldset() {
160 $this->oPage->setBreadcrumbDetails(_kt("Create New Fieldset")); 160 $this->oPage->setBreadcrumbDetails(_kt("Create New Fieldset"));
161 $oForm = $this->form_create(); 161 $oForm = $this->form_create();
162 - 162 +
163 return $oForm->render(); 163 return $oForm->render();
164 } 164 }
165 - 165 +
166 function do_create() { 166 function do_create() {
167 $oForm = $this->form_create(); 167 $oForm = $this->form_create();
168 $res = $oForm->validate(); 168 $res = $oForm->validate();
169 - 169 +
170 $data = $res['results']; 170 $data = $res['results'];
171 $errors = $res['errors']; 171 $errors = $res['errors'];
172 $extra_errors = array(); 172 $extra_errors = array();
173 - 173 +
174 if (!empty($data['name'])) { 174 if (!empty($data['name'])) {
175 $oFieldset = KTFieldset::getByName($data['name']); 175 $oFieldset = KTFieldset::getByName($data['name']);
176 if (!PEAR::isError($oFieldset)) { 176 if (!PEAR::isError($oFieldset)) {
177 // means we're looking at an existing name 177 // means we're looking at an existing name
178 $extra_errors['name'] = _kt("There is already a fieldset with that name."); 178 $extra_errors['name'] = _kt("There is already a fieldset with that name.");
179 - } 179 + }
180 } 180 }
181 - 181 +
182 $is_conditional = false; 182 $is_conditional = false;
183 // FIXME this is inelegant. get it from somewhere else. 183 // FIXME this is inelegant. get it from somewhere else.
184 if ($this->bHaveConditional && ($data['fieldset_type'] == 'conditional')) { 184 if ($this->bHaveConditional && ($data['fieldset_type'] == 'conditional')) {
185 $is_conditional = true; 185 $is_conditional = true;
186 } 186 }
187 -  
188 - 187 +
  188 +
189 if (!empty($errors) || !empty($extra_errors)) { 189 if (!empty($errors) || !empty($extra_errors)) {
190 return $oForm->handleError(null, $extra_errors); 190 return $oForm->handleError(null, $extra_errors);
191 } 191 }
192 - 192 +
193 // we also need a namespace. 193 // we also need a namespace.
194 $temp_name = $data['name']; 194 $temp_name = $data['name'];
195 $namespace = KTUtil::nameToLocalNamespace('fieldsets', $temp_name); 195 $namespace = KTUtil::nameToLocalNamespace('fieldsets', $temp_name);
196 $oOldFieldset = KTFieldset::getByNamespace($namespace); 196 $oOldFieldset = KTFieldset::getByNamespace($namespace);
197 - 197 +
198 while (!PEAR::isError($oOldFieldset)) { 198 while (!PEAR::isError($oOldFieldset)) {
199 $temp_name .= '_'; 199 $temp_name .= '_';
200 $namespace = KTUtil::nameToLocalNamespace('fieldsets', $temp_name); 200 $namespace = KTUtil::nameToLocalNamespace('fieldsets', $temp_name);
201 - $oOldFieldset = KTFieldset::getByNamespace($namespace); 201 + $oOldFieldset = KTFieldset::getByNamespace($namespace);
202 } 202 }
203 -  
204 - // we now know its a non-conflicting one. 203 +
  204 + // we now know its a non-conflicting one.
205 // FIXME handle conditional fieldsets, which should be ... a different object. 205 // FIXME handle conditional fieldsets, which should be ... a different object.
206 $oFieldset = KTFieldset::createFromArray(array( 206 $oFieldset = KTFieldset::createFromArray(array(
207 "name" => $data['name'], 207 "name" => $data['name'],
@@ -212,29 +212,29 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -212,29 +212,29 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
212 "isGeneric" => $data['generic'], 212 "isGeneric" => $data['generic'],
213 "isComplete" => false, 213 "isComplete" => false,
214 "isComplex" => false, 214 "isComplex" => false,
215 - "isSystem" => false, 215 + "isSystem" => false,
216 )); 216 ));
217 if (PEAR::isError($oFieldset)) { 217 if (PEAR::isError($oFieldset)) {
218 return $oForm->handleError(sprintf(_kt("Failed to create fieldset: %s"), $oFieldset->getMessage())); 218 return $oForm->handleError(sprintf(_kt("Failed to create fieldset: %s"), $oFieldset->getMessage()));
219 } 219 }
220 - 220 +
221 $this->successRedirectTo('edit',_kt("Fieldset created."), sprintf('fFieldsetId=%d', $oFieldset->getId())); 221 $this->successRedirectTo('edit',_kt("Fieldset created."), sprintf('fFieldsetId=%d', $oFieldset->getId()));
222 - } 222 + }
223 223
224 function getTypesForFieldset($oFieldset) { 224 function getTypesForFieldset($oFieldset) {
225 if ($oFieldset->getIsGeneric()) { 225 if ($oFieldset->getIsGeneric()) {
226 return _kt('All types use this generic fieldset.'); 226 return _kt('All types use this generic fieldset.');
227 } 227 }
228 - 228 +
229 $types = $oFieldset->getAssociatedTypes(); 229 $types = $oFieldset->getAssociatedTypes();
230 if (PEAR::isError($types)) { 230 if (PEAR::isError($types)) {
231 return _kt('Error retrieving list of types.'); 231 return _kt('Error retrieving list of types.');
232 } 232 }
233 - if (empty($types)) { 233 + if (empty($types)) {
234 return _kt('None'); 234 return _kt('None');
235 } 235 }
236 $aNames = array(); 236 $aNames = array();
237 - foreach ($types as $oType) { 237 + foreach ($types as $oType) {
238 if (!PEAR::isError($oType)) { 238 if (!PEAR::isError($oType)) {
239 $aNames[] = $oType->getName(); 239 $aNames[] = $oType->getName();
240 } 240 }
@@ -247,30 +247,30 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -247,30 +247,30 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
247 // here we engage in some major evil. 247 // here we engage in some major evil.
248 // we check for the subevent var 248 // we check for the subevent var
249 // and subdispatch if appropriate. 249 // and subdispatch if appropriate.
250 - // 250 + //
251 // saves a little code-duplication (actually, a lot of code-duplication) 251 // saves a little code-duplication (actually, a lot of code-duplication)
252 - 252 +
253 // FIXME this is essentially a stub for the fieldset-delegation code. 253 // FIXME this is essentially a stub for the fieldset-delegation code.
254 if ($this->oFieldset->getIsConditional()) { 254 if ($this->oFieldset->getIsConditional()) {
255 require_once('fieldsets/conditional.inc.php'); 255 require_once('fieldsets/conditional.inc.php');
256 - $oSubDispatcher = new ConditionalFieldsetManagementDispatcher; 256 + $oSubDispatcher = new ConditionalFieldsetManagementDispatcher;
257 } else { 257 } else {
258 require_once('fieldsets/basic.inc.php'); 258 require_once('fieldsets/basic.inc.php');
259 $oSubDispatcher = new BasicFieldsetManagementDispatcher; 259 $oSubDispatcher = new BasicFieldsetManagementDispatcher;
260 } 260 }
261 - 261 +
262 $subevent_var = 'fieldset_action'; 262 $subevent_var = 'fieldset_action';
263 $subevent = KTUtil::arrayGet($_REQUEST, $subevent_var); 263 $subevent = KTUtil::arrayGet($_REQUEST, $subevent_var);
264 if (!empty($subevent)) { 264 if (!empty($subevent)) {
265 // do nothing, since this will handle everything 265 // do nothing, since this will handle everything
266 $this_url = KTUtil::addQueryStringSelf($this->meldPersistQuery("","edit")); 266 $this_url = KTUtil::addQueryStringSelf($this->meldPersistQuery("","edit"));
267 - $oSubDispatcher->redispatch($subevent_var, null, $this, $this_url); 267 + $oSubDispatcher->redispatch($subevent_var, null, $this, $this_url);
268 exit(0); 268 exit(0);
269 } else { 269 } else {
270 // what we want is the "additional info" section 270 // what we want is the "additional info" section
271 $additional = $oSubDispatcher->describe_fieldset($this->oFieldset); 271 $additional = $oSubDispatcher->describe_fieldset($this->oFieldset);
272 } 272 }
273 - 273 +
274 $oTemplate =& $this->oValidator->validateTemplate('ktcore/metadata/admin/edit'); 274 $oTemplate =& $this->oValidator->validateTemplate('ktcore/metadata/admin/edit');
275 $oTemplate->setData(array( 275 $oTemplate->setData(array(
276 'context' => $this, 276 'context' => $this,
@@ -279,9 +279,19 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -279,9 +279,19 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
279 )); 279 ));
280 return $oTemplate->render(); 280 return $oTemplate->render();
281 } 281 }
282 - 282 +
283 function do_delete() { 283 function do_delete() {
284 $this->startTransaction(); 284 $this->startTransaction();
  285 +
  286 + // check if fieldset is associated with a document type - remove association
  287 + $types = $this->oFieldset->getAssociatedTypes();
  288 + $sFieldSetId = $this->oFieldset->getId();
  289 + if(!PEAR::isError($types) AND !empty($types)){
  290 + foreach($types as $oType){
  291 + $res = KTMetadataUtil::removeSetsFromDocumentType($oType, $sFieldSetId);
  292 + }
  293 + }
  294 +
285 $res = $this->oFieldset->delete('true'); 295 $res = $this->oFieldset->delete('true');
286 $this->oValidator->notErrorFalse($res, array( 296 $this->oValidator->notErrorFalse($res, array(
287 'redirect_to' => array('main', ''), 297 'redirect_to' => array('main', ''),
@@ -289,7 +299,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -289,7 +299,7 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
289 )); 299 ));
290 $this->successRedirectToMain(_kt('Fieldset deleted')); 300 $this->successRedirectToMain(_kt('Fieldset deleted'));
291 } 301 }
292 - 302 +
293 function form_edit() { 303 function form_edit() {
294 $oForm = new KTForm; 304 $oForm = new KTForm;
295 $oForm->setOptions(array( 305 $oForm->setOptions(array(
@@ -299,10 +309,10 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -299,10 +309,10 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
299 'cancel_action' => 'edit', 309 'cancel_action' => 'edit',
300 'fail_action' => 'editfieldset', 310 'fail_action' => 'editfieldset',
301 'action' => 'savefieldset', 311 'action' => 'savefieldset',
302 - 'context' => $this, 312 + 'context' => $this,
303 )); 313 ));
304 -  
305 - 314 +
  315 +
306 // construct the widget set. 316 // construct the widget set.
307 // we use a slight variation here, because "type" is only present in certain circumstances. 317 // we use a slight variation here, because "type" is only present in certain circumstances.
308 $widgets = array( 318 $widgets = array(
@@ -318,24 +328,24 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -318,24 +328,24 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
318 'name' => 'description', 328 'name' => 'description',
319 'required' => true, 329 'required' => true,
320 'description' => _kt("In order to ensure that the data that users enter is useful, it is essential that you provide a good example."), 330 'description' => _kt("In order to ensure that the data that users enter is useful, it is essential that you provide a good example."),
321 - 'value' => sanitizeForHTML($this->oFieldset->getDescription()),  
322 - )), 331 + 'value' => sanitizeForHTML($this->oFieldset->getDescription()),
  332 + )),
323 ); 333 );
324 - 334 +
325 $widgets[] = array('ktcore.widgets.boolean',array( 335 $widgets[] = array('ktcore.widgets.boolean',array(
326 'label' => _kt("Generic"), 336 'label' => _kt("Generic"),
327 'name' => 'generic', 337 'name' => 'generic',
328 'description' => _kt("A generic fieldset is one that is available for every document by default. These fieldsets will be available for users to edit and add for every document in the document management system."), 338 'description' => _kt("A generic fieldset is one that is available for every document by default. These fieldsets will be available for users to edit and add for every document in the document management system."),
329 - 'value' => $this->oFieldset->getIsGeneric(), 339 + 'value' => $this->oFieldset->getIsGeneric(),
330 )); 340 ));
331 - 341 +
332 $oForm->setWidgets($widgets); 342 $oForm->setWidgets($widgets);
333 - 343 +
334 // similarly, we construct validators here. 344 // similarly, we construct validators here.
335 $validators = array( 345 $validators = array(
336 array('ktcore.validators.string', array( 346 array('ktcore.validators.string', array(
337 'test' => 'name', 347 'test' => 'name',
338 - 'output' => 'name', 348 + 'output' => 'name',
339 )), 349 )),
340 array('ktcore.validators.string', array( 350 array('ktcore.validators.string', array(
341 'test' => 'description', 351 'test' => 'description',
@@ -346,22 +356,22 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -346,22 +356,22 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
346 'output' => 'generic', 356 'output' => 'generic',
347 )), 357 )),
348 ); 358 );
349 - 359 +
350 $oForm->setValidators($validators); 360 $oForm->setValidators($validators);
351 - 361 +
352 return $oForm; 362 return $oForm;
353 } 363 }
354 -  
355 - function do_editfieldset() { 364 +
  365 + function do_editfieldset() {
356 $oForm = $this->form_edit(); 366 $oForm = $this->form_edit();
357 $this->oPage->setBreadcrumbDetails(_kt('edit fieldset')); 367 $this->oPage->setBreadcrumbDetails(_kt('edit fieldset'));
358 return $oForm->renderPage(_kt("Edit Fieldset")); 368 return $oForm->renderPage(_kt("Edit Fieldset"));
359 } 369 }
360 -  
361 - function do_savefieldset() { 370 +
  371 + function do_savefieldset() {
362 $oForm = $this->form_edit(); 372 $oForm = $this->form_edit();
363 $res = $oForm->validate(); 373 $res = $oForm->validate();
364 - 374 +
365 $data = $res['results']; 375 $data = $res['results'];
366 $errors = $res['errors']; 376 $errors = $res['errors'];
367 $extra_errors = array(); 377 $extra_errors = array();
@@ -371,18 +381,18 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -371,18 +381,18 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
371 $extra_errors['name'][] = _kt("A fieldset with that name already exists."); 381 $extra_errors['name'][] = _kt("A fieldset with that name already exists.");
372 } 382 }
373 } 383 }
374 - 384 +
375 if (!empty($errors) || !empty($extra_errors)) { 385 if (!empty($errors) || !empty($extra_errors)) {
376 return $oForm->handleError(null, $extra_errors); 386 return $oForm->handleError(null, $extra_errors);
377 } 387 }
378 - 388 +
379 $this->startTransaction(); 389 $this->startTransaction();
380 - 390 +
381 $this->oFieldset->setName($data['name']); 391 $this->oFieldset->setName($data['name']);
382 - $this->oFieldset->setDescription($data['description']); 392 + $this->oFieldset->setDescription($data['description']);
383 $bGeneric = $data['generic']; 393 $bGeneric = $data['generic'];
384 if ($bGeneric != $this->oFieldset->getIsGeneric() && $bGeneric == true) { 394 if ($bGeneric != $this->oFieldset->getIsGeneric() && $bGeneric == true) {
385 - // delink it from all doctypes. 395 + // delink it from all doctypes.
386 $aTypes = $this->oFieldset->getAssociatedTypes(); 396 $aTypes = $this->oFieldset->getAssociatedTypes();
387 foreach ($aTypes as $oType) { 397 foreach ($aTypes as $oType) {
388 $res = KTMetadataUtil::removeSetsFromDocumentType($oType, $this->oFieldset->getId()); 398 $res = KTMetadataUtil::removeSetsFromDocumentType($oType, $this->oFieldset->getId());
@@ -392,17 +402,17 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher { @@ -392,17 +402,17 @@ class KTDocumentFieldDispatcher extends KTAdminDispatcher {
392 } 402 }
393 } 403 }
394 } 404 }
395 -  
396 - $this->oFieldset->setIsGeneric($data['generic']);  
397 - 405 +
  406 + $this->oFieldset->setIsGeneric($data['generic']);
  407 +
398 $res = $this->oFieldset->update(); 408 $res = $this->oFieldset->update();
399 if (PEAR::isError($res)) { 409 if (PEAR::isError($res)) {
400 $this->errorRedirectTo('edit', _kt('Could not save fieldset changes')); 410 $this->errorRedirectTo('edit', _kt('Could not save fieldset changes'));
401 exit(0); 411 exit(0);
402 } 412 }
403 - 413 +
404 return $this->successRedirectTo('edit', _kt("Fieldset details updated.")); 414 return $this->successRedirectTo('edit', _kt("Fieldset details updated."));
405 - } 415 + }
406 } 416 }
407 417
408 ?> 418 ?>