Skip to content

Commit 2436777

Browse files
committed
Portfolio: keep user seleccion context when going back to post list from post view - refs BT#22710
1 parent 995c4fb commit 2436777

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

main/inc/lib/PortfolioController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ public function index(HttpRequest $httpRequest)
10871087

10881088
$template = new Template(null, false, false, false, false, false, false);
10891089
$template->assign('user', $this->owner);
1090+
$template->assign('listByUser', $listByUser);
10901091
$template->assign('course', $this->course);
10911092
$template->assign('session', $this->session);
10921093
$template->assign('portfolio', $portfolio);
@@ -1133,7 +1134,7 @@ public function index(HttpRequest $httpRequest)
11331134
* @throws \Doctrine\ORM\OptimisticLockException
11341135
* @throws \Doctrine\ORM\TransactionRequiredException
11351136
*/
1136-
public function view(Portfolio $item)
1137+
public function view(Portfolio $item, $urlUser)
11371138
{
11381139
global $interbreadcrumb;
11391140

@@ -1415,10 +1416,15 @@ public function view(Portfolio $item)
14151416
$this->baseUrl.http_build_query(['action' => 'edit_item', 'id' => $item->getId()])
14161417
);
14171418

1419+
$urlUserString = "";
1420+
if (isset($urlUser)) {
1421+
$urlUserString = "user=" . $urlUser;
1422+
}
1423+
14181424
$actions = [];
14191425
$actions[] = Display::url(
14201426
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
1421-
$this->baseUrl
1427+
$this->baseUrl . $urlUserString
14221428
);
14231429

14241430
if ($this->itemBelongToOwner($item)) {

main/portfolio/index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@
190190
break;
191191
}
192192

193-
$controller->view($item);
193+
if ($httpRequest->query->has('user')) {
194+
$urlUser = $httpRequest->query->getInt('user');
195+
}
196+
$controller->view($item, $urlUser);
194197

195198
return;
196199
case 'copy':

main/template/default/portfolio/items.html.twig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% macro display(items, category_id, _c, _u, _p) %}
1+
{% macro display(items, category_id, _c, _u, _p, user, listByUser) %}
22
{% set edit_img = 'edit.png'|img(22, 'Edit'|get_lang) %}
33
{% set visible_img = 'visible.png'|img(22, 'Invisible'|get_lang) %}
44
{% set invisible_img = 'invisible.png'|img(22, 'Visible'|get_lang) %}
@@ -8,7 +8,11 @@
88

99
<section class="portfolio-items">
1010
{% for item in items %}
11-
{% set item_url = baseurl ~ {'action':'view', 'id':item.id}|url_encode %}
11+
{% if listByUser %}
12+
{% set item_url = baseurl ~ {'action':'view', 'id':item.id, 'user':user.id}|url_encode %}
13+
{% else %}
14+
{% set item_url = baseurl ~ {'action':'view', 'id':item.id}|url_encode %}
15+
{% endif %}
1216
{% set comments = item.lastComments(3, is_advanced_sharing_enabled) %}
1317

1418
{% if 'portfolio_show_base_course_post_in_sessions'|api_get_configuration_value %}

main/template/default/portfolio/list.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<h4 class="page-header">{{ 'Posts'|get_lang }}</h4>
5959
{% endif %}
6060

61-
{{ items.display(uncategorized_items, 0, _c, _u, _p) }}
61+
{{ items.display(uncategorized_items, 0, _c, _u, _p, user, listByUser) }}
6262

6363
{% if found_comments %}
6464
<section>

0 commit comments

Comments
 (0)