static function newField($title, $description = null, $type = 'str', $systemname = null)
 {
     $field = new GNUsocialProfileExtensionField();
     $field->title = $title;
     $field->description = $description;
     $field->type = $type;
     if (empty($systemname)) {
         $field->systemname = 'field' + $field->id;
     } else {
         $field->systemname = $systemname;
     }
     $field->id = $field->insert();
     if (!$field->id) {
         common_log_db_error($field, 'INSERT', __FILE__);
         throw new ServerException(_m('Error creating new field.'));
     }
     return $field;
 }
 function saveSettings()
 {
     $field = GNUsocialProfileExtensionField::getKV('id', $this->trimmed('id'));
     if (!$field) {
         $field = new GNUsocialProfileExtensionField();
     }
     $field->title = $this->trimmed('title');
     $field->description = $this->trimmed('description');
     $field->type = $this->trimmed('type');
     $field->systemname = $this->trimmed('systemname');
     if (!gnusocial_field_systemname_validate($field->systemname)) {
         $this->clientError(_('Internal system name must be unique and consist of only alphanumeric characters!'));
     }
     if ($field->id) {
         if ($field->validate()) {
             $field->update();
         } else {
             $this->clientError(_('There was an error with the field data.'));
         }
     } else {
         $field->insert();
     }
     return;
 }