Sort users in user lists by last name, OMP

Hi,

we would like to have the users sorted by last name in user lists, e.g. in the “add participant form”. I had a look at OMP 1.2 and the lists are still sorted by id.

So I added some code to “AddParticipantFormHandler.js”, but it’s just a hack (the last name variable is missing) that is restricted to the “add participant form” and of course we would prefer a proper PKP-solution in the OMP-code.

Do you plan to do that in the near future?

best,
Carola

Hi @carola,

To do this in the database, edit lib/pkp/classes/user/UserStageAssignmentDAO.inc.php and find the getUsersNotAssignedToStageInUserGroup function. As you can see, there’s no ORDER BY clause in the SQL. You could add this to the end of the query:

ORDER BY u.last_name

To get it merged into mainline OMP, all it would take is a pull request :wink:

Thanks,
Alec Smecher
Public Knowledge Project Team

Hi Alec,

sorting in UserStageAssignmentDAO doesn’t work, because the items are “resorted” later

AddParticipantFormHandler.js, line 106:

for (optionId in jsonData.content) { …}

best,
Carola

Hi @carola,

Serves me right for spending so much time writing PHP. Javascript arrays do not support ordering other than by the array index, so even if OJS serves up users in a different order, Javascript will dutifully rearrange them into ID order.

To resolve this, you’d need to serve up an array structure like this from PHP:

array(
  0 => array(12, UserWithId12),
  1 => array(15, UserWithId15),
  ...
)

…where the array indexes in the outer array are not informational.

However, I’m hesitant to commit this to OMP/OJS for version 1.2 because we have a bigger related problem to solve: Participants add process lists all users · Issue #411 · pkp/pkp-lib · GitHub

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I just noticed that you have already implemented a solution for OJS 3.0. Could you also add it to OMP 1.2 ? We urgently need it since we have a lot of proofreaders to select from.

best,
Carola

Hi @carola,

Did you find a github entry or something similar for this request for OJS?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @smecher,

I found these, but I don’t know if they are the rights ones:

best,
Carola

Hi @carola,

It looks like the relevant change is this pull request. I haven’t cherry-picked that into OMP 1.2.0, but I did perform a test-run of the cherry pick, and it appears to apply cleanly. I’d suggest seeing if that does the trick for you. Then cherry-pick this commit to make the sort occur by last name. (Both of these changes will be released with OMP 3.1, currently scheduled for March 1st. See the milestones page
for details.)

Regards,
Alec Smecher
Public Knowledge Project Team