Commit 99f868ce authored by Melissa Draper's avatar Melissa Draper Committed by Gerrit Code Review
Browse files

Merge changes...

Merge changes I5b2cc7e9,Ic9c216d3,I6931a34b,Iafae1c7b,Ibcf3549a,If97f429b,I0ecb734a,I221a5a57,Ie5b88afb,If8695b57,Id6a0d193,I7cf0105e,I9dc34ce9,Ie24a5bfa,I48f0f78c,I80259c76,Ia744e06f,Ic9d1e5d4,If353facd,I643746b1,Ic9b108f4,I71fbf2e5,I3ad549cd,Idd92be96,I8c39548b,I12dad07c,Ic3b9888d,Ia115f605,Ib18ab902,Id4a6b641,I6d0378c6,Ia4653b20,I0f034f04,I878eca87,I227652f1,I3d583b83,I98526af0,I2fb2eaa0,I59b1ab91,I25be1009,I16c826e9,I26528ff5,I8758cf2f,I4a018d8d,I33e12289,I325866c8,Ia43ae086,I0ab970bd

* changes:
  Fix malformed 'display page' urls when cleanurls are enabled
  When changing urlid on the settings page, force a page reload
  Add an option to stop users from editing their profile urls
  Fix malformed block pagination urls when clean urls are enabled
  Delete urlids when deleting users and groups
  Use clean group url for notification after adding a user to a group
  Use clean group urls in redirect after editing group homepage content
  Remove unused ownerlink dwoo variable
  Use clean group urls on view access page
  Use clean group url for redirect after editing group hompepage access
  Use clean group url in 'you have submitted this view...' message
  Use clean group urls on group topics page
  Use clean profile urls on the view access page
  Use clean urls in tagged posts block
  Use clean urls on share page
  Use clean profile and group urls in the artefactchooser
  Use clean profile urls in forums area
  Use get_user_for_display in View::get_owner_object()
  Use clean profile urls on the users tab of the site stats page
  Replace miscellaneous hardcoded view urls
  Use clean urls on notes page
  Use clean urls in watchlist block
  When releasing a view, redirect to the clean group or view url
  Use clean urls on the view submission page
  Use clean urls in admin stats area
  Use clean urls for views listed on my friends page
  Don't fetch views on staff, online users lists unnecessarily
  Collect url information and display clean urls in collections
  Two minor optimisations to get_extra_view_info
  Use clean urls in profile sideblock
  Replace hardcoded urls on choose template page
  Use clean urls on view/artefact.php
  Let can_view_view take a View object
  Use clean urls elsewhere in lib/view.php
  Use clean urls in view access notifications
  Deal with institution views in formatted_owner()
  Use full url in togglewatchlist link
  Use clean urls in watchlist notifications
  Use clean view urls on tags page
  Use View::get_url() to generate view urls in view listings
  Display clean urls on Portfolio->Pages aka My Views
  Generate view urls in get_extra_view_info
  Use clean urls in View::get_url() function
  Use clean urls for view owners after running view_search
  Use profile_url when data is easy or inexpensive to fetch
  Use clean profile urls on sendmessage, denyrequest pages
  Use clean profile urls when data is already available
  Use group_homepage_url when data is easy/inexpensive to fetch
