Skip to content

Commit

Permalink
Hide the navigation entries when they are just duplicates or empty
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Mar 25, 2015
1 parent d880378 commit 0403ea5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
4 changes: 3 additions & 1 deletion appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public function __construct (array $urlParams = array()) {
return new Navigation(
$c->query('ActivityL10N'),
$server->getActivityManager(),
$c->query('URLGenerator'),
$server->getURLGenerator(),
$c->query('UserSettings'),
$c->query('CurrentUID'),
$rssToken
);
});
Expand Down
2 changes: 1 addition & 1 deletion controller/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function show() {
$this->helper->setL10n($l);
$this->helper->setUser($user);

$description = $l->t('Personal activity feed for %s', $user);
$description = (string) $l->t('Personal activity feed for %s', $user);
$activities = $this->data->read($this->helper, $this->settings, 0, self::DEFAULT_PAGE_SIZE, 'all', $user);
} catch (\UnexpectedValueException $e) {
$l = Util::getL10N('activity');
Expand Down
28 changes: 19 additions & 9 deletions lib/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class Navigation {
/** @var string */
protected $active;

/** @var string */
protected $user;

/** @var string */
protected $rssLink;

Expand All @@ -55,13 +58,17 @@ class Navigation {
* @param \OC_L10N $l
* @param \OCP\Activity\IManager $manager
* @param \OCP\IURLGenerator $URLGenerator
* @param UserSettings $userSettings
* @param string $user
* @param string $rssToken
* @param null|string $active Navigation entry that should be marked as active
*/
public function __construct(\OC_L10N $l, IManager $manager, IURLGenerator $URLGenerator, $rssToken, $active = 'all') {
public function __construct(\OC_L10N $l, IManager $manager, IURLGenerator $URLGenerator, UserSettings $userSettings, $user, $rssToken, $active = 'all') {
$this->l = $l;
$this->activityManager = $manager;
$this->URLGenerator = $URLGenerator;
$this->userSettings = $userSettings;
$this->user = $user;
$this->active = $active;

if ($rssToken) {
Expand Down Expand Up @@ -104,23 +111,26 @@ public function getTemplate($forceActive = null) {
* @return array Notification data (user => array of rows from the table)
*/
public function getLinkList() {
$topEntries = array(
array(
$topEntries = [
[
'id' => 'all',
'name' => (string) $this->l->t('All Activities'),
'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList'),
),
array(
],
];

if ($this->user && $this->userSettings->getUserSetting($this->user, 'setting', 'self')) {
$topEntries[] = [
'id' => 'self',
'name' => (string) $this->l->t('Activities by you'),
'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self')),
),
array(
];
$topEntries[] = [
'id' => 'by',
'name' => (string) $this->l->t('Activities by others'),
'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by')),
),
);
];
}

$additionalEntries = $this->activityManager->getNavigation();
$topEntries = array_merge($topEntries, $additionalEntries['top']);
Expand Down

0 comments on commit 0403ea5

Please sign in to comment.