Commit 0888cfe3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Support for recent views on the home page


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent e2cd21e3
......@@ -47,6 +47,13 @@ else {
$smarty = smarty();
$smarty->assign('page_content', get_site_page_content($pagename));
if ($nviews = get_config('homepageviewlist')) {
require_once('view.php');
$views = View::view_search(null, null, null, null, $nviews, 0, true, 'mtime DESC');
$smarty->assign('views', $views->data);
}
$smarty->display('index.tpl');
?>
......@@ -879,4 +879,6 @@ $string['thisistheprofilepagefor'] = 'This is the profile page for %s';
$string['pleasedonotreplytothismessage'] = "Please do not reply to this message.";
$string['deleteduser'] = 'Deleted user';
$string['recentupdates'] = 'Recent Updates';
?>
......@@ -2130,9 +2130,10 @@ class View {
* @param integer $limit
* @param integer $offset
* @param bool $extra Return full set of properties on each view including an artefact list
* @param string $sort Order by
*
*/
public static function view_search($query=null, $ownerquery=null, $ownedby=null, $copyableby=null, $limit=null, $offset=0, $extra=true) {
public static function view_search($query=null, $ownerquery=null, $ownedby=null, $copyableby=null, $limit=null, $offset=0, $extra=true, $sort=null) {
global $USER;
$admin = $USER->get('admin');
$loggedin = $USER->is_logged_in();
......@@ -2248,14 +2249,15 @@ class View {
}
$count = count_records_sql('SELECT COUNT (DISTINCT v.id) ' . $from . $where, $ph);
$orderby = is_null($sort) ? 'title ASC' : $sort;
$viewdata = get_records_sql_array('
SELECT * FROM (
SELECT
v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution, v.template
v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution, v.template, v.mtime
' . $from . $where . '
GROUP BY v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution, v.template
GROUP BY v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution, v.template, v.mtime
) a
ORDER BY a.title, a.id ',
ORDER BY a.' . $orderby . ', a.id ASC',
$ph, $offset, $limit
);
......
{include file="header.tpl"}
{$page_content|clean_html}
{if $views}
<h5>{str tag=recentupdates}</h5>
<table>
{foreach from=$views item=view}
<tr>
{if $view.sharedby}
<td>
{if $view.group && $USER->is_logged_in()}
<a href="{$WWWROOT}group/view.php?id={$view.group}">{$view.sharedby}</a>
{elseif $view.owner && $USER->is_logged_in()}
<a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.sharedby}</a>
{else}
{$view.sharedby}
{/if}
<div>{$view.mtime|strtotime|format_date:'strftimedate'}</div>
</td>
{/if}
<td>
<div><strong><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|escape}</a></strong></div>
<div>{$view.shortdescription}</div>
</td>
</tr>
{/foreach}
</table>
{/if}
{include file="footer.tpl"}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment