/**
  * Execute the form, but first:
  * Make sure we're not saving an empty entry for sponsors. (This would
  * result in a possibly empty heading for the Sponsors section in About.)
  */
 function execute()
 {
     foreach (array('sponsors', 'contributors') as $element) {
         $elementValue = (array) $this->getData($element);
         foreach (array_keys($elementValue) as $key) {
             $values = array_values((array) $elementValue[$key]);
             $isEmpty = true;
             foreach ($values as $value) {
                 if (!empty($value)) {
                     $isEmpty = false;
                 }
             }
             if ($isEmpty) {
                 unset($elementValue[$key]);
             }
         }
         $this->setData($element, $elementValue);
     }
     return parent::execute();
 }
 /**
  * Save modified settings.
  */
 function execute()
 {
     $schedConf =& Request::getSchedConf();
     $paperTypeIds = array();
     $paperTypeDao = DAORegistry::getDAO('PaperTypeDAO');
     $paperTypeEntryDao = DAORegistry::getDAO('PaperTypeEntryDAO');
     if (isset($this->_data['paperTypes'])) {
         $paperTypes =& $this->_data['paperTypes'];
         $paperTypesEntry =& $paperTypeDao->build($schedConf->getId());
         $i = 0;
         foreach ($paperTypes as $paperTypeId => $paperType) {
             if (is_numeric($paperTypeId)) {
                 // Entry should already exist; update
                 $paperTypeEntry = $paperTypeEntryDao->getById($paperTypeId, $paperTypesEntry->getId());
                 if (!$paperTypeEntry) {
                     continue;
                 }
             } else {
                 // Entry is new; create
                 $paperTypeEntry = $paperTypeEntryDao->newDataObject();
                 $paperTypeEntry->setControlledVocabId($paperTypesEntry->getId());
             }
             $paperTypeEntry->setName($paperType['name'], null);
             // Localized
             $paperTypeEntry->setDescription($paperType['description'], null);
             // Localized
             $paperTypeEntry->setAbstractLength($paperType['abstractLength']);
             $paperTypeEntry->setLength($paperType['length']);
             $paperTypeEntry->setSequence($i++);
             if (is_numeric($paperTypeId)) {
                 $paperTypeEntryDao->updateObject($paperTypeEntry);
             } else {
                 $paperTypeEntryDao->insertObject($paperTypeEntry);
             }
             $paperTypeIds[] = $paperTypeEntry->getId();
         }
     }
     // Find and handle deletions
     $paperTypeEntryIterator = $paperTypeDao->getPaperTypes($schedConf->getId());
     while ($paperTypeEntry =& $paperTypeEntryIterator->next()) {
         if (!in_array($paperTypeEntry->getId(), $paperTypeIds)) {
             $paperTypeEntryDao->deleteObject($paperTypeEntry);
         }
         unset($paperTypeEntry);
     }
     return parent::execute();
 }