Forums | Mahara Community

Developers /
Sorting pages according to dates?


Shen Zhang's profile picture
Posts: 72

02 July 2014, 11:34 AM

Hi

We are looking at a possibility of sorting shared pages on the group home page according to the shared dates. Currrently they are sorted according to the title.

Has anyone else tried this?

 

Shen Zhang's profile picture
Posts: 72

06 August 2014, 2:00 PM

Is there any field in the database that records the date and time a page is shared with a group?

I had a look in the database, the best I could find is the "ctime", "mtime" and "atime" field in the "view" table. When a portfolio page is modified, the mtime and atime gets updated. However, can anyone advise whether there is any field records when a page is shared with a group?

Many thanks,

Shen

Kristina Hoeppner's profile picture
Posts: 3632

31 August 2014, 4:17 PM

Hello Shen,

As far as I can tell this happens:

When you add permissions for any access, the view_access table is updated. Each access group gets its own row (search by the ID of the page). So when you share a page with a group or a friend or a person, the record is added and the time stamp (ctime) added.

When you update the access for whatever reason, e.g. to add permissions for another user, group or person, the timestamps for ALL that already have permission to view the page are updated as well to the new ctime. Currently, we cannot distinguish in the database between access that has already existed and hasn't changed and new access. That is done elsewhere because otherwise you'd get a notification every time the access is changed.

This doesn't really solve your problem because you don't know if the ctime is really the first time the user shared the page with the group or whether it's been updated since then. We also do not keep track of previous access, i.e. with whom the page was shared 5 weeks ago before the access was taken away.

Cheers

Kristina

 

Jawyei Wong's profile picture
Posts: 17

03 September 2014, 9:52 AM

Hi Kristina

I assume ctime stands for create time and that does not change in the View table.

We are looking at changing the line 3357 of [mahara_root]/lib/view.php from

SELECT v.id,v.title,v.startdate,v.stopdate,v.description,v.group,v.owner,v.ownerformat,v.institution,v.urlid, ' . $from . '

to

SELECT v.id,v.title,v.startdate,v.stopdate,v.description,v.group,v.owner,v.ownerformat,v.institution,v.urlid,v.ctime ' . $from . '

Essentially adding in v.ctime in the SELECT statement. With this field we can sort the array returned by function get_sharedviews_data($limit=10, $offset=0, $groupid). Since this is changing core code, I am wondering that if we do add this in will it cause any ArrayIndexOutOfBounds or any loops that will not work correctly due to this extra field.

Thanks,Jawyei Wong

Shen Zhang's profile picture
Posts: 72

03 September 2014, 10:36 AM

Thanks Kristina for the reply. We eventually decided to use the ctime in the view table for sort the group shared pages. However, we need to change some code in the Mahara core code as what Jawyei has posted.

I'm not sure whether there are any other users have suggested to be able to sort the shared pages in the group homepage in any other way. However, we found sorting only by the page titles definitely has its limitation. Just wondering whether the development team has any intention in providing more sorting options?

 

We have been pondering about whether we should create our own query or use the method provided in the core code. Do you think the change Jawyei asked about could become part of the core code? Or even change it to return all the fields in the view table from the get_sharedviews_data method? Using the ctime from the view table probably is not the best solution. But this probably is the easiest solution for now. 

Aaron Wells's profile picture
Posts: 896

03 September 2014, 11:08 AM

Hm, I guess it would be a relatively harmless change, to add "view.ctime" to the columns returned by the get_sharedviews_data() function. If you want to submit a patch (see https://wiki.mahara.org/index.php/Developer_Area/Contributing_Code ) we can probably include that. Smile

Unfortunately, since 1.10 is already getting finalized, this change wouldn't be able to make it into Mahara core until version 1.11, around April of next year.

Cheers,

Aaron

6 results