Skip to content

Commit 2fdfdf8

Browse files
committed
Add optional custom user label field for User Switcher panel.
1 parent 9d5c4cc commit 2fdfdf8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

TracyDebugger.module.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.26.77',
30+
'version' => '4.26.78',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -284,6 +284,7 @@ static public function getDefaultData() {
284284
"userSwitcherSelector" => '',
285285
"userSwitcherRestricted" => null,
286286
"userSwitcherIncluded" => null,
287+
"userSwitcherUserLabel" => 'name',
287288
"todoIgnoreDirs" => 'git, svn, images, img, errors, sass-cache, node_modules',
288289
"todoScanAssets" => null,
289290
"todoScanModules" => null,
@@ -4487,6 +4488,14 @@ public function getModuleConfigInputfields(array $data) {
44874488
if($data['userSwitcherIncluded']) $f->attr('value', $data['userSwitcherIncluded']);
44884489
$fieldset->add($f);
44894490

4491+
$f = $this->wire('modules')->get("InputfieldText");
4492+
$f->attr('name', 'userSwitcherUserLabel');
4493+
$f->label = __('User label field', __FILE__);
4494+
$f->description = __('Use this to determine which user field will be used to identify users in the selection interace.', __FILE__);
4495+
$f->notes = __('Default: `name`', __FILE__);
4496+
if($data['userSwitcherUserLabel']) $f->attr('value', $data['userSwitcherUserLabel']);
4497+
$fieldset->add($f);
4498+
44904499
// requestLogger Panel
44914500
$fieldset = $this->wire('modules')->get("InputfieldFieldset");
44924501
$fieldset->attr('name+id', 'requestLoggerPanel');

panels/UserSwitcherPanel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function getPanel() {
110110

111111
foreach($selectableUsers->sort('name') as $u) {
112112
if($u->hasStatus('unpublished')) continue;
113-
if(count($u->roles)>1) $out .= '<option id="user_'.$u->id.'" value="'.$u->name.'" style="padding: 2px; ' . ($this->wire('user')->name === $u->name ? 'background:'.TracyDebugger::COLOR_WARN.'; color: #FFFFFF;" selected="selected"' : '"') . '>'.$u->name.'</option>';
113+
if(count($u->roles)>1) $out .= '<option id="user_'.$u->id.'" value="'.$u->name.'" style="padding: 2px; ' . ($this->wire('user')->name === $u->name ? 'background:'.TracyDebugger::COLOR_WARN.'; color: #FFFFFF;" selected="selected"' : '"') . '>'.$u->get(\TracyDebugger::getDataValue('userSwitcherUserLabel').'|name').'</option>';
114114
}
115115
$out .= '
116116
</select>

0 commit comments

Comments
 (0)