示例#1
0
 function do_removefieldsets()
 {
     $oDocumentType =& DocumentType::get($_REQUEST['fDocumentTypeId']);
     $res = KTMetadataUtil::removeSetsFromDocumentType($oDocumentType, $_REQUEST['fieldsetid']);
     if (PEAR::isError($res)) {
         var_dump($res);
         $this->errorRedirectTo('edit', _kt('Changes not saved'), 'fDocumentTypeId=' . $oDocumentType->getId());
         exit(0);
     }
     $this->successRedirectTo('edit', _kt('Fieldsets removed.'), 'fDocumentTypeId=' . $oDocumentType->getId());
     exit(0);
 }
 function do_savefieldset()
 {
     $oForm = $this->form_edit();
     $res = $oForm->validate();
     $data = $res['results'];
     $errors = $res['errors'];
     $extra_errors = array();
     if ($data['name'] != $this->oFieldset->getName()) {
         $oOldFieldset = KTFieldset::getByName($data['name']);
         if (!PEAR::isError($oOldFieldset)) {
             $extra_errors['name'][] = _kt("A fieldset with that name already exists.");
         }
     }
     if (!empty($errors) || !empty($extra_errors)) {
         return $oForm->handleError(null, $extra_errors);
     }
     $this->startTransaction();
     $this->oFieldset->setName($data['name']);
     $this->oFieldset->setDescription($data['description']);
     $bGeneric = $data['generic'];
     if ($bGeneric != $this->oFieldset->getIsGeneric() && $bGeneric == true) {
         // delink it from all doctypes.
         $aTypes = $this->oFieldset->getAssociatedTypes();
         foreach ($aTypes as $oType) {
             $res = KTMetadataUtil::removeSetsFromDocumentType($oType, $this->oFieldset->getId());
             if (PEAR::isError($res)) {
                 $this->errorRedirectTo('edit', _kt('Could not save fieldset changes'));
                 exit(0);
             }
         }
     }
     $this->oFieldset->setIsGeneric($data['generic']);
     $res = $this->oFieldset->update();
     if (PEAR::isError($res)) {
         $this->errorRedirectTo('edit', _kt('Could not save fieldset changes'));
         exit(0);
     }
     return $this->successRedirectTo('edit', _kt("Fieldset details updated."));
 }