Skip to content

Commit b25da62

Browse files
committed
Issues-524: Added PreferencesKey in sortsDropDown
1 parent 9535688 commit b25da62

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

Topcoder/class.topcoder.plugin.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,3 +2552,50 @@ function topcoderMentionAnchor($mention, $cssClass = null, $options = null) {
25522552
}
25532553
}
25542554

2555+
if (!function_exists('watchingSorts')) {
2556+
/**
2557+
* Returns watching sorting.
2558+
*
2559+
* @param string $extraClasses any extra classes you add to the drop down
2560+
* @return string
2561+
*/
2562+
function watchingSorts($extraClasses = '') {
2563+
if (!Gdn::session()->isValid()) {
2564+
return;
2565+
}
2566+
2567+
$baseUrl = preg_replace('/\?.*/', '', Gdn::request()->getFullPath());
2568+
$transientKey = Gdn::session()->transientKey();
2569+
$filters = [
2570+
[
2571+
'name' => t('New'),
2572+
'param' => 'sort',
2573+
'value' => 'new',
2574+
'extra' => ['TransientKey' => $transientKey, 'save' => 1]
2575+
],
2576+
2577+
[
2578+
'name' => t('Old'),
2579+
'param' => 'sort',
2580+
'value' => 'old',
2581+
'extra' => ['TransientKey' => $transientKey, 'save' => 1]
2582+
]
2583+
];
2584+
2585+
$defaultParams = [];
2586+
if (!empty($defaultParams)) {
2587+
$defaultUrl = $baseUrl.'?'.http_build_query($defaultParams);
2588+
} else {
2589+
$defaultUrl = $baseUrl;
2590+
}
2591+
2592+
return sortsDropDown('WatchingSort',
2593+
$baseUrl,
2594+
$filters,
2595+
$extraClasses,
2596+
null,
2597+
$defaultUrl,
2598+
'Sort'
2599+
);
2600+
}
2601+
}

Topcoder/controllers/class.watchingcontroller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function index($cp = '', $dp = '') {
5656
$sort = Gdn::request()->get('sort', null);
5757
$saveSorting = $sort !== null && Gdn::request()->get('save') && Gdn::session()->validateTransientKey(Gdn::request()->get('TransientKey', ''));
5858
if($saveSorting) {
59-
Gdn::session()->setPreference('CategorySort', $sort);
59+
Gdn::session()->setPreference('WatchingSort', $sort);
6060
}
61-
$sort = Gdn::session()->getPreference('CategorySort', false);
62-
$this->setData('CategorySort', $sort);
61+
$sort = Gdn::session()->getPreference('WatchingSort', false);
62+
$this->setData('WatchingSort', $sort);
6363

6464
$userMetaModel = new UserMetaModel();
6565
list($cp, $categoryLimit) = offsetLimit($cp, 30);

0 commit comments

Comments
 (0)