Commit d55f88c2 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1544381: Need to move get_homepage_url() out of template"

parents c4f11934 3df10959
......@@ -2084,6 +2084,11 @@ function group_get_associated_groups($userid, $filter='all', $limit=20, $offset=
ORDER BY g1.name';
$groups = get_records_sql_array($sql, $values, $offset, $limit);
if ($groups) {
foreach ($groups as $group) {
$group->homeurl = group_homepage_url($group);
}
}
return array('groups' => $groups ? $groups : array(), 'count' => $count);
......@@ -2133,6 +2138,11 @@ function group_get_user_groups($userid=null, $roles=null, $sort=null, $limit=nul
ORDER BY g.name, gm.role = 'admin' DESC, gm.role, g.id",
array($loggedinid, $userid)
);
if ($groups) {
foreach ($groups as $key => $group) {
$group->homeurl = group_homepage_url($group);
}
}
$usergroups[$userid] = $groups ? $groups : array();
}
......
......@@ -1110,7 +1110,11 @@ function group_stats_table($limit, $offset) {
$result['csv'] = true;
require_once('group.php');
if ($groupdata) {
foreach ($groupdata as $group) {
$group->homeurl = group_homepage_url($group);
}
}
$smarty = smarty_core();
$smarty->assign('data', $groupdata);
$smarty->assign('offset', $offset);
......
......@@ -5249,6 +5249,7 @@ class View {
else if (!empty($v->group)) {
$v->sharedby = $groups[$v->group]->name;
$v->groupdata = $groups[$v->group];
$v->groupdata->homeurl = group_homepage_url($v->groupdata);
}
else if (!empty($v->institution)) {
$v->sharedby = $institutions[$v->institution]->displayname;
......@@ -5566,6 +5567,9 @@ class View {
$results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, $search->sort, null, true);
$oldcollid = null;
foreach ($results->data as &$r) {
if (!empty($r['groupdata'])) {
$r['groupdata']->homeurl = group_homepage_url($r['groupdata'], true, true);
}
if (!empty($search->sort)) {
$collid = ($r['collid'] == $oldcollid) ? null : $r['collid'];
}
......
......@@ -10,7 +10,7 @@
{if $view.sharedby}
<span class="owner inner-link text-small text-midtone">
{if $view.group}
<a href="{group_homepage_url($view.groupdata)}" class="text-small">
<a href="{$view.groupdata->homeurl}" class="text-small">
{$view.sharedby}
</a>
{elseif $view.owner}
......
<div class="list-group">
{foreach from=$items item=item}
<div class="list-group-item list-group-item-link">
<a href="{group_homepage_url($item)}">
<h5 class="text-inline list-group-item-heading">{$item->name}</h5>
<a href="{$item->homeurl}">
<h5 class="text-inline list-group-item-heading">{$item->name}</h5>
<span class="text-small text-midtone"> ({$item->roledisplay})</span>
</a>
</div>
......
......@@ -9,7 +9,7 @@
{if $view.sharedby}
<div class="groupuserdate text-small">
{if $view.group && $loggedin}
<a href="{group_homepage_url($view.groupdata)}" class="text-link">
<a href="{$view.groupdata->homeurl}" class="text-link">
{$view.sharedby}
</a>
{elseif $view.owner && $loggedin}
......
......@@ -15,7 +15,7 @@
{if $view->sharedby}
<div class="groupuserdate text-small">
{if $view->group && $loggedin}
<a class="inner-link" href="{group_homepage_url($view->groupdata)}">{$view->sharedby}</a>
<a class="inner-link" href="{$view->groupdata->homeurl}">{$view->sharedby}</a>
{elseif $view->owner && $loggedin}
{if $view->anonymous}
{if $view->staff_or_admin}
......
{foreach from=$data item=item key=key}
<tr class="{cycle values='r0,r1'}">
<td>{$offset + $dwoo.foreach.default.iteration}</td>
<td><a href="{group_homepage_url($item)}">{$item->name}</a></td>
<td><a href="{$item->homeurl}">{$item->name}</a></td>
<td class="center">{$item->members}</td>
<td class="center">{$item->views}</td>
<td class="center">{$item->forums}</td>
......
<div class="list-group-item {if $group->membershiptype == 'invite' || $group->membershiptype == 'request' || $group->requests} list-group-item-warning{/if}">
<a href="{group_homepage_url($group)}" class="outer-link"><span class="sr-only">{$group->name}</span></a>
<a href="{$group->homeurl}" class="outer-link"><span class="sr-only">{$group->name}</span></a>
<div class="row">
<div class="col-md-8">
<h3 class="list-group-item-heading text-inline">
......
......@@ -36,7 +36,7 @@
<div class="list-group-item-heading sidebar-item-heading"><a href="{$WWWROOT}group/mygroups.php">{str tag="mygroups"}:</a></div>
<ul class="list-nested list-group-item-text list-unstyled list-group-item-link">
{foreach from=$sbdata.groups item=group}
<li><a href="{group_homepage_url($group)}" class="bordered">{$group->name} {if $group->role == 'admin'}<small>({str tag=Admin section=group})</small>{/if}</a></li>
<li><a href="{$group->homeurl}" class="bordered">{$group->name} {if $group->role == 'admin'}<small>({str tag=Admin section=group})</small>{/if}</a></li>
{/foreach}
</ul>
<span class="text-small text-midtone">{$sbdata.grouplimitstr}</span>
......
......@@ -5,7 +5,7 @@
{if $view.sharedby}
<div class="groupdate">
{if $view.group}
<a href="{group_homepage_url($view.groupdata)}">{$view.sharedby}</a>
<a href="{$view.groupdata->homeurl}">{$view.sharedby}</a>
{elseif $view.owner}
{if $view.anonymous}
{str tag=anonymoususer section=mahara}
......
......@@ -25,7 +25,7 @@
</td>
{elseif $row.group}
<td class="owner">
<a class="grouplink" href="{group_homepage_url($row.groupdata, true, true)}" target="_blank">{$row.sharedby}</a>
<a class="grouplink" href="{$row.groupdata->homeurl}" target="_blank">{$row.sharedby}</a>
</td>
{elseif $row.owner}
<td class="ownericon">
......
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