It would be nice to choose the order of the signup details for each signup or simply set it to order by last name.

Comments

dww’s picture

Do you mean at node/X/signups?

What do you mean "last name"? There's no such field in Drupal. If that's a custom signup field you added on your site, obviously I can commit code to sort on that. ;) In fact, it'd be really hard to sort on any of the custom signup data (the "Extra information" column in that table).

About the only thing we could safely do is split out the username and signup time, and then sort by either of those two columns. Is that what you've got in mind?

Cheers,
-Derek

pelicani’s picture

We need similar functionality.

First, we want to sort the signup list by the signup status.
This may be a patch to the signup status module, I haven't checked yet.
But this lets us filter the results based on status.
Not the most full featured filter/sort, but it is a start.

Second...
We were thinking of integrating the Bio fields of the user in the signup display.
Then we could sort on any of those fields.
That would give the results a lot of flexibility.

The other display option we were thinking...
Display signups on the user/# page.
And provide a way for users to interact with their signups (cancel) from their account page.

Maybe these all don't belong in one issue.
Hoping to spark some interest.

peace,
michael

pcorbett’s picture

Sorry for the delay, but yes, I was asking to sort on custom fields. Right now I'm just hacking it to do so. What I did was edit my template.php and added in the phptemplate_signup_user_form() override. There, I added first and last name fields:

function phptemplate_signup_user_form() {
  global $user;

  // This line is required for this form to function -- DO NOT EDIT OR REMOVE.
  $form['signup_form_data']['#tree'] = TRUE;

  $form['signup_form_data']['first_name'] = array(
    '#type' => 'textfield',
    '#title' => t('First Name'),
    '#size' => 40, '#maxlength' => 64,
    '#required' => true,
  );
  $form['signup_form_data']['last_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Last Name'),
    '#size' => 40, '#maxlength' => 64,
    '#required' => true,
  );	

...

In signup.module I altered signup_node_admin_page() (around line 1517) to re-order the rows in the $rows array populated from the DB. Altering the order in the DB query itself was basically impossible without really complicating the SQL:

    // Build the row for this user.
    $rows[] = array(
      $username .'<br />'. gmdate(variable_get('signup_date_string', 'M jS, g:i A'), $signed_up_user->signup_time + $offset),
      $signup_form_data,
      drupal_get_form('signup_user_cancel_form_'. $id, $id, $node->nid, $signed_up_user->uid, $signed_up_user->anon_mail)
    );
  }
  
  //NEW: sort rows alphabetically by last name
	function compare($x, $y)
	{
		$last_name_1 = explode('last_name: ', $x[1]);
		$last_name_2 = explode('last_name: ', $y[1]);
		if ( strtolower($last_name_1[1]) == strtolower($last_name_2[1]))
	 		return 0;
		else if (strtolower($last_name_1[1]) < strtolower($last_name_2[1]))
	 		return -1;
		else
	 		return 1;
	}
	usort($rows, 'compare');

Not a huge deal, but it's always nice when you don't have to modify the core module code.

dww’s picture

Yeah, it's impossible to cleanly sort by custom signup data given the current design of how that custom data is handled. It's a terrible hack. Integrating bio data or other fields is going to be impossible unless you do this via a view. Tempted to mark this "won't fix" in favor of spending time on a real solution to #29568: Flexible number and type of fields.

dww’s picture

Status: Active » Fixed

I just committed a fix for this to HEAD for the username and signup time: http://drupal.org/cvs?commit=144843
Sorting by custom fields is basically impossible in a clean way, so I'm just going to call this fixed for now.
More far reaching solutions will have to go into other issues, for example:
#243035: How to list all signed up users in a view??
#214091: Interraction with nodeprofile
#29568: Flexible number and type of fields

pcorbett’s picture

Thanks dww, I appreciate it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.