parents 7a3a65bf 6a1cbf9b
......@@ -85,7 +85,7 @@ if ($authobj->authname == 'internal') {
);
}
if (get_config('cleanurls')) {
if (get_config('cleanurls') && get_config('cleanurlusereditable')) {
$elements['changeprofileurl'] = array(
'value' => '<tr><td colspan="2"><h3>' . get_string('changeprofileurl', 'account') . '</h3></td></tr>'
);
......@@ -164,7 +164,7 @@ function accountprefs_validate(Pieform $form, $values) {
}
}
if (get_config('cleanurls') && $values['urlid'] != $USER->get('urlid')) {
if (isset($values['urlid']) && get_config('cleanurls') && $values['urlid'] != $USER->get('urlid')) {
if (strlen($values['urlid']) < 3) {
$form->set_error('urlid', get_string('rule.minlength.minlength', 'pieforms', 3));
}
......@@ -222,31 +222,33 @@ function accountprefs_submit(Pieform $form, $values) {
if (get_config('cleanurls') && isset($values['urlid']) && $values['urlid'] != $USER->get('urlid')) {
$USER->urlid = $values['urlid'];
$USER->commit();
$reload = true;
}
db_commit();
$updatelang = isset($values['lang']) && $values['lang'] != $oldlang;
$updatetheme = isset($values['theme']) && $values['theme'] != $oldtheme;
$returndata['message'] = get_string('prefssaved', 'account');
if ($updatetheme) {
if (isset($values['theme']) && $values['theme'] != $oldtheme) {
$USER->update_theme();
$message = get_string('prefssaved', 'account');
$reload = true;
}
if ($updatelang) {
if (isset($values['lang']) && $values['lang'] != $oldlang) {
// The session language pref is used when the user has no user pref,
// and when logged out.
$SESSION->set('lang', $values['lang']);
$message = get_string_from_language($values['lang'], 'prefssaved', 'account');
$returndata['message'] = get_string_from_language($values['lang'], 'prefssaved', 'account');
$reload = true;
}
if ($updatelang || $updatetheme) {
if (!empty($reload)) {
// Use PIEFORM_CANCEL here to force a page reload and show the new language.
$returndata['location'] = get_config('wwwroot') . 'account/index.php';
$SESSION->add_ok_msg($message);
$SESSION->add_ok_msg($returndata['message']);
$form->json_reply(PIEFORM_CANCEL, $returndata);
}
$returndata['message'] = get_string('prefssaved', 'account');
$form->json_reply(PIEFORM_OK, $returndata);
}
......
......@@ -42,7 +42,7 @@ $authobj = AuthFactory::create($user->authinstance);
if (!$USER->is_admin_for_user($user)) {
$SESSION->add_error_msg(get_string('youcannotadministerthisuser', 'admin'));
redirect('/user/view.php?id=' . $id);
redirect(profile_url($user));
}
if ($user->deleted) {
......
......@@ -70,7 +70,7 @@ if (!$USER->get('admin') && !$USER->get('staff')) {
$users = get_records_sql_assoc('
SELECT
u.id, u.username, u.email, u.firstname, u.lastname, u.studentid, u.preferredname,
u.id, u.username, u.email, u.firstname, u.lastname, u.studentid, u.preferredname, u.urlid,
aru.remoteusername AS remoteuser
FROM {usr} u
LEFT JOIN {auth_remote_user} aru ON u.id = aru.localusr AND u.authinstance = aru.authinstance
......
......@@ -582,12 +582,6 @@ function get_views_for_user($username, $query=null) {
require_once('view.php');
$data = View::view_search($query, null, (object) array('owner' => $USER->get('id')));
$data->displayname = display_name($user);
if ($data->count) {
foreach ($data->data as &$v) {
$v['url'] = '/view/view.php?id=' . $v['id'];
$v['fullurl'] = get_config('wwwroot') . 'view/view.php?id=' . $v['id'];
}
}
return $data;
}
......
......@@ -79,8 +79,10 @@ class PluginBlocktypeBlog extends PluginBlocktype {
$pagination = false;
}
else {
$baseurl = $instance->get_view()->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id');
$pagination = array(
'baseurl' => $instance->get_view()->get_url() . '&block=' . $instance->get('id'),
'baseurl' => $baseurl,
'id' => 'blogpost_pagination_' . $instance->get('id'),
'datatable' => 'postlist_' . $instance->get('id'),
'jsonscript' => 'artefact/blog/posts.json.php',
......
......@@ -92,13 +92,7 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
// check if the user viewing the page is the owner of the selected tag
$owner = $results[0]->owner;
if ($USER->id != $owner) {
$sql =
'SELECT id, firstname, lastname
FROM {usr}
WHERE id = ?';
$viewowner = get_records_sql_array($sql, array($owner));
$viewowner = get_user_for_display($owner);
$smarty->assign('viewowner', $viewowner);
}
......
......@@ -5,8 +5,7 @@
{else}
{str tag='blockheading' section='blocktype.blog/taggedposts'}
{if $viewowner}
{$viewowner = $viewowner[0]}
<strong>{$tag}</strong> by <strong><a href="{$WWWROOT}user/view.php?id={$viewowner->id}">{$viewowner->firstname} {$viewowner->lastname}</a></strong>
<strong>{$tag}</strong> by <strong><a href="{profile_url($viewowner)}">{$viewowner|display_default_name}</a></strong>
{else}
<strong><a href="{$WWWROOT}tags.php?tag={$tag}&sort=name&type=text">{$tag}</a></strong>
{/if}
......
......@@ -47,8 +47,10 @@ if ($blockid = param_integer('block', null)) {
$configdata['viewid'] = $bi->get('view');
$posts = ArtefactTypeBlogpost::get_posts($configdata['artefactid'], $limit, $offset, $configdata);
$template = 'artefact:blog:viewposts.tpl';
$baseurl = $bi->get_view()->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $blockid;
$pagination = array(
'baseurl' => $bi->get_view()->get_url() . '&block=' . $blockid,
'baseurl' => $baseurl,
'id' => 'blogpost_pagination_' . $blockid,
'datatable' => 'postlist_' . $blockid,
'jsonscript' => 'artefact/blog/posts.json.php',
......
......@@ -341,7 +341,7 @@ class ArtefactTypeComment extends ArtefactType {
a.id, a.author, a.authorname, a.ctime, a.mtime, a.description,
c.private, c.deletedby, c.requestpublic, c.rating,
u.username, u.firstname, u.lastname, u.preferredname, u.email, u.staff, u.admin,
u.deleted, u.profileicon
u.deleted, u.profileicon, u.urlid
FROM {artefact} a
INNER JOIN {artefact_comment_comment} c ON a.id = c.artefact
LEFT JOIN {usr} u ON a.author = u.id
......@@ -494,6 +494,7 @@ class ArtefactTypeComment extends ArtefactType {
'admin' => $item->admin,
'deleted' => $item->deleted,
'profileicon' => $item->profileicon,
'profileurl' => profile_url($item),
);
}
}
......@@ -838,7 +839,7 @@ function delete_comment_submit(Pieform $form, $values) {
$url = 'view/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
}
else {
$url = 'view/view.php?id=' . $viewid;
$url = $view->get_url(false);
}
db_begin();
......@@ -1073,7 +1074,7 @@ function add_feedback_form_submit(Pieform $form, $values) {
function add_feedback_form_cancel_submit(Pieform $form) {
global $view;
$form->reply(PIEFORM_OK, array(
'goto' => '/view/view.php?id=' . $view->get('id'),
'goto' => '/' . $view->get_url(false),
));
}
......
......@@ -13,10 +13,10 @@
</div>
<div class="details commentleft">
{if $item->author}
<div class="icon"><a href="{$WWWROOT}user/view.php?id={$item->author->id}">
<div class="icon"><a href="{$item->author->profileurl}">
<img src="{profile_icon_url user=$item->author maxheight=40 maxwidth=40}" valign="middle" alt="{$item->author|display_name}">
</a><br />
<a href="{$WWWROOT}user/view.php?id={$item->author->id}" class="username">{$item->author|display_name}</a></div>
<a href="{$item->author->profileurl}" class="username">{$item->author|display_name}</a></div>
{else}
{$item->authorname}
{/if}
......
......@@ -26,6 +26,7 @@
define('INTERNAL', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('artefact', 'internal');
require_once('view.php');
define('TITLE', get_string('Notes', 'artefact.internal'));
$offset = param_integer('offset', 0);
......@@ -93,22 +94,32 @@ if ($data) {
SELECT
bi.id AS block, bi.title AS blocktitle,
va.artefact,
va.view, v.title AS viewtitle,
v.owner, u.firstname, u.lastname, u.preferredname,
v.group, g.name AS groupname,
v.institution, i.displayname AS institutionname
va.view, v.title AS viewtitle, v.owner, v.group, v.institution, v.ownerformat, v.urlid
FROM
{block_instance} bi
JOIN {view_artefact} va ON bi.id = va.block
JOIN {view} v ON va.view = v.id
LEFT OUTER JOIN {usr} u ON v.owner = u.id
LEFT OUTER JOIN {group} g ON v.group = g.id
LEFT OUTER JOIN {institution} i ON v.institution = i.name
WHERE
va.artefact IN (' . join(',', array_fill(0, count($data), '?')) . ')',
array_keys($data)
);
if ($blocks) {
$viewdata = array();
foreach ($blocks as $b) {
if (!isset($viewdata[$b->view])) {
$viewdata[$b->view] = (object) array(
'id' => $b->view,
'title' => $b->viewtitle,
'owner' => $b->owner,
'group' => $b->group,
'institution' => $b->institution,
'ownerformat' => $b->ownerformat,
'urlid' => $b->urlid,
);
}
}
View::get_extra_view_info($viewdata, false, false);
foreach ($blocks as $b) {
if (!isset($data[$b->artefact]->views)) {
$data[$b->artefact]->views = array();
......@@ -116,23 +127,20 @@ if ($data) {
if (!isset($data[$b->artefact]->views[$b->view])) {
$data[$b->artefact]->views[$b->view] = array(
'view' => $b->view,
'viewtitle' => $b->viewtitle
'viewtitle' => $b->viewtitle,
'fullurl' => $viewdata[$b->view]['fullurl'],
);
// Add the view owner's name if it's not the same as the note owner. This will either
// be a group artefact inside an individual's view, or it's an institution/site artefact.
if ((!empty($params['group']) && $b->owner)
|| (!empty($params['institution']) && $params['institution'] != $b->institution)) {
if ($b->owner) {
$ownername = display_default_name((object) array(
'firstname' => $b->firstname,
'lastname' => $b->lastname,
'preferredname' => $b->preferredname,
));
$ownerurl = get_config('wwwroot') . 'user/view.php?id=' . $b->owner;
$ownername = display_default_name($viewdata[$b->view]['user']);
$ownerurl = profile_url($viewdata[$b->view]['user']);
}
else if ($b->group) {
$ownername = $b->groupname;
$ownerurl = get_config('wwwroot') . 'group/view.php?id=' . $b->group;
$ownername = $viewdata[$b->view]['groupdata']['name'];
$ownerurl = group_homepage_url($viewdata[$b->view]['groupdata']);
}
else if ($b->institution == 'mahara') {
$ownername = get_config('sitename');
......
......@@ -19,7 +19,7 @@
<td>
{foreach from=$n->views item=v}
<div>
<a href="{$WWWROOT}view/view.php?id={$v.view}">{$v.viewtitle|str_shorten_text:30:true}</a>
<a href="{$v.fullurl}">{$v.viewtitle|str_shorten_text:30:true}</a>
{if $v.ownername}{str tag=by section=view} {if $v.ownerurl}<a href="{$v.ownerurl}">{/if}{$v.ownername}{if $v.ownerurl}</a>{/if}{/if}
</div>
{/foreach}
......
......@@ -1642,8 +1642,8 @@ function artefact_get_owner_info($ids) {
$data = get_records_sql_assoc('
SELECT
a.id AS aid, a.owner, a.group, a.institution,
u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email,
g.name AS groupname,
u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.urlid,
g.name AS groupname, g.urlid as groupurlid,
i.displayname
FROM
{artefact} a
......@@ -1658,21 +1658,21 @@ function artefact_get_owner_info($ids) {
foreach ($data as &$d) {
if ($d->institution == 'mahara') {
$name = get_config('sitename');
$url = '';
$url = $wwwroot;
}
else if ($d->institution) {
$name = $d->displayname;;
$url = 'institution/index.php?institution=' . $d->institution;
$url = $wwwroot . 'institution/index.php?institution=' . $d->institution;
}
else if ($d->group) {
$name = $d->groupname;;
$url = 'group/view.php?id=' . $d->group;
$url = group_homepage_url((object) array('id' => $d->group, 'urlid' => $d->groupurlid));
}
else {
$name = display_name($d);
$url = 'user/view.php?id=' . $d->id;
$url = profile_url($d);
}
$d = (object) array('name' => $name, 'url' => $wwwroot . $url);
$d = (object) array('name' => $name, 'url' => $url);
}
return $data;
}
{foreach from=$groupmembers item=groupmember}
<div class="{cycle values='d0,d1'} friendcell center">
<a href="{$WWWROOT}user/view.php?id={$groupmember['id']}">
<a href="{profile_url($groupmember)}">
<img src="{profile_icon_url user=$groupmember maxwidth=60 maxheight=60}" alt="" title="{$groupmember|display_default_name|escape}">
</a>
<div class="membername"><a href="{$WWWROOT}user/view.php?id={$groupmember['id']}">{$groupmember|display_default_name|escape}</a></div>
<div class="membername"><a href="{profile_url($groupmember)}">{$groupmember|display_default_name|escape}</a></div>
</div>
{/foreach}
......@@ -174,7 +174,6 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
if (!empty($data['mysubmittedviews'])) {
foreach ($data['mysubmittedviews'] as &$v) {
$v['url'] = get_config('wwwroot') . 'view/view.php?id=' . $v['id'];
if ($v['submittedtime']) {
$v['submittedtime'] = format_date($v['submittedtime']);
}
......
......@@ -8,7 +8,7 @@
{if $view.template}
<div class="s fr valign">{$view.form|safe}</div>
{/if}
<h3><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title}</a></h3>
<h3><a href="{$view.fullurl}">{$view.title}</a></h3>
<div class="s">{$view.description|str_shorten_html:100:true|strip_tags|safe}</div>
{if $view.tags}<div class="tags"><label>{str tag=tags}:</label> {list_tags owner=$view.owner tags=$view.tags}</div>{/if}
</td>
......@@ -28,13 +28,13 @@
{if $view.template}
<div class="s fr valign">{$view.form|safe}</div>
{/if}
<h3><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title}</a></h3>
<h3><a href="{$view.fullurl}">{$view.title}</a></h3>
{if $view.sharedby}
<span class="owner">{str tag=by section=view}
{if $view.group}
<a href="{$WWWROOT}group/view.php?id={$view.group}">{$view.sharedby}</a>
<a href="{group_homepage_url($view.groupdata)}">{$view.sharedby}</a>
{elseif $view.owner}
<a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.sharedby}</a>
<a href="{profile_url($view.user)}">{$view.sharedby}</a>
{else}
{$view.sharedby}
{/if}
......@@ -60,9 +60,9 @@
{foreach from=$mysubmittedviews item=view}
<tr class="{cycle values='r0,r1'}"><td class="submittedform">
{if $view.submittedtime}
{str tag=youhavesubmittedon section=view arg1=$view.url arg2=$view.title arg3=$view.submittedtime}
{str tag=youhavesubmittedon section=view arg1=$view.fullurl arg2=$view.title arg3=$view.submittedtime}
{else}
{str tag=youhavesubmitted section=view arg1=$view.url arg2=$view.title}
{str tag=youhavesubmitted section=view arg1=$view.fullurl arg2=$view.title}
{/if}
</td></tr>
{/foreach}
......@@ -86,8 +86,8 @@
{foreach from=$allsubmittedviews item=view}
<tr class="{cycle values='r0,r1'}">
<td>
<strong><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|str_shorten_text:60:true}</a></strong>
<div><a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.sharedby}</a></div>
<strong><a href="{$view.fullurl}">{$view.title|str_shorten_text:60:true}</a></strong>
<div><a href="{profile_url($view.user)}">{$view.sharedby}</a></div>
</td>
<td>
<div class="postedon nowrap">{$view.submittedtime|format_date}</div>
......
......@@ -61,7 +61,8 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
return;
}
$baseurl = $instance->get_view()->get_url() . '&block=' . $instance->get('id');
$baseurl = $instance->get_view()->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id');
$baseurl .= '&user=' . (int) $userid;
$pagination = build_pagination(array(
'id' => 'userfriendstable_pagination',
......
{foreach from=$friends item=row}
{foreach from=$row item=friend}
<div class="{cycle values='d0,d1'} friendcell">
<a href="{$WWWROOT}user/view.php?id={$friend->id}">
<a href="{profile_url($friend)}">
<img src="{profile_icon_url user=$friend maxwidth=60 maxheight=60}" alt="">
</a>
<div><a href="{$WWWROOT}user/view.php?id={$friend->id}">{$friend|display_default_name|escape}</a></div>
<div><a href="{profile_url($friend)}">{$friend|display_default_name|escape}</a></div>
</div>
{/foreach}
{/foreach}
......
......@@ -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}
......
......@@ -3,7 +3,7 @@
{foreach from=$VIEWS item=item name=view}
<tr>
<td class="{cycle values='r0,r1'}">
<h4><a href="{$WWWROOT}view/view.php?id={$item.id}">{$item.title}</a></h4>
<h4><a href="{$item.fullurl}">{$item.title}</a></h4>
{if $item.description}
<div class="details">{$item.description|str_shorten_html:100:true|strip_tags|safe}</div>
{/if}
......
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