public function __actionEdit($new = false)
 {
     $fields = $_POST['fields'];
     $fields['dependencies'] = array();
     try {
         $result = RecipientGroupManager::create($this->_context[1]);
         $fields['dependencies'] = $result->_dependencies;
     } catch (Exception $e) {
     }
     if (isset($_POST['action']['delete'])) {
         if (RecipientgroupManager::delete($this->_context[1])) {
             redirect(SYMPHONY_URL . '/extension/email_newsletter_manager/recipientgroups');
         } else {
             $this->pageAlert(__('Could not delete, please check file permissions'), Alert::ERROR);
             return true;
         }
     }
     $post_fields = new XMLElement('post-fields');
     General::array_to_xml($post_fields, $fields);
     $this->_XML->appendChild($post_fields);
     $errors = new XMLElement('errors');
     if (!empty($fields['name']) && !empty($fields['name-xslt']) && General::validateXML($fields['name-xslt'], $error, false) == true) {
         try {
             if (RecipientGroupManager::save(str_replace('_', '-', $this->_context[1]), $fields)) {
                 redirect(SYMPHONY_URL . '/extension/email_newsletter_manager/recipientgroups/edit/' . Lang::createHandle($fields['name'], 225, '_') . '/saved');
                 return true;
             }
         } catch (Exception $e) {
             $this->pageAlert(__('Could not save: ' . $e->getMessage()), Alert::ERROR);
         }
     }
     if (empty($fields['name'])) {
         $errors->appendChild(new XMLElement('name', __('This field can not be empty.')));
     }
     if (strlen(Lang::createHandle($fields['name'])) == 0) {
         $errors->appendChild(new XMLElement('name', __('This field must at least contain a number or a letter')));
     }
     if (empty($fields['name-xslt'])) {
         $errors->appendChild(new XMLElement('name-xslt', __('This field can not be empty.')));
     }
     if (!General::validateXML($fields['name-xslt'], $error, false)) {
         $errors->appendChild(new XMLElement('name-xslt', __('XML is invalid')));
     }
     $this->_XML->appendChild($errors);
     $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
 }