/**
  * Save sort order. 
  */
 function execute()
 {
     if (isset($this->sortOrderId)) {
         $sortOrder =& $this->sortOrderDao->getSortOrder($this->sortOrderId);
     }
     if (!isset($sortOrder)) {
         $sortOrder = new SortOrder();
     }
     $sortOrder->setName($this->getData('name'), null);
     // Localized
     $sortOrder->setType($this->getData('type'));
     $sortOrder->setIsClean(false);
     // Index needs regenerating
     // Update or insert sort order
     if ($sortOrder->getSortOrderId() != null) {
         $this->sortOrderDao->updateSortOrder($sortOrder);
     } else {
         $this->sortOrderDao->insertSortOrder($sortOrder);
     }
     // Store the field IDs for the sort order
     $fieldNames = (array) $this->getData('fieldNames');
     $fieldIds = array();
     $schemaPlugins =& PluginRegistry::loadCategory('schemas');
     foreach ($schemaPlugins as $schemaPlugin) {
         $schema =& $schemaPlugin->getSchema();
         $schemaId = $schema->getSchemaId();
         foreach ($schemaPlugin->getFieldList() as $fieldName) {
             if (isset($fieldNames[$schemaId]) && $fieldNames[$schemaId] == $fieldName) {
                 $field =& $this->fieldDao->buildField($fieldName, $schemaPlugin->getName());
                 $fieldIds[] = $field->getFieldId();
                 unset($field);
             }
         }
         unset($schema);
     }
     $this->sortOrderDao->setSortOrderFields($sortOrder->getSortOrderId(), $fieldIds);
 }