RSS

LuxCal Forum

The place for questions, suggestions and news about the LuxCal Event Calendar

User:   Password:   Remember Me?   
LuxCal Forum / General / Support / Sort order by user_id
Posted:  01 Jun 2012 11:38   Last Edited By: Roel B.
I want to sort the events for each day by user_id.

I edited common/retrieve.php in line 104 and 121
from:
e.s_date
to:
e.user_id

This sorts almost all events in the order by user id, but not always and not all the time.
Sometimes when all event isn't sorted by user_id on a specific date it can help by adding another event to that date. But if I then delete this event then it goes back to sorting it in a wrong way.

How can I sort the events by user_id and only by user_id?

Feel free to look at the calendar at www.hoppafallskarm.nu/affcal/index.php
Posted:  01 Jun 2012 12:43   Last Edited By: Roel B.
Hi there,
The changes you made on lines 104 and 121 above are not correct; you should change these back (the events should always first be sorted by start date).
To change the order of the events for each day, you should change the function "sortEvt" on line 33 of the file common.retrieve.php (and for the Changes view: the function "changeEvts" on line 28 of the file common/retrieve2.php).
For instance change line 33 to:

function sortEvt($a, $b) { return strcmp($a['uid'], $b['uid']); }

Line 28 of retrieve2.php is a bit more complicated, I leave that to you :)
(let me know if you need help for the latter).
Roel
Posted:  01 Jun 2012 13:40   Last Edited By: Roel B.
Thanks for your super fast reply :)

I changed lines 104 and 121 back to e.s_date and edited line 33 in common/retrieve.php like you said.
This seems to work exactly as I want. The event is sorted by the user_id.

So do I have to edit retrieve2.php as well?
I took a look at it, but I'm not sure how it should look like if I need to edit it.

Thanks for your help,
Fredrik
Posted:  01 Jun 2012 22:27   Last Edited By: Roel B.
Fredrik,
You only have to edit retrieve2.php, if you also want the Changes view and the email notification message to be sorted by user_id.
If so, then change line 28 in the file common/retrieve2.php as follows:

function sortEvts($a, $b) { return strcmp(strval($a['sts']+1).$a['sda'].$a['uid'], strval($b['sts']+1).$b['sda'].$b['uid']); }

I've not tested this change; if it doesn't work let me know and I will make it work.
Roel

PS. Are you a Swedish speaking Polynesian (.nu)?
Posted:  02 Jun 2012 10:22
Thanks Roel, I will try that.

I'm Swedish living in Sweden. Its common that we in Sweden use the tld .nu since its the Swedish word for "now".

Cheers,
Fredrik