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

Merge "Allow pagination to be remembered when deleting page (Bug #1044877)"

parents 8f46cdab b309bf4c
......@@ -2828,6 +2828,28 @@ function get_relative_script_path() {
return substr(get_script_path(), strlen($maharadir) - 1);
}
/**
* Get query string from url
*
* Takes in a URL and returns the querystring portion
* or returns $_SERVER['QUERY_STRING']) if set
*
* @param string $url the url which may have a query string attached
* @return string
*/
function get_querystring($url = null) {
if (!empty($url) && $commapos = strpos($url, '?')) {
return substr($url, $commapos + 1);
}
else if (!empty($_SERVER['QUERY_STRING'])) {
return $_SERVER['QUERY_STRING'];
}
else {
return '';
}
}
/**
* Remove query string from url
*
......
......@@ -23,10 +23,10 @@
<div class="listrow {cycle values='r0,r1'}">
<div class="fr btns2">
{if !$view.submittedto && (!$view.locked || $editlocked)}
<a href="{$WWWROOT}view/blocks.php?id={$view.id}" title="{str tag ="editcontentandlayout" section="view"}"><img src="{theme_url filename='images/btn_edit.png'}" alt="{str tag=edit}"></a>
<a href="{$WWWROOT}view/blocks.php?id={$view.id}&{$querystring}" title="{str tag ="editcontentandlayout" section="view"}"><img src="{theme_url filename='images/btn_edit.png'}" alt="{str tag=edit}"></a>
{/if}
{if !$view.submittedto && $view.removable && (!$view.locked || $editlocked)}
<a href="{$WWWROOT}view/delete.php?id={$view.id}" title="{str tag=deletethisview section=view}"><img src="{theme_url filename='images/btn_deleteremove.png'}" alt="{str tag=delete}"></a>
<a href="{$WWWROOT}view/delete.php?id={$view.id}&{$querystring}" title="{str tag=deletethisview section=view}"><img src="{theme_url filename='images/btn_deleteremove.png'}" alt="{str tag=delete}"></a>
{/if}
</div>{* rbuttons *}
<h3 class="title"><a href="{$view.fullurl}">{$view.displaytitle}</a></h3>
......
......@@ -51,7 +51,10 @@ else if ($institution) {
$goto = 'institutionviews.php?institution=' . $institution;
}
else {
$goto = 'index.php';
$query = get_querystring();
// remove the id
$query = preg_replace('/id=([0-9]+)\&/','',$query);
$goto = 'index.php?' . $query;
}
define('TITLE', get_string('deletespecifiedview', 'view', $view->get('title')));
......@@ -77,7 +80,7 @@ $smarty->assign('form', $form);
$smarty->display('view/delete.tpl');
function deleteview_submit(Pieform $form, $values) {
global $SESSION, $USER, $viewid, $groupid, $institution;
global $SESSION, $USER, $viewid, $groupid, $institution, $goto;
$view = new View($viewid, null);
if (View::can_remove_viewtype($view->get('type')) || $USER->get('admin')) {
$view->delete();
......@@ -92,5 +95,5 @@ function deleteview_submit(Pieform $form, $values) {
if ($institution) {
redirect('/view/institutionviews.php?institution='.$institution);
}
redirect('/view/index.php');
redirect('/view/' . $goto);
}
......@@ -50,6 +50,7 @@ $smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('querystring', get_querystring());
$smarty->assign('searchform', $searchform);
$smarty->assign('createviewform', $createviewform);
$smarty->display('view/index.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