Index: og_reg_keys.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/og_reg_keys/og_reg_keys.module,v retrieving revision 1.2.2.1 diff -u -p -r1.2.2.1 og_reg_keys.module --- og_reg_keys.module 9 Jun 2009 19:30:40 -0000 1.2.2.1 +++ og_reg_keys.module 4 Sep 2009 23:05:30 -0000 @@ -117,6 +117,9 @@ function og_reg_keys_user($op, &$edit, & form_set_error('og_reg_key', t('Not a valid group registration key.')); } } + } + else if (variable_get('og_reg_key_required', 'required') == 'required'){ + form_set_error('og_reg_key', t('Group registration key is required.')); } break; case 'insert': @@ -136,13 +139,16 @@ function og_reg_keys_user($op, &$edit, & // no redirect to node as this is someone adding users through the standard interface break; case 'register': - $form['og_reg_key'] = array( - '#type' => 'textfield', - '#title' => t('Group registration key'), - '#required' => variable_get('og_reg_key_required', 1), - '#description' => '', - '#size' => 64, - ); + if (variable_get('og_reg_key_required', 'required') != + 'not_required_not_visible') { + $form['og_reg_key'] = array( + '#type' => 'textfield', + '#title' => t('Group registration key'), + '#required' => variable_get('og_reg_key_required', 'required'), + '#description' => _og_reg_keys_help_text(), + '#size' => 64, + ); + } return $form; break; @@ -240,11 +246,26 @@ function og_reg_keys_settings() { ); $form['og_reg_key_required'] = array( - '#type' => 'checkbox', - '#title' => t('Registration Key Required for new account creation'), - '#default_value' => variable_get('og_reg_key_required', 1), + '#type' => 'radios', + '#title' => t('Registration key control for new account creation'), + '#options' => array( + 'required' => t('Registration Key Required for new account creation.'), + 'not_required_visible' => + t('Registration Key Not Required for new account creation, but visible.'), + 'not_required_not_visible' => + t('Registration Key Not Required for new account creation, and not visible.'), + ), + '#default_value' => variable_get('og_reg_key_required', 'required'), ); + $form['og_reg_keys_help_text'] = array( + '#type' => 'textarea', + '#title' => t('Registration help text'), + '#description' => t('Additional help text to be added to the user registration form.'), + '#default_value' => _og_reg_keys_help_text(), + '#required' => TRUE, + ); + return system_settings_form($form); } @@ -611,6 +632,13 @@ function og_reg_keys_validate_key($node) } /** + * Return the user account registration key help text. + */ +function _og_reg_keys_help_text() { + return variable_get('og_reg_keys_help_text', t("If you were given a registration key for this site you can use it here to join a group.")); +} + +/** * Return the group join message. */ function _og_reg_keys_message() {