Index: invite_admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_admin.inc,v retrieving revision 1.3.2.2 diff -u -p -r1.3.2.2 invite_admin.inc --- invite_admin.inc 19 Apr 2009 21:26:01 -0000 1.3.2.2 +++ invite_admin.inc 15 Jun 2009 13:27:32 -0000 @@ -67,12 +67,12 @@ function invite_settings() { '#required' => TRUE, ); $form['role'][$role_no_space]['invite_maxnum_'. $role_no_space] = array( - '#type' => 'select', + '#type' => 'textfield', '#title' => t('Invitation limit'), '#default_value' => variable_get('invite_maxnum_'. $role_no_space, INVITE_UNLIMITED), - '#options' => array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500, 1000 => 1000, INVITE_UNLIMITED => t('unlimited')), - '#description' => t('Allows to limit the total number of invitations members of %role can send.', array('%role' => $role)), - '#multiple' => FALSE, + '#size' => 10, + '#maxlength' => 10, + '#description' => t('Limits the total numbers of invites users of role %role can send. Enter %unlimited for unlimited.', array('%role' => $role, '%unlimited' => INVITE_UNLIMITED)), '#required' => TRUE, ); } @@ -168,6 +168,22 @@ function invite_settings() { } /** + * Validates the settings form. + */ +function invite_settings_validate($form, &$form_state) { + // Check all of the invite limits are non-negative integers or INVITE_UNLIMITED. + foreach (user_roles(0, 'send invitations') as $readable_role) { + $role = str_replace(' ', '_', $readable_role); + $value = $form_state['values']["invite_maxnum_$role"]; + if (!is_numeric($value) or round($value) != (float)$value or INVITE_UNLIMITED > (int)$value) { + $vars = array('%role' => drupal_ucfirst($readable_role), '%zero' => 0, '%unlimited' => INVITE_UNLIMITED); + $message = t('Limit of %role must be at least %zero (zero), or %unlimited for unlimited.', $vars); + form_set_error("invite_maxnum_$role", $message); + } + } +} + +/** * Return a list of all users that have invited someone. */ function invite_admin_overview() {