Skip to content

Commit

Permalink
Hide the "Shared" heading if able.
Browse files Browse the repository at this point in the history
If shares are not enabled on any source and if there are no sources
shared via permissions, hide the section.
  • Loading branch information
mrubinsk committed Jun 16, 2015
1 parent f108747 commit 7e3c8e8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions turba/lib/Application.php
Expand Up @@ -235,19 +235,14 @@ public function sidebar($sidebar)
if ($GLOBALS['registry']->getAuth() &&
$GLOBALS['session']->get('turba', 'has_share') &&
!empty($conf['shares']['source'])) {
$create = true;
$sidebar->containers['my']['header']['add'] = array(
'url' => Horde::url('addressbooks/create.php'),
'label' => _("Create a new Address Book"),
);
}
$sidebar->containers['shared'] = array(
'header' => array(
'id' => 'turba-toggle-shared',
'label' => _("Shared Address Books"),
'collapsed' => true,
),
);
$shares = array();
$shared = array();
foreach (Turba::listShares(false, Horde_Perms::SHOW) as $id => $abook) {
$row = array(
'selected' => $id == Turba::$source,
Expand All @@ -265,12 +260,25 @@ public function sidebar($sidebar)
if ($abook->get('owner')) {
$row['label'] .= ' [' . $GLOBALS['registry']->convertUsername($abook->get('owner'), false) . ']';
}
$shared[] = $row;
}
$shares[$id] = true;
}

if (!empty($create) || count($shared)) {
$sidebar->containers['shared'] = array(
'header' => array(
'id' => 'turba-toggle-shared',
'label' => _("Shared Address Books"),
'collapsed' => true,
),
);
foreach ($shared as $row) {
$sidebar->addRow($row, 'shared');
if ($row['selected']) {
$sidebar->containers['shared']['header']['collapsed'] = false;
}
}
$shares[$id] = true;
}

$sidebar->containers['other'] = array(
Expand Down

0 comments on commit 7e3c8e8

Please sign in to comment.