Commit 7a3a65bf authored by Melissa Draper's avatar Melissa Draper Committed by Gerrit Code Review
Browse files

Merge "Use group_homepage_url for group links when url is available"

parents 88269586 7ea7efd1
......@@ -608,6 +608,7 @@ function get_groups_for_user($username) {
$data->displayname = display_name($user);
if ($data->count) {
foreach ($groupdata['groups'] as $g) {
$groupurl = group_homepage_url($g, false);
$record = array();
$record['id'] = $g->id;
$record['name'] = $g->name;
......@@ -617,8 +618,8 @@ function get_groups_for_user($username) {
$record['grouptype'] = $g->grouptype;
$record['membershiptype'] = $g->membershiptype;
$record['role'] = $g->role;
$record['url'] = '/group/view.php?id=' . $g->id;
$record['fullurl'] = get_config('wwwroot') . 'group/view.php?id=' . $g->id;
$record['url'] = '/' . $groupurl;
$record['fullurl'] = get_config('wwwroot') . $groupurl;
$data->data[] = $record;
}
}
......
......@@ -442,7 +442,12 @@ function editgroup_submit(Pieform $form, $values) {
db_commit();
redirect('/group/view.php?id=' . $group_data->id);
// Reload $group_data->urlid or else the redirect will fail
if (get_config('cleanurls') && !isset($values['urlid']) || $group_data->urlid != $values['urlid']) {
$group_data->urlid = get_field('group', 'urlid', 'id', $group_data->id);
}
redirect(group_homepage_url($group_data));
}
$js = '
......
......@@ -98,7 +98,7 @@ function addmembers_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('invitationssent', 'group', count($values['users'])));
if ($friends) {
redirect(get_config('wwwroot') . 'group/view.php?id=' . GROUP);
redirect(group_homepage_url($group));
}
redirect(get_config('wwwroot') . 'group/members.php?id=' . GROUP);
}
......@@ -86,6 +86,7 @@ function addmembers_submit(Pieform $form, $values) {
}
require_once('activity.php');
$groupurl = group_homepage_url($group, false);
activity_occurred('maharamessage', array(
'users' => $values['users'],
'subject' => '',
......@@ -102,10 +103,10 @@ function addmembers_submit(Pieform $form, $values) {
'args' => array(display_name($USER), hsc($group->name), get_config('sitename')),
),
),
'url' => 'group/view.php?id=' . GROUP,
'url' => $groupurl,
'urltext' => hsc($group->name),
));
$SESSION->add_ok_msg(get_string('recommendationssent', 'group', count($values['users'])));
redirect(get_config('wwwroot') . 'group/view.php?id=' . GROUP);
redirect(get_config('wwwroot') . $groupurl);
}
......@@ -916,7 +916,9 @@ class GroupAccessDeniedException extends AccessDeniedException {
|| get_record('group_member_invite', 'group', GROUP, 'member', $USER->get('id'))) {
$SESSION->add_error_msg(get_string('notmembermayjoin', 'group', $group->name));
$next = substr($_SERVER['REQUEST_URI'], strlen(get_mahara_install_subdirectory()) - 1);
redirect(get_config('wwwroot') . 'group/view.php?id=' . GROUP . '&next=' . urlencode($next));
$goto = group_homepage_url($group);
$goto .= (strpos($goto, '?') ? '&' : '?') . 'next=' . urlencode($next);
redirect($goto);
}
if ($group->request && !get_record('group_member_request', 'group', GROUP, 'member', $USER->get('id'))) {
$SESSION->add_error_msg(get_string('notamember', 'group'));
......
......@@ -968,7 +968,7 @@ function group_invite_user($group, $userid, $userfrom, $role='member', $delay=nu
'users' => array($user->id),
'subject' => get_string_from_language($lang, 'invitetogroupsubject', 'group'),
'message' => get_string_from_language($lang, 'invitetogroupmessage', 'group', display_name($userfrom, $user), $group->name),
'url' => 'group/view.php?id=' . $group->id,
'url' => group_homepage_url($group, false),
'urltext' => $group->name,
);
activity_occurred('maharamessage', $activitydata, null, null, $delay);
......@@ -1575,7 +1575,7 @@ function group_get_menu_tabs() {
$menu = array(
'info' => array(
'path' => 'groups/info',
'url' => 'group/view.php?id='.$group->id,
'url' => group_homepage_url($group, false),
'title' => get_string('About', 'group'),
'weight' => 20
),
......
......@@ -124,7 +124,7 @@ class Sitemap {
foreach ($publicgroups as $group) {
if (isset($group->mtime) && $this->check_date($group->mtime)) {
// each group gets a url entry
$groupurl = get_config('wwwroot') . 'group/view.php?id=' . $group->id;
$groupurl = group_homepage_url($group);
$groupurl = utf8_encode(htmlspecialchars($groupurl, ENT_QUOTES, 'UTF-8'));
$grouplastmod = format_date(strtotime($group->mtime), 'strftimew3cdate');
......
<div>
<h3>
<a href="{$WWWROOT}group/view.php?id={$group->id}">
<a href="{group_homepage_url($group)}">
{$group->name}
</a>
</h3>
......
......@@ -112,10 +112,10 @@ if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_
// been submitted to, and is entitled to release the view
$submittedgroup = get_record('group', 'id', $submittedgroup);
if ($view->get('submittedtime')) {
$text = get_string('viewsubmittedtogroupon', 'view', get_config('wwwroot') . 'group/view.php?id=' . $submittedgroup->id, hsc($submittedgroup->name), format_date(strtotime($view->get('submittedtime'))));
$text = get_string('viewsubmittedtogroupon', 'view', group_homepage_url($submittedgroup), hsc($submittedgroup->name), format_date(strtotime($view->get('submittedtime'))));
}
else {
$text = get_string('viewsubmittedtogroup', 'view', get_config('wwwroot') . 'group/view.php?id=' . $submittedgroup->id, hsc($submittedgroup->name));
$text = get_string('viewsubmittedtogroup', 'view', group_homepage_url($submittedgroup), hsc($submittedgroup->name));
}
$releaseform = pieform(array(
'name' => 'releaseview',
......
Supports Markdown
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