Commit ffb144ad authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use group_homepage_url when data is easy/inexpensive to fetch



Bug #1006634, part 3

Replaces existing group/view.php urls with calls to
group_homepage_url, in a bunch of places where only a minor change is
required to fetch the urlid property, and where it is clear it will
have little impact on performance:

- My groups block
- Cancel button on group delete
- Redirects after joining a group or inviting a user
- Group tab of the admin stats area
- My groups section of the profile sideblock
- Redirect after submitting a view

Change-Id: I0ab970bdc4aaefe9fb912f9e530ebe1684aed011
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 7ea7efd1
......@@ -3,7 +3,7 @@
{foreach from=$USERGROUPS item=item}
<tr>
<td class="{cycle values='r0,r1'}">
<h4><a href="{$WWWROOT}group/view.php?id={$item->id}">{$item->name}</a> - {$item->roledisplay}</h4>
<h4><a href="{group_homepage_url($item)}">{$item->name}</a> - {$item->roledisplay}</h4>
{if $item->description}
<div class="details">{$item->description|str_shorten_html:100:true|safe}</div>
{/if}
......
......@@ -33,7 +33,7 @@ require_once('group.php');
$groupid = param_integer('id');
define('GROUP', $groupid);
$group = get_record_sql("SELECT g.name
$group = get_record_sql("SELECT g.*
FROM {group} g
INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ? AND gm.role = 'admin')
WHERE g.id = ?
......@@ -54,7 +54,7 @@ $form = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . 'group/view.php?id=' . $groupid
'goto' => group_homepage_url($group),
)
),
));
......
......@@ -1118,7 +1118,7 @@ function joingroup_submit(Pieform $form, $values) {
$next = $values['returnto'];
}
else {
$next = '/group/view.php?id=' . $values['group'];
$next = group_homepage_url(get_record('group', 'id', $values['group']));
}
redirect($next);
}
......@@ -1135,7 +1135,7 @@ function group_invite_submit(Pieform $form, $values) {
$next = $values['returnto'];
}
else {
$next = '/group/view.php?id=' . $values['group'];
$next = group_homepage_url(get_record('group', 'id', $values['group']));
}
redirect($next);
}
......@@ -1879,7 +1879,7 @@ function group_get_user_groups($userid=null, $roles=null) {
if (!isset($usergroups[$userid])) {
$groups = get_records_sql_array("
SELECT g.id, g.name, gm.role, g.jointype, g.request, g.grouptype, gtr.see_submitted_views, g.category,
g.hidemembers, g.invitefriends, gm1.role AS loggedinrole
g.hidemembers, g.invitefriends, g.urlid, gm1.role AS loggedinrole
FROM {group} g
JOIN {group_member} gm ON gm.group = g.id
JOIN {grouptype_roles} gtr ON g.grouptype = gtr.grouptype AND gm.role = gtr.role
......
......@@ -578,7 +578,7 @@ function group_stats_table($limit, $offset) {
$groupdata = get_records_sql_array(
"SELECT
g.id, g.name, mc.members, vc.views, fc.forums, pc.posts
g.id, g.name, g.urlid, mc.members, vc.views, fc.forums, pc.posts
FROM {group} g
LEFT JOIN (
SELECT gm.group, COUNT(gm.member) AS members
......
{foreach from=$data item=item key=key}
<tr class="{cycle values='r0,r1'}">
<td>{$offset + $dwoo.foreach.default.iteration}</td>
<td><a href="{$WWWROOT}group/view.php?id={$item->id}">{$item->name}</a></td>
<td><a href="{group_homepage_url($item)}">{$item->name}</a></td>
<td class="center">{$item->members}</td>
<td class="center">{$item->views}</td>
<td class="center">{$item->forums}</td>
......
......@@ -24,7 +24,7 @@
<li id="groups"><label><a href="{$WWWROOT}group/mygroups.php">{str tag="mygroups"}:</a></label>
<ul>
{foreach from=$sbdata.groups item=group}
<li><a href="{$WWWROOT}group/view.php?id={$group->id}">{$group->name}</a>{if $group->role == 'admin'} ({str tag=Admin section=group}){/if}</li>
<li><a href="{group_homepage_url($group)}">{$group->name}</a>{if $group->role == 'admin'} ({str tag=Admin section=group}){/if}</li>
{/foreach}
</ul></li>
{/if}
......
......@@ -38,7 +38,7 @@ $returnto = param_variable('returnto', 'view');
$view = get_record('view', 'id', $viewid, 'owner', $USER->get('id'));
$group = get_record_sql(
'SELECT g.id, g.name, g.grouptype
'SELECT g.id, g.name, g.grouptype, g.urlid
FROM {group_member} u
INNER JOIN {group} g ON (u.group = g.id AND g.deleted = 0)
WHERE u.member = ?
......@@ -121,10 +121,10 @@ function submitview_submit(Pieform $form, $values) {
}
function returnto() {
GLOBAL $viewid, $groupid, $returnto;
global $viewid, $group, $returnto;
// Deteremine the best place to return to
if ($returnto === 'group') {
$goto = 'group/view.php?id=' . $groupid;
$goto = group_homepage_url($group, false);
}
else if ($returnto === 'view') {
$goto = 'view/view.php?id=' . $viewid;
......
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