Hacking Mahara to display last updates in pages

Tomorrow night will be the due date for my students to submit a Lab Report created in Mahara. I told them that I was not going to accept reports modified after the due date but I hadn’t realized that Mahara pages don’t show last update information so I had to hack the code to get it.

Footer Mahara Page displaying Last update

Footer Mahara Page displaying Last update

This is what I did:

########################################
# Hacking Mahara 1.8.1 to display ‘last update’ on pages #
########################################

We need to modify two files:

a.- /var/www/mahara/view/view.php (Lines 359, 360 and 361)

b.- /var/www/mahara/theme/raw/templates/view/view.tpl (Lines 37 and 38)

a.- First I added two new lines (and a comment) to /view/view.php (Lines 359, 360 and 361). Open the file with your favourite editor and add lines in blue

user@maharaserver:/# nano -wc /var/www/mahara/view/view.php

if ($viewgroupform) {
    $smarty->assign('view_group_submission_form', $viewgroupform);
}
# Hack: 2 lines added to display 'last update' on pages
$smarty->assign('datecreation', $view->get('ctime'));
$smarty->assign('datemodifica', $view->get('mtime'));

$smarty->display('view/view.tpl');

b.- Then I added 1 line (and a comment) to /theme/raw/templates/view/view.tpl (Lines 37 and 38). Open the file with your favourite editor and add lines in magenta

user@maharaserver:/# nano -wc  /var/www/mahara/theme/raw/templates/view/view.tpl

{if $tags}<div><label>{str tag=tags}:</label> {list_tags owner=$owner tags=$tags}</div>{/if}
<!-- //Hack: 1 line added to display 'last update' on pages --->
{if $datemodifica == $datecreation}<div><label>{str tag=Created}{else}<div><label>{str tag=Updated}{/if}</label> {$datemodifica}</div>
{if $releaseform}<div>{$releaseform|safe}</div>{/if}
{if $view_group_submission_form}<div>{$view_group_submission_form|safe}</div>{/if}

That’s all. Now you will see the last update at the footer of pages created with Mahara. The date format shows y/m/d hh:mm:ss. It means 2014:02:02 01:40. Another more elegant hack could be:

<!– //Hack: 1 line added to display ‘last update’ on pages —>
{if $datemodifica == $datecreation}<div><label>{str tag=Created}{else}<div><label>{str tag=Updated}{/if}</label> {$datemodifica|strtotime|format_date:’strftimedate‘}</div>

This hack display a more friendly date format: 02 Feb 2014. I choose the long one because I need to check hours too.

I don’t know if it’s the best way to hack the code but I needed it and it works for me.  I hope it helps you 🙂

2 comentarios

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.