Skip to content

Commit 2c604ea

Browse files
committed
Add username, fix user ID
1 parent d7aa5ac commit 2c604ea

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/Controllers/Files.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,13 @@ public function user($userId = null)
175175
}
176176

177177
$this->setData([
178-
'access' => 'display',
179-
'title' => 'User Files'
178+
'access' => 'display',
179+
'title' => 'User Files',
180+
'username' => 'User',
180181
]);
181182
}
182183
// Logged in, looking at another user
183-
elseif ($userId !== user_id())
184+
elseif ($userId != user_id())
184185
{
185186
// Check for list permission
186187
if (! $this->model->mayList())
@@ -189,16 +190,18 @@ public function user($userId = null)
189190
}
190191

191192
$this->setData([
192-
'access' => $this->model->mayAdmin() ? 'manage' : 'display',
193-
'title' => 'User Files'
193+
'access' => $this->model->mayAdmin() ? 'manage' : 'display',
194+
'title' => 'User Files',
195+
'username' => 'User',
194196
]);
195197
}
196198
// Looking at own files
197199
else
198200
{
199201
$this->setData([
200-
'access' => 'manage',
201-
'title' => 'My Files'
202+
'access' => 'manage',
203+
'title' => 'My Files',
204+
'username' => 'My',
202205
]);
203206
}
204207

@@ -611,6 +614,7 @@ protected function setDefaults(): self
611614
'files' => null,
612615
'selected' => explode(',', $this->request->getVar('selected') ?? ''),
613616
'userId' => null,
617+
'username' => '',
614618
'ajax' => $this->request->isAJAX(),
615619
'sort' => $this->getSort(),
616620
'order' => $this->getOrder(),

src/Views/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<a class="btn <?= $format === 'select' ? 'btn-secondary' : 'btn-outline-secondary' ?>" href="<?= site_url("files/{$source}") ?>?format=select" role="button"><i class="fas fa-tasks"></i></a>
1717
</div>
1818
</div>
19-
19+
2020
<h1><?= $access === 'manage' ? 'Manage' : 'Browse' ?> <?= $username ?? '' ?> Files</h1>
2121

2222
<form class="form-inline mb-3" name="files-search" method="get" action="<?= current_url() ?>">

tests/feature/UserTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function testShowsOwnFiles()
1313
model('FileModel')->addToUser($file->id, $user->id);
1414

1515
$result = $this->get('files/user/' . $user->id);
16+
$result->assertSee('Manage My Files', 'h1');
1617
$result->assertSee($file->filename);
1718
}
1819

@@ -24,6 +25,7 @@ public function testShowsOtherFiles()
2425
model('FileModel')->addToUser($file->id, $user->id);
2526

2627
$result = $this->get('files/user/1000');
28+
$result->assertSee('Browse User Files', 'h1');
2729
$result->assertDontSee($file->filename);
2830
}
2931
}

0 commit comments

Comments
 (0)