? 349228_signup_without_email.patch
Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.205.2.6
diff -u -p -r1.205.2.6 signup.module
--- signup.module 20 Dec 2008 06:31:27 -0000 1.205.2.6
+++ signup.module 21 Dec 2008 17:48:04 -0000
@@ -898,7 +898,8 @@ function signup_sign_up_user($signup_for
return FALSE;
}
}
- else {
+ // Now check to be sure Authenticated uid is beign passed?
+ if (!empty($signup_form['signup_username'])) {
// This query does the JOIN on {users} so we can avoid a full
// user_load() just so theme('username') can have the data it
// needs for the error message we might print out.
@@ -909,6 +910,10 @@ function signup_sign_up_user($signup_for
return FALSE;
}
}
+ // Or else now this must be a non-email signup :)
+ else {
+ // Do nothing.
+ }
// If we made it this far, we're going to need the full $user object.
$user = user_load(array('uid' => $signup_form['uid']));
Index: includes/signup_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/signup_form.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 signup_form.inc
--- includes/signup_form.inc 20 Dec 2008 06:31:27 -0000 1.1.2.1
+++ includes/signup_form.inc 21 Dec 2008 17:48:05 -0000
@@ -61,7 +61,7 @@ function signup_form(&$form_state, $node
$signup_form += $anon_form;
}
elseif ($signup_type == 'admin') {
- $admin_form = array();
+ $admin_form = array();
// Allow admin to select Authenticated or Anonymous users to add.
$useroptions = array('1' => t('Authenticated users'), '0' => t('Anonymous users'), '3' => t('Signup without email'));
if ($signup_type == 'admin') {
$admin_form['signup_usertype'] = array(
'#type' => 'radios',
'#title' => t('User type'),
'#options' => $useroptions,
'#weight' => -2,
'#required' => TRUE,
// Add some info for non-js enabled browsers.
'#description' => $hint .'
'. t('If Authenticated users is selected, please enter a Username. If Anonymous users is selected, please enter a valid Email. If Signup without email is selected, please leave both fields blank.') .'
',
'#prefix' => '',
'#suffix' => '
',
);
}
// If JS is enabled, system.css will hide all the settings on page
$justhideit_class = " js-hide";
$settings_class = "signup-usertype";
$settings_class .= " js-hide";
$settings_class2 = "signup-anontype";
$settings_class2 .= " js-hide";
// to use jQuery to hide these settings when signups are disabled.
drupal_add_js(drupal_get_path('module', 'signup') .'/js/signup_form.js');
$admin_form['signup_anon_mail'] = array(
'#title' => t('Email'),
'#type' => 'textfield',
'#description' => t('An e-mail address for users who are not registered at this site.'),
'#size' => 40,
'#maxlength' => 255,
'#weight' => -1,
#'#required' => TRUE,
'#prefix' => '',
'#suffix' => '
',
);
$admin_form['signup_username'] = array(
'#title' => t('Username'),
'#type' => 'textfield',
@@ -69,7 +69,7 @@ function signup_form(&$form_state, $node
'#maxlength' => USERNAME_MAX_LENGTH,
'#size' => 40,
'#weight' => -1,
- '#required' => TRUE,
+ #'#required' => TRUE,
'#prefix' => '',
'#suffix' => '
',
);
$validate_handler = 'signup_form_validate_username';
$signup_form += $admin_form;
@@ -180,15 +180,30 @@ function signup_form_validate_username($
$nid = $form_state['values']['nid'];
$username = $form_state['values']['signup_username'];
$account = user_load(array('name' => $username));
- if (empty($account)) {
- form_set_error('signup_username', t('User %user_name does not exist.', array('%user_name' => $username)));
+ // Add $usertype based on selected values in admin form.
+ $usertype = $form_state['values']['signup_usertype'];
+ // Authenticated user type is selected.
+ if ($usertype == '1') {
+ if (empty($account)) {
+ form_set_error('signup_username', t('User %user_name does not exist.', array('%user_name' => $username)));
+ }
+ elseif (!user_access('sign up for content', $account)) {
+ form_set_error('signup_username', t('User !user does not have permission to sign up.', array('!user' => theme('username', $account))));
+ }
+ elseif (db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE uid = %d AND nid = %d", $account->uid, $nid)) > 0) {
+ $node = node_load($nid);
+ form_set_error('signup_username', t('User !user is already signed up for %title', array('!user' => theme('username', $account), '%title' => $node->title)));
+ }
}
- elseif (!user_access('sign up for content', $account)) {
- form_set_error('signup_username', t('User !user does not have permission to sign up.', array('!user' => theme('username', $account))));
+ // Anymous user type is selected.
+ if ($usertype == '0') {
+ $nid = $form_state['values']['nid'];
+ $anon_mail = $form_state['values']['signup_anon_mail'];
+ signup_validate_anon_email($nid, $anon_mail, 'signup_anon_mail');
}
- elseif (db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE uid = %d AND nid = %d", $account->uid, $nid)) > 0) {
- $node = node_load($nid);
- form_set_error('signup_username', t('User !user is already signed up for %title', array('!user' => theme('username', $account), '%title' => $node->title)));
+ // No-email user is selected.
+ else {
+ // Do nothing
}
}
Index: js/signup_form.js
===================================================================
RCS file: js/signup_form.js
diff -N js/signup_form.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ js/signup_form.js 21 Dec 2008 17:48:05 -0000
@@ -0,0 +1,19 @@
+/* $Id: node_form.js,v 1.5 2008/11/06 10:20:48 dww Exp $ */
+
+/**
+ * On a node form, if the "Allow signups" radios are set to 1
+ * ('Enabled'), then show the other signup-specific settings,
+ * otherwise, hide them.
+ */
+Drupal.behaviors.signupShowNodeSettings = function () {
+ $('div.signup-allow-radios input[@type=radio]').click(function () {
+ $('div.signup-usertype')[['hide', 'show'][this.value]]();
+ });
+};
+
+// Try adding more than one (possible? or get JS help if not)
+Drupal.behaviors.signupShowNodeSettings2 = function () {
+ $('div.signup-allow-radios input[@type=radio]').click(function () {
+ $('div.signup-anontype')[['show', 'hide'][this.value]]();
+ });
+};
\ No newline at end of file